]> git.sesse.net Git - kdenlive/commitdiff
Try to fix keyframes resizing issue:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 4 Jul 2011 07:53:21 +0000 (07:53 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 4 Jul 2011 07:53:21 +0000 (07:53 +0000)
http://kdenlive.org/mantis/view.php?id=2210

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

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

index aa7c5e8f1224bc9258338d4346b891c257fe2578..62f71b42726ec2780ad02dcaff7883abc8388a17 100644 (file)
@@ -1750,26 +1750,6 @@ void ClipItem::updateKeyframes(QDomElement effect)
     update();
 }*/
 
-QList <int> ClipItem::updatePanZoom(int width, int height, int cut)
-{
-    QList <int> effectPositions;
-    for (int i = 0; i < m_effectList.count(); i++) {
-        QDomElement effect = m_effectList.at(i);
-        QDomNodeList params = effect.elementsByTagName("parameter");
-        for (int j = 0; j < params.count(); j++) {
-            QDomElement e = params.item(j).toElement();
-            if (e.isNull())
-                continue;
-            if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
-                effectPositions << i;
-//                 updateGeometryKeyframes(effect, j, width, height, cut);
-            }
-        }
-    }
-
-    return effectPositions;
-}
-
 Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
 {
     if (isAudioOnly())
@@ -1936,10 +1916,23 @@ bool ClipItem::updateNormalKeyframes(QDomElement parameter)
 
 void ClipItem::updateGeometryKeyframes(QDomElement effect, int paramIndex, int width, int height, ItemInfo oldInfo)
 {
-    QDomElement param = effect.elementsByTagName("parameter").item(paramIndex).toElement();
-
-    Mlt::Geometry geometry(param.attribute("value").toUtf8().data(), oldInfo.cropDuration.frames(m_fps), width, height);
 
+    QDomElement param = effect.elementsByTagName("parameter").item(paramIndex).toElement();
+    int offset = oldInfo.cropStart.frames(m_fps);
+    QString data = param.attribute("value");
+    if (offset > 0) {
+        QStringList kfrs = data.split(';');
+        data.clear();
+        foreach (QString keyframe, kfrs) {
+            if (keyframe.contains('=')) {
+                int pos = keyframe.section('=', 0, 0).toInt();
+                pos += offset;
+                data.append(QString::number(pos) + "=" + keyframe.section('=', 1) + ";");
+            }
+            else data.append(keyframe + ";");
+        }
+    }
+    Mlt::Geometry geometry(data.toUtf8().data(), oldInfo.cropDuration.frames(m_fps), width, height);
     param.setAttribute("value", geometry.serialise(cropStart().frames(m_fps), (cropStart() + cropDuration()).frames(m_fps) - 1));
 }
 
index 4ff7c4e0832f2167e7d17d4c514bd80be41731cb..8a1137d68d582a2407003549d2e4f422022cfb83 100644 (file)
@@ -160,14 +160,6 @@ public:
     void insertKeyframe(QDomElement effect, int pos, int val);
     void movedKeyframe(QDomElement effect, int oldpos, int newpos, double value);
     void updateKeyframes(QDomElement effect);
-    /** @brief Updates the keyframes in the pan and zoom effect to fit the clips cropDuration.
-     * @param width Render width
-     * @param height Render height
-     * @param cut (optional) if clip was cut, cut position relative to the original's clip position
-     * @return List of the pan and zoom effects indexes
-     * 
-     * Can be used for all effects using mlt_geometry with keyframes, but at the moment Pan & Zoom is the only one. */
-    QList <int> updatePanZoom(int width, int height, int cut = 0);
     void updateGeometryKeyframes(QDomElement effect, int paramIndex, int width, int height, ItemInfo oldInfo);
     bool updateNormalKeyframes(QDomElement parameter);
 
index 2ed7b65bf65400def82574a71fde868595d4d2c2..1910e67e036d8c8392648c7118af9fc34b7da2db 100644 (file)
@@ -2092,9 +2092,6 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
         if (dup->checkKeyFrames())
             slotRefreshEffects(dup);
 
-        updatePanZoom(item);
-        updatePanZoom(dup, cutTime - item->startPos());
-
         item->baseClip()->addReference();
         m_document->updateClip(item->baseClip()->getId());
         setDocumentModified();
@@ -2151,9 +2148,6 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
         bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, info.endPos - info.startPos);
         if (success) {
             item->resizeEnd((int) info.endPos.frames(m_document->fps()));
-
-            updatePanZoom(item);
-
             setDocumentModified();
         } else {
             emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
@@ -6601,23 +6595,6 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
     return parameters;
 }
 
-void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos)
-{
-    QList <int> effects = item->updatePanZoom(m_document->width(), m_document->height(), cutPos.frames(m_document->fps()));
-
-    for (int i = 0; i < effects.count(); ++i) {
-        if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(item->effectAt(effects.at(i)))))
-            emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-
-        // if effect is displayed, update the effect edit widget with new clip duration
-        /*if (item->isSelected() && effects.at(i) == item->selectedEffectIndex())
-            emit clipItemSelected(item, effects.at(i));*/
-    }
-    // update always, otherwise there might problems when resizing groups
-    if (effects.count())
-        emit clipItemSelected(item, item->selectedEffectIndex());
-}
-
 void CustomTrackView::updateTrackNames(int track, bool added)
 {
     QList <TrackInfo> tracks = m_document->tracksList();
index 9312566c6469034bd0dbfc2132aa75c57817da21..8b0b2da56a693e9a36dd5851a7d06ae36e9db148 100644 (file)
@@ -412,11 +412,6 @@ private:
     /** @brief Gets the effect parameters that will be passed to Mlt. */
     EffectsParameterList getEffectArgs(const QDomElement effect);
 
-    /** @brief Updates @param item's pan and zoom effect after resize or cut.
-     * @param item clip whose pan and zoom effect should be updated
-     * @param cutPos (optional) if clip was cut, cut position relative to the original's clip position */
-    void updatePanZoom(ClipItem *item, GenTime cutPos = GenTime());
-
     /** @brief Update Tracknames to fit again after track was added/deleted.
      * @param track Number of track which was added/deleted
      * @param added true = track added, false = track deleted