Mercurial > hg > dmlib
annotate edwaveform.h @ 400:f44a89a25c97
Fix waveform display from going over buffer limit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 19 Oct 2012 15:56:59 +0300 |
parents | 5137db55f00b |
children | d34922e6a244 |
rev | line source |
---|---|
357 | 1 #ifndef EDWAVEFORM_H |
2 #define EDWAVEFORM_H | |
3 | |
4 #include <QWidget> | |
384
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
5 #include <QLabel> |
357 | 6 #include "dmengine.h" |
7 | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
391
diff
changeset
|
8 class QWaveTrackDisplay : public QWidget |
357 | 9 { |
10 Q_OBJECT | |
11 | |
12 public: | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
391
diff
changeset
|
13 QWaveTrackDisplay(QWidget *parent = 0); |
357 | 14 |
391 | 15 void setWaveform(void *mdata, int msize, int mformat, int mchannels, int mfreq); |
16 float getScaledWidth(); | |
357 | 17 void setScale(const float mscale); |
391 | 18 int getBps(); |
19 float getDuration(); | |
20 float getTimeScale(float value); | |
21 float getTimeFromCoord(float value); | |
22 float getTime(); | |
23 float getOffset(); | |
384
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
24 |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
25 QSize minimumSizeHint() const |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
26 { |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
27 return QSize(100, 60); |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
28 } |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
29 |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
30 QSize sizeHint() const |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
31 { |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
32 return QSize(600, 60); |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
33 } |
357 | 34 |
391 | 35 public slots: |
36 void setTime(const float mtime); | |
37 void setOffset(const float moffs); | |
38 | |
39 signals: | |
40 void timeChanged(float value); | |
41 void offsetChanged(float value); | |
42 | |
357 | 43 protected: |
44 void mousePressEvent(QMouseEvent *event); | |
45 void mouseMoveEvent(QMouseEvent *event); | |
46 void mouseReleaseEvent(QMouseEvent *event); | |
47 | |
48 void paintEvent(QPaintEvent *event); | |
49 | |
50 private: | |
391 | 51 bool dragging; |
52 QPoint dragPoint; | |
53 float dragOffs; // milliseconds | |
54 | |
357 | 55 float scale; |
391 | 56 float time, offs, duration; // in milliseconds |
57 | |
400
f44a89a25c97
Fix waveform display from going over buffer limit.
Matti Hamalainen <ccr@tnsp.org>
parents:
393
diff
changeset
|
58 int size, channels, format, freq, sduration; |
384
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
59 void *data; |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
60 }; |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
61 |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
62 |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
391
diff
changeset
|
63 class QWaveTrackView : public QWidget |
384
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
64 { |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
65 Q_OBJECT |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
66 |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
67 private: |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
391
diff
changeset
|
68 QWaveTrackDisplay *wave; |
384
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
69 QLabel *infoName, *infoData; |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
70 |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
71 public: |
391 | 72 |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
391
diff
changeset
|
73 QWaveTrackView(QWidget *parent = 0); |
384
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
74 void setWaveform(void *mdata, int mlen, int mformat, int mchannels, int mfreq); |
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
75 void setName(QString name); |
391 | 76 void setTime(const float mtime); |
77 void setOffset(const float moffs); | |
78 float getScaledWidth(); | |
384
e5220ff48bc8
Slowly working on the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
79 void setScale(const float mscale); |
391 | 80 float getDuration(); |
81 float getTime(); | |
82 float getOffset(); | |
83 | |
84 private slots: | |
85 void slotTimeChanged(float value); | |
86 void slotOffsetChanged(float value); | |
87 | |
88 signals: | |
89 void timeChanged(float value); | |
90 void offsetChanged(float value); | |
357 | 91 }; |
92 | |
93 #endif |