]> git.sesse.net Git - kdenlive/commitdiff
Fix pasting of keyframe effects:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 7 Dec 2009 13:23:41 +0000 (13:23 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 7 Dec 2009 13:23:41 +0000 (13:23 +0000)
http://kdenlive.org/mantis/view.php?id=1328

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

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

index 94b5a543c648a2685b60ce6250ee865481c2e4ea..d907666ef54fdeeb159a7b199e3e943e7f5fd98f 100644 (file)
@@ -1342,8 +1342,7 @@ EffectsParameterList ClipItem::addEffect(const QDomElement effect, bool /*animat
                 parameters.addParam("starttag", e.attribute("starttag", "start"));
                 parameters.addParam("endtag", e.attribute("endtag", "end"));
             }
-
-            if (e.attribute("factor", "1") == "1") {
+            else if (e.attribute("factor", "1") == "1") {
                 parameters.addParam(e.attribute("name"), e.attribute("value"));
 
                 // check if it is a fade effect
index f079711f056157d3cd5a71d530eb4a4dd6393cdf..d93429ce82c4054d89a266800bd10bb68e3a40fe 100644 (file)
@@ -4740,7 +4740,7 @@ void CustomTrackView::pasteClipEffects()
             for (int j = 0; j < clip->effectsCount(); j++) {
                 QDomElement eff = clip->effectAt(j);
                 if (eff.attribute("unique", "0") == "0" || item->hasEffect(eff.attribute("tag"), eff.attribute("id")) == -1) {
-                    adjustKeyfames(clip->cropStart(), item->cropStart(), eff);
+                    adjustKeyfames(clip->cropStart(), item->cropStart(), item->cropDuration(), eff);
                     new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), eff, true, paste);
                 }
             }
@@ -4756,10 +4756,11 @@ void CustomTrackView::pasteClipEffects()
 }
 
 
-void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, QDomElement xml)
+void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime duration, QDomElement xml)
 {
     // parse parameters to check if we need to adjust to the new crop start
     int diff = (newstart - oldstart).frames(m_document->fps());
+    int max = (newstart + duration).frames(m_document->fps());
     QDomNodeList params = xml.elementsByTagName("parameter");
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
@@ -4771,7 +4772,11 @@ void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, QDomEle
             foreach(const QString &str, keys) {
                 int pos = str.section(':', 0, 0).toInt();
                 double val = str.section(':', 1, 1).toDouble();
-                newKeyFrames.append(QString::number(pos + diff) + ':' + QString::number(val));
+                pos += diff;
+                if (pos > max) {
+                    newKeyFrames.append(QString::number(max) + ':' + QString::number(val));
+                    break;
+                } else newKeyFrames.append(QString::number(pos) + ':' + QString::number(val));
             }
             //kDebug()<<"ORIGIN: "<<keys<<", FIXED: "<<newKeyFrames;
             e.setAttribute("keyframes", newKeyFrames.join(";"));
index 115c989978cffefd7c678e75fd68bb66c68b56bc..aaa0a9fb3d87a4856a33dd9cf34cb7cfe34ed52b 100644 (file)
@@ -271,7 +271,7 @@ private:
     void adjustTimelineClips(EDITMODE mode, ClipItem *item, ItemInfo posinfo, QUndoCommand *command);
     void adjustTimelineTransitions(EDITMODE mode, Transition *item, QUndoCommand *command);
     /** Adjust keyframes when pasted to another clip */
-    void adjustKeyfames(GenTime oldstart, GenTime newstart, QDomElement xml);
+    void adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime duration, QDomElement xml);
 
 private slots:
     void slotRefreshGuides();