Mercurial > hg > dmlib
annotate edtimeline.cpp @ 409:b529b7e8ff83
Various improvements and cruft cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 03 Nov 2012 02:40:07 +0200 |
parents | d34922e6a244 |
children | a4666c9e1336 |
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 void QEDTimelineTrackDisplay::setTime(const int mtime) |
357 | 34 { |
35 time = mtime; | |
36 } | |
37 | |
38 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
39 void QEDTimelineTrackDisplay::setOffset(const int moffs) |
357 | 40 { |
41 offs = moffs; | |
42 } | |
43 | |
44 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
45 void QEDTimelineTrackDisplay::setScale(const float mscale) |
357 | 46 { |
47 if (mscale > 0.05) | |
48 scale = mscale; | |
49 } | |
50 | |
51 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
52 float QEDTimelineTrackDisplay::getTimeScale(float value) |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
53 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
54 return value * scale; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
55 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
56 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
57 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
58 float QEDTimelineTrackDisplay::getTimeFromCoord(float value) |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
59 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
60 return value * scale * 1000.0f; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
61 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
62 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
63 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
64 void QEDTimelineTrackDisplay::paintEvent(QPaintEvent *) |
357 | 65 { |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
66 if (track == NULL) |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
67 return; |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
68 |
357 | 69 QColor eventColor(150, 150, 150); |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
70 QColor invalidEventColor(250, 150, 150); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
71 QColor eventBorder(200, 250, 200); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
72 QColor eventParam(200, 150, 100); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
73 QColor eventText(255, 255, 255); |
357 | 74 QColor markerColor(255,255,255); |
75 | |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
76 QFont fantti; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
77 fantti.setFamily("Arial"); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
78 fantti.setPointSizeF(8.0f); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
79 fantti.setStyleHint(QFont::SansSerif); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
80 |
357 | 81 QPainter painter(this); |
82 painter.setRenderHint(QPainter::Antialiasing); | |
83 | |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
84 |
357 | 85 painter.save(); |
86 painter.scale(scale, 1); | |
87 | |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
88 float wd = getTimeScale(width()); |
357 | 89 for (int event = 0; event < track->nevents; event++) |
90 { | |
91 DMTimelineEvent *ev = track->events[event]; | |
402
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
92 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
93 float x0 = getTimeScale(ev->start - offs), |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
94 x1 = getTimeScale(ev->start + ev->duration - offs); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
95 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
96 if ((x0 >= 0 && x0 < wd) || (x0 < 0 && x1 >= 0)) |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
97 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
98 painter.setFont(fantti); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
99 painter.setBrush(ev->effect != NULL ? eventColor : invalidEventColor); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
100 painter.setPen(eventBorder); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
101 x0 = ev->start - offs; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
102 x1 = ev->duration; |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
103 painter.fillRect(x0, 0, x1, height(), eventColor); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
104 |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
105 painter.setBrush(eventText); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
106 if (ev->effect != NULL) |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
107 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
108 QString name(ev->effect->name); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
109 painter.drawText(QPointF(x0 + 2, 10), name); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
110 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
111 else |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
112 { |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
113 painter.drawText(QPointF(x0 + 2, 10), "INVALID"); |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
114 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
115 } |
0f290af63fc1
Timeline event drawing prototype works.
Matti Hamalainen <ccr@tnsp.org>
parents:
401
diff
changeset
|
116 |
357 | 117 } |
118 | |
397 | 119 painter.restore(); |
120 | |
357 | 121 if (time >= offs * scale && time - offs <= width() * scale) |
122 { | |
123 int xc = time - offs; | |
397 | 124 painter.save(); |
357 | 125 painter.scale(scale, 1); |
126 painter.setPen(markerColor); | |
127 painter.drawLine(xc, 0, xc, height()); | |
397 | 128 painter.restore(); |
357 | 129 } |
130 } | |
131 | |
132 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
133 void QEDTimelineTrackDisplay::mousePressEvent(QMouseEvent *ev) |
357 | 134 { |
135 /* | |
136 if (ev->button() == Qt::LeftButton) | |
137 { | |
138 lastPoint = ev->pos(); | |
139 scribbling = true; | |
140 } | |
141 */ | |
142 } | |
143 | |
144 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
145 void QEDTimelineTrackDisplay::mouseMoveEvent(QMouseEvent *ev) |
357 | 146 { |
147 /* | |
148 if ((ev->buttons() & Qt::LeftButton) && scribbling) | |
149 drawLineTo(ev->pos()); | |
150 */ | |
151 } | |
152 | |
153 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
154 void QEDTimelineTrackDisplay::mouseReleaseEvent(QMouseEvent *ev) |
357 | 155 { |
156 /* | |
157 if (ev->button() == Qt::LeftButton && scribbling) | |
158 { | |
159 drawLineTo(ev->pos()); | |
160 scribbling = false; | |
161 } | |
162 */ | |
163 } | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
164 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
165 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
166 QEDTimelineTrackView::QEDTimelineTrackView(QWidget *parent) : QWidget(parent) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
167 { |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
168 QHBoxLayout *mainLayout = new QHBoxLayout(this); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
169 mainLayout->setMargin(0); |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
170 track = new QEDTimelineTrackDisplay(this); |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
171 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
172 QFrame *infoLayoutContainer = new QFrame(this); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
173 infoLayoutContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
174 infoLayoutContainer->setLineWidth(2); |
398 | 175 infoLayoutContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
176 infoLayoutContainer->setFixedWidth(200); | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
177 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
178 QVBoxLayout *infoLayout = new QVBoxLayout(infoLayoutContainer); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
179 infoLayout->setMargin(0); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
180 // QVBoxLayout *infoLayout = new QVBoxLayout(); |
398 | 181 infoName = new QLineEdit(); |
182 infoName->setFrame(false); | |
183 infoName->setMaxLength(DT_MAX_NAME_LENGTH); | |
184 infoName->setStyleSheet("QLineEdit { background-color: black; color: white; padding: 2px; }"); | |
185 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
|
186 infoLayout->addWidget(infoName); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
187 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
188 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
189 enabledCheck = new QCheckBox("Enabled"); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
190 infoLayout->addWidget(enabledCheck); |
398 | 191 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
|
192 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
193 infoData = new QLabel(); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
194 infoData->setStyleSheet("QLabel { padding: 2px; }"); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
195 infoLayout->addWidget(infoData); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
196 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
197 mainLayout->addWidget(infoLayoutContainer); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
198 // mainLayout->addLayout(infoLayout); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
199 mainLayout->addWidget(track); |
398 | 200 } |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
201 |
398 | 202 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
203 void QEDTimelineTrackView::update() |
398 | 204 { |
205 if (track != NULL && track->track) | |
206 { | |
207 infoName->setText(QString(track->track->name)); | |
208 enabledCheck->setChecked(track->track->enabled); | |
209 infoData->setText(QString("<b>%1</b> events").arg(track->track->nevents)); | |
210 } | |
211 else | |
212 { | |
213 infoName->setText(""); | |
214 infoData->setText("-"); | |
215 enabledCheck->setChecked(false); | |
216 } | |
217 | |
218 QWidget::update(); | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
219 } |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
220 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
221 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
222 void QEDTimelineTrackView::setTrack(DMTimelineTrack *mtrack) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
223 { |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
224 track->setTrack(mtrack); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
225 update(); |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
226 } |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
227 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
228 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
229 void QEDTimelineTrackView::slotTrackEnabledChanged(bool value) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
230 { |
397 | 231 track->track->enabled = value; |
398 | 232 emit trackChanged(); |
233 } | |
234 | |
235 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
236 void QEDTimelineTrackView::slotTrackNameChanged(const QString & text) |
398 | 237 { |
238 QByteArray ba = text.toUtf8(); | |
239 track->track->name = dm_strdup(ba.constData()); | |
240 emit trackChanged(); | |
397 | 241 } |
242 | |
243 | |
244 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
245 QEDTimelineView::QEDTimelineView(QWidget *parent) : QWidget(parent) |
397 | 246 { |
247 layout = new QVBoxLayout(this); | |
248 tl = NULL; | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
249 } |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
250 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
251 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
252 void QEDTimelineView::setTimeline(EDTimelineObject *mtl) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
253 { |
397 | 254 tl = mtl; |
255 | |
256 delete layout; | |
257 layout = new QVBoxLayout(this); | |
398 | 258 layout->setMargin(0); |
259 | |
397 | 260 tracks.clear(); |
261 | |
262 if (tl != NULL && tl->tl != NULL) | |
263 { | |
264 for (int track = 0; track < tl->tl->ntracks; track++) | |
265 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
266 QEDTimelineTrackView *vtr = new QEDTimelineTrackView(this); |
397 | 267 vtr->setTrack(tl->tl->tracks[track]); |
268 tracks.append(vtr); | |
269 layout->addWidget(vtr); | |
398 | 270 connect(vtr, SIGNAL(trackChanged()), this, SLOT(slotTimelineChanged())); |
397 | 271 } |
272 } | |
273 update(); | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
274 } |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
275 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
276 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
277 void QEDTimelineView::slotTimelineChanged() |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
278 { |
397 | 279 if (tl != NULL) |
280 { | |
401 | 281 tl->touch(); |
397 | 282 emit timelineChanged(); |
283 } | |
284 } | |
285 | |
398 | 286 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
287 void QEDTimelineView::setTime(const int mtime) |
397 | 288 { |
289 if (tl != NULL && tl->tl != NULL) | |
290 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
291 QList<QEDTimelineTrackView *>::iterator track; |
397 | 292 for (track = tracks.begin(); track != tracks.end(); track++) |
293 { | |
294 (*track)->track->setTime(mtime); | |
295 } | |
296 update(); | |
297 } | |
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 |
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
300 |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
301 void QEDTimelineView::setOffset(const int moffs) |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
302 { |
397 | 303 if (tl != NULL && tl->tl != NULL) |
304 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
305 QList<QEDTimelineTrackView *>::iterator track; |
397 | 306 for (track = tracks.begin(); track != tracks.end(); track++) |
307 { | |
308 (*track)->track->setOffset(moffs); | |
309 } | |
310 update(); | |
311 } | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
386
diff
changeset
|
312 } |
397 | 313 |
314 | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
315 void QEDTimelineView::setScale(const float mscale) |
397 | 316 { |
317 if (tl != NULL && tl->tl != NULL) | |
318 { | |
403
d34922e6a244
Even more work towards the editor.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
319 QList<QEDTimelineTrackView *>::iterator track; |
397 | 320 for (track = tracks.begin(); track != tracks.end(); track++) |
321 { | |
322 (*track)->track->setScale(mscale); | |
323 } | |
324 update(); | |
325 } | |
326 } |