X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcustomtrackview.cpp;h=35b11c21c9910934a8899d04f904da7d742f2ee8;hb=e0a70e0428309070f6ed2716beaeaaba05edd3b5;hp=2ed7b65bf65400def82574a71fde868595d4d2c2;hpb=a6b9fba3ddca6e3e1a4b3d48aef2dcb9228c79c9;p=kdenlive diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 2ed7b65b..35b11c21 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -22,20 +22,20 @@ #include "docclipbase.h" #include "clipitem.h" #include "definitions.h" -#include "moveclipcommand.h" -#include "movetransitioncommand.h" -#include "resizeclipcommand.h" -#include "editguidecommand.h" -#include "addtimelineclipcommand.h" -#include "addeffectcommand.h" -#include "editeffectcommand.h" -#include "moveeffectcommand.h" -#include "addtransitioncommand.h" -#include "edittransitioncommand.h" -#include "editkeyframecommand.h" -#include "changespeedcommand.h" -#include "addmarkercommand.h" -#include "razorclipcommand.h" +#include "commands/moveclipcommand.h" +#include "commands/movetransitioncommand.h" +#include "commands/resizeclipcommand.h" +#include "commands/editguidecommand.h" +#include "commands/addtimelineclipcommand.h" +#include "commands/addeffectcommand.h" +#include "commands/editeffectcommand.h" +#include "commands/moveeffectcommand.h" +#include "commands/addtransitioncommand.h" +#include "commands/edittransitioncommand.h" +#include "commands/editkeyframecommand.h" +#include "commands/changespeedcommand.h" +#include "commands/addmarkercommand.h" +#include "commands/razorclipcommand.h" #include "kdenlivesettings.h" #include "transition.h" #include "clipmanager.h" @@ -45,21 +45,21 @@ #include "ui_keyframedialog_ui.h" #include "clipdurationdialog.h" #include "abstractgroupitem.h" -#include "insertspacecommand.h" +#include "commands/insertspacecommand.h" #include "spacerdialog.h" -#include "addtrackcommand.h" -#include "movegroupcommand.h" +#include "commands/addtrackcommand.h" +#include "commands/movegroupcommand.h" #include "ui_addtrack_ui.h" #include "initeffects.h" -#include "locktrackcommand.h" -#include "groupclipscommand.h" -#include "splitaudiocommand.h" -#include "changecliptypecommand.h" +#include "commands/locktrackcommand.h" +#include "commands/groupclipscommand.h" +#include "commands/splitaudiocommand.h" +#include "commands/changecliptypecommand.h" #include "trackdialog.h" #include "tracksconfigdialog.h" -#include "configtrackscommand.h" -#include "rebuildgroupcommand.h" -#include "razorgroupcommand.h" +#include "commands/configtrackscommand.h" +#include "commands/rebuildgroupcommand.h" +#include "commands/razorgroupcommand.h" #include "profilesdialog.h" #include @@ -130,7 +130,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen m_commandStack = doc->commandStack(); else m_commandStack = NULL; - + m_ct = 0; setMouseTracking(true); setAcceptDrops(true); setFrameShape(QFrame::NoFrame); @@ -262,14 +262,35 @@ void CustomTrackView::checkAutoScroll() 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 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 itemList = items(); ClipItem *item; Transition *transitionitem; + int frameWidth = getFrameWidth(); bool snap = KdenliveSettings::snaptopoints(); KdenliveSettings::setSnaptopoints(false); for (int i = 0; i < itemList.count(); i++) { @@ -277,6 +298,7 @@ void CustomTrackView::checkTrackHeight() 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); @@ -297,6 +319,7 @@ void CustomTrackView::checkTrackHeight() // verticalScrollBar()->setMaximum(m_tracksHeight * m_document->tracksCount()); KdenliveSettings::setSnaptopoints(snap); viewport()->update(); + return true; } /** Zoom or move viewport on mousewheel @@ -584,7 +607,14 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) 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); @@ -701,7 +731,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) m_blockRefresh = true; m_dragGuide = NULL; - bool collision = false; if (m_tool != RAZORTOOL) activateMonitor(); else if (m_document->renderer()->playSpeed() != 0.0) { @@ -712,7 +741,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) // check item under mouse QList 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); @@ -729,7 +757,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) 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(); @@ -900,7 +927,8 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) } else { setCursorPos((int)(mapToScene(event->x(), 0).x())); } - QGraphicsView::mousePressEvent(event); + //QGraphicsView::mousePressEvent(event); + event->ignore(); return; } @@ -969,7 +997,12 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) 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 @@ -1361,7 +1394,7 @@ void CustomTrackView::editItemDuration() } } -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) { @@ -1446,7 +1479,7 @@ void CustomTrackView::insertClipCut(DocClipBase *clip, int in, int out) 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; @@ -1458,7 +1491,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos) 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; } @@ -1481,7 +1514,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos) 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); @@ -1513,7 +1546,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos) 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; } @@ -1539,7 +1572,7 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos) 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); @@ -1591,7 +1624,7 @@ void CustomTrackView::slotRefreshEffects(ClipItem *clip) { 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; } @@ -1607,6 +1640,11 @@ void CustomTrackView::addEffect(int track, GenTime pos, QDomElement effect) { 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)); @@ -1622,7 +1660,8 @@ void CustomTrackView::addEffect(int track, GenTime pos, QDomElement 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()); @@ -1643,7 +1682,7 @@ void CustomTrackView::deleteEffect(int track, GenTime pos, QDomElement effect) 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); @@ -1658,11 +1697,11 @@ void CustomTrackView::deleteEffect(int track, GenTime pos, QDomElement effect) 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; @@ -1679,8 +1718,8 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem * QList 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; @@ -1704,13 +1743,6 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem * } item->initEffect(effect); - // Old LADSPA filter, deprecated - /* - 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++; } @@ -1726,8 +1758,8 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) QList 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)); @@ -1783,13 +1815,6 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track) } else { item->initEffect(effect); } - // Old LADSPA filter, deprecated - /* 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); } } @@ -1828,8 +1853,8 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement ef QList 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)); @@ -1876,11 +1901,6 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE if (pos < GenTime()) { // editing a track effect EffectsParameterList effectParams = getEffectArgs(effect); - // Old LADSPA filter, deprecated - /*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); @@ -1901,7 +1921,8 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE 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; + 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()); @@ -1916,11 +1937,6 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE } EffectsParameterList effectParams = getEffectArgs(effect); - // Old LADSPA filter, deprecated - /*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); @@ -2092,9 +2108,6 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo if (dup->checkKeyFrames()) slotRefreshEffects(dup); - updatePanZoom(item); - updatePanZoom(dup, cutTime - item->startPos()); - item->baseClip()->addReference(); m_document->updateClip(item->baseClip()->getId()); setDocumentModified(); @@ -2151,9 +2164,6 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo 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); @@ -2410,7 +2420,7 @@ void CustomTrackView::dropEvent(QDropEvent * event) 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); @@ -2653,6 +2663,7 @@ void CustomTrackView::addTrack(TrackInfo type, int ix) m_selectionGroup->translate(0, m_tracksHeight); // adjust track number + Mlt::Tractor *tractor = m_document->renderer()->lockService(); QList children = m_selectionGroup->childItems(); for (int i = 0; i < children.count(); i++) { if (children.at(i)->type() == GROUPWIDGET) { @@ -2670,7 +2681,7 @@ void CustomTrackView::addTrack(TrackInfo type, int ix) // 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); } @@ -2684,6 +2695,7 @@ void CustomTrackView::addTrack(TrackInfo type, int ix) } } resetSelectionGroup(false); + m_document->renderer()->unlockService(tractor); } int maxHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22(); @@ -2725,6 +2737,7 @@ void CustomTrackView::removeTrack(int ix) // 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 children = m_selectionGroup->childItems(); @@ -2742,7 +2755,7 @@ void CustomTrackView::removeTrack(int ix) // We add a move clip command so that we get the correct producer for new track number if (clip->clipType() == AV || clip->clipType() == AUDIO || clip->clipType() == PLAYLIST) { Mlt::Producer *prod = clip->getProducer(clipinfo.track); - if (prod == NULL || !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); } } @@ -2757,6 +2770,7 @@ void CustomTrackView::removeTrack(int ix) } } 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++) { @@ -2909,9 +2923,16 @@ void CustomTrackView::slotRemoveSpace() 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); @@ -2928,7 +2949,6 @@ void CustomTrackView::slotRemoveSpace() 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; @@ -2960,6 +2980,38 @@ void CustomTrackView::slotRemoveSpace() } } + 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 (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); @@ -3025,7 +3077,7 @@ void CustomTrackView::slotInsertSpace() } } -void CustomTrackView::insertSpace(QList clipsToMove, QList transToMove, int track, const GenTime duration, const GenTime offset) +void CustomTrackView::insertSpace(QList clipsToMove, QList transToMove, int track, const GenTime &duration, const GenTime &offset) { int diff = duration.frames(m_document->fps()); resetSelectionGroup(); @@ -3717,9 +3769,15 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) 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: "<fps())<<", "<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: "<fps())<<", TK: "<renderer()->saveSceneList(QString("/tmp/error%1.mlt").arg(m_ct), QDomElement()); + exit(1); return; } m_waitingThumbs.removeAll(item); @@ -3769,7 +3827,6 @@ void CustomTrackView::deleteSelectedClips() scene()->clearSelection(); QUndoCommand *deleteSelected = new QUndoCommand(); - bool resetGroup = false; int groupCount = 0; int clipCount = 0; int transitionCount = 0; @@ -3780,7 +3837,6 @@ void CustomTrackView::deleteSelectedClips() QList children = itemList.at(i)->childItems(); QList clipInfos; QList 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 (children.at(j)); @@ -3806,7 +3862,6 @@ void CustomTrackView::deleteSelectedClips() if (itemList.at(i)->type() == AVWIDGET) { clipCount++; ClipItem *item = static_cast (itemList.at(i)); - if (item->parentItem()) resetGroup = true; //kDebug()<<"// DELETE CLP AT: "<info().startPos.frames(25); new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, true, true, deleteSelected); emit clipItemSelected(NULL); @@ -3814,7 +3869,6 @@ void CustomTrackView::deleteSelectedClips() transitionCount++; Transition *item = static_cast (itemList.at(i)); //kDebug()<<"// DELETE TRANS AT: "<info().startPos.frames(25); - if (item->parentItem()) resetGroup = true; new AddTransitionCommand(this, item->info(), item->transitionEndTrack(), item->toXML(), true, true, deleteSelected); emit transitionItemSelected(NULL); } @@ -3832,6 +3886,7 @@ void CustomTrackView::deleteSelectedClips() void CustomTrackView::changeClipSpeed() { + // TODO: remove after string freeze QList itemList = scene()->selectedItems(); if (itemList.count() == 0) { emit displayMessage(i18n("Select clip to change speed"), ErrorMessage); @@ -3845,7 +3900,6 @@ void CustomTrackView::changeClipSpeed() for (int i = 0; i < itemList.count(); i++) { if (itemList.at(i)->type() == AVWIDGET) { ClipItem *item = static_cast (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; @@ -3995,7 +4049,6 @@ void CustomTrackView::groupClips(bool group) QList itemList = scene()->selectedItems(); QList clipInfos; QList transitionInfos; - GenTime currentPos = GenTime(m_cursorPos, m_document->fps()); // Expand groups int max = itemList.count(); @@ -4074,18 +4127,18 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i 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; @@ -4094,7 +4147,7 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i 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); @@ -4122,19 +4175,25 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload) { + QMutexLocker locker(&m_mutex); QList list = scene()->items(); QList 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 (list.at(i)); if (clip->clipProducer() == clipId) { + if (baseClip == NULL) { + baseClip = clip->baseClip(); + } ItemInfo info = clip->info(); Mlt::Producer *prod = NULL; - if (clip->isAudioOnly()) prod = clip->baseClip()->audioProducer(info.track); - else if (clip->isVideoOnly()) prod = clip->baseClip()->videoProducer(); - else prod = clip->baseClip()->producer(info.track); - if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), prod)) { + 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); } else clipList.append(clip); @@ -4143,6 +4202,7 @@ void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload) } for (int i = 0; i < clipList.count(); i++) clipList.at(i)->refreshClip(true, true); + m_document->renderer()->unlockService(tractor); } ClipItem *CustomTrackView::getClipItemAtEnd(GenTime pos, int track) @@ -4249,7 +4309,7 @@ Transition *CustomTrackView::getTransitionItemAtStart(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); @@ -4292,7 +4352,7 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end, bool re if (refresh) m_document->renderer()->doRefresh(); } -void CustomTrackView::moveGroup(QList startClip, QList startTransition, const GenTime offset, const int trackOffset, bool reverseMove) +void CustomTrackView::moveGroup(QList startClip, QList startTransition, const GenTime &offset, const int trackOffset, bool reverseMove) { // Group Items resetSelectionGroup(); @@ -4410,7 +4470,7 @@ void CustomTrackView::moveGroup(QList startClip, QList sta } 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 refresh) { Transition *item = getTransitionItemAt(start.startPos, start.track); if (!item) { @@ -4454,11 +4514,11 @@ void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end, b } emit transitionItemSelected(item, getPreviousVideoTrack(item->track()), p); } - if (m_refresh) m_document->renderer()->doRefresh(); + if (refresh) m_document->renderer()->doRefresh(); 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); @@ -4962,7 +5022,7 @@ void CustomTrackView::slotDeleteAllClipMarkers(const QString &id) 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); @@ -4994,7 +5054,7 @@ void CustomTrackView::buildGuidesMenu(QMenu *goMenu) const 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 @@ -5022,7 +5082,7 @@ void CustomTrackView::editGuide(const GenTime oldPos, const GenTime pos, const Q 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) { @@ -5520,6 +5580,7 @@ void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime // 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(); @@ -5533,9 +5594,9 @@ void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime 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: "<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); @@ -5686,8 +5747,8 @@ void CustomTrackView::saveThumbnails() } 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); @@ -5811,26 +5872,7 @@ void CustomTrackView::autoTransition() 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 list = scene()->items(); ClipItem *clip = NULL; @@ -5877,7 +5919,7 @@ void CustomTrackView::getTransitionAvailableSpace(AbstractClipItem *item, GenTim } } -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(); @@ -5915,7 +5957,9 @@ void CustomTrackView::splitAudio() 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); } } } @@ -5926,7 +5970,7 @@ void CustomTrackView::splitAudio() } } -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) { @@ -5962,15 +6006,31 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split) 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); } } @@ -5992,9 +6052,19 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split) 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; } } @@ -6086,28 +6156,30 @@ void CustomTrackView::doChangeClipType(const GenTime &pos, int track, bool video 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(); } @@ -6526,7 +6598,7 @@ bool CustomTrackView::hasAudio(int track) const 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); @@ -6534,9 +6606,10 @@ void CustomTrackView::slotAddTrackEffect(const QDomElement effect, int ix) } -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")); @@ -6549,15 +6622,19 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) 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(";")); @@ -6571,6 +6648,7 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) 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(';')) { @@ -6587,12 +6665,15 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) } 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").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")); } @@ -6601,23 +6682,6 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect) return parameters; } -void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos) -{ - QList 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()) - emit clipItemSelected(item, item->selectedEffectIndex()); -} - void CustomTrackView::updateTrackNames(int track, bool added) { QList tracks = m_document->tracksList();