From 706d22f3a96b9dd1fa19e84e58ec4aaf3d9d67bc Mon Sep 17 00:00:00 2001 From: Till Theato Date: Thu, 12 Aug 2010 21:50:47 +0000 Subject: [PATCH] Keep timeline cursor position in sync with local timelines of effects: http://kdenlive.org/mantis/view.php?id=550 svn path=/trunk/kdenlive/; revision=4709 --- src/effectstackedit.cpp | 7 +++++++ src/effectstackedit.h | 2 ++ src/effectstackview.cpp | 7 +++++++ src/effectstackview.h | 4 ++++ src/geometryval.cpp | 10 ++++++++++ src/geometryval.h | 2 ++ src/geometrywidget.cpp | 13 ++++++++++++- src/geometrywidget.h | 2 ++ src/transitionsettings.cpp | 8 ++++++++ src/transitionsettings.h | 3 ++- 10 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index b3bda144..2c20c8fd 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -275,6 +275,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int))); connect(geometry, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); + connect(this, SIGNAL(syncEffectsPos(int)), geometry, SLOT(slotSyncPosition(int))); } else { Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos); if (minFrame == maxFrame) @@ -285,6 +286,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in m_valueItems[paramName+"geometry"] = geo; connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); + connect(this, SIGNAL(syncEffectsPos(int)), geo, SLOT(slotSyncPosition(int))); } } else if (type == "keyframe" || type == "simplekeyframe") { // keyframe editor widget @@ -692,3 +694,8 @@ void EffectStackEdit::clearAllItems() m_keyframeEditor = NULL; blockSignals(false); } + +void EffectStackEdit::slotSyncEffectsPos(int pos) +{ + emit syncEffectsPos(pos); +} diff --git a/src/effectstackedit.h b/src/effectstackedit.h index 78e7b52a..ce9eaa1b 100644 --- a/src/effectstackedit.h +++ b/src/effectstackedit.h @@ -79,12 +79,14 @@ public slots: * * Transfers all Dynamic gui parameter settings into m_params(??) */ void collectAllParameters(); + void slotSyncEffectsPos(int pos); signals: void parameterChanged(const QDomElement, const QDomElement); void seekTimeline(int); void displayMessage(const QString&, int); void checkMonitorPosition(int); + void syncEffectsPos(int pos); }; #endif diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index 9509421f..8f11455b 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -85,6 +85,7 @@ EffectStackView::EffectStackView(Monitor *monitor, QWidget *parent) : connect(m_effectedit, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int))); connect(m_effectedit, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int))); connect(m_effectedit, SIGNAL(checkMonitorPosition(int)), this, SLOT(slotCheckMonitorPosition(int))); + connect(monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int))); m_effectLists["audio"] = &MainWindow::audioEffects; m_effectLists["video"] = &MainWindow::videoEffects; m_effectLists["custom"] = &MainWindow::customEffects; @@ -407,4 +408,10 @@ void EffectStackView::slotCheckMonitorPosition(int renderPos) } } +void EffectStackView::slotRenderPos(int pos) +{ + if (m_clipref) + m_effectedit->slotSyncEffectsPos(pos - m_clipref->startPos().frames(KdenliveSettings::project_fps())); +} + #include "effectstackview.moc" diff --git a/src/effectstackview.h b/src/effectstackview.h index 4744fbff..d0127014 100644 --- a/src/effectstackview.h +++ b/src/effectstackview.h @@ -116,8 +116,12 @@ private slots: /** @brief Define the region filter for current effect. */ void slotRegionChanged(); + /** @brief Checks whether the monitor scene has to be displayed. */ void slotCheckMonitorPosition(int renderPos); + /** @brief Pass position changes in project monitor/timline to the effects to keep their local timelines in sync. */ + void slotRenderPos(int pos); + signals: void removeEffect(ClipItem*, QDomElement); /** Parameters for an effect changed, update the filter in playlist */ diff --git a/src/geometryval.cpp b/src/geometryval.cpp index 9fb81d6e..a4879463 100644 --- a/src/geometryval.cpp +++ b/src/geometryval.cpp @@ -423,6 +423,16 @@ void Geometryval::setupParam(const QDomElement par, int minFrame, int maxFrame) connect(spinTransp, SIGNAL(valueChanged(int)), this , SLOT(slotTransparencyChanged(int))); } +void Geometryval::slotSyncPosition(int relTimelinePos) +{ + if (m_timePos.maximum() > 0 && KdenliveSettings::transitionfollowcursor()) { + relTimelinePos = qMax(0, relTimelinePos); + relTimelinePos = qMin(relTimelinePos, m_timePos.maximum()); + if (relTimelinePos != m_timePos.getValue()) + slotPositionChanged(relTimelinePos, false); + } +} + void Geometryval::updateTransitionPath() { if (m_fixedMode) return; diff --git a/src/geometryval.h b/src/geometryval.h index 1eee0374..3bacb18d 100644 --- a/src/geometryval.h +++ b/src/geometryval.h @@ -72,6 +72,8 @@ private: public slots: void setupParam(const QDomElement, int minframe, int maxframe); + /** @brief Updates position of the local timeline to @param relTimelinePos. */ + void slotSyncPosition(int relTimelinePos); private slots: void slotNextFrame(); diff --git a/src/geometrywidget.cpp b/src/geometrywidget.cpp index 72572e44..ad20fefc 100644 --- a/src/geometrywidget.cpp +++ b/src/geometrywidget.cpp @@ -108,7 +108,7 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos, m_scene = monitor->getEffectScene(); connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateGeometry())); - connect(m_monitor->render, SIGNAL(rendererPosition(int)), this, SLOT(slotCheckMonitorPosition(int))); + connect(m_monitor, SIGNAL(renderPosition(int)), this, SLOT(slotCheckMonitorPosition(int))); connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateProperties())); } @@ -147,6 +147,7 @@ void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxfra // Keyframes are disabled m_ui.widgetTimeWrapper->setHidden(true); } else { + m_ui.widgetTimeWrapper->setHidden(false); m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint - 1); m_timeline->update(); m_timePos->setRange(0, m_outPoint - m_inPoint - 1); @@ -172,6 +173,16 @@ void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxfra slotCheckMonitorPosition(m_monitor->render->seekFramePosition()); } +void GeometryWidget::slotSyncPosition(int relTimelinePos) +{ + if (m_timePos->maximum() > 0 && KdenliveSettings::transitionfollowcursor()) { + relTimelinePos = qMax(0, relTimelinePos); + relTimelinePos = qMin(relTimelinePos, m_timePos->maximum()); + if (relTimelinePos != m_timePos->getValue()) + slotPositionChanged(relTimelinePos, false); + } +} + void GeometryWidget::slotPositionChanged(int pos, bool seek) { diff --git a/src/geometrywidget.h b/src/geometrywidget.h index 35369f43..18ff8622 100644 --- a/src/geometrywidget.h +++ b/src/geometrywidget.h @@ -55,6 +55,8 @@ public slots: * @param minframe In point of the clip * @param maxframe Out point of the clip */ void setupParam(const QDomElement elem, int minframe, int maxframe); + /** @brief Updates position of the local timeline to @param relTimelinePos. */ + void slotSyncPosition(int relTimelinePos); private: Ui::GeometryWidget_UI m_ui; diff --git a/src/transitionsettings.cpp b/src/transitionsettings.cpp index 68f6651f..e7984f19 100644 --- a/src/transitionsettings.cpp +++ b/src/transitionsettings.cpp @@ -63,6 +63,7 @@ TransitionSettings::TransitionSettings(Monitor *monitor, QWidget* parent) : connect(transitionList, SIGNAL(activated(int)), this, SLOT(slotTransitionChanged())); connect(transitionTrack, SIGNAL(activated(int)), this, SLOT(slotTransitionTrackChanged())); connect(m_effectEdit, SIGNAL(parameterChanged(const QDomElement&, const QDomElement&)), this , SLOT(slotUpdateEffectParams(const QDomElement&, const QDomElement&))); + connect(monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int))); } void TransitionSettings::updateProjectFormat(MltVideoProfile profile, Timecode t, const QList info) @@ -205,3 +206,10 @@ void TransitionSettings::raiseWindow(QWidget* dock) } +void TransitionSettings::slotRenderPos(int pos) +{ + if (m_usedTransition) + m_effectEdit->slotSyncEffectsPos(pos - m_usedTransition->startPos().frames(KdenliveSettings::project_fps())); +} + +#include "transitionsettings.moc" diff --git a/src/transitionsettings.h b/src/transitionsettings.h index 0a31e2a0..81d652c1 100644 --- a/src/transitionsettings.h +++ b/src/transitionsettings.h @@ -53,9 +53,10 @@ public slots: void slotUpdateEffectParams(const QDomElement&, const QDomElement&); private slots: - /** @brief Sets the new B track for the transition (automatic or forced). */ void slotTransitionTrackChanged(); + /** @brief Pass position changes in project monitor/timline to the effects to keep their local timelines in sync. */ + void slotRenderPos(int pos); signals: void transitionUpdated(Transition *, QDomElement); -- 2.39.2