]> git.sesse.net Git - kdenlive/commitdiff
Fix handling of effects with multiple keyframable parameters during cut:
authorTill Theato <root@ttill.de>
Sat, 19 Jun 2010 06:53:37 +0000 (06:53 +0000)
committerTill Theato <root@ttill.de>
Sat, 19 Jun 2010 06:53:37 +0000 (06:53 +0000)
http://kdenlive.org/mantis/view.php?id=1658

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

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

index 5e1a7503cfeaa01575d824fc9bdd12dd9e32cc2c..1d428a575899d14ca3800bc388de5e8482483294 100644 (file)
@@ -309,9 +309,14 @@ void ClipItem::initEffect(QDomElement effect, int diff)
 bool ClipItem::checkKeyFrames()
 {
     bool clipEffectsModified = false;
-    for (int ix = 0; ix < m_effectList.count(); ix ++) {
-        QString kfr = keyframes(ix);
-        if (!kfr.isEmpty()) {
+    // go through all effects this clip has
+    for (int ix = 0; ix < m_effectList.count(); ++ix) {
+        QStringList keyframeParams = keyframes(ix);
+        QStringList newKeyFrameParams;
+        bool effModified = false;
+
+        // go through all params which have keyframes
+        foreach (const QString &kfr, keyframeParams) {
             const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
             QStringList newKeyFrames;
             bool cutKeyFrame = false;
@@ -320,6 +325,8 @@ bool ClipItem::checkKeyFrames()
             double lastValue = -1;
             int start = cropStart().frames(m_fps);
             int end = (cropStart() + cropDuration()).frames(m_fps);
+
+            // go through all keyframes for one param
             foreach(const QString &str, keyframes) {
                 int pos = str.section(':', 0, 0).toInt();
                 double val = str.section(':', 1, 1).toDouble();
@@ -355,26 +362,32 @@ bool ClipItem::checkKeyFrames()
                 lastPos = pos;
                 lastValue = val;
             }
-            if (modified) {
-                // update KeyFrames
-                setKeyframes(ix, newKeyFrames.join(";"));
-                clipEffectsModified = true;
-            }
+
+            newKeyFrameParams.append(newKeyFrames.join(";"));
+            if (modified)
+                effModified = true;
+        }
+
+        if (effModified) {
+            // update KeyFrames
+            setKeyframes(ix, newKeyFrameParams);
+            clipEffectsModified = true;
         }
     }
     return clipEffectsModified;
 }
 
-void ClipItem::setKeyframes(const int ix, const QString keyframes)
+void ClipItem::setKeyframes(const int ix, const QStringList keyframes)
 {
     QDomElement effect = getEffectAt(ix);
     if (effect.attribute("disable") == "1") return;
     QDomNodeList params = effect.elementsByTagName("parameter");
+    int keyframeParams = 0;
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
-            e.setAttribute("keyframes", keyframes);
-            if (ix == m_selectedEffect) {
+            e.setAttribute("keyframes", keyframes.at(keyframeParams));
+            if (ix == m_selectedEffect && keyframeParams == 0) {
                 m_keyframes.clear();
                 double max = e.attribute("max").toDouble();
                 double min = e.attribute("min").toDouble();
@@ -391,9 +404,8 @@ void ClipItem::setKeyframes(const int ix, const QString keyframes)
                 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
                 if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
                 update();
-                return;
             }
-            break;
+            ++keyframeParams;
         }
     }
 }
@@ -435,18 +447,16 @@ void ClipItem::setSelectedEffect(const int ix)
     }
 }
 
-QString ClipItem::keyframes(const int index)
+QStringList ClipItem::keyframes(const int index)
 {
-    QString result;
+    QStringList result;
     QDomElement effect = effectAt(index);
     QDomNodeList params = effect.elementsByTagName("parameter");
 
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
-            result = e.attribute("keyframes");
-            break;
-        }
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe"))
+            result.append(e.attribute("keyframes"));
     }
     return result;
 }
index 6ef64c16217e573779ec89fd6bb584823a129b9a..27fc24d02aced85fac2bd61aaf701b2497ae99d7 100644 (file)
@@ -124,8 +124,16 @@ public:
     QDomElement selectedEffect();
     int selectedEffectIndex() const;
     void initEffect(QDomElement effect, int diff = 0);
-    QString keyframes(const int index);
-    void setKeyframes(const int ix, const QString keyframes);
+
+    /** @brief Gets all keyframes.
+    * @param index Number of the effect
+    * @return a list of strings of keyframes (one string per param) */
+    QStringList keyframes(const int index);
+
+    /** @brief Sets params with keyframes and updates the visible keyframes.
+    * @param ix Number of the effect
+    * @param keyframes a list of strings of keyframes (one string per param), which should be used */
+    void setKeyframes(const int ix, const QStringList keyframes);
     void setEffectList(const EffectsList effectList);
     void setSpeed(const double speed, int strobe);
     double speed() const;
@@ -135,6 +143,9 @@ public:
     GenTime speedIndependantCropDuration() const;
     const ItemInfo speedIndependantInfo() const;
     int hasEffect(const QString &tag, const QString &id) const;
+
+    /** @brief Makes sure all keyframes are in the clip's cropped duration.
+    * @return Whether or not changes were made */
     bool checkKeyFrames();
     QPixmap startThumb() const;
     QPixmap endThumb() const;
index 181d24d679c64bb72aac38bfcd640118b0dde858..de7e724e4a6b30b55e7891042696371be75bcc08 100644 (file)
@@ -1387,11 +1387,11 @@ void CustomTrackView::editItemDuration()
 
 void CustomTrackView::editKeyFrame(const GenTime pos, const int track, const int index, const QString keyframes)
 {
-    ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track);
+    /*ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track);
     if (clip) {
         clip->setKeyframes(index, keyframes);
         updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(index), index, false);
-    } else emit displayMessage(i18n("Cannot find clip with keyframe"), ErrorMessage);
+    } else emit displayMessage(i18n("Cannot find clip with keyframe"), ErrorMessage);*/
 }
 
 
index be1fafa56d5f72cf18d24848e9460986a368bc18..1dbdef51b7b2dbb1c34999cebaee6bc309a4683e 100644 (file)
@@ -3432,7 +3432,8 @@ void MainWindow::slotChangePalette(QAction *action, const QString &themename)
                 ((QWidget*)subchild)->setPalette(plt);
         }
     }
-    if (m_activeTimeline) m_activeTimeline->projectView()->updatePalette();
+    if (m_activeTimeline)
+        m_activeTimeline->projectView()->updatePalette();
 }