]> git.sesse.net Git - kdenlive/commitdiff
- Fix some problems with undoing resizing a clip containing a pan & zoom effect
authorTill Theato <root@ttill.de>
Tue, 31 Aug 2010 18:19:15 +0000 (18:19 +0000)
committerTill Theato <root@ttill.de>
Tue, 31 Aug 2010 18:19:15 +0000 (18:19 +0000)
- Fix keeping sync of geometry widget timeline and project timeline

svn path=/trunk/kdenlive/; revision=4799

src/clipitem.cpp
src/customtrackview.cpp
src/geometrywidget.cpp

index 974ecf1cb1cec91fffc0ec0c18ba71e01949e42b..db0f69fac76c4fe1614aa4801e8d80d5e80ffcb9 100644 (file)
@@ -1219,7 +1219,9 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
         for (int j = 0; j < params.count(); j++) {
             bool modified = false;
             QDomElement e = params.item(j).toElement();
-            if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
+            if (e.isNull())
+                continue;
+            if (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") {
                 // parse keyframes and adjust values
                 const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
                 QMap <int, double> kfr;
@@ -1250,6 +1252,18 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
                     }
                     e.setAttribute("keyframes", newkfr);
                 }
+            } else if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
+                char *tmp = (char *) qstrdup(e.attribute("value").toUtf8().data());
+                Mlt::Geometry geometry(tmp, cropDuration().frames(fps()));
+                delete[] tmp;
+
+                Mlt::GeometryItem item;
+                while (!geometry.next_key(&item, cropDuration().frames(fps()))) {
+                    geometry.remove(item.frame());
+                    modified = true;
+                }
+                e.setAttribute("value", geometry.serialise());
             }
         }
     }
index 6d910500d27d35906b0bfbdfb2ef75e4ca043b91..f1bc1fda9ba2d5adb76261512b676fcce9cffdc0 100644 (file)
@@ -4385,6 +4385,9 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
                     new MoveTransitionCommand(this, trInfo, newTrInfo, true, command);
             }
 
+            /*
+                TODO: cleanup the effect update process
+             */
             ClipItem *clip = static_cast < ClipItem * >(item);
             updatePositionEffects(clip, oldInfo);
 
@@ -4401,6 +4404,12 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
                 }
             }
 
+            int panZoomPos = clip->hasEffect("affine", "pan_zoom");
+            if (panZoomPos != -1) {
+                doc.appendChild(doc.importNode(clip->effectAt(panZoomPos), true));
+                indexes.append(panZoomPos);
+            }
+
             if (clip->checkEffectsKeyframesPos(oldInfo.cropStart.frames(m_document->fps()), clip->cropStart().frames(m_document->fps()), true)) {
                 // Keyframes were modified, updateClip
                 QDomNodeList effs = doc.elementsByTagName("effect");
@@ -4673,6 +4682,7 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
         }
         oldeffect.setAttribute("in", start);
         oldeffect.setAttribute("out", max);
+
         if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
             emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
         // if effect is displayed, update the effect edit widget with new clip duration
index 496214237bbab221486e6d530af405415b5ff33d..787a4562e0588eb026ef781f321bec6f9b66dcb6 100644 (file)
@@ -190,14 +190,6 @@ void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxfra
         m_geometry = new Mlt::Geometry(tmp, maxframe - minframe, m_monitor->render->renderWidth(), m_monitor->render->renderHeight());
     delete[] tmp;
 
-    // remove keyframes out of range
-    Mlt::GeometryItem invalidItem;
-    bool foundInvalidItem = false;
-    while (!m_geometry->next_key(&invalidItem, maxframe - minframe)) {
-        foundInvalidItem = true;
-        m_geometry->remove(invalidItem.frame());
-    }
-
     if (elem.attribute("fixed") == "1") {
         // Keyframes are disabled
         m_ui.widgetTimeWrapper->setHidden(true);
@@ -229,10 +221,6 @@ void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxfra
 
     slotPositionChanged(0, false);
     slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
-
-    // update if we had to remove a keyframe which got out of range
-    if (foundInvalidItem)
-        QTimer::singleShot(300, this, SIGNAL(parameterChanged()));
 }
 
 void GeometryWidget::slotSyncPosition(int relTimelinePos)
@@ -249,14 +237,14 @@ void GeometryWidget::slotSyncPosition(int relTimelinePos)
 
 void GeometryWidget::slotPositionChanged(int pos, bool seek)
 {
-    if (pos == -1) {
+    if (pos == -1)
         pos = m_timePos->getValue();
-        m_timeline->blockSignals(true);
-        m_timeline->setValue(pos);
-        m_timeline->blockSignals(false);
-    } else {
+    else
         m_timePos->setValue(pos);
-    }
+
+    m_timeline->blockSignals(true);
+    m_timeline->setValue(pos);
+    m_timeline->blockSignals(false);
 
     Mlt::GeometryItem item;
     if (m_geometry->fetch(&item, pos) || item.key() == false) {