]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
add / edit effect keyframe is now integrated in the undo framework
[kdenlive] / src / clipitem.cpp
index 16a173e6c0aa4257a97eb97601a595f5d81e146e..585902988e08084d9bad386d5d5e2270cdb5871d 100644 (file)
@@ -122,8 +122,37 @@ void ClipItem::initEffect(QDomElement effect) {
     }
 }
 
+void ClipItem::setKeyframes(const int ix, const QString keyframes) {
+    QDomElement effect = effectAt(ix);
+    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.setAttribute("keyframes", keyframes);
+           if (ix == m_selectedEffect) {
+             m_keyframes.clear();
+             double max = e.attribute("max").toDouble();
+             double min = e.attribute("min").toDouble();
+             m_keyframeFactor = 100.0 / (max - min);
+             m_keyframeDefault = e.attribute("default").toDouble();
+             // parse keyframes
+             QStringList keyframes = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+             foreach(QString str, keyframes) {
+                 int pos = str.section(":", 0, 0).toInt();
+                 double val = str.section(":", 1, 1).toDouble();
+                 m_keyframes[pos] = val;
+             }
+             update();
+             return;
+           }
+           break;
+        }
+    }
+
+}
+
 
-void ClipItem::setSelectedEffect(int ix) {
+void ClipItem::setSelectedEffect(const int ix) {
 
     m_selectedEffect = ix;
     QDomElement effect = effectAt(m_selectedEffect);
@@ -153,6 +182,21 @@ void ClipItem::setSelectedEffect(int ix) {
     }
 }
 
+QString ClipItem::keyframes(const int index) {
+    QString 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") {
+           result = e.attribute("keyframes");
+           break;
+       }
+    }
+    return result;
+}
+
 void ClipItem::updateKeyframeEffect() {
     // regenerate xml parameter from the clip keyframes
     QDomElement effect = effectAt(m_selectedEffect);