From a1381ab8f18c9f06e97c6ce963c4388284247c27 Mon Sep 17 00:00:00 2001 From: Till Theato Date: Tue, 31 Aug 2010 18:19:15 +0000 Subject: [PATCH] - Fix some problems with undoing resizing a clip containing a pan & zoom effect - Fix keeping sync of geometry widget timeline and project timeline svn path=/trunk/kdenlive/; revision=4799 --- src/clipitem.cpp | 16 +++++++++++++++- src/customtrackview.cpp | 10 ++++++++++ src/geometrywidget.cpp | 24 ++++++------------------ 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 974ecf1c..db0f69fa 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -1219,7 +1219,9 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b for (int j = 0; j < params.count(); j++) { bool modified = false; QDomElement e = params.item(j).toElement(); - if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) { + if (e.isNull()) + continue; + if (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") { // parse keyframes and adjust values const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts); QMap kfr; @@ -1250,6 +1252,18 @@ bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b } e.setAttribute("keyframes", newkfr); } + } else if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) { + char *tmp = (char *) qstrdup(e.attribute("value").toUtf8().data()); + Mlt::Geometry geometry(tmp, cropDuration().frames(fps())); + delete[] tmp; + + Mlt::GeometryItem item; + while (!geometry.next_key(&item, cropDuration().frames(fps()))) { + geometry.remove(item.frame()); + modified = true; + } + + e.setAttribute("value", geometry.serialise()); } } } diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 6d910500..f1bc1fda 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -4385,6 +4385,9 @@ 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); @@ -4401,6 +4404,12 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol } } + int panZoomPos = clip->hasEffect("affine", "pan_zoom"); + if (panZoomPos != -1) { + doc.appendChild(doc.importNode(clip->effectAt(panZoomPos), true)); + indexes.append(panZoomPos); + } + 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"); @@ -4673,6 +4682,7 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info) } oldeffect.setAttribute("in", start); oldeffect.setAttribute("out", max); + if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect))) emit displayMessage(i18n("Problem editing effect"), ErrorMessage); // if effect is displayed, update the effect edit widget with new clip duration diff --git a/src/geometrywidget.cpp b/src/geometrywidget.cpp index 49621423..787a4562 100644 --- a/src/geometrywidget.cpp +++ b/src/geometrywidget.cpp @@ -190,14 +190,6 @@ void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxfra m_geometry = new Mlt::Geometry(tmp, maxframe - minframe, m_monitor->render->renderWidth(), m_monitor->render->renderHeight()); delete[] tmp; - // remove keyframes out of range - Mlt::GeometryItem invalidItem; - bool foundInvalidItem = false; - while (!m_geometry->next_key(&invalidItem, maxframe - minframe)) { - foundInvalidItem = true; - m_geometry->remove(invalidItem.frame()); - } - if (elem.attribute("fixed") == "1") { // Keyframes are disabled m_ui.widgetTimeWrapper->setHidden(true); @@ -229,10 +221,6 @@ void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxfra slotPositionChanged(0, false); slotCheckMonitorPosition(m_monitor->render->seekFramePosition()); - - // update if we had to remove a keyframe which got out of range - if (foundInvalidItem) - QTimer::singleShot(300, this, SIGNAL(parameterChanged())); } void GeometryWidget::slotSyncPosition(int relTimelinePos) @@ -249,14 +237,14 @@ void GeometryWidget::slotSyncPosition(int relTimelinePos) void GeometryWidget::slotPositionChanged(int pos, bool seek) { - if (pos == -1) { + if (pos == -1) pos = m_timePos->getValue(); - m_timeline->blockSignals(true); - m_timeline->setValue(pos); - m_timeline->blockSignals(false); - } else { + else m_timePos->setValue(pos); - } + + m_timeline->blockSignals(true); + m_timeline->setValue(pos); + m_timeline->blockSignals(false); Mlt::GeometryItem item; if (m_geometry->fetch(&item, pos) || item.key() == false) { -- 2.39.2