From: Jean-Baptiste Mardelle Date: Tue, 24 Aug 2010 20:03:31 +0000 (+0000) Subject: Almost finished implementing track effects X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=42af581eaabb00ee75768352d0baa01e4c98df58;p=kdenlive Almost finished implementing track effects svn path=/trunk/kdenlive/; revision=4754 --- diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 1c9d225c..42eff731 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -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(); } diff --git a/src/customtrackview.h b/src/customtrackview.h index 7d7a55e2..a4cf4013 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -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 diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index 3b26ddf5..257a5468 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -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); } diff --git a/src/effectstackview.h b/src/effectstackview.h index 7bea226c..7754c5df 100644 --- a/src/effectstackview.h +++ b/src/effectstackview.h @@ -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 diff --git a/src/headertrack.cpp b/src/headertrack.cpp index 2e4a7eff..e04df247 100644 --- a/src/headertrack.cpp +++ b/src/headertrack.cpp @@ -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(); diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 538d5e72..8615b2ba 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -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); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d900c254..a42dbfb8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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))); diff --git a/src/trackview.cpp b/src/trackview.cpp index 93c0e9ed..54d916a4 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -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" diff --git a/src/trackview.h b/src/trackview.h index a46530dd..fdae3fc7 100644 --- a/src/trackview.h +++ b/src/trackview.h @@ -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 diff --git a/src/widgets/effectstack_ui.ui b/src/widgets/effectstack_ui.ui index da81307c..31813cd5 100644 --- a/src/widgets/effectstack_ui.ui +++ b/src/widgets/effectstack_ui.ui @@ -140,7 +140,7 @@ - + false