From: Jean-Baptiste Mardelle Date: Sat, 23 Feb 2013 16:17:28 +0000 (+0100) Subject: Merge branch 'master' of git://anongit.kde.org/kdenlive X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=ba1ba937af590000157599aca776708ded840a28;hp=c1ad9ec174e137d76b6bb92430d2798db27f07d7;p=kdenlive Merge branch 'master' of git://anongit.kde.org/kdenlive --- diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 9c7a9a17..83b387be 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -349,12 +349,16 @@ const QString ClipItem::adjustKeyframes(QString keyframes, int offset) return result.join(";"); } -bool ClipItem::checkKeyFrames() +bool ClipItem::checkKeyFrames(int width, int height, int previousDuration, int cutPos) { bool clipEffectsModified = false; QLocale locale; // go through all effects this clip has for (int ix = 0; ix < m_effectList.count(); ++ix) { + // Check geometry params + resizeGeometries(ix, width, height, previousDuration, cutPos == -1 ? 0 : cutPos, cropDuration().frames(m_fps) - 1); + + // Check keyframe params QStringList keyframeParams = keyframes(ix); QStringList newKeyFrameParams; bool effModified = false; @@ -499,6 +503,22 @@ void ClipItem::setSelectedEffect(const int ix) } } +void ClipItem::resizeGeometries(const int index, int width, int height, int previousDuration, int start, int duration) +{ + QString geom; + QDomElement effect = m_effectList.at(index); + QDomNodeList params = effect.elementsByTagName("parameter"); + + for (int i = 0; i < params.count(); i++) { + QDomElement e = params.item(i).toElement(); + if (!e.isNull() && e.attribute("type") == "geometry") { + geom = e.attribute("value"); + Mlt::Geometry geometry(geom.toUtf8().data(), previousDuration, width, height); + e.setAttribute("value", geometry.serialise(start, start + duration)); + } + } +} + QStringList ClipItem::keyframes(const int index) { QStringList result; diff --git a/src/clipitem.h b/src/clipitem.h index 9303cba8..08432689 100644 --- a/src/clipitem.h +++ b/src/clipitem.h @@ -138,10 +138,14 @@ public: void initEffect(QDomElement effect, int diff = 0, int offset = 0); /** @brief Gets all keyframes. - * @param index Number of the effect + * @param index Index of the effect * @return a list of strings of keyframes (one string per param) */ QStringList keyframes(const int index); + /** @brief Adjust all geometry keyframes. + * @param index Index of the effect */ + void resizeGeometries(const int index, int width, int height, int previousDuration, int start, int duration); + /** @brief Sets params with keyframes and updates the visible keyframes. * @param ix Number of the effect * @param keyframes a list of strings of keyframes (one string per param), which should be used */ @@ -159,8 +163,9 @@ public: /** @brief Adjust keyframes to the new clip. */ const QString adjustKeyframes(QString keyframes, int offset); /** @brief Makes sure all keyframes are in the clip's cropped duration. + * @param cutPos the frame number where the new clip starts * @return Whether or not changes were made */ - bool checkKeyFrames(); + bool checkKeyFrames(int width, int height, int previousDuration, int cutPos = -1); QPixmap startThumb() const; QPixmap endThumb() const; void setVideoOnly(bool force); diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 81746b57..a0447fae 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -2470,10 +2470,10 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, Eff item->resizeEnd(cutPos); scene()->addItem(dup); - if (item->checkKeyFrames()) + if (item->checkKeyFrames(m_document->width(), m_document->height(), info.cropDuration.frames(m_document->fps()))) slotRefreshEffects(item); - if (dup->checkKeyFrames()) + if (dup->checkKeyFrames(m_document->width(), m_document->height(), info.cropDuration.frames(m_document->fps()), cutTime.frames(m_document->fps()))) slotRefreshEffects(dup); item->baseClip()->addReference();