QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
- kDebug() << "// init eff: " << e.attribute("name");
+
+ if (e.isNull())
+ continue;
// Check if this effect has a variable parameter
if (e.attribute("default").startsWith('%')) {
}
}
- if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe")) {
- QString def = e.attribute("default");
+ if ((e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("keyframes").isEmpty()) {
// Effect has a keyframe type parameter, we need to set the values
- if (e.attribute("keyframes").isEmpty()) {
- e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + def);
- kDebug() << "///// EFFECT KEYFRAMES INITED: " << e.attribute("keyframes");
- //break;
- }
+ e.setAttribute("keyframes", QString::number(cropStart().frames(m_fps)) + ':' + e.attribute("default"));
}
}
if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") {
{
m_selectedEffect = ix;
QDomElement effect = effectAt(m_selectedEffect);
- if (effect.isNull() == false) {
+ if (!effect.isNull() && effect.attribute("disable") != "1") {
QDomNodeList params = effect.elementsByTagName("parameter");
- if (effect.attribute("disable") != "1")
- for (int i = 0; i < params.count(); i++) {
- QDomElement e = params.item(i).toElement();
- if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
- m_keyframes.clear();
- m_visibleParam = i;
- double max = e.attribute("max").toDouble();
- double min = e.attribute("min").toDouble();
- m_keyframeFactor = 100.0 / (max - min);
- m_keyframeOffset = min;
- m_keyframeDefault = e.attribute("default").toDouble();
- m_selectedKeyframe = 0;
-
- // parse keyframes
- const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
- foreach(const QString &str, keyframes) {
- int pos = str.section(':', 0, 0).toInt();
- double val = str.section(':', 1, 1).toDouble();
- m_keyframes[pos] = val;
- }
- if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end()) m_editedKeyframe = -1;
- update();
- return;
+ for (int i = 0; i < params.count(); i++) {
+ QDomElement e = params.item(i).toElement();
+ if (!e.isNull() && (e.attribute("type") == "keyframe" || e.attribute("type") == "simplekeyframe") && e.attribute("intimeline") == "1") {
+ m_keyframes.clear();
+ m_visibleParam = i;
+ double max = e.attribute("max").toDouble();
+ double min = e.attribute("min").toDouble();
+ m_keyframeFactor = 100.0 / (max - min);
+ m_keyframeOffset = min;
+ m_keyframeDefault = e.attribute("default").toDouble();
+ m_selectedKeyframe = 0;
+
+ // parse keyframes
+ const QStringList keyframes = e.attribute("keyframes").split(';', QString::SkipEmptyParts);
+ foreach(const QString &str, keyframes) {
+ int pos = str.section(':', 0, 0).toInt();
+ double val = str.section(':', 1, 1).toDouble();
+ m_keyframes[pos] = val;
}
+ if (m_keyframes.find(m_editedKeyframe) == m_keyframes.end())
+ m_editedKeyframe = -1;
+ update();
+ return;
}
+ }
}
+
if (!m_keyframes.isEmpty()) {
m_keyframes.clear();
update();
{
if (pos == m_startFade) return;
int oldIn = m_startFade;
- if (pos < 0) pos = 0;
- if (pos > cropDuration().frames(m_fps)) pos = (int)(cropDuration().frames(m_fps));
- m_startFade = pos;
+ m_startFade = qBound(0, pos, (int)cropDuration().frames(m_fps));
QRectF rect = boundingRect();
- update(rect.x(), rect.y(), qMax(oldIn, pos), rect.height());
+ update(rect.x(), rect.y(), qMax(oldIn, m_startFade), rect.height());
}
void ClipItem::setFadeOut(int pos)
{
if (pos == m_endFade) return;
int oldOut = m_endFade;
- if (pos < 0) pos = 0;
- if (pos > cropDuration().frames(m_fps)) pos = (int)(cropDuration().frames(m_fps));
- m_endFade = pos;
+ m_endFade = qBound(0, pos, (int)cropDuration().frames(m_fps));
QRectF rect = boundingRect();
- update(rect.x() + rect.width() - qMax(oldOut, pos), rect.y(), qMax(oldOut, pos), rect.height());
+ update(rect.x() + rect.width() - qMax(oldOut, m_endFade), rect.y(), qMax(oldOut, m_endFade), rect.height());
}
initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
}
// check if we are trying to reset a keyframe effect
- if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
- //clip->initEffect(effect);
+ /*if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
+ clip->initEffect(effect);
effectParams = getEffectArgs(effect);
- }
+ }*/
if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - track, pos, effectParams))
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
m_document->setTrackEffect(m_document->tracksCount() - track - 1, ix, effect);
if (clip) {
// Special case: speed effect
if (effect.attribute("id") == "speed") {
- if (effect.attribute("disable") == "1") doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
- else {
+ if (effect.attribute("disable") == "1") {
+ doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
+ } else {
double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
int strobe = EffectsList::parameter(effect, "strobe").toInt();
if (strobe == 0) strobe = 1;
clip->setEffectAt(ix, effect);
if (ix == clip->selectedEffectIndex()) {
clip->setSelectedEffect(ix);
- if (!triggeredByUser) emit clipItemSelected(clip, ix);
+ if (!triggeredByUser)
+ emit clipItemSelected(clip, ix);
}
return;
}
clip->initEffect(effect);
effectParams = getEffectArgs(effect);
}
- if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams))
- emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
- clip->setEffectAt(ix, effect);
- if (ix == clip->selectedEffectIndex()) {
- clip->setSelectedEffect(ix);
- if (!triggeredByUser) emit clipItemSelected(clip, ix);
- }
if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") {
// A fade effect was modified, update the clip
if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
clip->setFadeOut(pos);
}
}
+
+ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams))
+ emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+
+ clip->setEffectAt(ix, effect);
+ if (ix == clip->selectedEffectIndex()) {
+ clip->setSelectedEffect(ix);
+ if (!triggeredByUser)
+ emit clipItemSelected(clip, ix);
+ }
}
setDocumentModified();
}
if (success) {
kDebug() << "RESIZE CLP STRAT TO:" << end.startPos.frames(m_document->fps()) << ", OLD ST: " << start.startPos.frames(25);
item->resizeStart((int) end.startPos.frames(m_document->fps()));
- updatePositionEffects(item, clipinfo);
+// updatePositionEffects(item, clipinfo);
} else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
} else {
ItemInfo clipinfo = item->info();
bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, end.endPos - clipinfo.startPos);
if (success) {
item->resizeEnd((int) end.endPos.frames(m_document->fps()));
- updatePositionEffects(item, clipinfo);
+// updatePositionEffects(item, clipinfo);
} else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
}
if (!resizeClipStart && end.cropStart != start.cropStart) {
new MoveTransitionCommand(this, trInfo, newTrInfo, true, command);
}
- /*
- * TODO: cleanup the effect update process
- */
ClipItem *clip = static_cast < ClipItem * >(item);
- updatePositionEffects(clip, oldInfo);
-
- // check keyframes
- QDomDocument doc;
- QDomElement root = doc.createElement("list");
- doc.appendChild(root);
- QList <int> indexes;
- for (int i = 0; i < clip->effectsCount(); i++) {
- QDomElement effect = clip->effectAt(i);
- if (EffectsList::hasKeyFrames(effect)) {
- doc.appendChild(doc.importNode(effect, true));
- indexes.append(i);
- }
- }
-
- 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");
- // Hack:
- // Since we must always resize clip before updating the keyframes, we
- // 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);
- for (int i = 0; i < indexes.count(); i++) {
- new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, command);
- updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
- }
- new ResizeClipCommand(this, oldInfo, info, false, true, command);
- emit clipItemSelected(clip);
- } else {
- new ResizeClipCommand(this, oldInfo, info, false, false, command);
- }
+ // Hack:
+ // Since we must always resize clip before updating the keyframes, we
+ // 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);
+ new ResizeClipCommand(this, oldInfo, info, false, true, command);
+ emit clipItemSelected(clip);
} else {
KdenliveSettings::setSnaptopoints(false);
item->resizeStart((int) oldInfo.startPos.frames(m_document->fps()));
ClipItem *clip = static_cast < ClipItem * >(item);
- updatePositionEffects(clip, oldInfo);
-
- // check keyframes
- QDomDocument doc;
- QDomElement root = doc.createElement("list");
- doc.appendChild(root);
- QList <int> indexes;
- for (int i = 0; i < clip->effectsCount(); i++) {
- QDomElement effect = clip->effectAt(i);
- if (EffectsList::hasKeyFrames(effect)) {
- doc.appendChild(doc.importNode(effect, true));
- indexes.append(i);
- }
- }
-
- if (clip->checkEffectsKeyframesPos((oldInfo.cropStart + oldInfo.endPos - oldInfo.startPos).frames(m_document->fps()) - 1, (clip->cropStart() + clip->cropDuration()).frames(m_document->fps()) - 1, false)) {
- // Keyframes were modified, updateClip
- QDomNodeList effs = doc.elementsByTagName("effect");
- // Hack:
- // Since we must always resize clip before updating the keyframes, we
- // 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);
- for (int i = 0; i < indexes.count(); i++) {
- new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, command);
- updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
- }
- new ResizeClipCommand(this, oldInfo, info, false, true, command);
- emit clipItemSelected(clip);
- } else {
- new ResizeClipCommand(this, oldInfo, info, false, false, command);
- }
+ // Hack:
+ // Since we must always resize clip before updating the keyframes, we
+ // 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);
+ new ResizeClipCommand(this, oldInfo, info, false, true, command);
+ emit clipItemSelected(clip);
} else {
KdenliveSettings::setSnaptopoints(false);
item->resizeEnd((int) oldInfo.endPos.frames(m_document->fps()));
}
}
-void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
+void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool standalone)
{
int end = item->fadeIn();
if (end != 0) {
end += start;
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
- if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
- emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
- // if fade effect is displayed, update the effect edit widget with new clip duration
- if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+ if (standalone) {
+ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
+ emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+ // if fade effect is displayed, update the effect edit widget with new clip duration
+ if (item->isSelected() && effectPos == item->selectedEffectIndex())
+ emit clipItemSelected(item, effectPos);
+ }
}
effectPos = item->hasEffect("brightness", "fade_from_black");
if (effectPos != -1) {
end += start;
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
- if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
- emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
- // if fade effect is displayed, update the effect edit widget with new clip duration
- if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+ if (standalone) {
+ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
+ emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+ // if fade effect is displayed, update the effect edit widget with new clip duration
+ if (item->isSelected() && effectPos == item->selectedEffectIndex())
+ emit clipItemSelected(item, effectPos);
+ }
}
}
+
int start = item->fadeOut();
if (start != 0) {
// there is a fade out effect
start = end - start;
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
- if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
- emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
- // if fade effect is displayed, update the effect edit widget with new clip duration
- if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+ if (standalone) {
+ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
+ emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+ // if fade effect is displayed, update the effect edit widget with new clip duration
+ if (item->isSelected() && effectPos == item->selectedEffectIndex())
+ emit clipItemSelected(item, effectPos);
+ }
}
effectPos = item->hasEffect("brightness", "fade_to_black");
if (effectPos != -1) {
start = end - start;
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
- if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
- emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
- // if fade effect is displayed, update the effect edit widget with new clip duration
- if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+ if (standalone) {
+ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
+ emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+ // if fade effect is displayed, update the effect edit widget with new clip duration
+ if (item->isSelected() && effectPos == item->selectedEffectIndex())
+ emit clipItemSelected(item, effectPos);
+ }
}
}
if (!eff.isNull() && diff != 0) {
int freeze_pos = EffectsList::parameter(eff, "frame").toInt() + diff;
EffectsList::setParameter(eff, "frame", QString::number(freeze_pos));
- if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") {
- emit clipItemSelected(item, item->selectedEffectIndex());
+ if (standalone) {
+ if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") {
+ emit clipItemSelected(item, item->selectedEffectIndex());
+ }
}
}
}
-
- updatePanZoom(item);
}
double CustomTrackView::getSnapPointForPos(double pos)
void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos)
{
QList <int> effects = item->updatePanZoom(m_document->width(), m_document->height(), cutPos.frames(m_document->fps()));
+
for (int i = 0; i < effects.count(); ++i) {
if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(item->effectAt(effects.at(i)))))
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
emit clipItemSelected(item, effects.at(i));*/
}
// update always, otherwise there might problems when resizing groups
- if (effects.count() > 0)
+ if (effects.count())
emit clipItemSelected(item, item->selectedEffectIndex());
}
}
}
}
+
+void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, bool fromStart, QUndoCommand* command)
+{
+ bool update = false;
+
+ QMap<int, QDomElement> effects;
+ for (int i = 0; i < item->effectsCount(); ++i) {
+ QDomElement effect = item->getEffectAt(i);
+ bool nonStdKeyframeUpdate = effect.attribute("id").startsWith("fade") || effect.attribute("id") == "freeze" || EffectsList::hasGeometryKeyFrames(effect);
+ if (nonStdKeyframeUpdate)
+ update = true;
+ if (nonStdKeyframeUpdate || EffectsList::hasKeyFrames(effect) || EffectsList::hasSimpleKeyFrames(effect))
+ effects.insert(i, effect.cloneNode().toElement());
+ }
+
+ if(effects.isEmpty())
+ return;
+
+ if (fromStart)
+ update |= item->checkEffectsKeyframesPos(oldInfo.cropStart.frames(m_document->fps()), item->cropStart().frames(m_document->fps()), true);
+ else
+ update |= item->checkEffectsKeyframesPos((oldInfo.cropStart + oldInfo.endPos - oldInfo.startPos).frames(m_document->fps()) - 1, (item->cropStart() + item->cropDuration()).frames(m_document->fps()) - 1, false);
+
+ update |= item->updatePanZoom(m_document->width(), m_document->height(), 0).count() > 0;
+ updatePositionEffects(item, oldInfo, false);
+
+ if (update) {
+ QMap<int, QDomElement>::const_iterator i = effects.constBegin();
+ while (i != effects.constEnd()) {
+ new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effectAt(i.key()), i.key(), false, command);
+ ++i;
+ }
+ }
+}