view edwaveform.h @ 510:43ea59887c69

Start work on making C64 formats encoding possible by changing DMDecodeOps to DMEncDecOps and adding fields and op enums for custom encode functions, renaming, etc. Split generic op sanity checking into a separate function in preparation for its use in generic encoding function.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 19 Nov 2012 15:06:01 +0200
parents d34922e6a244
children a4666c9e1336
line wrap: on
line source

#ifndef EDWAVEFORM_H
#define EDWAVEFORM_H

#include <QWidget>
#include <QLabel>
#include "dmengine.h"

class QEDWaveTrackDisplay : public QWidget
{
    Q_OBJECT

public:
    QEDWaveTrackDisplay(QWidget *parent = 0);

    void setWaveform(void *mdata, int msize, int mformat, int mchannels, int mfreq);
    float getScaledWidth();
    void setScale(const float mscale);
    int getBps();
    float getDuration();
    float getTimeScale(float value);
    float getTimeFromCoord(float value);
    float getTime();
    float getOffset();

    QSize minimumSizeHint() const
    {
        return QSize(100, 60);
    }

    QSize sizeHint() const
    {
        return QSize(600, 60);
    }

public slots:
    void setTime(const float mtime);
    void setOffset(const float moffs);

signals:
    void timeChanged(float value);
    void offsetChanged(float value);

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);

    void paintEvent(QPaintEvent *event);

private:
    bool dragging;
    QPoint dragPoint;
    float dragOffs; // milliseconds

    float scale;
    float time, offs, duration; // in milliseconds

    int size, channels, format, freq, sduration;
    void *data;
};


class QEDWaveTrackView : public QWidget
{
    Q_OBJECT

private:
    QEDWaveTrackDisplay *wave;
    QLabel *infoName, *infoData;

public:

    QEDWaveTrackView(QWidget *parent = 0);
    void setWaveform(void *mdata, int mlen, int mformat, int mchannels, int mfreq);
    void setName(QString name);
    void setTime(const float mtime);
    void setOffset(const float moffs);
    float getScaledWidth();
    void setScale(const float mscale);
    float getDuration();
    float getTime();
    float getOffset();

private slots:
    void slotTimeChanged(float value);
    void slotOffsetChanged(float value);

signals:
    void timeChanged(float value);
    void offsetChanged(float value);
};

#endif