Commit 5e70eb03 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix cutting of geometry keyframes (like pan & zoom): http://kdenlive.org/mantis/view.php?id=2991

parent dd1f644e
......@@ -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;
......
......@@ -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);
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment