]> git.sesse.net Git - kdenlive/commitdiff
Almost finished implementing track effects
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 24 Aug 2010 20:03:31 +0000 (20:03 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 24 Aug 2010 20:03:31 +0000 (20:03 +0000)
svn path=/trunk/kdenlive/; revision=4754

src/customtrackview.cpp
src/customtrackview.h
src/effectstackview.cpp
src/effectstackview.h
src/headertrack.cpp
src/kdenlivedoc.cpp
src/mainwindow.cpp
src/trackview.cpp
src/trackview.h
src/widgets/effectstack_ui.ui

index 1c9d225c3d448099f3ce98c7be7ddb17b5d526df..42eff73162087d468e91fcb15b3ad743390e32cb 100644 (file)
@@ -1548,9 +1548,9 @@ void CustomTrackView::addEffect(int track, GenTime pos, QDomElement effect)
 {
     if (pos < GenTime()) {
         // Add track effect
-        m_document->addTrackEffect(m_document->tracksCount() - track, effect);
+        m_document->addTrackEffect(track - 1, effect);
         m_document->renderer()->mltAddTrackEffect(track, getEffectArgs(effect));
-        emit showTrackEffects(track, m_document->getTrackEffects(m_document->tracksCount() - track));
+        emit showTrackEffects(track, m_document->trackInfoAt(track - 1));
         return;
     }
     ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), m_document->tracksCount() - track);
@@ -1582,9 +1582,9 @@ void CustomTrackView::deleteEffect(int track, GenTime pos, QDomElement effect)
     QString index = effect.attribute("kdenlive_ix");
     if (pos < GenTime()) {
         // Delete track effect
-        m_document->removeTrackEffect(m_document->tracksCount() - track, effect);
+        m_document->removeTrackEffect(track - 1, effect);
         m_document->renderer()->mltRemoveTrackEffect(track, index, true);
-        emit showTrackEffects(track, m_document->getTrackEffects(m_document->tracksCount() - track));
+        emit showTrackEffects(track, m_document->trackInfoAt(track - 1));
         return;
     }
     // Special case: speed effect
@@ -1790,7 +1790,7 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
         }
         if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - track, pos, effectParams))
             emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-        m_document->setTrackEffect(track, ix, effect);
+        m_document->setTrackEffect(track - 1, ix, effect);
         return;
 
     }
@@ -1850,15 +1850,14 @@ void CustomTrackView::moveEffect(int track, GenTime pos, int oldPos, int newPos)
 {
     if (pos < GenTime()) {
         // Moving track effect
-        kDebug() << "MOVING EFFECT IN TK: " << track;
-        QDomElement act = m_document->getTrackEffect(track, newPos - 1);
-        QDomElement before = m_document->getTrackEffect(track, oldPos - 1);
+        QDomElement act = m_document->getTrackEffect(m_document->tracksCount() - track - 1, newPos - 1);
+        QDomElement before = m_document->getTrackEffect(m_document->tracksCount() - track - 1, oldPos - 1);
 
         if (!act.isNull() && !before.isNull()) {
-            m_document->setTrackEffect(track, oldPos - 1, act);
-            m_document->setTrackEffect(track, newPos - 1, before);
+            m_document->setTrackEffect(m_document->tracksCount() - track - 1, oldPos - 1, act);
+            m_document->setTrackEffect(m_document->tracksCount() - track - 1, newPos - 1, before);
             m_document->renderer()->mltMoveEffect(m_document->tracksCount() - track, pos, oldPos, newPos);
-            emit showTrackEffects(m_document->tracksCount() - track, m_document->getTrackEffects(track));
+            emit showTrackEffects(m_document->tracksCount() - track, m_document->trackInfoAt(m_document->tracksCount() - track - 1));
         } else emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
         return;
     }
@@ -1883,7 +1882,7 @@ void CustomTrackView::slotChangeEffectState(ClipItem *clip, int track, int effec
 {
     EditEffectCommand *command;
     QDomElement effect;
-    if (clip == NULL) effect = m_document->getTrackEffect(m_document->tracksCount() - track, effectPos);
+    if (clip == NULL) effect = m_document->getTrackEffect(track - 1, effectPos);
     else effect = clip->effectAt(effectPos);
     QDomElement oldEffect = effect.cloneNode().toElement();
     effect.setAttribute("disable", (int) disable);
@@ -6338,6 +6337,7 @@ void CustomTrackView::slotAddTrackEffect(const QDomElement effect, int ix)
 {
     AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - ix, GenTime(-1), effect, true);
     m_commandStack->push(command);
+    setDocumentModified();
 }
 
 
index 7d7a55e2811038a22b4acfb5cef8b91187ef4243..a4cf40133f67740395e95d6a5e2f1a8784a97ea0 100644 (file)
@@ -422,7 +422,7 @@ signals:
     /** @brief Monitor document changes (for example the presence of audio data in timeline for export widget.*/
     void documentModified();
     void forceClipProcessing(const QString &);
-    void showTrackEffects(int, EffectsList);
+    void showTrackEffects(int, TrackInfo);
 };
 
 #endif
index 3b26ddf5dadcb30a0ed06c0c2f36b8491e8e9509..257a54682c66dc9e88672f1353354b8a786bb927 100644 (file)
@@ -169,6 +169,7 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix)
     } else {
         m_clipref = c;
         if (c) {
+            m_ui.checkAll->setText(i18n("Effects for %1").arg(m_clipref->clipName()));
             ix = c->selectedEffectIndex();
             QString size = c->baseClip()->getProperty("frame_size");
             double factor = c->baseClip()->getProperty("aspect_ratio").toDouble();
@@ -192,12 +193,14 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix)
     setupListView(ix);
 }
 
-void EffectStackView::slotTrackItemSelected(int ix, EffectsList list)
+void EffectStackView::slotTrackItemSelected(int ix, const TrackInfo info)
 {
-    setEnabled(!list.isEmpty());
     m_clipref = NULL;
     m_trackMode = true;
-    m_currentEffectList = list;
+    m_currentEffectList = info.effectsList;
+    kDebug() << "// TRACK; " << ix << ", EFFECTS: " << m_currentEffectList.count();
+    setEnabled(true);
+    m_ui.checkAll->setText(i18n("Effects for track %1").arg(info.trackName.isEmpty() ? QString::number(ix) : info.trackName));
     m_trackindex = ix;
     setupListView(0);
 }
index 7bea226ca6b5717e09a92ce4bde424e33b83fa77..7754c5df2d98458639ab2eb623073ae982491633 100644 (file)
@@ -80,7 +80,7 @@ public slots:
     * @param ix Effect to preselect */
     void slotClipItemSelected(ClipItem* c, int ix);
 
-    void slotTrackItemSelected(int ix, EffectsList list);
+    void slotTrackItemSelected(int ix, const TrackInfo info);
 
     /** @brief Emits updateClipEffect.
     * @param old Old effect information
index 2e4a7eff63095a5a9dbd3c9bebb29b8c11bf4539..e04df2470e9f1c876de1dbed1fcae203d7aa49ad 100644 (file)
@@ -151,6 +151,7 @@ void HeaderTrack::dropEvent(QDropEvent * event)
     QDomDocument doc;
     doc.setContent(effects, true);
     const QDomElement e = doc.documentElement();
+    emit selectTrack(m_index);
     emit addTrackInfo(e, m_index);
     /*if (scene() && !scene()->views().isEmpty()) {
         event->accept();
index 538d5e72ef85bc9388fadfc172542f8c4174bab2..8615b2bad41800b6ae1f83a8bddf41fb4e86beae 100644 (file)
@@ -114,13 +114,13 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                         // Build tracks
                         QDomElement e;
                         QDomElement tracksinfo = infoXml.firstChildElement("tracksinfo");
-                        TrackInfo projectTrack;
                         if (!tracksinfo.isNull()) {
                             QDomNodeList trackslist = tracksinfo.childNodes();
                             int maxchild = trackslist.count();
                             for (int k = 0; k < maxchild; k++) {
                                 e = trackslist.at(k).toElement();
                                 if (e.tagName() == "trackinfo") {
+                                    TrackInfo projectTrack;
                                     if (e.attribute("type") == "audio") projectTrack.type = AUDIOTRACK;
                                     else projectTrack.type = VIDEOTRACK;
                                     projectTrack.isMute = e.attribute("mute").toInt();
@@ -262,29 +262,27 @@ int KdenliveDoc::setSceneList()
 
 QDomDocument KdenliveDoc::createEmptyDocument(int videotracks, int audiotracks)
 {
-    TrackInfo videoTrack;
-    videoTrack.type = VIDEOTRACK;
-    videoTrack.isMute = false;
-    videoTrack.isBlind = false;
-    videoTrack.isLocked = false;
-
-    TrackInfo audioTrack;
-    audioTrack.type = AUDIOTRACK;
-    audioTrack.isMute = false;
-    audioTrack.isBlind = true;
-    audioTrack.isLocked = false;
-
     m_tracksList.clear();
 
     // Tracks are added «backwards», so we need to reverse the track numbering
     // mbt 331: http://www.kdenlive.org/mantis/view.php?id=331
     // Better default names for tracks: Audio 1 etc. instead of blank numbers
     for (int i = 0; i < audiotracks; i++) {
+        TrackInfo audioTrack;
+        audioTrack.type = AUDIOTRACK;
+        audioTrack.isMute = false;
+        audioTrack.isBlind = true;
+        audioTrack.isLocked = false;
         audioTrack.trackName = QString("Audio ") + QString::number(audiotracks - i);
         m_tracksList.append(audioTrack);
 
     }
     for (int i = 0; i < videotracks; i++) {
+        TrackInfo videoTrack;
+        videoTrack.type = VIDEOTRACK;
+        videoTrack.isMute = false;
+        videoTrack.isBlind = false;
+        videoTrack.isLocked = false;
         videoTrack.trackName = QString("Video ") + QString::number(videotracks - i);
         m_tracksList.append(videoTrack);
     }
@@ -1318,7 +1316,6 @@ void KdenliveDoc::setTrackEffect(int trackIndex, int effectIndex, QDomElement ef
         kDebug() << "Invalid effect index: " << effectIndex;
         return;
     }
-    kDebug() << "CHange TRK EFFECT AT: " << trackIndex;
     effect.setAttribute("kdenlive_ix", effectIndex + 1);
     m_tracksList[trackIndex].effectsList.replace(effectIndex, effect);
 }
index d900c254d13517721a0d09e1b1e00565e1cecfa2..a42dbfb8521269cb153deac66986f4d6e1c052b2 100644 (file)
@@ -2174,8 +2174,8 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
 
     connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
     connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
-    connect(trackView, SIGNAL(showTrackEffects(int, EffectsList)), m_effectStack, SLOT(slotTrackItemSelected(int, EffectsList)));
-    connect(trackView, SIGNAL(showTrackEffects(int, EffectsList)), this, SLOT(slotActivateEffectStackView()));
+    connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
+    connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
 
     connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int)), this, SLOT(slotActivateEffectStackView()));
     connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
index 93c0e9ed4633809514f609d97a9167782685cbbd..54d916a4067fc414e65487884b6125044caa948e 100644 (file)
@@ -19,7 +19,6 @@
 
 
 #include "trackview.h"
-#include "definitions.h"
 #include "headertrack.h"
 #include "clipitem.h"
 #include "transition.h"
@@ -105,7 +104,7 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
     connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
     connect(m_trackview, SIGNAL(tracksChanged()), this, SLOT(slotReloadTracks()));
     connect(m_trackview, SIGNAL(updateTrackHeaders()), this, SLOT(slotRepaintTracks()));
-    connect(m_trackview, SIGNAL(showTrackEffects(int, EffectsList)), this, SIGNAL(showTrackEffects(int, EffectsList)));
+    connect(m_trackview, SIGNAL(showTrackEffects(int, TrackInfo)), this, SIGNAL(showTrackEffects(int, TrackInfo)));
 
     parseDocument(m_doc->toXml());
     if (m_doc->setSceneList() == -1) *ok = false;
@@ -241,6 +240,7 @@ void TrackView::parseDocument(QDomDocument doc)
         }
     }
 
+    int trackIndex = 0;
     for (int i = 0; i < m_projectTracks; i++) {
         e = tracks.item(i).toElement();
         QString playlist_name = e.attribute("producer");
@@ -249,7 +249,13 @@ void TrackView::parseDocument(QDomDocument doc)
             p = QDomElement();
             for (int j = 0; j < m_projectTracks; j++) {
                 p = playlists.item(j).toElement();
-                if (p.attribute("id") == playlist_name) break;
+                if (p.attribute("id") == playlist_name) {
+                    // playlist found, check track effects
+                    QDomNodeList trackEffects = p.elementsByTagName("filter");
+                    kDebug() << "<< PLAYLIST: " << playlist_name << ", effects: " << trackEffects.count() << ", TK IX: " << trackIndex;
+                    slotAddProjectEffects(trackEffects, p, NULL, trackIndex++);
+                    break;
+                }
             }
             if (p.attribute("id") != playlist_name) { // then it didn't work.
                 kDebug() << "NO PLAYLIST FOUND FOR TRACK " + pos;
@@ -668,199 +674,201 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
                 }
 
                 // parse clip effects
-                QDomNodeList effects = elem.childNodes();
-                for (int ix = 0; ix < effects.count(); ix++) {
-                    bool disableeffect = false;
-                    QDomElement effect = effects.at(ix).toElement();
-                    if (effect.tagName() == "filter") {
-                        // add effect to clip
-                        QString effecttag;
-                        QString effectid;
-                        QString effectindex = QString::number(ix + 1);
-                        QString ladspaEffectFile;
-                        // Get effect tag & index
-                        for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
-                            // parse effect parameters
-                            QDomElement effectparam = n3.toElement();
-                            if (effectparam.attribute("name") == "tag") {
-                                effecttag = effectparam.text();
-                            } else if (effectparam.attribute("name") == "kdenlive_id") {
-                                effectid = effectparam.text();
-                            } else if (effectparam.attribute("name") == "disable" && effectparam.text().toInt() == 1) {
-                                // Fix effects index
-                                disableeffect = true;
-                            } else if (effectparam.attribute("name") == "kdenlive_ix") {
-                                // Fix effects index
-                                effectparam.firstChild().setNodeValue(effectindex);
-                            } else if (effectparam.attribute("name") == "src") {
-                                ladspaEffectFile = effectparam.text();
-                                if (!QFile::exists(ladspaEffectFile)) {
-                                    // If the ladspa effect file is missing, recreate it
-                                    kDebug() << "// MISSING LADSPA FILE: " << ladspaEffectFile;
-                                    ladspaEffectFile = m_doc->getLadspaFile();
-                                    effectparam.firstChild().setNodeValue(ladspaEffectFile);
-                                    kDebug() << "// ... REPLACED WITH: " << ladspaEffectFile;
-                                }
-                            }
-                        }
-                        //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
-                        // get effect standard tags
-                        QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
-                        if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
-                        if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
-                        if (clipeffect.isNull()) {
-                            kDebug() << "///  WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
-                            m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
-                            elem.removeChild(effects.at(ix));
-                            ix--;
-                        } else {
-                            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
-                                QString factor;
-                                QString starttag;
-                                QString endtag;
-                                QDomNodeList params = currenteffect.elementsByTagName("parameter");
-                                for (int i = 0; i < params.count(); i++) {
-                                    QDomElement e = params.item(i).toElement();
-                                    if (e.attribute("type") == "keyframe") {
-                                        starttag = e.attribute("starttag", "start");
-                                        endtag = e.attribute("endtag", "end");
-                                        factor = e.attribute("factor", "1");
-                                        break;
-                                    }
-                                }
-                                QString keyframes;
-                                int effectin = effect.attribute("in").toInt();
-                                int effectout = effect.attribute("out").toInt();
-                                double startvalue = 0;
-                                double endvalue = 0;
-                                double fact;
-                                if (factor.isEmpty()) fact = 1;
-                                else if (factor.startsWith('%')) {
-                                    fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
-                                } else fact = factor.toDouble();
-                                for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
-                                    // parse effect parameters
-                                    QDomElement effectparam = n3.toElement();
-                                    if (effectparam.attribute("name") == starttag)
-                                        startvalue = effectparam.text().toDouble() * fact;
-                                    if (effectparam.attribute("name") == endtag)
-                                        endvalue = effectparam.text().toDouble() * fact;
-                                }
-                                // add first keyframe
-                                keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
-                                QDomNode lastParsedEffect;
-                                ix++;
-                                QDomNode n2 = effects.at(ix);
-                                bool continueParsing = true;
-                                for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
-                                    // parse all effects
-                                    QDomElement kfreffect = n2.toElement();
-                                    int effectout = kfreffect.attribute("out").toInt();
-
-                                    for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
-                                        // parse effect parameters
-                                        QDomElement subeffectparam = n4.toElement();
-                                        if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
-                                            //We are not in the same effect, stop parsing
-                                            lastParsedEffect = n2.previousSibling();
-                                            ix--;
-                                            continueParsing = false;
-                                            break;
-                                        } else if (subeffectparam.attribute("name") == endtag) {
-                                            endvalue = subeffectparam.text().toDouble() * fact;
-                                            break;
-                                        }
-                                    }
-                                    if (continueParsing) {
-                                        keyframes.append(QString::number(effectout) + ':' + QString::number(endvalue) + ';');
-                                        ix++;
-                                    }
-                                }
+                QDomNodeList effects = elem.elementsByTagName("filter");
+                slotAddProjectEffects(effects, elem, item, -1);
+            }
+        }
+    }
+    kDebug() << "*************  ADD DOC TRACK " << ix << ", DURATION: " << position;
+    return position;
+}
 
-                                params = currenteffect.elementsByTagName("parameter");
-                                for (int i = 0; i < params.count(); i++) {
-                                    QDomElement e = params.item(i).toElement();
-                                    if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
-                                }
-                                if (!continueParsing) {
-                                    n2 = lastParsedEffect;
-                                }
-                            } else {
-                                // Check if effect has in/out points
-                                if (effect.hasAttribute("in")) {
-                                    EffectsList::setParameter(currenteffect, "in",  effect.attribute("in"));
-                                }
-                                if (effect.hasAttribute("out")) {
-                                    EffectsList::setParameter(currenteffect, "out",  effect.attribute("out"));
-                                }
-                            }
+void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parent, ClipItem *clip, int trackIndex)
+{
+    for (int ix = 0; ix < effects.count(); ix++) {
+        bool disableeffect = false;
+        QDomElement effect = effects.at(ix).toElement();
+
+        // add effect to clip
+        QString effecttag;
+        QString effectid;
+        QString effectindex = QString::number(ix + 1);
+        QString ladspaEffectFile;
+        // Get effect tag & index
+        for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
+            // parse effect parameters
+            QDomElement effectparam = n3.toElement();
+            if (effectparam.attribute("name") == "tag") {
+                effecttag = effectparam.text();
+            } else if (effectparam.attribute("name") == "kdenlive_id") {
+                effectid = effectparam.text();
+            } else if (effectparam.attribute("name") == "disable" && effectparam.text().toInt() == 1) {
+                // Fix effects index
+                disableeffect = true;
+            } else if (effectparam.attribute("name") == "kdenlive_ix") {
+                // Fix effects index
+                effectparam.firstChild().setNodeValue(effectindex);
+            } else if (effectparam.attribute("name") == "src") {
+                ladspaEffectFile = effectparam.text();
+                if (!QFile::exists(ladspaEffectFile)) {
+                    // If the ladspa effect file is missing, recreate it
+                    kDebug() << "// MISSING LADSPA FILE: " << ladspaEffectFile;
+                    ladspaEffectFile = m_doc->getLadspaFile();
+                    effectparam.firstChild().setNodeValue(ladspaEffectFile);
+                    kDebug() << "// ... REPLACED WITH: " << ladspaEffectFile;
+                }
+            }
+        }
+        //kDebug() << "+ + CLIP EFF FND: " << effecttag << ", " << effectid << ", " << effectindex;
+        // get effect standard tags
+        QDomElement clipeffect = MainWindow::customEffects.getEffectByTag(QString(), effectid);
+        if (clipeffect.isNull()) clipeffect = MainWindow::videoEffects.getEffectByTag(effecttag, effectid);
+        if (clipeffect.isNull()) clipeffect = MainWindow::audioEffects.getEffectByTag(effecttag, effectid);
+        if (clipeffect.isNull()) {
+            kDebug() << "///  WARNING, EFFECT: " << effecttag << ": " << effectid << " not found, removing it from project";
+            m_documentErrors.append(i18n("Effect %1:%2 not found in MLT, it was removed from this project\n", effecttag, effectid));
+            parent.removeChild(effects.at(ix));
+            ix--;
+        } else {
+            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
+                QString factor;
+                QString starttag;
+                QString endtag;
+                QDomNodeList params = currenteffect.elementsByTagName("parameter");
+                for (int i = 0; i < params.count(); i++) {
+                    QDomElement e = params.item(i).toElement();
+                    if (e.attribute("type") == "keyframe") {
+                        starttag = e.attribute("starttag", "start");
+                        endtag = e.attribute("endtag", "end");
+                        factor = e.attribute("factor", "1");
+                        break;
+                    }
+                }
+                QString keyframes;
+                int effectin = effect.attribute("in").toInt();
+                int effectout = effect.attribute("out").toInt();
+                double startvalue = 0;
+                double endvalue = 0;
+                double fact;
+                if (factor.isEmpty()) fact = 1;
+                else if (factor.startsWith('%')) {
+                    fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
+                } else fact = factor.toDouble();
+                for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
+                    // parse effect parameters
+                    QDomElement effectparam = n3.toElement();
+                    if (effectparam.attribute("name") == starttag)
+                        startvalue = effectparam.text().toDouble() * fact;
+                    if (effectparam.attribute("name") == endtag)
+                        endvalue = effectparam.text().toDouble() * fact;
+                }
+                // add first keyframe
+                keyframes.append(QString::number(effectin) + ':' + QString::number(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
+                QDomNode lastParsedEffect;
+                ix++;
+                QDomNode n2 = effects.at(ix);
+                bool continueParsing = true;
+                for (; !n2.isNull() && continueParsing; n2 = n2.nextSibling()) {
+                    // parse all effects
+                    QDomElement kfreffect = n2.toElement();
+                    int effectout = kfreffect.attribute("out").toInt();
+
+                    for (QDomNode n4 = kfreffect.firstChild(); !n4.isNull(); n4 = n4.nextSibling()) {
+                        // parse effect parameters
+                        QDomElement subeffectparam = n4.toElement();
+                        if (subeffectparam.attribute("name") == "kdenlive_ix" && subeffectparam.text() != effectindex) {
+                            //We are not in the same effect, stop parsing
+                            lastParsedEffect = n2.previousSibling();
+                            ix--;
+                            continueParsing = false;
+                            break;
+                        } else if (subeffectparam.attribute("name") == endtag) {
+                            endvalue = subeffectparam.text().toDouble() * fact;
+                            break;
+                        }
+                    }
+                    if (continueParsing) {
+                        keyframes.append(QString::number(effectout) + ':' + QString::number(endvalue) + ';');
+                        ix++;
+                    }
+                }
 
-                            // adjust effect parameters
-                            for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
-                                // parse effect parameters
-                                QDomElement effectparam = n3.toElement();
-                                QString paramname = effectparam.attribute("name");
-                                QString paramvalue = effectparam.text();
-
-
-                                // try to find this parameter in the effect xml
-                                QDomElement e;
-                                for (int k = 0; k < clipeffectparams.count(); k++) {
-                                    e = clipeffectparams.item(k).toElement();
-                                    if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
-                                        if (e.attribute("factor", "1") != "1") {
-                                            QString factor = e.attribute("factor", "1");
-                                            double fact;
-                                            if (factor.startsWith('%')) {
-                                                fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
-                                            } else fact = factor.toDouble();
-                                            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;
-                                    }
-                                }
-                            }
-                            if (effecttag == "ladspa") {
-                                //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
+                params = currenteffect.elementsByTagName("parameter");
+                for (int i = 0; i < params.count(); i++) {
+                    QDomElement e = params.item(i).toElement();
+                    if (e.attribute("type") == "keyframe") e.setAttribute("keyframes", keyframes);
+                }
+                if (!continueParsing) {
+                    n2 = lastParsedEffect;
+                }
+            } else {
+                // Check if effect has in/out points
+                if (effect.hasAttribute("in")) {
+                    EffectsList::setParameter(currenteffect, "in",  effect.attribute("in"));
+                }
+                if (effect.hasAttribute("out")) {
+                    EffectsList::setParameter(currenteffect, "out",  effect.attribute("out"));
+                }
+            }
 
-                                if (!QFile::exists(ladspaEffectFile)) {
-                                    // If the ladspa effect file is missing, recreate it
-                                    initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
+            // adjust effect parameters
+            for (QDomNode n3 = effect.firstChild(); !n3.isNull(); n3 = n3.nextSibling()) {
+                // parse effect parameters
+                QDomElement effectparam = n3.toElement();
+                QString paramname = effectparam.attribute("name");
+                QString paramvalue = effectparam.text();
+
+                // try to find this parameter in the effect xml
+                QDomElement e;
+                for (int k = 0; k < clipeffectparams.count(); k++) {
+                    e = clipeffectparams.item(k).toElement();
+                    if (!e.isNull() && e.tagName() == "parameter" && e.attribute("name") == paramname) {
+                        if (e.attribute("factor", "1") != "1") {
+                            QString factor = e.attribute("factor", "1");
+                            double fact;
+                            if (factor.startsWith('%')) {
+                                fact = ProfilesDialog::getStringEval(m_doc->mltProfile(), factor);
+                            } else fact = factor.toDouble();
+                            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));
                                 }
-                                currenteffect.setAttribute("src", ladspaEffectFile);
-                            }
-                            if (disableeffect) currenteffect.setAttribute("disable", "1");
-                            item->addEffect(currenteffect, false);
-                        }
+                                e.setAttribute("keyframes", kfrs.join(";"));
+                            } else e.setAttribute("value", paramvalue.toDouble() * fact);
+                        } else e.setAttribute("value", paramvalue);
+                        break;
                     }
                 }
             }
-            //m_clipList.append(clip);
+            if (effecttag == "ladspa") {
+                //QString ladspaEffectFile = EffectsList::parameter(effect, "src", "property");
+
+                if (!QFile::exists(ladspaEffectFile)) {
+                    // If the ladspa effect file is missing, recreate it
+                    initEffects::ladspaEffectFile(ladspaEffectFile, currenteffect.attribute("ladspaid").toInt(), m_trackview->getLadspaParams(currenteffect));
+                }
+                currenteffect.setAttribute("src", ladspaEffectFile);
+            }
+            if (disableeffect) currenteffect.setAttribute("disable", "1");
+            if (clip) clip->addEffect(currenteffect, false);
+            else {
+                kDebug() << "<< TRACK: " << trackIndex << ", adding effect";;
+                m_doc->addTrackEffect(trackIndex, currenteffect);
+            }
         }
     }
-    //m_trackDuration = position;
-
-
-    //documentTracks.insert(ix, track);
-    kDebug() << "*************  ADD DOC TRACK " << ix << ", DURATION: " << position;
-    return position;
-    //track->show();
 }
 
+
 DocClipBase *TrackView::getMissingProducer(const QString id) const
 {
     QDomElement missingXml;
@@ -981,7 +989,7 @@ void TrackView::updateRuler()
 
 void TrackView::slotShowTrackEffects(int ix)
 {
-    emit showTrackEffects(m_doc->tracksCount() - ix, m_doc->getTrackEffects(ix));
+    emit showTrackEffects(m_doc->tracksCount() - ix, m_doc->trackInfoAt(m_doc->tracksCount() - ix - 1));
 }
 
 #include "trackview.moc"
index a46530ddc4f73b0b747bbd52ed83b0cb907a2d00..fdae3fc72d3589d6dc568a8ce0895c65793e887d 100644 (file)
@@ -37,6 +37,7 @@
 #include "customtrackscene.h"
 #include "effectslist.h"
 #include "ui_timeline_ui.h"
+#include "definitions.h"
 
 class ClipItem;
 class Transition;
@@ -100,6 +101,7 @@ private:
     int slotAddProjectTrack(int ix, QDomElement xml, bool locked);
     DocClipBase *getMissingProducer(const QString id) const;
     void adjustTrackHeaders();
+    void slotAddProjectEffects(QDomNodeList effects, QDomElement parent, ClipItem *clip, int trackIndex);
 
 private slots:
     void setCursorPos(int pos);
@@ -135,7 +137,7 @@ signals:
     void configTrack(int);
     void updateTracksInfo();
     void setZoom(int);
-    void showTrackEffects(int, EffectsList);
+    void showTrackEffects(int, TrackInfo);
 };
 
 #endif
index da81307c67a47f0473e5599dbdcb935bdf55ecf2..31813cd5bf2280859ff94a8bb2d8e74ee0a942e1 100644 (file)
          </property>
         </widget>
        </item>
-       <item row="0" column="0">
+       <item row="0" column="0" colspan="7">
         <widget class="QCheckBox" name="checkAll">
          <property name="enabled">
           <bool>false</bool>