Commit c61a7e8c authored by Till Theato's avatar Till Theato
Browse files

make the new effect adjustment function more generic

svn path=/trunk/kdenlive/; revision=5539
parent b4b63ec8
......@@ -1749,7 +1749,7 @@ Mlt::Producer *ClipItem::getProducer(int track, bool trackSpecific)
return m_clip->producer(trackSpecific ? track : -1);
}
QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, int previous, int current, bool fromStart)
QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height, ItemInfo oldInfo)
{
QMap<int, QDomElement> effects;
for (int i = 0; i < m_effectList.count(); i++) {
......@@ -1794,9 +1794,9 @@ QMap<int, QDomElement> ClipItem::adjustEffectsToDuration(int width, int height,
setFadeOut(out - in);
}
continue;
} else if (fromStart && effect.attribute("id") == "freeze") {
} else if (effect.attribute("id") == "freeze" && cropStart() != oldInfo.cropStart) {
effects[i] = effect.cloneNode().toElement();
int diff = previous - current;
int diff = (oldInfo.cropStart - cropStart()).frames(m_fps);
int frame = EffectsList::parameter(effect, "frame").toInt();
EffectsList::setParameter(effect, "frame", QString::number(frame - diff));
continue;
......
......@@ -171,7 +171,7 @@ public:
bool updateNormalKeyframes(QDomElement parameter);
/** @brief Adjusts effects after a clip duration change. */
QMap<int, QDomElement> adjustEffectsToDuration(int width, int height, int previous, int current, bool fromStart);
QMap<int, QDomElement> adjustEffectsToDuration(int width, int height, ItemInfo oldInfo);
/** Returns the necessary (audio, video, general) producer.
* @param track Track of the requested producer
......
......@@ -4548,7 +4548,7 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
// 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);
adjustEffects(clip, oldInfo, command);
new ResizeClipCommand(this, oldInfo, info, false, true, command);
emit clipItemSelected(clip);
} else {
......@@ -4643,7 +4643,7 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
// 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);
adjustEffects(clip, oldInfo, command);
new ResizeClipCommand(this, oldInfo, info, false, true, command);
emit clipItemSelected(clip);
} else {
......@@ -6661,14 +6661,10 @@ void CustomTrackView::slotRefreshThumbs(const QString &id, bool resetThumbs)
}
}
void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, bool fromStart, QUndoCommand* command)
void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoCommand* command)
{
QMap<int, QDomElement> effects;
if (fromStart)
effects = item->adjustEffectsToDuration(m_document->width(), m_document->height(), oldInfo.cropStart.frames(m_document->fps()), item->cropStart().frames(m_document->fps()), true);
else
effects = item->adjustEffectsToDuration(m_document->width(), m_document->height(), (oldInfo.cropStart + oldInfo.cropDuration).frames(m_document->fps()) - 1,
(item->cropStart() + item->cropDuration()).frames(m_document->fps()) - 1, false);
item->adjustEffectsToDuration(m_document->width(), m_document->height(), oldInfo);
if (effects.count()) {
QMap<int, QDomElement>::const_iterator i = effects.constBegin();
......
......@@ -438,7 +438,7 @@ private:
* @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);
void adjustEffects(ClipItem *item, ItemInfo oldInfo, QUndoCommand *command);
private slots:
void slotRefreshGuides();
......
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