]> git.sesse.net Git - kdenlive/commitdiff
Fix fade effects
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 18 Jun 2012 23:25:54 +0000 (01:25 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 18 Jun 2012 23:26:46 +0000 (01:26 +0200)
src/clipitem.cpp
src/customtrackview.cpp
src/trackview.cpp

index 14bf09f545d7185f762bd2fc34a5f83eb2c15c08..3f342969f8c88c9054a23dd59a90a829addab518 100644 (file)
@@ -312,6 +312,7 @@ void ClipItem::initEffect(QDomElement effect, int diff, int offset)
             if (effect.attribute("id") == "fadein") {
                 if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
                     int effectDuration = EffectsList::parameter(effect, "out").toInt();
+                   if (offset != 0) effectDuration -= offset - cropStart().frames(m_fps);
                     if (effectDuration > cropDuration().frames(m_fps)) {
                         effectDuration = cropDuration().frames(m_fps) / 2;
                     }
@@ -321,6 +322,7 @@ void ClipItem::initEffect(QDomElement effect, int diff, int offset)
             } else if (effect.attribute("id") == "fade_from_black") {
                 if (m_effectList.hasEffect(QString(), "fadein") == -1) {
                     int effectDuration = EffectsList::parameter(effect, "out").toInt();
+                   if (offset != 0) effectDuration -= offset - cropStart().frames(m_fps);
                     if (effectDuration > cropDuration().frames(m_fps)) {
                         effectDuration = cropDuration().frames(m_fps) / 2;
                     }
@@ -1462,6 +1464,18 @@ EffectsParameterList ClipItem::addEffect(QDomElement effect, bool /*animate*/)
     
     // Update index to the real one
     effect.setAttribute("kdenlive_ix", insertedEffect.attribute("kdenlive_ix"));
+    int effectIn;
+    int effectOut;
+
+    if (effect.attribute("tag") == "affine") {
+       // special case: the affine effect needs in / out points
+       effectIn = effect.attribute("in").toInt();
+       effectOut = effect.attribute("out").toInt();
+    }
+    else {
+       effectIn = EffectsList::parameter(effect, "in").toInt();
+       effectOut = EffectsList::parameter(effect, "out").toInt();
+    }
     
     EffectsParameterList parameters;
     parameters.addParam("tag", insertedEffect.attribute("tag"));
@@ -1473,11 +1487,50 @@ EffectsParameterList ClipItem::addEffect(QDomElement effect, bool /*animate*/)
     if (effectId.isEmpty()) effectId = insertedEffect.attribute("tag");
     parameters.addParam("id", effectId);
 
-    // special case: the affine effect needs in / out points
-
     QDomNodeList params = insertedEffect.elementsByTagName("parameter");
     int fade = 0;
     bool needInOutSync = false;
+
+    // check if it is a fade effect
+    if (effectId == "fadein") {
+       needRepaint = true;
+        if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
+           fade = effectOut - effectIn;
+        }/* else {
+           QDomElement fadein = m_effectList.getEffectByTag(QString(), "fade_from_black");
+            if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
+            else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
+        }*/
+    } else if (effectId == "fade_from_black") {
+       kDebug()<<"// FOUND FTB:"<<effectOut<<" - "<<effectIn;
+       needRepaint = true;
+        if (m_effectList.hasEffect(QString(), "fadein") == -1) {
+           fade = effectOut - effectIn;
+        }/* else {
+           QDomElement fadein = m_effectList.getEffectByTag(QString(), "fadein");
+            if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
+            else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
+        }*/
+     } else if (effectId == "fadeout") {
+       needRepaint = true;
+        if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
+           fade = effectIn - effectOut;
+        } /*else {
+           QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
+            if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
+            else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
+        }*/
+    } else if (effectId == "fade_to_black") {
+       needRepaint = true;
+        if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
+           fade = effectIn - effectOut;
+        }/* else {
+           QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
+            if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
+            else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
+        }*/
+    }
+
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
         if (!e.isNull()) {
@@ -1511,48 +1564,6 @@ EffectsParameterList ClipItem::addEffect(QDomElement effect, bool /*animate*/)
             } else if (e.attribute("factor", "1") == "1" && e.attribute("offset", "0") == "0") {
                 parameters.addParam(e.attribute("name"), e.attribute("value"));
 
-                // check if it is a fade effect
-                if (effectId == "fadein") {
-                    needRepaint = true;
-                    if (m_effectList.hasEffect(QString(), "fade_from_black") == -1) {
-                        if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
-                        else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
-                    } else {
-                        QDomElement fadein = m_effectList.getEffectByTag(QString(), "fade_from_black");
-                        if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
-                        else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
-                    }
-                } else if (effectId == "fade_from_black") {
-                    needRepaint = true;
-                    if (m_effectList.hasEffect(QString(), "fadein") == -1) {
-                        if (e.attribute("name") == "out") fade += e.attribute("value").toInt();
-                        else if (e.attribute("name") == "in") fade -= e.attribute("value").toInt();
-                    } else {
-                        QDomElement fadein = m_effectList.getEffectByTag(QString(), "fadein");
-                        if (fadein.attribute("name") == "out") fade += fadein.attribute("value").toInt();
-                        else if (fadein.attribute("name") == "in") fade -= fadein.attribute("value").toInt();
-                    }
-                } else if (effectId == "fadeout") {
-                    needRepaint = true;
-                    if (m_effectList.hasEffect(QString(), "fade_to_black") == -1) {
-                        if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
-                        else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
-                    } else {
-                        QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fade_to_black");
-                        if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
-                        else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
-                    }
-                } else if (effectId == "fade_to_black") {
-                    needRepaint = true;
-                    if (m_effectList.hasEffect(QString(), "fadeout") == -1) {
-                        if (e.attribute("name") == "out") fade -= e.attribute("value").toInt();
-                        else if (e.attribute("name") == "in") fade += e.attribute("value").toInt();
-                    } else {
-                        QDomElement fadeout = m_effectList.getEffectByTag(QString(), "fadeout");
-                        if (fadeout.attribute("name") == "out") fade -= fadeout.attribute("value").toInt();
-                        else if (fadeout.attribute("name") == "in") fade += fadeout.attribute("value").toInt();
-                    }
-                }
             } else {
                 double fact;
                 if (e.attribute("factor").contains('%')) {
index 2cb91a93cbe5ad67bc1796a201b89364ebc48f11..32d519a60d666bb3feb3266a0fd848ecacb7f0bd 100644 (file)
@@ -2008,11 +2008,11 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
         if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") {
             // A fade effect was modified, update the clip
             if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
-                int pos = effectParams.paramValue("out").toInt() - effectParams.paramValue("in").toInt();
+                int pos = EffectsList::parameter(effect, "out").toInt() - EffectsList::parameter(effect, "in").toInt();
                 clip->setFadeIn(pos);
             }
             if (effect.attribute("id") == "fadeout" || effect.attribute("id") == "fade_to_black") {
-                int pos = effectParams.paramValue("out").toInt() - effectParams.paramValue("in").toInt();
+                int pos = EffectsList::parameter(effect, "out").toInt() - EffectsList::parameter(effect, "in").toInt();
                 clip->setFadeOut(pos);
             }
         }
index 7a5f0c99e8b79f12d53d1b0ee0ca48cfd3c7c8f4..9cda82de4b26ececa01c47c1e9bf858a9196b2b3 100644 (file)
@@ -887,10 +887,12 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
             } else {
                 // Check if effect has in/out points
                 if (effect.hasAttribute("in")) {
+                   EffectsList::setParameter(currenteffect, "in",  effect.attribute("in"));
                    currenteffect.setAttribute("in", effect.attribute("in"));
                    currenteffect.setAttribute("_sync_in_out", "1");
                 }
                 if (effect.hasAttribute("out")) {
+                   EffectsList::setParameter(currenteffect, "out",  effect.attribute("out"));
                    currenteffect.setAttribute("out", effect.attribute("out"));
                 }
             }