Mercurial > hg > dmlib
annotate editor/edtimeline.cpp @ 2293:587b26cecf5b
Add read/write RAW palette function prototypes to public header.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 03 Jul 2019 09:01:47 +0300 |
parents | b4992d9f72fe |
children |
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: |
1738 | 239 if (parent.getActiveTrack() != this) |
565
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 } |
1738 | 266 |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
267 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
|
268 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
269 dragging = true; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
270 setOffset(dragOffs - (ev->pos().x() - dragPoint.x()) / scale); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
271 } |
357 | 272 } |
273 | |
274 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
275 void QEDTimelineTrackDisplay::mouseReleaseEvent(QMouseEvent *ev) |
357 | 276 { |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
277 if (ev->button() == Qt::LeftButton) |
357 | 278 { |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
279 if (selecting) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
280 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
281 selecting = false; |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
282 setSelection(selectionOffs + (ev->pos().x() - selectionPoint.x()) / scale); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
283 } |
357 | 284 } |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
285 else |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
286 if (ev->button() == Qt::RightButton && !dragging) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
287 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
288 setTime(offs + getTimeFromCoord(ev->pos().x())); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
289 } |
357 | 290 } |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
291 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
292 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
293 QEDTimelineTrackView::QEDTimelineTrackView(QWidget *parent) : QWidget(parent) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
294 { |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
295 QHBoxLayout *mainLayout = new QHBoxLayout(this); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
296 mainLayout->setMargin(0); |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
297 track = new QEDTimelineTrackDisplay(this); |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
298 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
299 QFrame *infoLayoutContainer = new QFrame(this); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
300 infoLayoutContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
301 infoLayoutContainer->setLineWidth(2); |
398 | 302 infoLayoutContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
303 infoLayoutContainer->setFixedWidth(200); | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
304 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
305 QVBoxLayout *infoLayout = new QVBoxLayout(infoLayoutContainer); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
306 infoLayout->setMargin(0); |
398 | 307 infoName = new QLineEdit(); |
308 infoName->setFrame(false); | |
309 infoName->setMaxLength(DT_MAX_NAME_LENGTH); | |
310 infoName->setStyleSheet("QLineEdit { background-color: black; color: white; padding: 2px; }"); | |
311 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
|
312 infoLayout->addWidget(infoName); |
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 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
315 enabledCheck = new QCheckBox("Enabled"); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
316 infoLayout->addWidget(enabledCheck); |
398 | 317 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
|
318 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
319 infoData = new QLabel(); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
320 infoData->setStyleSheet("QLabel { padding: 2px; }"); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
321 infoLayout->addWidget(infoData); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
322 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
323 mainLayout->addWidget(infoLayoutContainer); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
324 mainLayout->addWidget(track); |
398 | 325 } |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
326 |
398 | 327 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
328 void QEDTimelineTrackView::update() |
398 | 329 { |
330 if (track != NULL && track->track) | |
331 { | |
332 infoName->setText(QString(track->track->name)); | |
333 enabledCheck->setChecked(track->track->enabled); | |
334 infoData->setText(QString("<b>%1</b> events").arg(track->track->nevents)); | |
335 } | |
336 else | |
337 { | |
338 infoName->setText(""); | |
339 infoData->setText("-"); | |
340 enabledCheck->setChecked(false); | |
341 } | |
342 | |
343 QWidget::update(); | |
393
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 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
346 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
347 void QEDTimelineTrackView::setTrack(DMTimelineTrack *mtrack) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
348 { |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
349 track->setTrack(mtrack); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
350 update(); |
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 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
353 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
354 void QEDTimelineTrackView::slotTrackEnabledChanged(bool value) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
355 { |
397 | 356 track->track->enabled = value; |
398 | 357 emit trackChanged(); |
358 } | |
359 | |
360 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
361 void QEDTimelineTrackView::slotTrackNameChanged(const QString & text) |
398 | 362 { |
363 QByteArray ba = text.toUtf8(); | |
364 track->track->name = dm_strdup(ba.constData()); | |
365 emit trackChanged(); | |
397 | 366 } |
367 | |
368 | |
369 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
370 QEDTimelineView::QEDTimelineView(QWidget *parent) : QWidget(parent) |
397 | 371 { |
372 layout = new QVBoxLayout(this); | |
373 tl = NULL; | |
393
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 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
376 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
377 void QEDTimelineView::setTimeline(EDTimelineObject *mtl) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
378 { |
397 | 379 tl = mtl; |
380 | |
381 delete layout; | |
382 layout = new QVBoxLayout(this); | |
398 | 383 layout->setMargin(0); |
384 | |
397 | 385 tracks.clear(); |
386 | |
387 if (tl != NULL && tl->tl != NULL) | |
388 { | |
389 for (int track = 0; track < tl->tl->ntracks; track++) | |
390 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
391 QEDTimelineTrackView *vtr = new QEDTimelineTrackView(this); |
397 | 392 vtr->setTrack(tl->tl->tracks[track]); |
393 tracks.append(vtr); | |
394 layout->addWidget(vtr); | |
398 | 395 connect(vtr, SIGNAL(trackChanged()), this, SLOT(slotTimelineChanged())); |
565
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
396 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
|
397 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
|
398 connect(vtr, SIGNAL(selectionChanged(float,float)), this, SLOT(slotSelectionChanged(float,float))); |
397 | 399 } |
400 } | |
401 update(); | |
393
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 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
404 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
405 void QEDTimelineView::slotTimelineChanged() |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
406 { |
397 | 407 if (tl != NULL) |
408 { | |
401 | 409 tl->touch(); |
397 | 410 emit timelineChanged(); |
411 } | |
412 } | |
413 | |
398 | 414 |
1738 | 415 void QEDTimelineView::setTime(const float mtime) |
397 | 416 { |
417 if (tl != NULL && tl->tl != NULL) | |
418 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
419 QList<QEDTimelineTrackView *>::iterator track; |
397 | 420 for (track = tracks.begin(); track != tracks.end(); track++) |
421 { | |
422 (*track)->track->setTime(mtime); | |
423 } | |
424 update(); | |
425 } | |
393
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 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
428 |
1738 | 429 void QEDTimelineView::setOffset(const float moffs) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
430 { |
397 | 431 if (tl != NULL && tl->tl != NULL) |
432 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
433 QList<QEDTimelineTrackView *>::iterator track; |
397 | 434 for (track = tracks.begin(); track != tracks.end(); track++) |
435 { | |
436 (*track)->track->setOffset(moffs); | |
437 } | |
438 update(); | |
439 } | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
440 } |
397 | 441 |
442 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
443 void QEDTimelineView::setScale(const float mscale) |
397 | 444 { |
445 if (tl != NULL && tl->tl != NULL) | |
446 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
447 QList<QEDTimelineTrackView *>::iterator track; |
397 | 448 for (track = tracks.begin(); track != tracks.end(); track++) |
449 { | |
450 (*track)->track->setScale(mscale); | |
451 } | |
452 update(); | |
453 } | |
454 } | |
565
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 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
457 QList<DMTimelineEvent *> QEDTimelineView::getEventsAt(const int time) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
458 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
459 if (tl != NULL && tl->tl != NULL && |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
460 activeTrack >= 0 && activeTrack < tl->tl->ntracks) |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
461 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
462 return tracks[activeTrack]->tl->getEventsAt(time); |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
463 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
464 else |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
465 return QList<DMTimelineEvent *>(); |
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 |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
469 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
|
470 { |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
471 } |
a4666c9e1336
Moar work on the editor (broken).
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
472 |