]> git.sesse.net Git - kdenlive/commitdiff
make the new effect adjustment function more generic
authorTill Theato <root@ttill.de>
Wed, 6 Apr 2011 16:43:23 +0000 (16:43 +0000)
committerTill Theato <root@ttill.de>
Wed, 6 Apr 2011 16:43:23 +0000 (16:43 +0000)
svn path=/trunk/kdenlive/; revision=5539

src/clipitem.cpp
src/clipitem.h
src/customtrackview.cpp
src/customtrackview.h

index 5e4cf6f6656cbf19707ff17cb229e1547009c983..22baf363bbff70c637bfedb6bed2876190f92924 100644 (file)
@@ -1749,7 +1749,7 @@ Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
         return m_clip->producer(trackSpecific ? track : -1);
 }
 
-QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, int previous, int current, bool fromStart)
+QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, ItemInfo oldInfo)
 {
     QMap<int, QDomElement> effects;
     for (int i = 0; i < m_effectList.count(); i++) {
@@ -1794,9 +1794,9 @@ QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height,
                     setFadeOut(out - in);
             }
             continue;
-        } else if (fromStart && effect.attribute("id") == "freeze") {
+        } else if (effect.attribute("id") == "freeze" && cropStart() != oldInfo.cropStart) {
             effects[i] = effect.cloneNode().toElement();
-            int diff = previous - current;
+            int diff = (oldInfo.cropStart - cropStart()).frames(m_fps);
             int frame = EffectsList::parameter(effect, "frame").toInt();
             EffectsList::setParameter(effect, "frame", QString::number(frame - diff));
             continue;
index fddbd007e8556c87667b317dab72bf52c540d84e..710a031f836c4752804c8d4c2e80c35525eff15e 100644 (file)
@@ -171,7 +171,7 @@ public:
     bool updateNormalKeyframes(QDomElement parameter);
 
     /** @brief Adjusts effects after a clip duration change. */
-    QMap<int, QDomElement> adjustEffectsToDuration(int width, int height, int previous, int current, bool fromStart);
+    QMap<int, QDomElement> adjustEffectsToDuration(int width, int height, ItemInfo oldInfo);
 
     /** Returns the necessary (audio, video, general) producer.
      * @param track Track of the requested producer
index 5fc2cea0727e2e92fe51bdc09c2fc42375b3eb26..44e932e02aa0fed328abc003640a310dbb936c56 100644 (file)
@@ -4548,7 +4548,7 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
             // put a resize command before & after checking keyframes so that
             // we are sure the resize is performed before whenever we do or undo the action
             new ResizeClipCommand(this, oldInfo, info, false, true, command);
-            adjustEffects(clip, oldInfo, true, command);
+            adjustEffects(clip, oldInfo, command);
             new ResizeClipCommand(this, oldInfo, info, false, true, command);
             emit clipItemSelected(clip);
         } else {
@@ -4643,7 +4643,7 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
             // put a resize command before & after checking keyframes so that
             // we are sure the resize is performed before whenever we do or undo the action
             new ResizeClipCommand(this, oldInfo, info, false, true, command);
-            adjustEffects(clip, oldInfo, false, command);
+            adjustEffects(clip, oldInfo, command);
             new ResizeClipCommand(this, oldInfo, info, false, true, command);
             emit clipItemSelected(clip);
         } else {
@@ -6661,14 +6661,10 @@ void CustomTrackView::slotRefreshThumbs(const QString &id, bool resetThumbs)
     }
 }
 
-void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, bool fromStart, QUndoCommand* command)
+void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoCommand* command)
 {
     QMap<int, QDomElement> effects;
-    if (fromStart)
-        effects = item->adjustEffectsToDuration(m_document->width(), m_document->height(), oldInfo.cropStart.frames(m_document->fps()), item->cropStart().frames(m_document->fps()), true);
-    else
-        effects = item->adjustEffectsToDuration(m_document->width(), m_document->height(), (oldInfo.cropStart +  oldInfo.cropDuration).frames(m_document->fps()) - 1,
-                                                (item->cropStart() + item->cropDuration()).frames(m_document->fps()) - 1, false);
+    item->adjustEffectsToDuration(m_document->width(), m_document->height(), oldInfo);
 
     if (effects.count()) {
         QMap<int, QDomElement>::const_iterator i = effects.constBegin();
index a4b555ae4f55e26c796f6d0d1736a5888ba89cdb..1de28076e4fd5cded97b3d5eb137f771ad4b028b 100644 (file)
@@ -438,7 +438,7 @@ private:
      * @param oldInfo pre resize info
      * @param fromStart false = resize from end
      * @param command Used as a parent for EditEffectCommand */
-    void adjustEffects(ClipItem *item, ItemInfo oldInfo, bool fromStart, QUndoCommand *command);
+    void adjustEffects(ClipItem *item, ItemInfo oldInfo, QUndoCommand *command);
 
 private slots:
     void slotRefreshGuides();