Mercurial > hg > dmlib
diff edtimeline.cpp @ 397:9993873ff655
More work towards editor.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 19 Oct 2012 07:22:09 +0300 |
parents | 5137db55f00b |
children | 8660c6005032 |
line wrap: on
line diff
--- a/edtimeline.cpp Fri Oct 19 07:21:54 2012 +0300 +++ b/edtimeline.cpp Fri Oct 19 07:22:09 2012 +0300 @@ -27,21 +27,18 @@ void QTimelineTrackDisplay::setTrack(DMTimelineTrack *mtrack) { track = mtrack; - update(); } void QTimelineTrackDisplay::setTime(const int mtime) { time = mtime; - update(); } void QTimelineTrackDisplay::setOffset(const int moffs) { offs = moffs; - update(); } @@ -49,7 +46,6 @@ { if (mscale > 0.05) scale = mscale; - update(); } @@ -72,12 +68,16 @@ DMTimelineEvent *ev = track->events[event]; } + painter.restore(); + if (time >= offs * scale && time - offs <= width() * scale) { int xc = time - offs; + painter.save(); painter.scale(scale, 1); painter.setPen(markerColor); painter.drawLine(xc, 0, xc, height()); + painter.restore(); } } @@ -137,7 +137,7 @@ enabledCheck = new QCheckBox("Enabled"); infoLayout->addWidget(enabledCheck); - connect(enabledCheck, SIGNAL(toggled(bool)), this, SLOT(slotEnabledChanged(bool))); + connect(enabledCheck, SIGNAL(toggled(bool)), this, SLOT(slotTrackChanged(bool))); infoData = new QLabel(); infoData->setStyleSheet("QLabel { padding: 2px; }"); @@ -167,26 +167,91 @@ } -void QTimelineTrackView::setTime(const int mtime) +void QTimelineTrackView::slotTrackChanged(bool value) { - track->setTime(mtime); + track->track->enabled = value; + emit trackChanged(value); +} + + + +QTimelineView::QTimelineView(QWidget *parent) : QWidget(parent) +{ + layout = new QVBoxLayout(this); + tl = NULL; } -void QTimelineTrackView::setOffset(const int moffs) +void QTimelineView::setTimeline(TimelineObject *mtl) { - track->setOffset(moffs); + tl = mtl; + + delete layout; + layout = new QVBoxLayout(this); + tracks.clear(); + + if (tl != NULL && tl->tl != NULL) + { + for (int track = 0; track < tl->tl->ntracks; track++) + { + QTimelineTrackView *vtr = new QTimelineTrackView(this); + vtr->setTrack(tl->tl->tracks[track]); + tracks.append(vtr); + layout->addWidget(vtr); + connect(vtr, SIGNAL(trackChanged(bool)), this, SLOT(slotTimelineChanged())); + } + } + update(); } -void QTimelineTrackView::setScale(const float mscale) +void QTimelineView::slotTimelineChanged() { - track->setScale(mscale); + if (tl != NULL) + { + tl->changed++; + emit timelineChanged(); + } +} + +void QTimelineView::setTime(const int mtime) +{ + if (tl != NULL && tl->tl != NULL) + { + QList<QTimelineTrackView *>::iterator track; + for (track = tracks.begin(); track != tracks.end(); track++) + { + (*track)->track->setTime(mtime); + } + update(); + } } -void QTimelineTrackView::slotEnabledChanged(bool value) + +void QTimelineView::setOffset(const int moffs) { - track->track->enabled = value; -// emit enabledChanged(value); + if (tl != NULL && tl->tl != NULL) + { + QList<QTimelineTrackView *>::iterator track; + for (track = tracks.begin(); track != tracks.end(); track++) + { + (*track)->track->setOffset(moffs); + } + update(); + } } + + +void QTimelineView::setScale(const float mscale) +{ + if (tl != NULL && tl->tl != NULL) + { + QList<QTimelineTrackView *>::iterator track; + for (track = tracks.begin(); track != tracks.end(); track++) + { + (*track)->track->setScale(mscale); + } + update(); + } +}