]> git.sesse.net Git - kdenlive/commitdiff
Fix keyframes not editable in timeline if first parameter is not keyframable
authorTill Theato <root@ttill.de>
Sat, 30 Oct 2010 22:35:15 +0000 (22:35 +0000)
committerTill Theato <root@ttill.de>
Sat, 30 Oct 2010 22:35:15 +0000 (22:35 +0000)
svn path=/trunk/kdenlive/; revision=5064

src/abstractclipitem.h
src/clipitem.cpp
src/keyframeedit.h

index c47ec9514fa310ed1979c712fa89ed83f3a54a42..f24e0ab24ac6ab5abac6f600be1a7a8fe1c10eef 100644 (file)
@@ -103,6 +103,8 @@ protected:
     QMap <int, int> m_keyframes;
     double m_keyframeFactor;
     double m_keyframeDefault;
+    /** The (keyframe) parameter that is visible and editable in timeline (on the clip) */
+    int m_visibleParam;
     double m_fps;
     //QRect visibleRect();
     void drawKeyFrames(QPainter *painter, QRectF exposedRect);
index 3631256a45c66473dc4a1239eb6b1a163c0dcecb..41dea03345973e4a7264421b80821cab7e9cdfc1 100644 (file)
@@ -393,6 +393,7 @@ void ClipItem::setKeyframes(const int ix, const QStringList keyframes)
             e.setAttribute("keyframes", keyframes.at(keyframeParams));
             if (ix == m_selectedEffect && keyframeParams == 0) {
                 m_keyframes.clear();
+                m_visibleParam = i;
                 double max = e.attribute("max").toDouble();
                 double min = e.attribute("min").toDouble();
                 m_keyframeFactor = 100.0 / (max - min);
@@ -426,6 +427,7 @@ void ClipItem::setSelectedEffect(const int ix)
                 QDomElement e = params.item(i).toElement();
                 if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
                     m_keyframes.clear();
+                    m_visibleParam = i;
                     double max = e.attribute("max").toDouble();
                     double min = e.attribute("min").toDouble();
                     m_keyframeFactor = 100.0 / (max - min);
@@ -471,23 +473,19 @@ void ClipItem::updateKeyframeEffect()
     QDomElement effect = getEffectAt(m_selectedEffect);
     if (effect.attribute("disable") == "1") return;
     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")) {
-            QString keyframes;
-            if (m_keyframes.count() > 0) {
-                QMap<int, int>::const_iterator i = m_keyframes.constBegin();
-                while (i != m_keyframes.constEnd()) {
-                    keyframes.append(QString::number(i.key()) + ':' + QString::number(i.value()) + ';');
-                    ++i;
-                }
+    QDomElement e = params.item(m_visibleParam).toElement();
+
+    if (!e.isNull()) {
+        QString keyframes;
+        if (m_keyframes.count() > 0) {
+            QMap<int, int>::const_iterator i = m_keyframes.constBegin();
+            while (i != m_keyframes.constEnd()) {
+                keyframes.append(QString::number(i.key()) + ':' + QString::number(i.value()) + ';');
+                ++i;
             }
-            // Effect has a keyframe type parameter, we need to set the values
-            //kDebug() << ":::::::::::::::   SETTING EFFECT KEYFRAMES: " << keyframes;
-            e.setAttribute("keyframes", keyframes);
-            break;
         }
+        // Effect has a keyframe type parameter, we need to set the values
+        e.setAttribute("keyframes", keyframes);
     }
 }
 
@@ -1221,9 +1219,7 @@ 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())
-                continue;
-            if (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") {
+            if (!e.isNull() && (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;
@@ -1683,29 +1679,33 @@ void ClipItem::insertKeyframe(QDomElement effect, int pos, int val)
     QDomNodeList params = effect.elementsByTagName("parameter");
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        QString kfr = e.attribute("keyframes");
-        const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
-        QStringList newkfr;
-        bool added = false;
-        foreach(const QString &str, keyframes) {
-            int kpos = str.section(':', 0, 0).toInt();
-            double newval = str.section(':', 1, 1).toDouble();
-            if (kpos < pos) {
-                newkfr.append(str);
-            } else if (!added) {
-                if (i == 0) newkfr.append(QString::number(pos) + ":" + QString::number(val));
-                else newkfr.append(QString::number(pos) + ":" + QString::number(newval));
-                if (kpos > pos) newkfr.append(str);
-                added = true;
-            } else newkfr.append(str);
-        }
-        if (!added) {
-            if (i == 0)
-                newkfr.append(QString::number(pos) + ":" + QString::number(val));
-            else
-                newkfr.append(QString::number(pos) + ":" + e.attribute("default"));
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
+            QString kfr = e.attribute("keyframes");
+            const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
+            QStringList newkfr;
+            bool added = false;
+            foreach(const QString &str, keyframes) {
+                int kpos = str.section(':', 0, 0).toInt();
+                double newval = str.section(':', 1, 1).toDouble();
+                if (kpos < pos) {
+                    newkfr.append(str);
+                } else if (!added) {
+                    if (i == m_visibleParam)
+                        newkfr.append(QString::number(pos) + ":" + QString::number(val));
+                    else
+                        newkfr.append(QString::number(pos) + ":" + QString::number(newval));
+                    if (kpos > pos) newkfr.append(str);
+                    added = true;
+                } else newkfr.append(str);
+            }
+            if (!added) {
+                if (i == m_visibleParam)
+                    newkfr.append(QString::number(pos) + ":" + QString::number(val));
+                else
+                    newkfr.append(QString::number(pos) + ":" + e.attribute("default"));
+            }
+            e.setAttribute("keyframes", newkfr.join(";"));
         }
-        e.setAttribute("keyframes", newkfr.join(";"));
     }
 }
 
@@ -1718,20 +1718,24 @@ void ClipItem::movedKeyframe(QDomElement effect, int oldpos, int newpos, double
     int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        QString kfr = e.attribute("keyframes");
-        const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
-        QStringList newkfr;
-        foreach(const QString &str, keyframes) {
-            if (str.section(':', 0, 0).toInt() != oldpos) {
-                newkfr.append(str);
-            } else if (newpos != -1) {
-                newpos = qMax(newpos, start);
-                newpos = qMin(newpos, end);
-                if (i == 0) newkfr.append(QString::number(newpos) + ":" + QString::number(value));
-                else newkfr.append(QString::number(newpos) + ":" + str.section(':', 1, 1));
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
+            QString kfr = e.attribute("keyframes");
+            const QStringList keyframes = kfr.split(';', QString::SkipEmptyParts);
+            QStringList newkfr;
+            foreach(const QString &str, keyframes) {
+                if (str.section(':', 0, 0).toInt() != oldpos) {
+                    newkfr.append(str);
+                } else if (newpos != -1) {
+                    newpos = qMax(newpos, start);
+                    newpos = qMin(newpos, end);
+                    if (i == m_visibleParam)
+                        newkfr.append(QString::number(newpos) + ":" + QString::number(value));
+                    else
+                        newkfr.append(QString::number(newpos) + ":" + str.section(':', 1, 1));
+                }
             }
+            e.setAttribute("keyframes", newkfr.join(";"));
         }
-        e.setAttribute("keyframes", newkfr.join(";"));
     }
 
     updateKeyframes(effect);
@@ -1743,7 +1747,7 @@ void ClipItem::updateKeyframes(QDomElement effect)
     m_keyframes.clear();
     // parse keyframes
     QDomNodeList params = effect.elementsByTagName("parameter");
-    QDomElement e = params.item(0).toElement();
+    QDomElement e = params.item(m_visibleParam).toElement();
     const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
     foreach(const QString &str, keyframes) {
         int pos = str.section(':', 0, 0).toInt();
index 3069dd99f18300f2f070f7fb1c4b2b001f4b34c8..a2fcd1c2e84606c7060595ffe25bacf1c2fca8f2 100644 (file)
@@ -115,7 +115,7 @@ private slots:
     void slotAdjustKeyframePos(int value);
     void slotAdjustKeyframeValue(int value);
     /** @brief Turns the seek to keyframe position setting on/off.
-    * @param state State of the associated checkbox */
+    * @param seek true = seeking on */
     void slotSetSeeking(bool seek);
 
     /** @brief Shows the keyframe table and adds a second keyframe. */