Mercurial > hg > dmlib
annotate editor/edtimeline.cpp @ 1315:7687412f9aef
Fix jssmod sample conversion flags storing .. urgh.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 20 Aug 2017 01:54:54 +0300 |
parents | e2ac08228a0f |
children | b4992d9f72fe |
rev | line source |
---|---|
357 | 1 #include <QtGui> |
2 #include "edtimeline.h" | |
3 | |
4 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
5 QEDTimelineTrackDisplay::QEDTimelineTrackDisplay(QWidget *parent) : QWidget(parent) |
357 | 6 { |
7 track = NULL; | |
8 time = offs = 0; | |
9 scale = 1.0f; | |
386 | 10 |
11 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); | |
12 } | |
13 | |
14 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
15 QSize QEDTimelineTrackDisplay::minimumSizeHint() const |
386 | 16 { |
17 return QSize(100, 60); | |
18 } | |
19 | |
20 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
21 QSize QEDTimelineTrackDisplay::sizeHint() const |
386 | 22 { |
23 return QSize(600, 60); | |
357 | 24 } |
25 | |
26 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
27 void QEDTimelineTrackDisplay::setTrack(DMTimelineTrack *mtrack) |
357 | 28 { |
29 track = mtrack; | |
30 } | |
31 | |
32 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
33 float QEDTimelineTrackDisplay::getTimeScale(float value) |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
34 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
35 return value * scale; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
36 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
37 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
38 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
39 float QEDTimelineTrackDisplay::getTimeFromCoord(float value) |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
40 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
41 return value * scale * 1000.0f; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
42 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
43 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
44 |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
45 void QEDTimelineTrackDisplay::setTime(const float mtime) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
46 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
47 if (time != mtime && mtime >= 0) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
48 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
49 time = mtime; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
50 emit timeChanged(time); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
51 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
52 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
53 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
54 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
55 void QEDTimelineTrackDisplay::setOffset(const float moffs) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
56 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
57 if (offs != moffs && moffs >= 0) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
58 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
59 offs = moffs; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
60 emit offsetChanged(offs); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
61 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
62 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
63 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
64 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
65 void QEDTimelineTrackDisplay::setScale(const float mscale) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
66 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
67 if (mscale > 0.05) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
68 scale = mscale; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
69 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
70 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
71 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
72 void QEDTimelineTrackDisplay::setSelection(const float mstart, const float mend) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
73 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
74 if (mstart >= 0 && mend >= 0 && fabs(mend - mstart) > 0) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
75 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
76 selectionValid = true; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
77 if (mend > mstart) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
78 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
79 selectionStart = mstart; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
80 selectionDuration = mend - mstart + 1; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
81 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
82 else |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
83 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
84 selectionStart = mend; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
85 selectionDuration = mstart - mend + 1; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
86 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
87 emit selectionChanged(selectionStart, selectionDuration); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
88 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
89 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
90 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
91 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
92 void QEDTimelineTrackDisplay::clearSelection() |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
93 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
94 selectionValid = false; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
95 selectionStart = 0; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
96 selectionDuration = 0; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
97 emit selectionChanged(selectionStart, selectionDuration); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
98 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
99 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
100 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
101 bool QEDTimelineTrackDisplay::getSelection(float *mstart, float *mduration) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
102 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
103 if (selectionValid) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
104 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
105 *mstart = selectionStart; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
106 *mduration = selectionDuration; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
107 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
108 return selectionValid; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
109 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
110 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
111 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
112 QList<DMTimelineEvent *> QEDTimelineTrackDisplay::getEventsAt(const int time) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
113 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
114 QList<DMTimelineEvent *> list; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
115 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
116 for (int event = 0; event < track->nevents; event++) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
117 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
118 DMTimelineEvent *ev = track->events[event]; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
119 if (time >= ev->start && time <= ev->start + ev->duration) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
120 list.append(ev); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
121 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
122 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
123 return list; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
124 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
125 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
126 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
127 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
128 QList<DMTimelineEvent *> QEDTimelineTrackDisplay::getEventsForRange(const int start, const int duration) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
129 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
130 QList<DMTimelineEvent *> list; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
131 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
132 for (int event = 0; event < track->nevents; event++) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
133 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
134 DMTimelineEvent *ev = track->events[event]; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
135 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
136 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
137 return list; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
138 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
139 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
140 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
141 void QEDTimelineTrackDisplay::paintEvent(QPaintEvent *) |
357 | 142 { |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
143 if (track == NULL) |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
144 return; |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
145 |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
146 QColor eventColor(150, 150, 150, 128); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
147 QColor invalidEventColor(250, 150, 150, 128); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
148 QColor eventBorder(200, 250, 200, 200); |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
149 QColor eventParam(200, 150, 100); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
150 QColor eventText(255, 255, 255); |
357 | 151 QColor markerColor(255,255,255); |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
152 QColor selectionColor(0,255,0, 150); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
153 QColor selectionEnd(0,255,0, 200); |
357 | 154 |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
155 QFont fantti; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
156 fantti.setFamily("Arial"); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
157 fantti.setPointSizeF(8.0f); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
158 fantti.setStyleHint(QFont::SansSerif); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
159 |
357 | 160 QPainter painter(this); |
161 painter.setRenderHint(QPainter::Antialiasing); | |
162 | |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
163 |
357 | 164 painter.save(); |
165 painter.scale(scale, 1); | |
166 | |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
167 float wd = getTimeScale(width()); |
357 | 168 for (int event = 0; event < track->nevents; event++) |
169 { | |
170 DMTimelineEvent *ev = track->events[event]; | |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
171 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
172 float x0 = getTimeScale(ev->start - offs), |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
173 x1 = getTimeScale(ev->start + ev->duration - offs); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
174 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
175 if ((x0 >= 0 && x0 < wd) || (x0 < 0 && x1 >= 0)) |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
176 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
177 painter.setFont(fantti); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
178 painter.setBrush(ev->effect != NULL ? eventColor : invalidEventColor); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
179 painter.setPen(eventBorder); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
180 x0 = ev->start - offs; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
181 x1 = ev->duration; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
182 painter.fillRect(x0, 0, x1, height(), eventColor); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
183 |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
184 QPainterPath path; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
185 path.addText(QPointF(x0 + 2, 10), fantti, ev->effect != NULL ? QString(ev->effect->name) : "INVALID"); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
186 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
187 painter.save(); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
188 painter.translate(1,1); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
189 painter.setPen(Qt::black); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
190 painter.setBrush(Qt::black); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
191 painter.drawPath(path); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
192 painter.restore(); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
193 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
194 painter.setPen(eventText); |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
195 painter.setBrush(eventText); |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
196 painter.drawPath(path); |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
197 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
198 |
357 | 199 } |
200 | |
397 | 201 painter.restore(); |
202 | |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
203 if (selectionValid) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
204 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
205 float x0 = getTimeScale(selectionStart - offs), |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
206 x1 = getTimeScale(selectionStart + selectionDuration - offs); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
207 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
208 if ((x0 >= 0 && x0 < wd) || (x0 < 0 && x1 >= 0)) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
209 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
210 painter.setBrush(selectionColor); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
211 painter.setPen(selectionEnd); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
212 x0 = selectionStart - offs; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
213 x1 = selectionDuration; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
214 painter.fillRect(x0, 0, x1, height(), eventColor); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
215 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
216 painter.drawLine(x0, 0, x0, height()); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
217 painter.drawLine(x1, 0, x1, height()); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
218 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
219 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
220 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
221 |
357 | 222 if (time >= offs * scale && time - offs <= width() * scale) |
223 { | |
224 int xc = time - offs; | |
397 | 225 painter.save(); |
357 | 226 painter.scale(scale, 1); |
227 painter.setPen(markerColor); | |
228 painter.drawLine(xc, 0, xc, height()); | |
397 | 229 painter.restore(); |
357 | 230 } |
231 } | |
232 | |
233 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
234 void QEDTimelineTrackDisplay::mousePressEvent(QMouseEvent *ev) |
357 | 235 { |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
236 switch (ev->button()) |
357 | 237 { |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
238 case Qt::LeftButton: |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
239 if (parent->getActiveTrack() != this) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
240 emit trackActivated(this); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
241 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
242 selectionPoint = ev->pos(); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
243 selectionOffs = offs / scale; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
244 selecting = false; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
245 break; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
246 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
247 case Qt::RightButton: |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
248 dragPoint = ev->pos(); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
249 dragOffs = offs / scale; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
250 dragging = false; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
251 break; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
252 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
253 default: |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
254 break; |
357 | 255 } |
256 } | |
257 | |
258 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
259 void QEDTimelineTrackDisplay::mouseMoveEvent(QMouseEvent *ev) |
357 | 260 { |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
261 if ((ev->buttons() & Qt::LeftButton) && ev->pos().x() != selectionPoint.x()) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
262 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
263 selecting = true; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
264 setSelection(selectionOffs, offs + (ev->pos().x() - selectionPoint.x()) / scale); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
265 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
266 if ((ev->buttons() & Qt::RightButton) && ev->pos().x() != dragPoint.x()) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
267 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
268 dragging = true; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
269 setOffset(dragOffs - (ev->pos().x() - dragPoint.x()) / scale); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
270 } |
357 | 271 } |
272 | |
273 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
274 void QEDTimelineTrackDisplay::mouseReleaseEvent(QMouseEvent *ev) |
357 | 275 { |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
276 if (ev->button() == Qt::LeftButton) |
357 | 277 { |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
278 if (selecting) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
279 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
280 selecting = false; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
281 setSelection(selectionOffs + (ev->pos().x() - selectionPoint.x()) / scale); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
282 } |
357 | 283 } |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
284 else |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
285 if (ev->button() == Qt::RightButton && !dragging) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
286 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
287 setTime(offs + getTimeFromCoord(ev->pos().x())); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
288 } |
357 | 289 } |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
290 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
291 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
292 QEDTimelineTrackView::QEDTimelineTrackView(QWidget *parent) : QWidget(parent) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
293 { |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
294 QHBoxLayout *mainLayout = new QHBoxLayout(this); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
295 mainLayout->setMargin(0); |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
296 track = new QEDTimelineTrackDisplay(this); |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
297 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
298 QFrame *infoLayoutContainer = new QFrame(this); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
299 infoLayoutContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
300 infoLayoutContainer->setLineWidth(2); |
398 | 301 infoLayoutContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
302 infoLayoutContainer->setFixedWidth(200); | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
303 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
304 QVBoxLayout *infoLayout = new QVBoxLayout(infoLayoutContainer); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
305 infoLayout->setMargin(0); |
398 | 306 infoName = new QLineEdit(); |
307 infoName->setFrame(false); | |
308 infoName->setMaxLength(DT_MAX_NAME_LENGTH); | |
309 infoName->setStyleSheet("QLineEdit { background-color: black; color: white; padding: 2px; }"); | |
310 connect(infoName, SIGNAL(textEdited(const QString&)), this, SLOT(slotTrackNameChanged(const QString&))); | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
311 infoLayout->addWidget(infoName); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
312 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
313 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
314 enabledCheck = new QCheckBox("Enabled"); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
315 infoLayout->addWidget(enabledCheck); |
398 | 316 connect(enabledCheck, SIGNAL(toggled(bool)), this, SLOT(slotTrackEnabledChanged(bool))); |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
317 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
318 infoData = new QLabel(); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
319 infoData->setStyleSheet("QLabel { padding: 2px; }"); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
320 infoLayout->addWidget(infoData); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
321 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
322 mainLayout->addWidget(infoLayoutContainer); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
323 mainLayout->addWidget(track); |
398 | 324 } |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
325 |
398 | 326 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
327 void QEDTimelineTrackView::update() |
398 | 328 { |
329 if (track != NULL && track->track) | |
330 { | |
331 infoName->setText(QString(track->track->name)); | |
332 enabledCheck->setChecked(track->track->enabled); | |
333 infoData->setText(QString("<b>%1</b> events").arg(track->track->nevents)); | |
334 } | |
335 else | |
336 { | |
337 infoName->setText(""); | |
338 infoData->setText("-"); | |
339 enabledCheck->setChecked(false); | |
340 } | |
341 | |
342 QWidget::update(); | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
343 } |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
344 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
345 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
346 void QEDTimelineTrackView::setTrack(DMTimelineTrack *mtrack) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
347 { |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
348 track->setTrack(mtrack); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
349 update(); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
350 } |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
351 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
352 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
353 void QEDTimelineTrackView::slotTrackEnabledChanged(bool value) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
354 { |
397 | 355 track->track->enabled = value; |
398 | 356 emit trackChanged(); |
357 } | |
358 | |
359 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
360 void QEDTimelineTrackView::slotTrackNameChanged(const QString & text) |
398 | 361 { |
362 QByteArray ba = text.toUtf8(); | |
363 track->track->name = dm_strdup(ba.constData()); | |
364 emit trackChanged(); | |
397 | 365 } |
366 | |
367 | |
368 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
369 QEDTimelineView::QEDTimelineView(QWidget *parent) : QWidget(parent) |
397 | 370 { |
371 layout = new QVBoxLayout(this); | |
372 tl = NULL; | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
373 } |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
374 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
375 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
376 void QEDTimelineView::setTimeline(EDTimelineObject *mtl) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
377 { |
397 | 378 tl = mtl; |
379 | |
380 delete layout; | |
381 layout = new QVBoxLayout(this); | |
398 | 382 layout->setMargin(0); |
383 | |
397 | 384 tracks.clear(); |
385 | |
386 if (tl != NULL && tl->tl != NULL) | |
387 { | |
388 for (int track = 0; track < tl->tl->ntracks; track++) | |
389 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
390 QEDTimelineTrackView *vtr = new QEDTimelineTrackView(this); |
397 | 391 vtr->setTrack(tl->tl->tracks[track]); |
392 tracks.append(vtr); | |
393 layout->addWidget(vtr); | |
398 | 394 connect(vtr, SIGNAL(trackChanged()), this, SLOT(slotTimelineChanged())); |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
395 connect(vtr, SIGNAL(timeChanged(float)), this, SLOT(slotTimeChanged(float))); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
396 connect(vtr, SIGNAL(offsetChanged(float)), this, SLOT(slotOffsetChanged(float))); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
397 connect(vtr, SIGNAL(selectionChanged(float,float)), this, SLOT(slotSelectionChanged(float,float))); |
397 | 398 } |
399 } | |
400 update(); | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
401 } |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
402 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
403 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
404 void QEDTimelineView::slotTimelineChanged() |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
405 { |
397 | 406 if (tl != NULL) |
407 { | |
401 | 408 tl->touch(); |
397 | 409 emit timelineChanged(); |
410 } | |
411 } | |
412 | |
398 | 413 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
414 void QEDTimelineView::setTime(const int mtime) |
397 | 415 { |
416 if (tl != NULL && tl->tl != NULL) | |
417 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
418 QList<QEDTimelineTrackView *>::iterator track; |
397 | 419 for (track = tracks.begin(); track != tracks.end(); track++) |
420 { | |
421 (*track)->track->setTime(mtime); | |
422 } | |
423 update(); | |
424 } | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
425 } |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
426 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
427 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
428 void QEDTimelineView::setOffset(const int moffs) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
429 { |
397 | 430 if (tl != NULL && tl->tl != NULL) |
431 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
432 QList<QEDTimelineTrackView *>::iterator track; |
397 | 433 for (track = tracks.begin(); track != tracks.end(); track++) |
434 { | |
435 (*track)->track->setOffset(moffs); | |
436 } | |
437 update(); | |
438 } | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
439 } |
397 | 440 |
441 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
442 void QEDTimelineView::setScale(const float mscale) |
397 | 443 { |
444 if (tl != NULL && tl->tl != NULL) | |
445 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
446 QList<QEDTimelineTrackView *>::iterator track; |
397 | 447 for (track = tracks.begin(); track != tracks.end(); track++) |
448 { | |
449 (*track)->track->setScale(mscale); | |
450 } | |
451 update(); | |
452 } | |
453 } | |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
454 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
455 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
456 QList<DMTimelineEvent *> QEDTimelineView::getEventsAt(const int time) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
457 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
458 if (tl != NULL && tl->tl != NULL && |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
459 activeTrack >= 0 && activeTrack < tl->tl->ntracks) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
460 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
461 return tracks[activeTrack]->tl->getEventsAt(time); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
462 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
463 else |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
464 return QList<DMTimelineEvent *>(); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
465 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
466 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
467 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
468 QList<DMTimelineEvent *> QEDTimelineView::getEventsForRange(const int start, const int duration) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
469 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
470 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
471 |