Commit a1381ab8 authored by Till Theato's avatar Till Theato

- 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
parent b1126cff
......@@ -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 <int, double> 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());
}
}
}
......
......@@ -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
......
......@@ -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) {
......
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