From: Till Theato Date: Tue, 29 Mar 2011 18:53:12 +0000 (+0000) Subject: Fix "Pan and Zoom" and position effects (fade, freeze) not obeying to undo/redo syste... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=d16b3f4a7856800710cc21e66f2e16721fd75298;p=kdenlive Fix "Pan and Zoom" and position effects (fade, freeze) not obeying to undo/redo system after clip resize svn path=/trunk/kdenlive/; revision=5524 --- diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 2857703e..02a4cc44 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -232,7 +232,9 @@ void ClipItem::initEffect(QDomElement effect, int diff) QDomNodeList params = effect.elementsByTagName("parameter"); for (int i = 0; i < params.count(); i++) { QDomElement e = params.item(i).toElement(); - kDebug() << "// init eff: " << e.attribute("name"); + + if (e.isNull()) + continue; // Check if this effect has a variable parameter if (e.attribute("default").startsWith('%')) { @@ -243,14 +245,9 @@ void ClipItem::initEffect(QDomElement effect, int diff) } } - if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) { - QString def = e.attribute("default"); + if ((e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("keyframes").isEmpty()) { // Effect has a keyframe type parameter, we need to set the values - if (e.attribute("keyframes").isEmpty()) { - e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + def); - kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes"); - //break; - } + e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + e.attribute("default")); } } if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") { @@ -421,34 +418,35 @@ void ClipItem::setSelectedEffect(const int ix) { m_selectedEffect = ix; QDomElement effect = effectAt(m_selectedEffect); - if (effect.isNull() == false) { + if (!effect.isNull() && effect.attribute("disable") != "1") { QDomNodeList params = effect.elementsByTagName("parameter"); - if (effect.attribute("disable") != "1") - for (int i = 0; i < params.count(); i++) { - QDomElement e = params.item(i).toElement(); - if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") { - m_keyframes.clear(); - m_visibleParam = i; - double max = e.attribute("max").toDouble(); - double min = e.attribute("min").toDouble(); - m_keyframeFactor = 100.0 / (max - min); - m_keyframeOffset = min; - m_keyframeDefault = e.attribute("default").toDouble(); - m_selectedKeyframe = 0; - - // parse keyframes - const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts); - foreach(const QString &str, keyframes) { - int pos = str.section(':', 0, 0).toInt(); - double val = str.section(':', 1, 1).toDouble(); - m_keyframes[pos] = val; - } - if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1; - update(); - return; + for (int i = 0; i < params.count(); i++) { + QDomElement e = params.item(i).toElement(); + if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") { + m_keyframes.clear(); + m_visibleParam = i; + double max = e.attribute("max").toDouble(); + double min = e.attribute("min").toDouble(); + m_keyframeFactor = 100.0 / (max - min); + m_keyframeOffset = min; + m_keyframeDefault = e.attribute("default").toDouble(); + m_selectedKeyframe = 0; + + // parse keyframes + const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts); + foreach(const QString &str, keyframes) { + int pos = str.section(':', 0, 0).toInt(); + double val = str.section(':', 1, 1).toDouble(); + m_keyframes[pos] = val; } + if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) + m_editedKeyframe = -1; + update(); + return; } + } } + if (!m_keyframes.isEmpty()) { m_keyframes.clear(); update(); @@ -1094,22 +1092,18 @@ void ClipItem::setFadeIn(int pos) { if (pos == m_startFade) return; int oldIn = m_startFade; - if (pos < 0) pos = 0; - if (pos > cropDuration().frames(m_fps)) pos = (int)(cropDuration().frames(m_fps)); - m_startFade = pos; + m_startFade = qBound(0, pos, (int)cropDuration().frames(m_fps)); QRectF rect = boundingRect(); - update(rect.x(), rect.y(), qMax(oldIn, pos), rect.height()); + update(rect.x(), rect.y(), qMax(oldIn, m_startFade), rect.height()); } void ClipItem::setFadeOut(int pos) { if (pos == m_endFade) return; int oldOut = m_endFade; - if (pos < 0) pos = 0; - if (pos > cropDuration().frames(m_fps)) pos = (int)(cropDuration().frames(m_fps)); - m_endFade = pos; + m_endFade = qBound(0, pos, (int)cropDuration().frames(m_fps)); QRectF rect = boundingRect(); - update(rect.x() + rect.width() - qMax(oldOut, pos), rect.y(), qMax(oldOut, pos), rect.height()); + update(rect.x() + rect.width() - qMax(oldOut, m_endFade), rect.y(), qMax(oldOut, m_endFade), rect.height()); } diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 587d7812..f202ad61 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1869,10 +1869,10 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect)); } // check if we are trying to reset a keyframe effect - if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) { - //clip->initEffect(effect); + /*if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) { + clip->initEffect(effect); effectParams = getEffectArgs(effect); - } + }*/ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - track, pos, effectParams)) emit displayMessage(i18n("Problem editing effect"), ErrorMessage); m_document->setTrackEffect(m_document->tracksCount() - track - 1, ix, effect); @@ -1885,8 +1885,9 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE if (clip) { // Special case: speed effect if (effect.attribute("id") == "speed") { - if (effect.attribute("disable") == "1") doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId()); - else { + if (effect.attribute("disable") == "1") { + doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId()); + } else { double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0; int strobe = EffectsList::parameter(effect, "strobe").toInt(); if (strobe == 0) strobe = 1; @@ -1895,7 +1896,8 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE clip->setEffectAt(ix, effect); if (ix == clip->selectedEffectIndex()) { clip->setSelectedEffect(ix); - if (!triggeredByUser) emit clipItemSelected(clip, ix); + if (!triggeredByUser) + emit clipItemSelected(clip, ix); } return; } @@ -1910,14 +1912,7 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE clip->initEffect(effect); effectParams = getEffectArgs(effect); } - if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams)) - emit displayMessage(i18n("Problem editing effect"), ErrorMessage); - clip->setEffectAt(ix, effect); - if (ix == clip->selectedEffectIndex()) { - clip->setSelectedEffect(ix); - if (!triggeredByUser) emit clipItemSelected(clip, ix); - } 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") { @@ -1929,6 +1924,16 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE clip->setFadeOut(pos); } } + + if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams)) + emit displayMessage(i18n("Problem editing effect"), ErrorMessage); + + clip->setEffectAt(ix, effect); + if (ix == clip->selectedEffectIndex()) { + clip->setSelectedEffect(ix); + if (!triggeredByUser) + emit clipItemSelected(clip, ix); + } } setDocumentModified(); } @@ -4455,7 +4460,7 @@ void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end, bool if (success) { kDebug() << "RESIZE CLP STRAT TO:" << end.startPos.frames(m_document->fps()) << ", OLD ST: " << start.startPos.frames(25); item->resizeStart((int) end.startPos.frames(m_document->fps())); - updatePositionEffects(item, clipinfo); +// updatePositionEffects(item, clipinfo); } else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage); } else { ItemInfo clipinfo = item->info(); @@ -4463,7 +4468,7 @@ void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end, bool bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, end.endPos - clipinfo.startPos); if (success) { item->resizeEnd((int) end.endPos.frames(m_document->fps())); - updatePositionEffects(item, clipinfo); +// updatePositionEffects(item, clipinfo); } else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage); } if (!resizeClipStart && end.cropStart != start.cropStart) { @@ -4536,44 +4541,16 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol new MoveTransitionCommand(this, trInfo, newTrInfo, true, command); } - /* - * TODO: cleanup the effect update process - */ ClipItem *clip = static_cast < ClipItem * >(item); - updatePositionEffects(clip, oldInfo); - - // check keyframes - QDomDocument doc; - QDomElement root = doc.createElement("list"); - doc.appendChild(root); - QList indexes; - for (int i = 0; i < clip->effectsCount(); i++) { - QDomElement effect = clip->effectAt(i); - if (EffectsList::hasKeyFrames(effect)) { - doc.appendChild(doc.importNode(effect, true)); - indexes.append(i); - } - } - - if (clip->checkEffectsKeyframesPos(oldInfo.cropStart.frames(m_document->fps()), clip->cropStart().frames(m_document->fps()), true)) { - // Keyframes were modified, updateClip - QDomNodeList effs = doc.elementsByTagName("effect"); - // Hack: - // Since we must always resize clip before updating the keyframes, we - // put a resize command before & after checking keyframes so that - // we are sure the resize is performed before whenever we do or undo the action - - new ResizeClipCommand(this, oldInfo, info, false, true, command); - for (int i = 0; i < indexes.count(); i++) { - new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, command); - updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i)); - } - new ResizeClipCommand(this, oldInfo, info, false, true, command); - emit clipItemSelected(clip); - } else { - new ResizeClipCommand(this, oldInfo, info, false, false, command); - } + // Hack: + // Since we must always resize clip before updating the keyframes, we + // put a resize command before & after checking keyframes so that + // we are sure the resize is performed before whenever we do or undo the action + new ResizeClipCommand(this, oldInfo, info, false, true, command); + adjustEffects(clip, oldInfo, true, command); + new ResizeClipCommand(this, oldInfo, info, false, true, command); + emit clipItemSelected(clip); } else { KdenliveSettings::setSnaptopoints(false); item->resizeStart((int) oldInfo.startPos.frames(m_document->fps())); @@ -4661,39 +4638,14 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI ClipItem *clip = static_cast < ClipItem * >(item); - updatePositionEffects(clip, oldInfo); - - // check keyframes - QDomDocument doc; - QDomElement root = doc.createElement("list"); - doc.appendChild(root); - QList indexes; - for (int i = 0; i < clip->effectsCount(); i++) { - QDomElement effect = clip->effectAt(i); - if (EffectsList::hasKeyFrames(effect)) { - doc.appendChild(doc.importNode(effect, true)); - indexes.append(i); - } - } - - if (clip->checkEffectsKeyframesPos((oldInfo.cropStart + oldInfo.endPos - oldInfo.startPos).frames(m_document->fps()) - 1, (clip->cropStart() + clip->cropDuration()).frames(m_document->fps()) - 1, false)) { - // Keyframes were modified, updateClip - QDomNodeList effs = doc.elementsByTagName("effect"); - // Hack: - // Since we must always resize clip before updating the keyframes, we - // put a resize command before & after checking keyframes so that - // we are sure the resize is performed before whenever we do or undo the action - - new ResizeClipCommand(this, oldInfo, info, false, true, command); - for (int i = 0; i < indexes.count(); i++) { - new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, command); - updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i)); - } - new ResizeClipCommand(this, oldInfo, info, false, true, command); - emit clipItemSelected(clip); - } else { - new ResizeClipCommand(this, oldInfo, info, false, false, command); - } + // Hack: + // Since we must always resize clip before updating the keyframes, we + // put a resize command before & after checking keyframes so that + // we are sure the resize is performed before whenever we do or undo the action + new ResizeClipCommand(this, oldInfo, info, false, true, command); + adjustEffects(clip, oldInfo, false, command); + new ResizeClipCommand(this, oldInfo, info, false, true, command); + emit clipItemSelected(clip); } else { KdenliveSettings::setSnaptopoints(false); item->resizeEnd((int) oldInfo.endPos.frames(m_document->fps())); @@ -4729,7 +4681,7 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI } } -void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info) +void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool standalone) { int end = item->fadeIn(); if (end != 0) { @@ -4747,10 +4699,13 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info) end += start; EffectsList::setParameter(oldeffect, "in", QString::number(start)); EffectsList::setParameter(oldeffect, "out", QString::number(end)); - if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect))) - emit displayMessage(i18n("Problem editing effect"), ErrorMessage); - // if fade effect is displayed, update the effect edit widget with new clip duration - if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos); + if (standalone) { + if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect))) + emit displayMessage(i18n("Problem editing effect"), ErrorMessage); + // if fade effect is displayed, update the effect edit widget with new clip duration + if (item->isSelected() && effectPos == item->selectedEffectIndex()) + emit clipItemSelected(item, effectPos); + } } effectPos = item->hasEffect("brightness", "fade_from_black"); if (effectPos != -1) { @@ -4765,12 +4720,16 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info) end += start; EffectsList::setParameter(oldeffect, "in", QString::number(start)); EffectsList::setParameter(oldeffect, "out", QString::number(end)); - if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect))) - emit displayMessage(i18n("Problem editing effect"), ErrorMessage); - // if fade effect is displayed, update the effect edit widget with new clip duration - if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos); + if (standalone) { + if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect))) + emit displayMessage(i18n("Problem editing effect"), ErrorMessage); + // if fade effect is displayed, update the effect edit widget with new clip duration + if (item->isSelected() && effectPos == item->selectedEffectIndex()) + emit clipItemSelected(item, effectPos); + } } } + int start = item->fadeOut(); if (start != 0) { // there is a fade out effect @@ -4787,10 +4746,13 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info) start = end - start; EffectsList::setParameter(oldeffect, "in", QString::number(start)); EffectsList::setParameter(oldeffect, "out", QString::number(end)); - if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect))) - emit displayMessage(i18n("Problem editing effect"), ErrorMessage); - // if fade effect is displayed, update the effect edit widget with new clip duration - if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos); + if (standalone) { + if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect))) + emit displayMessage(i18n("Problem editing effect"), ErrorMessage); + // if fade effect is displayed, update the effect edit widget with new clip duration + if (item->isSelected() && effectPos == item->selectedEffectIndex()) + emit clipItemSelected(item, effectPos); + } } effectPos = item->hasEffect("brightness", "fade_to_black"); if (effectPos != -1) { @@ -4805,10 +4767,13 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info) start = end - start; EffectsList::setParameter(oldeffect, "in", QString::number(start)); EffectsList::setParameter(oldeffect, "out", QString::number(end)); - if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect))) - emit displayMessage(i18n("Problem editing effect"), ErrorMessage); - // if fade effect is displayed, update the effect edit widget with new clip duration - if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos); + if (standalone) { + if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect))) + emit displayMessage(i18n("Problem editing effect"), ErrorMessage); + // if fade effect is displayed, update the effect edit widget with new clip duration + if (item->isSelected() && effectPos == item->selectedEffectIndex()) + emit clipItemSelected(item, effectPos); + } } } @@ -4820,13 +4785,13 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info) if (!eff.isNull() && diff != 0) { int freeze_pos = EffectsList::parameter(eff, "frame").toInt() + diff; EffectsList::setParameter(eff, "frame", QString::number(freeze_pos)); - if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") { - emit clipItemSelected(item, item->selectedEffectIndex()); + if (standalone) { + if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") { + emit clipItemSelected(item, item->selectedEffectIndex()); + } } } } - - updatePanZoom(item); } double CustomTrackView::getSnapPointForPos(double pos) @@ -6600,6 +6565,7 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos) { QList effects = item->updatePanZoom(m_document->width(), m_document->height(), cutPos.frames(m_document->fps())); + for (int i = 0; i < effects.count(); ++i) { if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(item->effectAt(effects.at(i))))) emit displayMessage(i18n("Problem editing effect"), ErrorMessage); @@ -6609,7 +6575,7 @@ void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos) emit clipItemSelected(item, effects.at(i));*/ } // update always, otherwise there might problems when resizing groups - if (effects.count() > 0) + if (effects.count()) emit clipItemSelected(item, item->selectedEffectIndex()); } @@ -6694,3 +6660,37 @@ void CustomTrackView::slotRefreshThumbs(const QString &id, bool resetThumbs) } } } + +void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, bool fromStart, QUndoCommand* command) +{ + bool update = false; + + QMap effects; + for (int i = 0; i < item->effectsCount(); ++i) { + QDomElement effect = item->getEffectAt(i); + bool nonStdKeyframeUpdate = effect.attribute("id").startsWith("fade") || effect.attribute("id") == "freeze" || EffectsList::hasGeometryKeyFrames(effect); + if (nonStdKeyframeUpdate) + update = true; + if (nonStdKeyframeUpdate || EffectsList::hasKeyFrames(effect) || EffectsList::hasSimpleKeyFrames(effect)) + effects.insert(i, effect.cloneNode().toElement()); + } + + if(effects.isEmpty()) + return; + + if (fromStart) + update |= item->checkEffectsKeyframesPos(oldInfo.cropStart.frames(m_document->fps()), item->cropStart().frames(m_document->fps()), true); + else + update |= item->checkEffectsKeyframesPos((oldInfo.cropStart + oldInfo.endPos - oldInfo.startPos).frames(m_document->fps()) - 1, (item->cropStart() + item->cropDuration()).frames(m_document->fps()) - 1, false); + + update |= item->updatePanZoom(m_document->width(), m_document->height(), 0).count() > 0; + updatePositionEffects(item, oldInfo, false); + + if (update) { + QMap::const_iterator i = effects.constBegin(); + while (i != effects.constEnd()) { + new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effectAt(i.key()), i.key(), false, command); + ++i; + } + } +} diff --git a/src/customtrackview.h b/src/customtrackview.h index ca08d507..a4b555ae 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -356,7 +356,7 @@ private: /** Get the index of the video track that is just below current track */ int getPreviousVideoTrack(int track); - void updatePositionEffects(ClipItem * item, ItemInfo info); + void updatePositionEffects(ClipItem * item, ItemInfo info, bool standalone = true); bool insertDropClips(const QMimeData *data, const QPoint pos); bool canBePastedTo(ItemInfo info, int type) const; bool canBePastedTo(QList infoList, int type) const; @@ -433,6 +433,13 @@ private: * In addition to update the duration in TrackInfo it updates effects with keyframes on the track. */ void updateTrackDuration(int track, QUndoCommand *command); + /** @brief Adjusts effects after a clip resize. + * @param item The item that was resized + * @param oldInfo pre resize info + * @param fromStart false = resize from end + * @param command Used as a parent for EditEffectCommand */ + void adjustEffects(ClipItem *item, ItemInfo oldInfo, bool fromStart, QUndoCommand *command); + private slots: void slotRefreshGuides(); void slotEnableRefresh(); diff --git a/src/effectslist.cpp b/src/effectslist.cpp index 3fb2891e..d048e6d9 100644 --- a/src/effectslist.cpp +++ b/src/effectslist.cpp @@ -165,6 +165,18 @@ bool EffectsList::hasSimpleKeyFrames(QDomElement effect) return false; } +// static +bool EffectsList::hasGeometryKeyFrames(QDomElement effect) +{ + QDomNodeList params = effect.elementsByTagName("parameter"); + for (int i = 0; i < params.count(); ++i) { + QDomElement param = params.item(i).toElement(); + if (param.attribute("type") == "geometry" && !param.hasAttribute("fixed")) + return true; + } + return false; +} + void EffectsList::clone(const EffectsList original) { setContent(original.toString()); diff --git a/src/effectslist.h b/src/effectslist.h index f60c50ab..17d7f9a5 100644 --- a/src/effectslist.h +++ b/src/effectslist.h @@ -69,6 +69,7 @@ public: void replace(int ix, QDomElement effect); static bool hasKeyFrames(QDomElement effect); static bool hasSimpleKeyFrames(QDomElement effect); + static bool hasGeometryKeyFrames(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); diff --git a/src/renderer.cpp b/src/renderer.cpp index c70abc4e..e224186e 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -2697,6 +2697,12 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par for (int j = 0; j < params.count(); j++) { filter->set((prefix + params.at(j).name()).toUtf8().constData(), params.at(j).value().toUtf8().constData()); } + + // Pan and Zoom will be updated upon clip duration change + if (params.paramValue("id") == "pan_zoom") { + filter->set_in_and_out(service.get_int("in"), service.get_int("out") + 1); + } + mlt_service_unlock(service.get_service()); m_isBlocked = false;