EffectsParameterList params = clip->addEffect(effect);
if (!m_document->renderer()->mltAddEffect(track, pos, params))
emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage);
+ clip->setSelectedEffect(params.paramValue("kdenlive_ix").toInt());
if (clip->isSelected()) emit clipItemSelected(clip);
} else emit displayMessage(i18n("Cannot find clip to add effect"), ErrorMessage);
}
if (effect.tagName() == "effectgroup") {
QDomNodeList effectlist = effect.elementsByTagName("effect");
for (int j = 0; j < effectlist.count(); j++) {
- processEffect(item, effectlist.at(j).toElement(), effectCommand);
+ QDomElement subeffect = effectlist.at(j).toElement();
+ if (subeffect.hasAttribute("kdenlive_info")) {
+ // effect is in a group
+ EffectInfo effectInfo;
+ effectInfo.fromString(subeffect.attribute("kdenlive_info"));
+ if (effectInfo.groupIndex < 0) {
+ // group needs to be appended
+ effectInfo.groupIndex = item->nextFreeEffectGroupIndex();
+ subeffect.setAttribute("kdenlive_info", effectInfo.toString());
+ }
+ }
+ processEffect(item, subeffect, effectCommand);
}
}
else {
if (effect.tagName() == "effectgroup") {
QDomNodeList effectlist = effect.elementsByTagName("effect");
for (int j = 0; j < effectlist.count(); j++) {
- processEffect(item, effectlist.at(j).toElement(), effectCommand);
+ QDomElement subeffect = effectlist.at(j).toElement();
+ if (subeffect.hasAttribute("kdenlive_info")) {
+ // effect is in a group
+ EffectInfo effectInfo;
+ effectInfo.fromString(subeffect.attribute("kdenlive_info"));
+ if (effectInfo.groupIndex < 0) {
+ // group needs to be appended
+ effectInfo.groupIndex = item->nextFreeEffectGroupIndex();
+ subeffect.setAttribute("kdenlive_info", effectInfo.toString());
+ }
+ }
+ processEffect(item, subeffect, effectCommand);
}
}
else processEffect(item, effect, effectCommand);
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == AVWIDGET) {
ClipItem *clip = static_cast<ClipItem *>(itemList.at(i));
- clip->setSelectedEffect(clip->effectsCount() - 1);
+ clip->setSelectedEffect(clip->effectsCount());
if (!clip->isSelected()) {
clearSelection(false);
clip->setSelected(true);
- emit clipItemSelected(clip, clip->selectedEffectIndex());
+ emit clipItemSelected(clip);
}
break;
}
}
clip->updateEffect(effect);
if (updateEffectStack && clip->isSelected())
- emit clipItemSelected(clip, ix);
+ emit clipItemSelected(clip);
if (ix == clip->selectedEffectIndex()) {
// make sure to update display of clip keyframes
clip->setSelectedEffect(ix);
if (success) {
clip->updateEffect(effect);
if (updateEffectStack && clip->isSelected()) {
- emit clipItemSelected(clip, ix);
+ emit clipItemSelected(clip);
}
if (ix == clip->selectedEffectIndex()) {
// make sure to update display of clip keyframes
setDocumentModified();
}
-void CustomTrackView::moveEffect(int track, GenTime pos, int oldPos, int newPos)
+void CustomTrackView::moveEffect(int track, GenTime pos, QList <int> oldPos, QList <int> newPos)
{
if (pos < GenTime()) {
// Moving track effect
- if (newPos > m_document->getTrackEffects(m_document->tracksCount() - track - 1).count()) {
- newPos = m_document->getTrackEffects(m_document->tracksCount() - track - 1).count();
+ int documentTrack = m_document->tracksCount() - track - 1;
+ int max = m_document->getTrackEffects(documentTrack).count();
+ int new_position = newPos.at(0);
+ if (new_position > max) {
+ new_position = max;
+ }
+ int old_position = oldPos.at(0);
+ for (int i = 0; i < newPos.count(); i++) {
+ QDomElement act = m_document->getTrackEffect(documentTrack, new_position);
+ if (old_position > new_position) {
+ // Moving up, we need to adjust index
+ old_position = oldPos.at(i);
+ new_position = newPos.at(i);
+ }
+ QDomElement before = m_document->getTrackEffect(documentTrack, old_position);
+ if (!act.isNull() && !before.isNull()) {
+ m_document->setTrackEffect(documentTrack, new_position, before);
+ m_document->renderer()->mltMoveEffect(m_document->tracksCount() - track, pos, old_position, new_position);
+ } else emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
}
- QDomElement act = m_document->getTrackEffect(m_document->tracksCount() - track - 1, newPos);
- QDomElement before = m_document->getTrackEffect(m_document->tracksCount() - track - 1, oldPos);
- if (!act.isNull() && !before.isNull()) {
- //m_document->setTrackEffect(m_document->tracksCount() - track - 1, oldPos, act);
- m_document->setTrackEffect(m_document->tracksCount() - track - 1, newPos, before);
- m_document->renderer()->mltMoveEffect(m_document->tracksCount() - track, pos, oldPos, newPos);
- emit showTrackEffects(m_document->tracksCount() - track, m_document->trackInfoAt(m_document->tracksCount() - track - 1));
- } else emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
+ emit showTrackEffects(m_document->tracksCount() - track, m_document->trackInfoAt(documentTrack));
return;
}
ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), m_document->tracksCount() - track);
- if (newPos > clip->effectsCount()) {
- newPos = clip->effectsCount();
- }
if (clip) {
- QDomElement act = clip->effectAt(newPos);
- QDomElement before = clip->effectAt(oldPos);
- if (act.isNull() || before.isNull()) {
- emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
- return;
+ int new_position = newPos.at(0);
+ if (new_position > clip->effectsCount()) {
+ new_position = clip->effectsCount();
+ }
+ int old_position = oldPos.at(0);
+ for (int i = 0; i < newPos.count(); i++) {
+ QDomElement act = clip->effectAt(new_position);
+ if (old_position > new_position) {
+ // Moving up, we need to adjust index
+ old_position = oldPos.at(i);
+ new_position = newPos.at(i);
+ }
+ QDomElement before = clip->effectAt(old_position);
+ if (act.isNull() || before.isNull()) {
+ emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
+ return;
+ }
+ clip->moveEffect(before, new_position);
+ // special case: speed effect, which is a pseudo-effect, not appearing in MLT's effects
+ if (act.attribute("id") == "speed") {
+ m_document->renderer()->mltUpdateEffectPosition(track, pos, old_position, new_position);
+ } else if (before.attribute("id") == "speed") {
+ m_document->renderer()->mltUpdateEffectPosition(track, pos, new_position, old_position);
+ } else m_document->renderer()->mltMoveEffect(track, pos, old_position, new_position);
}
- //clip->moveEffect(act, oldPos);
- clip->moveEffect(before, newPos);
- // special case: speed effect, which is a pseudo-effect, not appearing in MLT's effects
- if (act.attribute("id") == "speed") {
- m_document->renderer()->mltUpdateEffectPosition(track, pos, oldPos, newPos);
- } else if (before.attribute("id") == "speed") {
- m_document->renderer()->mltUpdateEffectPosition(track, pos, newPos, oldPos);
- } else m_document->renderer()->mltMoveEffect(track, pos, oldPos, newPos);
- emit clipItemSelected(clip, newPos);
+ clip->setSelectedEffect(newPos.at(0));
+ emit clipItemSelected(clip);
setDocumentModified();
} else emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
}
setDocumentModified();;
}
-void CustomTrackView::slotChangeEffectPosition(ClipItem *clip, int track, int currentPos, int newPos)
+void CustomTrackView::slotChangeEffectPosition(ClipItem *clip, int track, QList <int> currentPos, int newPos)
{
MoveEffectCommand *command;
if (clip == NULL) {
groupSelectedItems(true);
} else if (items.count() == 1) {
m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
- emit clipItemSelected((ClipItem*)m_dragItem, -1, false);
+ emit clipItemSelected((ClipItem*)m_dragItem, false);
}
event->setDropAction(Qt::MoveAction);
event->accept();
void CustomTrackView::addTrack(TrackInfo type, int ix)
{
+ QList <TransitionInfo> transitionInfos;
if (ix == -1 || ix == m_document->tracksCount()) {
m_document->insertTrack(0, type);
- m_document->renderer()->mltInsertTrack(1, type.type == VIDEOTRACK);
+ transitionInfos = m_document->renderer()->mltInsertTrack(1, type.type == VIDEOTRACK);
} else {
m_document->insertTrack(m_document->tracksCount() - ix, type);
// insert track in MLT playlist
- m_document->renderer()->mltInsertTrack(m_document->tracksCount() - ix, type.type == VIDEOTRACK);
+ transitionInfos = m_document->renderer()->mltInsertTrack(m_document->tracksCount() - ix, type.type == VIDEOTRACK);
double startY = ix * m_tracksHeight + 1 + m_tracksHeight / 2;
QRectF r(0, startY, sceneRect().width(), sceneRect().height() - startY);
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", clipinfo.startPos.frames(m_document->fps()), clipinfo.track), ErrorMessage);
}
}
- } else if (item->type() == TRANSITIONWIDGET) {
+ } /*else if (item->type() == TRANSITIONWIDGET) {
Transition *tr = static_cast <Transition *>(item);
int track = tr->transitionEndTrack();
if (track >= ix) {
tr->updateTransitionEndTrack(getPreviousVideoTrack(clipinfo.track));
}
- }
- }
+ }*/
+ }
+ // Sync transition tracks with MLT playlist
+ Transition *tr;
+ TransitionInfo info;
+ for (int i = 0; i < transitionInfos.count(); i++) {
+ info = transitionInfos.at(i);
+ tr = getTransitionItem(info);
+ if (tr) tr->setForcedTrack(info.forceTrack, info.a_track);
+ else kDebug()<<"// Cannot update TRANSITION AT: "<<info.b_track<<" / "<<info.startPos.frames(m_document->fps());
+ }
+
resetSelectionGroup(false);
m_document->renderer()->unlockService(tractor);
}
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
slotUpdateClipEffect(item, -1, effect, oldeffect, ix);
- emit clipItemSelected(item, ix);
+ emit clipItemSelected(item);
}
} else if (item->fadeIn() != 0 && ix2 == -1) {
QDomElement effect;
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
slotUpdateClipEffect(item, -1, effect, oldeffect, ix2);
- emit clipItemSelected(item, ix2);
+ emit clipItemSelected(item);
}
}
} else if (m_operationMode == FADEOUT) {
EffectsList::setParameter(oldeffect, "out", QString::number(end));
// kDebug()<<"EDIT FADE OUT : "<<start<<"x"<<end;
slotUpdateClipEffect(item, -1, effect, oldeffect, ix);
- emit clipItemSelected(item, ix);
+ emit clipItemSelected(item);
}
} else if (item->fadeOut() != 0 && ix2 == -1) {
QDomElement effect;
EffectsList::setParameter(oldeffect, "out", QString::number(end));
// kDebug()<<"EDIT FADE OUT : "<<start<<"x"<<end;
slotUpdateClipEffect(item, -1, effect, oldeffect, ix2);
- emit clipItemSelected(item, ix2);
+ emit clipItemSelected(item);
}
}
} else if (m_operationMode == KEYFRAME) {
m_commandStack->push(command);
updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect(), item->selectedEffectIndex());
- emit clipItemSelected(item, item->selectedEffectIndex());
+ emit clipItemSelected(item);
}
if (m_dragItem && m_dragItem->type() == TRANSITIONWIDGET && m_dragItem->isSelected()) {
// A transition is selected
return getClipItemAt((int) pos.frames(m_document->fps()), track);
}
+
+Transition *CustomTrackView::getTransitionItem(TransitionInfo info)
+{
+ int pos = info.startPos.frames(m_document->fps());
+ int track = m_document->tracksCount() - info.b_track;
+ return getTransitionItemAt(pos, track);
+}
+
Transition *CustomTrackView::getTransitionItemAt(int pos, int track)
{
const QPointF p(pos, track * m_tracksHeight + Transition::itemOffset() + 1);
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);
+ emit clipItemSelected(item);
}
}
effectPos = item->hasEffect("brightness", "fade_from_black");
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);
+ emit clipItemSelected(item);
}
}
}
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);
+ emit clipItemSelected(item);
}
}
effectPos = item->hasEffect("brightness", "fade_to_black");
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);
+ emit clipItemSelected(item);
}
}
}
EffectsList::setParameter(eff, "frame", QString::number(freeze_pos));
if (standalone) {
if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") {
- emit clipItemSelected(item, item->selectedEffectIndex());
+ emit clipItemSelected(item);
}
}
}
EffectsParameterList parameters;
QLocale locale;
parameters.addParam("tag", effect.attribute("tag"));
- if (effect.hasAttribute("region")) parameters.addParam("region", effect.attribute("region"));
+ //if (effect.hasAttribute("region")) parameters.addParam("region", effect.attribute("region"));
parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
parameters.addParam("kdenlive_info", effect.attribute("kdenlive_info"));
parameters.addParam("id", effect.attribute("id"));
if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
if (effect.hasAttribute("in")) parameters.addParam("in", effect.attribute("in"));
if (effect.hasAttribute("out")) parameters.addParam("out", effect.attribute("out"));
+ if (effect.attribute("id") == "region") {
+ QDomNodeList subeffects = effect.elementsByTagName("effect");
+ for (int i = 0; i < subeffects.count(); i++) {
+ QDomElement subeffect = subeffects.at(i).toElement();
+ int subeffectix = subeffect.attribute("region_ix").toInt();
+ parameters.addParam(QString("filter%1").arg(subeffectix), subeffect.attribute("id"));
+ parameters.addParam(QString("filter%1.tag").arg(subeffectix), subeffect.attribute("tag"));
+ parameters.addParam(QString("filter%1.kdenlive_info").arg(subeffectix), subeffect.attribute("kdenlive_info"));
+ QDomNodeList subparams = subeffect.elementsByTagName("parameter");
+ adjustEffectParameters(parameters, subparams, QString("filter%1.").arg(subeffectix));
+ }
+ }
QDomNodeList params = effect.elementsByTagName("parameter");
- for (int i = 0; i < params.count(); i++) {
+ adjustEffectParameters(parameters, params);
+
+ return parameters;
+}
+
+
+void CustomTrackView::adjustEffectParameters(EffectsParameterList ¶meters, QDomNodeList params, const QString &prefix)
+{
+ QLocale locale;
+ for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
+ QString paramname = prefix + e.attribute("name");
if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
// effects with geometry param need in / out synced with the clip, request it...
parameters.addParam("_sync_in_out", "1");
}
if (e.attribute("type") == "simplekeyframe") {
-
QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
double factor = e.attribute("factor", "1").toDouble();
double offset = e.attribute("offset", "0").toDouble();
values[j] = pos + "=" + locale.toString(val);
}
// kDebug() << "/ / / /SENDING KEYFR:" << values;
- parameters.addParam(e.attribute("name"), values.join(";"));
+ parameters.addParam(paramname, values.join(";"));
/*parameters.addParam(e.attribute("name"), e.attribute("keyframes").replace(":", "="));
parameters.addParam("max", e.attribute("max"));
parameters.addParam("min", e.attribute("min"));
fact = e.attribute("factor", "1").toDouble();
}
double offset = e.attribute("offset", "0").toDouble();
- parameters.addParam(e.attribute("name"), locale.toString((e.attribute("value").toDouble() - offset) / fact));
+ parameters.addParam(paramname, locale.toString((e.attribute("value").toDouble() - offset) / fact));
} else {
- parameters.addParam(e.attribute("name"), e.attribute("value"));
+ parameters.addParam(paramname, e.attribute("value"));
}
}
}
- return parameters;
}
+
void CustomTrackView::updateTrackNames(int track, bool added)
{
QList <TrackInfo> tracks = m_document->tracksList();
}
EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, newEffect, clip->selectedEffectIndex(), true, true);
m_commandStack->push(command);
- emit clipItemSelected(clip, clip->selectedEffectIndex());
+ emit clipItemSelected(clip);
}
}