hasParentCommand = true;
} else {
command = new QUndoCommand();
- command->setText(i18n("Resize clip end"));
}
// do this here, too, because otherwise undo won't update the group
ItemInfo info = item->info();
if (item->type() == AVWIDGET) {
+ if (!hasParentCommand) command->setText(i18n("Resize clip end"));
ItemInfo resizeinfo = info;
resizeinfo.track = m_document->tracksCount() - resizeinfo.track;
bool success = m_document->renderer()->mltResizeClipEnd(resizeinfo, resizeinfo.cropDuration);
emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
}
} else if (item->type() == TRANSITIONWIDGET) {
+ if (!hasParentCommand) command->setText(i18n("Resize transition end"));
Transition *transition = static_cast <Transition *>(item);
if (!m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_document->tracksCount() - oldInfo.track), (int)(m_document->tracksCount() - oldInfo.track), transition->transitionEndTrack(), oldInfo.startPos, oldInfo.endPos, info.startPos, info.endPos)) {
// Cannot resize transition
KdenliveSettings::setSnaptopoints(true);
emit displayMessage(i18n("Cannot resize transition"), ErrorMessage);
} else {
- MoveTransitionCommand *moveCommand = new MoveTransitionCommand(this, oldInfo, info, false, command);
- if (command == NULL)
- m_commandStack->push(moveCommand);
+ // Check transition keyframes
+ QDomElement old = transition->toXML();
+ if (transition->updateKeyframes()) {
+ QDomElement xml = transition->toXML();
+ m_document->renderer()->mltUpdateTransition(xml.attribute("tag"), xml.attribute("tag"), xml.attribute("transition_btrack").toInt(), m_document->tracksCount() - xml.attribute("transition_atrack").toInt(), transition->startPos(), transition->endPos(), xml);
+ new EditTransitionCommand(this, transition->track(), transition->startPos(), old, xml, false, command);
+ }
+ new MoveTransitionCommand(this, oldInfo, info, false, command);
}
}
if (item->parentItem() && item->parentItem() != m_selectionGroup)
return 3;
}
+bool Transition::updateKeyframes()
+{
+ QString keyframes;
+ QDomElement pa;
+ bool modified = false;
+ QDomNodeList namenode = m_parameters.elementsByTagName("parameter");
+ for (int i = 0; i < namenode.count() ; i++) {
+ pa = namenode.item(i).toElement();
+ if (pa.attribute("type") == "geometry") {
+ keyframes = pa.attribute("value");
+ break;
+ }
+ }
+ if (keyframes.isEmpty()) return false;
+ int duration = cropDuration().frames(m_fps) - 1;
+ QStringList values = keyframes.split(";");
+ int frame;
+ int i = 0;
+ foreach(const QString &pos, values) {
+ if (!pos.contains('=')) {
+ i++;
+ continue;
+ }
+ frame = pos.section('=', 0, 0).toInt();
+ if (frame > duration) {
+ modified = true;
+ break;
+ }
+ i++;
+ }
+ if (modified) {
+ if (i > 0) {
+ // Check if there is a keyframe at transition end
+ QString prev = values.at(i-1);
+ bool done = false;
+ if (prev.contains('=')) {
+ int previousKeyframe = prev.section('=', 0, 0).toInt();
+ if (previousKeyframe == duration) {
+ // Remove the last keyframes
+ while (values.count() > i) {
+ values.removeLast();
+ }
+ done = true;
+ }
+ }
+ if (!done) {
+ // Add new keyframe at end and remove last keyframes
+ QString last = values.at(i);
+ last = QString::number(duration) + '=' + last.section('=', 1);
+ values[i] = last;
+ while (values.count() > (i + 1)) {
+ values.removeLast();
+ }
+ }
+ }
+ pa.setAttribute("value", values.join(";"));
+ }
+
+ return true;
+}
+