]> git.sesse.net Git - kdenlive/commitdiff
First draft for keyframes in frei0r effects
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 14 Nov 2009 02:19:31 +0000 (02:19 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 14 Nov 2009 02:19:31 +0000 (02:19 +0000)
svn path=/trunk/kdenlive/; revision=4121

src/clipitem.cpp
src/effectslist.cpp
src/effectslist.h
src/effectstackedit.cpp
src/trackview.cpp

index 6835d41912d0c2d81a8092f1a2d6d9da0fa32ef8..d9d113fd03299f5b4fbb31dae59a744a0879eca3 100644 (file)
@@ -183,7 +183,7 @@ void ClipItem::initEffect(QDomElement effect, int diff)
             }
         }
 
-        if (!e.isNull() && e.attribute("type") == "keyframe") {
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             QString def = e.attribute("default");
             // Effect has a keyframe type parameter, we need to set the values
             if (e.attribute("keyframes").isEmpty()) {
@@ -316,7 +316,7 @@ void ClipItem::setKeyframes(const int ix, const QString keyframes)
     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") {
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             e.setAttribute("keyframes", keyframes);
             if (ix == m_selectedEffect) {
                 m_keyframes.clear();
@@ -349,7 +349,7 @@ void ClipItem::setSelectedEffect(const int ix)
         if (effect.attribute("disabled") != "1")
             for (int i = 0; i < params.count(); i++) {
                 QDomElement e = params.item(i).toElement();
-                if (!e.isNull() && e.attribute("type") == "keyframe") {
+                if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
                     m_keyframes.clear();
                     double max = e.attribute("max").toDouble();
                     double min = e.attribute("min").toDouble();
@@ -381,7 +381,7 @@ QString ClipItem::keyframes(const int index)
 
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        if (!e.isNull() && e.attribute("type") == "keyframe") {
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             result = e.attribute("keyframes");
             break;
         }
@@ -398,7 +398,7 @@ void ClipItem::updateKeyframeEffect()
 
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        if (!e.isNull() && e.attribute("type") == "keyframe") {
+        if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
             QString keyframes;
             if (m_keyframes.count() > 1) {
                 QMap<int, int>::const_iterator i = m_keyframes.constBegin();
@@ -1111,7 +1111,7 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
         QDomNodeList params = effect.elementsByTagName("parameter");
         for (int j = 0; j < params.count(); j++) {
             QDomElement e = params.item(i).toElement();
-            if (e.attribute("type") == "keyframe") {
+            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;
@@ -1308,7 +1308,22 @@ EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animat
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull()) {
-            if (e.attribute("type") == "keyframe") {
+           if (e.attribute("type") == "simplekeyframe") {
+               QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+               double factor = e.attribute("factor", "1").toDouble();
+               if (factor != 1) {
+                   for (int j = 0; j < values.count(); j++) {
+                       QString pos = values.at(j).section(":", 0, 0);
+                       double val = values.at(j).section(":", 1, 1).toDouble() / factor;
+                       values[j] = pos + "=" + QString::number(val);
+                   }
+               }
+                parameters.addParam(e.attribute("name"), values.join(";"));
+                /*parameters.addParam("max", e.attribute("max"));
+                parameters.addParam("min", e.attribute("min"));
+                parameters.addParam("factor", );*/
+            }
+            else if (e.attribute("type") == "keyframe") {
                 parameters.addParam("keyframes", e.attribute("keyframes"));
                 parameters.addParam("max", e.attribute("max"));
                 parameters.addParam("min", e.attribute("min"));
@@ -1403,7 +1418,24 @@ EffectsParameterList ClipItem::getEffectArgs(const QDomElement effect)
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
         //kDebug() << "/ / / /SENDING EFFECT PARAM: " << e.attribute("type") << ", NAME_ " << e.attribute("tag");
-        if (e.attribute("type") == "keyframe") {
+       if (e.attribute("type") == "simplekeyframe") {
+            kDebug() << "/ / / /SENDING KEYFR EFFECT TYPE";
+           QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+           double factor = e.attribute("factor", "1").toDouble();
+           if (factor != 1) {
+               for (int j = 0; j < values.count(); j++) {
+                   QString pos = values.at(j).section(":", 0, 0);
+                   double val = values.at(j).section(":", 1, 1).toDouble() / factor;
+                   values[j] = pos + "=" + QString::number(val);
+               }
+           }
+            parameters.addParam(e.attribute("name"), values.join(";"));
+            /*parameters.addParam(e.attribute("name"), e.attribute("keyframes").replace(":", "="));
+            parameters.addParam("max", e.attribute("max"));
+            parameters.addParam("min", e.attribute("min"));
+            parameters.addParam("factor", e.attribute("factor", "1"));*/
+        }
+        else if (e.attribute("type") == "keyframe") {
             kDebug() << "/ / / /SENDING KEYFR EFFECT TYPE";
             parameters.addParam("keyframes", e.attribute("keyframes"));
             parameters.addParam("max", e.attribute("max"));
index 490f2f39b82ad7ad424fa2f997bdc49dbed645a9..1b400ae64020b3ba5fd0f692ea9cbc9cd50208cb 100644 (file)
@@ -150,6 +150,17 @@ bool EffectsList::hasKeyFrames(QDomElement effect)
     return false;
 }
 
+// static
+bool EffectsList::hasSimpleKeyFrames(QDomElement effect)
+{
+    QDomNodeList params = effect.elementsByTagName("parameter");
+    for (int i = 0; i < params.count(); i++) {
+        QDomElement e = params.item(i).toElement();
+        if (e.attribute("type") == "simplekeyframe") return true;
+    }
+    return false;
+}
+
 void EffectsList::clone(const EffectsList original)
 {
     setContent(original.toString());
index a9de689c8b2ccc4af106b924a81ec84f9d903d18..220174f06a6a5a7e048279ad47087f0e5bec567d 100644 (file)
@@ -51,6 +51,7 @@ public:
     void insert(int ix, QDomElement effect);
     void replace(int ix, QDomElement effect);
     static bool hasKeyFrames(QDomElement effect);
+    static bool hasSimpleKeyFrames(QDomElement effect);
     static void setParameter(QDomElement effect, const QString &name, const QString &value);
     static QString parameter(QDomElement effect, const QString &name);
     static void setProperty(QDomElement effect, const QString &name, const QString &value);
index b57747e0a1acb04484315c26280a0f03d2765649..add62549ad4efb4a9b70a38b24c7dc533a3886dc 100644 (file)
@@ -231,7 +231,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int in, int out)
             m_valueItems[paramName+"geometry"] = geo;
             connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
             connect(geo, SIGNAL(seekToPos(int)), this, SLOT(slotSeekToPos(int)));
-        } else if (type == "keyframe") {
+        } else if (type == "keyframe" || type == "simplekeyframe") {
             // keyframe editor widget
             kDebug() << "min: " << m_in << ", MAX: " << m_out;
             KeyframeEdit *geo = new KeyframeEdit(pa, m_out - m_in - 1, pa.attribute("min").toInt(), pa.attribute("max").toInt(), m_timecode);
index 70573a5d13ff4e3ad9f9b535d672bad75676c90a..16e0da314683bb46a31b69d0b36313a530b22381 100644 (file)
@@ -689,7 +689,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                             QDomElement currenteffect = clipeffect.cloneNode().toElement();
                             currenteffect.setAttribute("kdenlive_ix", effectindex);
                             QDomNodeList clipeffectparams = currenteffect.childNodes();
-
+                           
                             if (MainWindow::videoEffects.hasKeyFrames(currenteffect)) {
                                 //kDebug() << " * * * * * * * * * * ** CLIP EFF WITH KFR FND  * * * * * * * * * * *";
                                 // effect is key-framable, read all effects to retrieve keyframes
@@ -792,7 +792,16 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                                             if (factor.startsWith('%')) {
                                                 fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
                                             } else fact = factor.toDouble();
-                                            e.setAttribute("value", paramvalue.toDouble() * fact);
+                                           if (e.attribute("type") == "simplekeyframe") {
+                                               QStringList kfrs = paramvalue.split(";");
+                                               for (int l = 0; l < kfrs.count(); l++) {
+                                                   QString fr = kfrs.at(l).section("=", 0, 0);
+                                                   double val = kfrs.at(l).section("=", 1, 1).toDouble();
+                                                   kfrs[l] = fr + ":" + QString::number((int) (val * fact));
+                                               }
+                                               e.setAttribute("keyframes", kfrs.join(";"));
+                                           }
+                                            else e.setAttribute("value", paramvalue.toDouble() * fact);
                                         } else e.setAttribute("value", paramvalue);
                                         break;
                                     }