m_commandStack = doc->commandStack();
else
m_commandStack = NULL;
-
+ m_ct = 0;
setMouseTracking(true);
setAcceptDrops(true);
setFrameShape(QFrame::NoFrame);
m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
- pixmapCache = new KPixmapCache("kdenlive-thumbs");
-
m_animationTimer = new QTimeLine(800);
m_animationTimer->setFrameRange(0, 5);
m_animationTimer->setUpdateInterval(100);
qDeleteAll(m_guides);
m_guides.clear();
m_waitingThumbs.clear();
+ delete m_animationTimer;
}
//virtual
return m_scene->m_tracksList;
}*/
-void CustomTrackView::checkTrackHeight()
+
+int CustomTrackView::getFrameWidth()
+{
+ return (int) (m_tracksHeight * m_document->mltProfile().display_aspect_num / m_document->mltProfile().display_aspect_den + 0.5);
+}
+
+void CustomTrackView::updateSceneFrameWidth()
+{
+ int frameWidth = getFrameWidth();
+ QList<QGraphicsItem *> itemList = items();
+ ClipItem *item;
+ for (int i = 0; i < itemList.count(); i++) {
+ if (itemList.at(i)->type() == AVWIDGET) {
+ item = (ClipItem*) itemList.at(i);
+ item->resetFrameWidth(frameWidth);
+ item->resetThumbs(true);
+ }
+ }
+}
+
+bool CustomTrackView::checkTrackHeight()
{
- if (m_tracksHeight == KdenliveSettings::trackheight()) return;
+ if (m_tracksHeight == KdenliveSettings::trackheight()) return false;
m_tracksHeight = KdenliveSettings::trackheight();
emit trackHeightChanged();
QList<QGraphicsItem *> itemList = items();
ClipItem *item;
Transition *transitionitem;
+ int frameWidth = getFrameWidth();
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
for (int i = 0; i < itemList.count(); i++) {
item = (ClipItem*) itemList.at(i);
item->setRect(0, 0, item->rect().width(), m_tracksHeight - 1);
item->setPos((qreal) item->startPos().frames(m_document->fps()), (qreal) item->track() * m_tracksHeight + 1);
+ item->resetFrameWidth(frameWidth);
item->resetThumbs(true);
} else if (itemList.at(i)->type() == TRANSITIONWIDGET) {
transitionitem = (Transition*) itemList.at(i);
// verticalScrollBar()->setMaximum(m_tracksHeight * m_document->tracksCount());
KdenliveSettings::setSnaptopoints(snap);
viewport()->update();
+ return true;
}
/** Zoom or move viewport on mousewheel
{
if (!m_waitingThumbs.isEmpty()) {
ClipItem *item = m_waitingThumbs.takeFirst();
- while ((item == NULL) && !m_waitingThumbs.isEmpty()) {
+ while (item == NULL && !m_waitingThumbs.isEmpty()) {
item = m_waitingThumbs.takeFirst();
}
if (item) item->slotFetchThumbs();
{
int pos = event->x();
int mappedXPos = qMax((int)(mapToScene(event->pos()).x() + 0.5), 0);
+
double snappedPos = getSnapPointForPos(mappedXPos);
emit mousePosition(mappedXPos);
event->accept();
return;
}
- opMode = clip->operationMode(mapToScene(event->pos()));
+
+ if (m_selectionGroup && clip->parentItem() == m_selectionGroup) {
+ // all other modes break the selection, so the user probably wants to move it
+ opMode = MOVE;
+ } else {
+ opMode = clip->operationMode(mapToScene(event->pos()));
+ }
+
const double size = 5;
if (opMode == m_moveOpMode) {
QGraphicsView::mouseMoveEvent(event);
}
m_moveOpMode = opMode;
setTipAnimation(clip, opMode, size);
+ ClipItem *ci = NULL;
+ if (item->type() == AVWIDGET)
+ ci = static_cast <ClipItem *>(item);
+ QString message;
if (opMode == MOVE) {
setCursor(Qt::OpenHandCursor);
- if (item->type() == AVWIDGET) {
- ClipItem *ci = static_cast <ClipItem *>(item);
- QString message = ci->clipName() + i18n(":");
+ if (ci) {
+ message = ci->clipName() + i18n(":");
message.append(i18n(" Position:") + m_document->timecode().getDisplayTimecode(ci->info().startPos, KdenliveSettings::frametimecode()));
message.append(i18n(" Duration:") + m_document->timecode().getDisplayTimecode(ci->cropDuration(), KdenliveSettings::frametimecode()));
if (clip->parentItem() && clip->parentItem()->type() == GROUPWIDGET) {
message.append(i18n(" Selection duration:") + m_document->timecode().getDisplayTimecode(parent2->duration(), KdenliveSettings::frametimecode()));
}
}
- emit displayMessage(message, InformationMessage);
}
} else if (opMode == RESIZESTART) {
setCursor(KCursor("left_side", Qt::SizeHorCursor));
+ if (ci)
+ message = i18n("Crop from start: ") + m_document->timecode().getDisplayTimecode(ci->cropStart(), KdenliveSettings::frametimecode());
if (item->type() == AVWIDGET && item->parentItem() && item->parentItem() != m_selectionGroup)
- emit displayMessage(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."), InformationMessage);
+ message.append(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."));
} else if (opMode == RESIZEEND) {
setCursor(KCursor("right_side", Qt::SizeHorCursor));
+ if (ci)
+ message = i18n("Duration: ") + m_document->timecode().getDisplayTimecode(ci->cropDuration(), KdenliveSettings::frametimecode());
if (item->type() == AVWIDGET && item->parentItem() && item->parentItem() != m_selectionGroup)
- emit displayMessage(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."), InformationMessage);
+ message.append(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."));
} else if (opMode == FADEIN || opMode == FADEOUT) {
setCursor(Qt::PointingHandCursor);
- emit displayMessage(i18n("Drag to add or resize a fade effect."), InformationMessage);
+ if (ci && opMode == FADEIN && ci->fadeIn()) {
+ message = i18n("Fade in duration: ");
+ message.append(m_document->timecode().getDisplayTimecodeFromFrames(ci->fadeIn(), KdenliveSettings::frametimecode()));
+ } else if (ci && opMode == FADEOUT && ci->fadeOut()) {
+ message = i18n("Fade out duration: ");
+ message.append(m_document->timecode().getDisplayTimecodeFromFrames(ci->fadeOut(), KdenliveSettings::frametimecode()));
+ } else {
+ message = i18n("Drag to add or resize a fade effect.");
+ }
} else if (opMode == TRANSITIONSTART || opMode == TRANSITIONEND) {
setCursor(Qt::PointingHandCursor);
- emit displayMessage(i18n("Click to add a transition."), InformationMessage);
+ message = i18n("Click to add a transition.");
} else if (opMode == KEYFRAME) {
setCursor(Qt::PointingHandCursor);
emit displayMessage(i18n("Move keyframe above or below clip to remove it, double click to add a new one."), InformationMessage);
}
+
+ if (!message.isEmpty())
+ emit displayMessage(message, InformationMessage);
} // no clip under mouse
else if (m_tool == RAZORTOOL) {
event->accept();
m_blockRefresh = true;
m_dragGuide = NULL;
- bool collision = false;
if (m_tool != RAZORTOOL) activateMonitor();
else if (m_document->renderer()->playSpeed() != 0.0) {
// check item under mouse
QList<QGraphicsItem *> collisionList = items(m_clickEvent);
-
if (event->modifiers() == Qt::ControlModifier && m_tool != SPACERTOOL && collisionList.count() == 0) {
// Pressing Ctrl + left mouse button in an empty area scrolls the timeline
setDragMode(QGraphicsView::ScrollHandDrag);
m_dragGuide = (Guide *) collisionList.at(i);
if (event->button() == Qt::LeftButton) { // move it
m_dragGuide->setFlag(QGraphicsItem::ItemIsMovable, true);
- collision = true;
m_operationMode = MOVEGUIDE;
// deselect all clips so that only the guide will move
m_scene->clearSelection();
} else {
setCursorPos((int)(mapToScene(event->x(), 0).x()));
}
- QGraphicsView::mousePressEvent(event);
+ //QGraphicsView::mousePressEvent(event);
+ event->ignore();
return;
}
if (event->modifiers() != Qt::ControlModifier && m_operationMode == NONE) QGraphicsView::mousePressEvent(event);
m_clickPoint = QPoint((int)(mapToScene(event->pos()).x() - m_dragItem->startPos().frames(m_document->fps())), (int)(event->pos().y() - m_dragItem->pos().y()));
- m_operationMode = m_dragItem->operationMode(mapToScene(event->pos()));
+ if (m_selectionGroup && m_dragItem->parentItem() == m_selectionGroup) {
+ // all other modes break the selection, so the user probably wants to move it
+ m_operationMode = MOVE;
+ } else {
+ m_operationMode = m_dragItem->operationMode(mapToScene(event->pos()));
+ }
m_controlModifier = (event->modifiers() == Qt::ControlModifier);
// Update snap points
children.at(i)->setSelected(selectItems);
}
}
+
m_selectionGroup = NULL;
KdenliveSettings::setSnaptopoints(snap);
}
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);
}
}
-void CustomTrackView::editKeyFrame(const GenTime /*pos*/, const int /*track*/, const int /*index*/, const QString /*keyframes*/)
+void CustomTrackView::editKeyFrame(const GenTime & /*pos*/, const int /*track*/, const int /*index*/, const QString & /*keyframes*/)
{
/*ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track);
if (clip) {
splitAudio();
}
-bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
+bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint &pos)
{
if (data->hasFormat("kdenlive/clip")) {
m_clipDrag = true;
kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << list.at(0);
return false;
}
- if (clip->producer() == NULL) {
+ if (clip->getProducer() == NULL) {
emit displayMessage(i18n("Clip not ready"), ErrorMessage);
return false;
}
return true;
}
m_selectionGroup = new AbstractGroupItem(m_document->fps());
- ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1);
+ ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, getFrameWidth());
m_selectionGroup->addToGroup(item);
item->setFlag(QGraphicsItem::ItemIsMovable, false);
kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << ids.at(i);
return false;
}
- if (clip->producer() == NULL) {
+ if (clip->getProducer() == NULL) {
emit displayMessage(i18n("Clip not ready"), ErrorMessage);
return false;
}
info.track = 0;
start += info.cropDuration;
offsetList.append(start);
- ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, false);
+ ClipItem *item = new ClipItem(clip, info, m_document->fps(), 1.0, 1, getFrameWidth(), false);
item->setFlag(QGraphicsItem::ItemIsMovable, false);
m_selectionGroup->addToGroup(item);
if (!clip->isPlaceHolder()) m_waitingThumbs.append(item);
{
int track = m_document->tracksCount() - clip->track();
GenTime pos = clip->startPos();
- if (!m_document->renderer()->mltRemoveEffect(track, pos, "-1", false, false)) {
+ if (!m_document->renderer()->mltRemoveEffect(track, pos, -1, false, false)) {
emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
return;
}
{
if (pos < GenTime()) {
// Add track effect
+ if (effect.attribute("id") == "speed") {
+ // TODO: uncomment after 0.8.2 release
+ // emit displayMessage(i18n("Cannot add speed effect to track"));
+ return;
+ }
clearSelection();
m_document->addTrackEffect(track - 1, effect);
m_document->renderer()->mltAddTrackEffect(track, getEffectArgs(effect));
emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage);
return;
}
- double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
+ QLocale locale;
+ double speed = locale.toDouble(EffectsList::parameter(effect, "speed")) / 100.0;
int strobe = EffectsList::parameter(effect, "strobe").toInt();
if (strobe == 0) strobe = 1;
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, 1.0, strobe, clip->baseClip()->getId());
QString index = effect.attribute("kdenlive_ix");
if (pos < GenTime()) {
// Delete track effect
- if (m_document->renderer()->mltRemoveTrackEffect(track, index, true)) {
+ if (m_document->renderer()->mltRemoveTrackEffect(track, index.toInt(), true)) {
m_document->removeTrackEffect(track - 1, effect);
}
else emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
clip->deleteEffect(index);
emit clipItemSelected(clip);
- m_document->renderer()->mltRemoveEffect(track, pos, index, true);
+ m_document->renderer()->mltRemoveEffect(track, pos, index.toInt(), true);
return;
}
}
- if (!m_document->renderer()->mltRemoveEffect(track, pos, index, true)) {
+ if (!m_document->renderer()->mltRemoveEffect(track, pos, index.toInt(), true)) {
kDebug() << "// ERROR REMOV EFFECT: " << index << ", DISABLE: " << effect.attribute("disable");
emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
return;
QList<QGraphicsItem *> itemList = group->childItems();
QUndoCommand *effectCommand = new QUndoCommand();
QString effectName;
- QDomNode namenode = effect.elementsByTagName("name").item(0);
- if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
+ QDomElement namenode = effect.firstChildElement("name");
+ if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data());
else effectName = i18n("effect");
effectCommand->setText(i18n("Add %1", effectName));
int count = 0;
continue;
}
item->initEffect(effect);
- if (effect.attribute("tag") == "ladspa") {
- QString ladpsaFile = m_document->getLadspaFile();
- initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
- effect.setAttribute("src", ladpsaFile);
- }
+
new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
count++;
}
QList<QGraphicsItem *> itemList;
QUndoCommand *effectCommand = new QUndoCommand();
QString effectName;
- QDomNode namenode = effect.elementsByTagName("name").item(0);
- if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
+ QDomElement namenode = effect.firstChildElement("name");
+ if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data());
else effectName = i18n("effect");
effectCommand->setText(i18n("Add %1", effectName));
} else {
item->initEffect(effect);
}
-
- if (effect.attribute("tag") == "ladspa") {
- QString ladpsaFile = m_document->getLadspaFile();
- initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
- effect.setAttribute("src", ladpsaFile);
- }
new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
}
}
QList<QGraphicsItem *> items = m_selectionGroup->childItems();
QUndoCommand *delCommand = new QUndoCommand();
QString effectName;
- QDomNode namenode = effect.elementsByTagName("name").item(0);
- if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
+ QDomElement namenode = effect.firstChildElement("name");
+ if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data());
else effectName = i18n("effect");
delCommand->setText(i18n("Delete %1", effectName));
if (pos < GenTime()) {
// editing a track effect
EffectsParameterList effectParams = getEffectArgs(effect);
- if (effect.attribute("tag") == "ladspa") {
- // Update the ladspa affect file
- 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 {
- double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
+ if (effect.attribute("disable") == "1") {
+ doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
+ } else {
+ QLocale locale;
+ double speed = locale.toDouble(EffectsList::parameter(effect, "speed")) / 100.0;
int strobe = EffectsList::parameter(effect, "strobe").toInt();
if (strobe == 0) strobe = 1;
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, clip->speed(), strobe, clip->baseClip()->getId());
clip->setEffectAt(ix, effect);
if (ix == clip->selectedEffectIndex()) {
clip->setSelectedEffect(ix);
- if (!triggeredByUser) emit clipItemSelected(clip, ix);
+ if (!triggeredByUser)
+ emit clipItemSelected(clip, ix);
}
return;
}
EffectsParameterList effectParams = getEffectArgs(effect);
- if (effect.attribute("tag") == "ladspa") {
- // Update the ladspa affect file
- 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);
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();
}
return NULL;
}
- kDebug() << "///////// CUTTING CLIP : (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), INFO: (" << info.startPos.frames(25) << "-" << info.endPos.frames(25) << ")" << ", CUT: " << cutTime.frames(25);
-
if (execute) m_document->renderer()->mltCutClip(m_document->tracksCount() - info.track, cutTime);
int cutPos = (int) cutTime.frames(m_document->fps());
ItemInfo newPos;
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
ClipItem *dup = item->clone(newPos);
- // remove unwanted effects (fade in) from 2nd part of cutted clip
+
+ // remove unwanted effects
+ // fade in from 2nd part of the clip
int ix = dup->hasEffect(QString(), "fadein");
if (ix != -1) {
- QDomElement oldeffect = item->effectAt(ix);
+ QDomElement oldeffect = dup->effectAt(ix);
dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
}
ix = dup->hasEffect(QString(), "fade_from_black");
if (ix != -1) {
- QDomElement oldeffect = item->effectAt(ix);
+ QDomElement oldeffect = dup->effectAt(ix);
dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
}
+ // fade out from 1st part of the clip
+ ix = item->hasEffect(QString(), "fadeout");
+ if (ix != -1) {
+ QDomElement oldeffect = item->effectAt(ix);
+ item->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+ }
+ ix = item->hasEffect(QString(), "fade_to_black");
+ if (ix != -1) {
+ QDomElement oldeffect = item->effectAt(ix);
+ item->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+ }
+
+
item->resizeEnd(cutPos);
scene()->addItem(dup);
if (item->checkKeyFrames())
if (dup->checkKeyFrames())
slotRefreshEffects(dup);
- updatePanZoom(item);
- updatePanZoom(dup, cutTime - item->startPos());
-
item->baseClip()->addReference();
m_document->updateClip(item->baseClip()->getId());
setDocumentModified();
KdenliveSettings::setSnaptopoints(snap);
+ if (execute && item->isSelected())
+ emit clipItemSelected(item);
return dup;
- //kDebug() << "///////// CUTTING CLIP RESULT: (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), DUP: (" << dup->startPos().frames(25) << "-" << dup->endPos().frames(25) << ")" << ", CUT: " << cutTime.frames(25);
} else {
// uncut clip
return NULL;
}
- /*kDebug() << "// UNCUTTING CLIPS: ITEM 1 (" << item->startPos().frames(25) << "x" << item->endPos().frames(25) << ")";
- kDebug() << "// UNCUTTING CLIPS: ITEM 2 (" << dup->startPos().frames(25) << "x" << dup->endPos().frames(25) << ")";
- kDebug() << "// UNCUTTING CLIPS, INFO (" << info.startPos.frames(25) << "x" << info.endPos.frames(25) << ") , CUT: " << cutTime.frames(25);;*/
- //deleteClip(dup->info());
-
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
- if (dup->isSelected()) emit clipItemSelected(NULL);
+ // join fade effects again
+ int ix = dup->hasEffect(QString(), "fadeout");
+ if (ix != -1) {
+ QDomElement effect = dup->effectAt(ix);
+ item->addEffect(effect);
+ }
+ ix = dup->hasEffect(QString(), "fade_to_black");
+ if (ix != -1) {
+ QDomElement effect = dup->effectAt(ix);
+ item->addEffect(effect);
+ }
+
+ m_waitingThumbs.removeAll(dup);
+ bool selected = item->isSelected();
+ if (dup->isSelected()) {
+ selected = true;
+ item->setSelected(true);
+ emit clipItemSelected(NULL);
+ }
dup->baseClip()->removeReference();
m_document->updateClip(dup->baseClip()->getId());
scene()->removeItem(dup);
delete dup;
+ dup = NULL;
ItemInfo clipinfo = item->info();
clipinfo.track = m_document->tracksCount() - clipinfo.track;
bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, info.endPos - info.startPos);
if (success) {
item->resizeEnd((int) info.endPos.frames(m_document->fps()));
-
- updatePanZoom(item);
-
setDocumentModified();
} else {
emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
}
KdenliveSettings::setSnaptopoints(snap);
+ if (execute && selected)
+ emit clipItemSelected(item);
return item;
}
//QTimer::singleShot(3000, this, SLOT(slotEnableRefresh()));
kWarning() << "Unable to find transition at pos :" << pos.frames(m_document->fps()) << ", ON track: " << track;
return;
}
+
bool force = false;
if (oldTransition.attribute("transition_atrack") != transition.attribute("transition_atrack") || oldTransition.attribute("transition_btrack") != transition.attribute("transition_btrack"))
force = true;
ItemInfo clipInfo = info;
clipInfo.track = m_document->tracksCount() - item->track();
- int worked = m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->producer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
+ int worked = m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->getProducer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
if (worked == -1) {
emit displayMessage(i18n("Cannot insert clip in timeline"), ErrorMessage);
brokenClips.append(item);
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();
}
} else if (clip->endPos() <= info.endPos) {
new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), clip->info(), clip->effectList(), false, false, false, true, command);
+ m_waitingThumbs.removeAll(clip);
scene()->removeItem(clip);
delete clip;
clip = NULL;
m_selectionGroup->translate(0, m_tracksHeight);
// adjust track number
+ Mlt::Tractor *tractor = m_document->renderer()->lockService();
QList<QGraphicsItem *> children = m_selectionGroup->childItems();
for (int i = 0; i < children.count(); i++) {
if (children.at(i)->type() == GROUPWIDGET) {
// We add a move clip command so that we get the correct producer for new track number
if (clip->clipType() == AV || clip->clipType() == AUDIO) {
Mlt::Producer *prod = clip->getProducer(clipinfo.track);
- if (m_document->renderer()->mltUpdateClipProducer((int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod) == false) {
+ if (m_document->renderer()->mltUpdateClipProducer(tractor, (int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod) == false) {
// problem updating clip
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", clipinfo.startPos.frames(m_document->fps()), clipinfo.track), ErrorMessage);
}
}
}
resetSelectionGroup(false);
+ m_document->renderer()->unlockService(tractor);
}
int maxHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22();
// Move graphic items
qreal ydiff = 0 - (int) m_tracksHeight;
m_selectionGroup->translate(0, ydiff);
+ Mlt::Tractor *tractor = m_document->renderer()->lockService();
// adjust track number
QList<QGraphicsItem *> children = m_selectionGroup->childItems();
clip->updateItem();
ItemInfo clipinfo = clip->info();
// We add a move clip command so that we get the correct producer for new track number
- if (clip->clipType() == AV || clip->clipType() == AUDIO) {
+ if (clip->clipType() == AV || clip->clipType() == AUDIO || clip->clipType() == PLAYLIST) {
Mlt::Producer *prod = clip->getProducer(clipinfo.track);
- if (!m_document->renderer()->mltUpdateClipProducer((int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod)) {
+ if (prod == NULL || !m_document->renderer()->mltUpdateClipProducer(tractor, (int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod)) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", clipinfo.startPos.frames(m_document->fps()), clipinfo.track), ErrorMessage);
}
}
}
}
resetSelectionGroup(false);
+ m_document->renderer()->unlockService(tractor);
int maxHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22();
for (int i = 0; i < m_guides.count(); i++) {
int track = 0;
if (m_menuPosition.isNull()) {
pos = GenTime(cursorPos(), m_document->fps());
- bool ok;
- track = QInputDialog::getInteger(this, i18n("Remove Space"), i18n("Track"), 0, 0, m_document->tracksCount() - 1, 1, &ok);
- if (!ok) return;
+
+ TrackDialog d(m_document, parentWidget());
+ d.comboTracks->setCurrentIndex(m_selectedTrack);
+ d.label->setText(i18n("Track"));
+ d.before_select->setHidden(true);
+ d.setWindowTitle(i18n("Remove Space"));
+ d.video_track->setHidden(true);
+ d.audio_track->setHidden(true);
+ if (d.exec() != QDialog::Accepted) return;
+ track = d.comboTracks->currentIndex();
} else {
pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps());
track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight);
return;
}
int length = m_document->renderer()->mltGetSpaceLength(pos, m_document->tracksCount() - track, true);
- //kDebug() << "// GOT LENGT; " << length;
if (length <= 0) {
emit displayMessage(i18n("You must be in an empty space to remove space (time: %1, track: %2)", m_document->timecode().getTimecodeFromFrames(mapToScene(m_menuPosition).x()), track), ErrorMessage);
return;
}
}
+ if (!transitionsToMove.isEmpty()) {
+ // Make sure that by moving the items, we don't get a transition collision
+ // Find first transition
+ ItemInfo info = transitionsToMove.at(0);
+ for (int i = 1; i < transitionsToMove.count(); i++)
+ if (transitionsToMove.at(i).startPos < info.startPos) info = transitionsToMove.at(i);
+
+ // make sure there are no transitions on the way
+ QRectF rect(info.startPos.frames(m_document->fps()) - length, track * m_tracksHeight + m_tracksHeight / 2, length - 1, m_tracksHeight / 2 - 2);
+ items = scene()->items(rect);
+ int transitionCorrection = -1;
+ for (int i = 0; i < items.count(); i++) {
+ if (items.at(i)->type() == TRANSITIONWIDGET) {
+ // There is a transition on the way
+ AbstractClipItem *item = static_cast <AbstractClipItem *>(items.at(i));
+ int transitionEnd = item->endPos().frames(m_document->fps());
+ if (transitionEnd > transitionCorrection) transitionCorrection = transitionEnd;
+ }
+ }
+
+ if (transitionCorrection > 0) {
+ // We need to fix the move length
+ length = info.startPos.frames(m_document->fps()) - transitionCorrection;
+ }
+
+ // Make sure we don't send transition before 0
+ if (info.startPos.frames(m_document->fps()) < length) {
+ // reduce length to maximum possible
+ length = info.startPos.frames(m_document->fps());
+ }
+ }
+
InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, GenTime(-length, m_document->fps()), true);
updateTrackDuration(track, command);
m_commandStack->push(command);
}
}
-void CustomTrackView::insertSpace(QList<ItemInfo> clipsToMove, QList<ItemInfo> transToMove, int track, const GenTime duration, const GenTime offset)
+void CustomTrackView::insertSpace(QList<ItemInfo> clipsToMove, QList<ItemInfo> transToMove, int track, const GenTime &duration, const GenTime &offset)
{
int diff = duration.frames(m_document->fps());
resetSelectionGroup();
if (pos == m_cursorPos) return;
emit cursorMoved((int)(m_cursorPos), (int)(pos));
m_cursorPos = pos;
- if (seek) m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+ if (seek) m_document->renderer()->seek(m_cursorPos);
else if (m_autoScroll) checkScrolling();
m_cursorLine->setPos(m_cursorPos, 0);
}
emit cursorMoved((int)(m_cursorPos), (int)((m_cursorPos + delta)));
m_cursorPos += delta;
m_cursorLine->setPos(m_cursorPos, 0);
- m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+ m_document->renderer()->seek(m_cursorPos);
}
void CustomTrackView::initCursorPos(int pos)
if (item->type() == AVWIDGET) {
ClipItem *clip = static_cast <ClipItem*>(item);
+ int trackProducer = info.track;
info.track = m_document->tracksCount() - info.track;
adjustTimelineClips(m_scene->editMode(), clip, ItemInfo(), moveGroup);
- m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(info.track), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
+ m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(trackProducer), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
for (int i = 0; i < clip->effectsCount(); i++) {
m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false);
}
items.at(i)->parentItem()->setSelected(true);
}
}
+ resetSelectionGroup();
groupSelectedItems();
} else {
rebuildGroup((AbstractGroupItem *)group);
void CustomTrackView::deleteClip(ItemInfo info, bool refresh)
{
ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
-
+ m_ct++;
+ if (!item) kDebug()<<"// PROBLEM FINDING CLIP ITEM TO REMOVVE!!!!!!!!!";
+ else kDebug()<<"// deleting CLIP: "<<info.startPos.frames(m_document->fps())<<", "<<item->baseClip()->fileURL();
+ //m_document->renderer()->saveSceneList(QString("/tmp/error%1.mlt").arg(m_ct), QDomElement());
if (!item || m_document->renderer()->mltRemoveClip(m_document->tracksCount() - info.track, info.startPos) == false) {
emit displayMessage(i18n("Error removing clip at %1 on track %2", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps())), info.track), ErrorMessage);
+ kDebug()<<"CANNOT REMOVE: "<<info.startPos.frames(m_document->fps())<<", TK: "<<info.track;
+ //m_document->renderer()->saveSceneList(QString("/tmp/error%1.mlt").arg(m_ct), QDomElement());
+ exit(1);
return;
}
+ m_waitingThumbs.removeAll(item);
if (item->isSelected()) emit clipItemSelected(NULL);
item->baseClip()->removeReference();
m_document->updateClip(item->baseClip()->getId());
delete tr;
}
}*/
- m_waitingThumbs.removeAll(item);
+
if (m_dragItem == item) m_dragItem = NULL;
+
#if QT_VERSION >= 0x040600
// animate item deletion
item->closeAnimation();
scene()->clearSelection();
QUndoCommand *deleteSelected = new QUndoCommand();
- bool resetGroup = false;
int groupCount = 0;
int clipCount = 0;
int transitionCount = 0;
QList<QGraphicsItem *> children = itemList.at(i)->childItems();
QList <ItemInfo> clipInfos;
QList <ItemInfo> transitionInfos;
- GenTime currentPos = GenTime(m_cursorPos, m_document->fps());
for (int j = 0; j < children.count(); j++) {
if (children.at(j)->type() == AVWIDGET) {
AbstractClipItem *clip = static_cast <AbstractClipItem *>(children.at(j));
if (itemList.at(i)->type() == AVWIDGET) {
clipCount++;
ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
- if (item->parentItem()) resetGroup = true;
//kDebug()<<"// DELETE CLP AT: "<<item->info().startPos.frames(25);
new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, true, true, deleteSelected);
emit clipItemSelected(NULL);
transitionCount++;
Transition *item = static_cast <Transition *>(itemList.at(i));
//kDebug()<<"// DELETE TRANS AT: "<<item->info().startPos.frames(25);
- if (item->parentItem()) resetGroup = true;
new AddTransitionCommand(this, item->info(), item->transitionEndTrack(), item->toXML(), true, true, deleteSelected);
emit transitionItemSelected(NULL);
}
void CustomTrackView::changeClipSpeed()
{
+ // TODO: remove after string freeze
QList<QGraphicsItem *> itemList = scene()->selectedItems();
if (itemList.count() == 0) {
emit displayMessage(i18n("Select clip to change speed"), ErrorMessage);
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == AVWIDGET) {
ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
- ItemInfo info = item->info();
if (percent == -1) percent = QInputDialog::getInteger(this, i18n("Edit Clip Speed"), i18n("New speed (percents)"), item->speed() * 100, 1, 10000, 1, &ok);
if (!ok) break;
double speed = (double) percent / 100.0;
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);
QList<QGraphicsItem *> itemList = scene()->selectedItems();
QList <ItemInfo> clipInfos;
QList <ItemInfo> transitionInfos;
- GenTime currentPos = GenTime(m_cursorPos, m_document->fps());
// Expand groups
int max = itemList.count();
clip->setSelected(true);
}
}
-
groupSelectedItems(false, true);
setDocumentModified();
}
return;
}
- if (baseclip->producer() == NULL) {
+ if (baseclip->getProducer() == NULL) {
// If the clip has no producer, we must wait until it is created...
m_mutex.lock();
emit displayMessage(i18n("Waiting for clip..."), InformationMessage);
emit forceClipProcessing(clipId);
qApp->processEvents();
for (int i = 0; i < 3; i++) {
- if (baseclip->producer() == NULL) {
+ if (baseclip->getProducer() == NULL) {
m_producerNotReady.wait(&m_mutex, 500 + 500 * i);
} else break;
}
- if (baseclip->producer() == NULL) {
+ if (baseclip->getProducer() == NULL) {
emit displayMessage(i18n("Cannot insert clip..."), ErrorMessage);
m_mutex.unlock();
return;
m_mutex.unlock();
}
- ClipItem *item = new ClipItem(baseclip, info, m_document->fps(), xml.attribute("speed", "1").toDouble(), xml.attribute("strobe", "1").toInt());
+ ClipItem *item = new ClipItem(baseclip, info, m_document->fps(), xml.attribute("speed", "1").toDouble(), xml.attribute("strobe", "1").toInt(), getFrameWidth());
item->setEffectList(effects);
if (xml.hasAttribute("audio_only")) item->setAudioOnly(true);
else if (xml.hasAttribute("video_only")) item->setVideoOnly(true);
scene()->addItem(item);
+ int producerTrack = info.track;
int tracknumber = m_document->tracksCount() - info.track - 1;
bool isLocked = m_document->trackInfoAt(tracknumber).isLocked;
if (isLocked) item->setItemLocked(true);
baseclip->addReference();
m_document->updateClip(baseclip->getId());
info.track = m_document->tracksCount() - info.track;
- m_document->renderer()->mltInsertClip(info, xml, item->getProducer(info.track), overwrite, push);
+ m_document->renderer()->mltInsertClip(info, xml, item->getProducer(producerTrack), overwrite, push);
for (int i = 0; i < item->effectsCount(); i++) {
m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(item->effectAt(i)), false);
}
void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload)
{
+ QMutexLocker locker(&m_mutex);
QList<QGraphicsItem *> list = scene()->items();
+ QList <ClipItem *>clipList;
ClipItem *clip = NULL;
+ DocClipBase *baseClip = NULL;
+ Mlt::Tractor *tractor = m_document->renderer()->lockService();
for (int i = 0; i < list.size(); ++i) {
if (list.at(i)->type() == AVWIDGET) {
clip = static_cast <ClipItem *>(list.at(i));
if (clip->clipProducer() == clipId) {
+ if (baseClip == NULL) {
+ baseClip = clip->baseClip();
+ }
ItemInfo info = clip->info();
- info.track = m_document->tracksCount() - clip->track();
- if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer(info.track))) {
+ Mlt::Producer *prod = NULL;
+ if (clip->isAudioOnly()) prod = baseClip->audioProducer(info.track);
+ else if (clip->isVideoOnly()) prod = baseClip->videoProducer();
+ else prod = baseClip->getProducer(info.track);
+ if (reload && !m_document->renderer()->mltUpdateClip(tractor, info, clip->xml(), prod)) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
}
- clip->refreshClip(true, true);
+ else clipList.append(clip);
}
}
}
+ m_document->renderer()->unlockService(tractor);
+ for (int i = 0; i < clipList.count(); i++)
+ clipList.at(i)->refreshClip(true, true);
+ if (baseClip) {
+ baseClip->cleanupProducers();
+ }
}
ClipItem *CustomTrackView::getClipItemAtEnd(GenTime pos, int track)
return clip;
}
-void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end, bool refresh)
+void CustomTrackView::moveClip(const ItemInfo &start, const ItemInfo &end, bool refresh)
{
if (m_selectionGroup) resetSelectionGroup(false);
ClipItem *item = getClipItemAt((int) start.startPos.frames(m_document->fps()), start.track);
if (refresh) m_document->renderer()->doRefresh();
}
-void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime offset, const int trackOffset, bool reverseMove)
+void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime &offset, const int trackOffset, bool reverseMove)
{
// Group Items
resetSelectionGroup();
if (item->type() == AVWIDGET) {
ClipItem *clip = static_cast <ClipItem*>(item);
+ int trackProducer = info.track;
info.track = m_document->tracksCount() - info.track;
- m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(info.track));
+ m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(trackProducer));
for (int i = 0; i < clip->effectsCount(); i++) {
m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false);
}
} else kDebug() << "///////// WARNING; NO GROUP TO MOVE";
}
-void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end, bool m_refresh)
+void CustomTrackView::moveTransition(const ItemInfo &start, const ItemInfo &end, bool m_refresh)
{
Transition *item = getTransitionItemAt(start.startPos, start.track);
if (!item) {
setDocumentModified();
}
-void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end, bool dontWorry)
+void CustomTrackView::resizeClip(const ItemInfo &start, const ItemInfo &end, bool dontWorry)
{
bool resizeClipStart = (start.startPos != end.startPos);
ClipItem *item = getClipItemAtStart(start.startPos, start.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()));
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);
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()));
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)
}
}
-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)
m_commandStack->push(deleteMarkers);
}
-void CustomTrackView::addMarker(const QString &id, const GenTime &pos, const QString comment)
+void CustomTrackView::addMarker(const QString &id, const GenTime &pos, const QString &comment)
{
DocClipBase *base = m_document->clipManager()->getClipById(id);
if (!comment.isEmpty()) base->addSnapMarker(pos, comment);
goMenu->setEnabled(!m_guides.isEmpty());
}
-void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const QString &comment)
+void CustomTrackView::editGuide(const GenTime &oldPos, const GenTime &pos, const QString &comment)
{
if (oldPos > GenTime() && pos > GenTime()) {
// move guide
m_document->syncGuides(m_guides);
}
-bool CustomTrackView::addGuide(const GenTime pos, const QString &comment)
+bool CustomTrackView::addGuide(const GenTime &pos, const QString &comment)
{
for (int i = 0; i < m_guides.count(); i++) {
if (m_guides.at(i)->position() == pos) {
if (dialog) {
MarkerDialog d(NULL, marker, m_document->timecode(), i18n("Add Guide"), this);
if (d.exec() != QDialog::Accepted) return;
- marker.setComment(d.newMarker().comment());
+ marker = d.newMarker();
+
} else {
marker.setComment(m_document->timecode().getDisplayTimecodeFromFrames(m_cursorPos, false));
}
// If we are in overwrite mode, always allow the move
return true;
}
- QRectF rect((double) info.startPos.frames(m_document->fps()), (double)(info.track * m_tracksHeight + 1), (double)(info.endPos - info.startPos).frames(m_document->fps()), (double)(m_tracksHeight - 1));
+ int height = m_tracksHeight - 2;
+ int offset = 0;
+ if (type == TRANSITIONWIDGET) {
+ height = Transition::itemHeight();
+ offset = Transition::itemOffset();
+ }
+ else if (type == AVWIDGET) {
+ height = ClipItem::itemHeight();
+ offset = ClipItem::itemOffset();
+ }
+ QRectF rect((double) info.startPos.frames(m_document->fps()), (double)(info.track * m_tracksHeight + 1 + offset), (double)(info.endPos - info.startPos).frames(m_document->fps()), (double) height);
QList<QGraphicsItem *> collisions = scene()->items(rect, Qt::IntersectsItemBoundingRect);
for (int i = 0; i < collisions.count(); i++) {
- if (collisions.at(i)->type() == type) return false;
+ if (collisions.at(i)->type() == type) {
+ return false;
+ }
}
return true;
}
// parse parameters to check if we need to adjust to the new crop start
int diff = (newstart - oldstart).frames(m_document->fps());
int max = (newstart + duration).frames(m_document->fps());
+ QLocale locale;
QDomNodeList params = xml.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
double val = str.section(':', 1, 1).toDouble();
pos += diff;
if (pos > max) {
- newKeyFrames.append(QString::number(max) + ':' + QString::number(val));
+ newKeyFrames.append(QString::number(max) + ':' + locale.toString(val));
break;
- } else newKeyFrames.append(QString::number(pos) + ':' + QString::number(val));
+ } else newKeyFrames.append(QString::number(pos) + ':' + locale.toString(val));
}
//kDebug()<<"ORIGIN: "<<keys<<", FIXED: "<<newKeyFrames;
e.setAttribute("keyframes", newKeyFrames.join(";"));
} else {
QString startThumb = thumbBase + item->baseClip()->getClipHash() + '_';
QString endThumb = startThumb;
- startThumb.append(QString::number(item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
- endThumb.append(QString::number((item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
+ startThumb.append(QString::number((int) item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
+ endThumb.append(QString::number((int) (item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
if (QFile::exists(startThumb)) {
QPixmap pix(startThumb);
if (pix.isNull()) KIO::NetAccess::del(KUrl(startThumb), this);
} else {
QString startThumb = thumbBase + item->baseClip()->getClipHash() + '_';
QString endThumb = startThumb;
- startThumb.append(QString::number(item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
- endThumb.append(QString::number((item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
+ startThumb.append(QString::number((int) item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
+ endThumb.append(QString::number((int) (item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
if (!QFile::exists(startThumb)) {
QPixmap pix(item->startThumb());
pix.save(startThumb);
if (selection.at(i)->type() == AVWIDGET) {
ClipItem *item = static_cast <ClipItem *>(selection.at(i));
new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, false, true, deleteTrack);
+ m_waitingThumbs.removeAll(item);
m_scene->removeItem(item);
delete item;
item = NULL;
setDocumentModified();
}
-
-QStringList CustomTrackView::getLadspaParams(QDomElement effect) const
-{
- QStringList result;
- QDomNodeList params = effect.elementsByTagName("parameter");
- for (int i = 0; i < params.count(); i++) {
- QDomElement e = params.item(i).toElement();
- if (!e.isNull() && e.attribute("type") == "constant") {
- if (e.hasAttribute("factor")) {
- double factor = e.attribute("factor").toDouble();
- double value = e.attribute("value").toDouble();
- value = value / factor;
- result.append(QString::number(value));
- } else result.append(e.attribute("value"));
- }
- }
- return result;
-}
-
-void CustomTrackView::clipNameChanged(const QString id, const QString name)
+void CustomTrackView::clipNameChanged(const QString &id, const QString &name)
{
QList<QGraphicsItem *> list = scene()->items();
ClipItem *clip = NULL;
}
}
-void CustomTrackView::loadGroups(const QDomNodeList groups)
+void CustomTrackView::loadGroups(const QDomNodeList &groups)
{
for (int i = 0; i < groups.count(); i++) {
QDomNodeList children = groups.at(i).childNodes();
scene()->clearSelection();
for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
- QDomNode n = children.item(nodeindex);
- QDomElement elem = n.toElement();
+ QDomElement elem = children.item(nodeindex).toElement();
int pos = elem.attribute("position").toInt();
int track = elem.attribute("track").toInt();
if (elem.tagName() == "clipitem") {
if (clip->parentItem()) {
emit displayMessage(i18n("Cannot split audio of grouped clips"), ErrorMessage);
} else {
- new SplitAudioCommand(this, clip->track(), clip->startPos(), splitCommand);
+ EffectsList effects;
+ effects.clone(clip->effectList());
+ new SplitAudioCommand(this, clip->track(), clip->startPos(), effects, splitCommand);
}
}
}
}
}
-void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
+void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList effects, bool split)
{
ClipItem *clip = getClipItemAt(pos, track);
if (clip == NULL) {
clip->setSelected(true);
ClipItem *audioClip = getClipItemAt(start, info.track);
if (audioClip) {
+ Mlt::Tractor *tractor = m_document->renderer()->lockService();
clip->setVideoOnly(true);
- if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) {
+ if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
}
- if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, start, clip->baseClip()->audioProducer(info.track)) == false) {
+ if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - info.track, start, clip->baseClip()->audioProducer(info.track)) == false) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, info.track), ErrorMessage);
}
+ m_document->renderer()->unlockService(tractor);
audioClip->setSelected(true);
audioClip->setAudioOnly(true);
+
+ // keep video effects, move audio effects to audio clip
+ int videoIx = 0;
+ int audioIx = 0;
+ for (int i = 0; i < effects.count(); ++i) {
+ if (effects.at(i).attribute("type") == "audio") {
+ deleteEffect(m_document->tracksCount() - track, pos, clip->effectAt(videoIx));
+ audioIx++;
+ } else {
+ deleteEffect(freetrack, pos, audioClip->effectAt(audioIx));
+ videoIx++;
+ }
+ }
+
groupSelectedItems(false, true);
}
}
ItemInfo info = clip->info();
deleteClip(clp->info());
clip->setVideoOnly(false);
- if (!m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, info.startPos.frames(m_document->fps()), clip->baseClip()->producer(info.track))) {
+ Mlt::Tractor *tractor = m_document->renderer()->lockService();
+ if (!m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - info.track, info.startPos.frames(m_document->fps()), clip->baseClip()->getProducer(info.track))) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
}
+ m_document->renderer()->unlockService(tractor);
+
+ // re-add audio effects
+ for (int i = 0; i < effects.count(); ++i) {
+ if (effects.at(i).attribute("type") == "audio") {
+ addEffect(m_document->tracksCount() - track, pos, effects.at(i));
+ }
+ }
+
break;
}
}
kDebug() << "// Cannot find clip to split!!!";
return;
}
+ Mlt::Tractor *tractor = m_document->renderer()->lockService();
if (videoOnly) {
int start = pos.frames(m_document->fps());
clip->setVideoOnly(true);
clip->setAudioOnly(false);
- if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) {
+ if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->videoProducer()) == false) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
}
} else if (audioOnly) {
int start = pos.frames(m_document->fps());
clip->setAudioOnly(true);
clip->setVideoOnly(false);
- if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->audioProducer(track)) == false) {
+ if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->audioProducer(track)) == false) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
}
} else {
int start = pos.frames(m_document->fps());
clip->setAudioOnly(false);
clip->setVideoOnly(false);
- if (m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - track, start, clip->baseClip()->producer(track)) == false) {
+ if (m_document->renderer()->mltUpdateClipProducer(tractor, m_document->tracksCount() - track, start, clip->baseClip()->getProducer(track)) == false) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", start, track), ErrorMessage);
}
}
+ m_document->renderer()->unlockService(tractor);
clip->update();
setDocumentModified();
}
m_document->clipManager()->removeGroup(grp);
m_scene->addItem(grp);
scene()->destroyItemGroup(grp);
+ scene()->clearSelection();
for (int j = 0; j < children.count(); j++) {
if (children.at(j)->type() == AVWIDGET || children.at(j)->type() == TRANSITIONWIDGET) {
//children.at(j)->setParentItem(0);
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;
}
return false;
}
-void CustomTrackView::slotAddTrackEffect(const QDomElement effect, int ix)
+void CustomTrackView::slotAddTrackEffect(const QDomElement &effect, int ix)
{
AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - ix, GenTime(-1), effect, true);
m_commandStack->push(command);
}
-EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
+EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement &effect)
{
EffectsParameterList parameters;
+ QLocale locale;
parameters.addParam("tag", effect.attribute("tag"));
if (effect.hasAttribute("region")) parameters.addParam("region", effect.attribute("region"));
parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
QDomElement e = params.item(i).toElement();
- //kDebug() << "/ / / /SENDING EFFECT PARAM: " << e.attribute("type") << ", NAME_ " << e.attribute("tag");
+ 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();
for (int j = 0; j < values.count(); j++) {
QString pos = values.at(j).section(':', 0, 0);
- double val = values.at(j).section(':', 1, 1).toDouble() / factor;
- values[j] = pos + "=" + QString::number(val);
+ double val = (values.at(j).section(':', 1, 1).toDouble() - offset) / factor;
+ values[j] = pos + "=" + locale.toString(val);
}
// kDebug() << "/ / / /SENDING KEYFR:" << values;
parameters.addParam(e.attribute("name"), values.join(";"));
parameters.addParam("max", e.attribute("max"));
parameters.addParam("min", e.attribute("min"));
parameters.addParam("factor", e.attribute("factor", "1"));
+ parameters.addParam("offset", e.attribute("offset", "0"));
parameters.addParam("starttag", e.attribute("starttag", "start"));
parameters.addParam("endtag", e.attribute("endtag", "end"));
} else if (e.attribute("namedesc").contains(';')) {
}
parameters.addParam("start", neu);
} else {
- if (e.attribute("factor", "1") != "1") {
+ if (e.attribute("factor", "1") != "1" || e.attribute("offset", "0") != "0") {
double fact;
- if (e.attribute("factor").startsWith('%')) {
+ if (e.attribute("factor").contains('%')) {
fact = ProfilesDialog::getStringEval(m_document->mltProfile(), e.attribute("factor"));
- } else fact = e.attribute("factor", "1").toDouble();
- parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / fact));
+ } else {
+ 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));
} else {
parameters.addParam(e.attribute("name"), e.attribute("value"));
}
return parameters;
}
-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);
-
- // if effect is displayed, update the effect edit widget with new clip duration
- /*if (item->isSelected() && effects.at(i) == item->selectedEffectIndex())
- emit clipItemSelected(item, effects.at(i));*/
- }
- // update always, otherwise there might problems when resizing groups
- if (effects.count() > 0)
- emit clipItemSelected(item, item->selectedEffectIndex());
-}
-
void CustomTrackView::updateTrackNames(int track, bool added)
{
QList <TrackInfo> tracks = m_document->tracksList();
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;
+ }
+ }
+}
+
+