m_commandStack->push(command);
} else {
// move and resize clip
+ ClipItem *clip = static_cast<ClipItem *>(item);
QUndoCommand *moveCommand = new QUndoCommand();
moveCommand->setText(i18n("Edit clip"));
if (d.duration() < item->cropDuration() || d.cropStart() != clipInfo.cropStart) {
// duration was reduced, so process it first
clipInfo.endPos = clipInfo.startPos + d.duration();
clipInfo.cropStart = d.cropStart();
- new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
+
+ resizeClip(startInfo, clipInfo);
+ new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
+ adjustEffects(clip, startInfo, moveCommand);
+ new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
}
+
if (d.startPos() != clipInfo.startPos) {
startInfo = clipInfo;
clipInfo.startPos = d.startPos();
clipInfo.endPos = item->endPos() + (clipInfo.startPos - startInfo.startPos);
new MoveClipCommand(this, startInfo, clipInfo, true, moveCommand);
}
+
if (d.duration() > item->cropDuration()) {
// duration was increased, so process it after move
startInfo = clipInfo;
clipInfo.endPos = clipInfo.startPos + d.duration();
clipInfo.cropStart = d.cropStart();
- new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
+
+ resizeClip(startInfo, clipInfo);
+ new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
+ adjustEffects(clip, startInfo, moveCommand);
+ new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
}
updateTrackDuration(clipInfo.track, moveCommand);
m_commandStack->push(moveCommand);
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();
}
groupSelectedItems(true);
} else if (items.count() == 1) {
m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
- emit clipItemSelected((ClipItem*)m_dragItem);
+ emit clipItemSelected((ClipItem*)m_dragItem, -1, false);
}
event->setDropAction(Qt::MoveAction);
event->accept();
void CustomTrackView::doChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, const double speed, const double oldspeed, int strobe, const QString &id)
{
- Q_UNUSED(id);
+ Q_UNUSED(id)
//DocClipBase *baseclip = m_document->clipManager()->getClipById(id);
ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
ItemInfo clipinfo = item->info();
clipinfo.track = m_document->tracksCount() - clipinfo.track;
bool success = m_document->renderer()->mltResizeClipStart(clipinfo, end.startPos - clipinfo.startPos);
- if (success) {
- kDebug() << "RESIZE CLP STRAT TO:" << end.startPos.frames(m_document->fps()) << ", OLD ST: " << start.startPos.frames(25);
+ if (success)
item->resizeStart((int) end.startPos.frames(m_document->fps()));
- updatePositionEffects(item, clipinfo);
- } else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
+ else
+ emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
} else {
ItemInfo clipinfo = item->info();
clipinfo.track = m_document->tracksCount() - clipinfo.track;
bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, end.endPos - clipinfo.startPos);
- if (success) {
+ if (success)
item->resizeEnd((int) end.endPos.frames(m_document->fps()));
- updatePositionEffects(item, clipinfo);
- } else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
+ else
+ emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
}
if (!resizeClipStart && end.cropStart != start.cropStart) {
kDebug() << "// RESIZE CROP, DIFF: " << (end.cropStart - start.cropStart).frames(25);
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, 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, 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) {
// there is a fade in effect
int effectPos = item->hasEffect("volume", "fadein");
if (effectPos != -1) {
- QDomElement oldeffect = item->effectAt(effectPos);
+ QDomElement effect = item->getEffectAt(effectPos);
int start = item->cropStart().frames(m_document->fps());
int max = item->cropDuration().frames(m_document->fps());
if (end > max) {
end = item->fadeIn();
}
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);
+ EffectsList::setParameter(effect, "in", QString::number(start));
+ EffectsList::setParameter(effect, "out", QString::number(end));
+ if (standalone) {
+ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+ 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) {
- QDomElement oldeffect = item->effectAt(effectPos);
+ QDomElement effect = item->getEffectAt(effectPos);
int start = item->cropStart().frames(m_document->fps());
int max = item->cropDuration().frames(m_document->fps());
if (end > max) {
end = item->fadeIn();
}
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);
+ EffectsList::setParameter(effect, "in", QString::number(start));
+ EffectsList::setParameter(effect, "out", QString::number(end));
+ if (standalone) {
+ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+ 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
int effectPos = item->hasEffect("volume", "fadeout");
if (effectPos != -1) {
- QDomElement oldeffect = item->effectAt(effectPos);
+ QDomElement effect = item->getEffectAt(effectPos);
int max = item->cropDuration().frames(m_document->fps());
int end = max + item->cropStart().frames(m_document->fps());
if (start > max) {
start = item->fadeOut();
}
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);
+ EffectsList::setParameter(effect, "in", QString::number(start));
+ EffectsList::setParameter(effect, "out", QString::number(end));
+ if (standalone) {
+ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+ 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) {
- QDomElement oldeffect = item->effectAt(effectPos);
+ QDomElement effect = item->getEffectAt(effectPos);
int max = item->cropDuration().frames(m_document->fps());
int end = max + item->cropStart().frames(m_document->fps());
if (start > max) {
start = item->fadeOut();
}
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);
+ EffectsList::setParameter(effect, "in", QString::number(start));
+ EffectsList::setParameter(effect, "out", QString::number(end));
+ if (standalone) {
+ if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+ 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)
if (itemList.at(i)->type() == TRANSITIONWIDGET) {
transitionitem = static_cast <Transition*>(itemList.at(i));
transitionXml = transitionitem->toXML();
+ // luma files in transitions can be in "resource" or "luma" property
QString luma = EffectsList::parameter(transitionXml, "luma");
- if (!luma.isEmpty()) urls << luma;
+ if (luma.isEmpty()) luma = EffectsList::parameter(transitionXml, "resource");
+ if (!luma.isEmpty()) urls << KUrl(luma).path();
}
}
+#if QT_VERSION >= 0x040500
+ urls.removeDuplicates();
+#endif
return urls;
}
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::updateTrackDuration(int track, QUndoCommand *command)
{
- Q_UNUSED(command);
+ Q_UNUSED(command)
QList<int> tracks;
if (track >= 0) {
}
}
}
+
+void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoCommand* command)
+{
+ QMap<int, QDomElement> effects = item->adjustEffectsToDuration(m_document->width(), m_document->height(), oldInfo);
+
+ if (effects.count()) {
+ 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;
+ }
+ }
+}