m_selectedTrack(0),
m_controlModifier(false)
{
- if (doc) m_commandStack = doc->commandStack();
- else m_commandStack = NULL;
+ if (doc)
+ m_commandStack = doc->commandStack();
+ else
+ m_commandStack = NULL;
+
setMouseTracking(true);
setAcceptDrops(true);
setFrameShape(QFrame::NoFrame);
setLineWidth(0);
//setCacheMode(QGraphicsView::CacheBackground);
- //setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
setAutoFillBackground(false);
setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
+ setContentsMargins(0, 0, 0, 0);
+
m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
+
pixmapCache = new KPixmapCache("kdenlive-thumbs");
- KdenliveSettings::setTrackheight(m_tracksHeight);
+
m_animationTimer = new QTimeLine(800);
m_animationTimer->setFrameRange(0, 5);
m_animationTimer->setUpdateInterval(100);
m_animationTimer->setLoopCount(0);
+
m_tipColor = QColor(0, 192, 0, 200);
- QColor border = QColor(255, 255, 255, 100);
- m_tipPen.setColor(border);
+ m_tipPen.setColor(QColor(255, 255, 255, 100));
m_tipPen.setWidth(3);
- setContentsMargins(0, 0, 0, 0);
+
const int maxHeight = m_tracksHeight * m_document->tracksCount();
setSceneRect(0, 0, sceneRect().width(), maxHeight);
verticalScrollBar()->setMaximum(maxHeight);
+ verticalScrollBar()->setTracking(true);
+ // repaint guides when using vertical scroll
+ connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotRefreshGuides()));
+
m_cursorLine = projectscene->addLine(0, 0, 0, maxHeight);
m_cursorLine->setZValue(1000);
-
QPen pen1 = QPen();
pen1.setWidth(1);
pen1.setColor(palette().text().color());
m_cursorLine->setPen(pen1);
m_cursorLine->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
- KIcon razorIcon("edit-cut");
- m_razorCursor = QCursor(razorIcon.pixmap(22, 22));
-
- KIcon spacerIcon("kdenlive-spacer-tool");
- m_spacerCursor = QCursor(spacerIcon.pixmap(22, 22));
- verticalScrollBar()->setTracking(true);
- // Line below was supposed to scroll guides label with scrollbar, not implemented yet
- //connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotRefreshGuides()));
connect(&m_scrollTimer, SIGNAL(timeout()), this, SLOT(slotCheckMouseScrolling()));
m_scrollTimer.setInterval(100);
m_scrollTimer.setSingleShot(true);
connect(&m_thumbsTimer, SIGNAL(timeout()), this, SLOT(slotFetchNextThumbs()));
m_thumbsTimer.setInterval(500);
m_thumbsTimer.setSingleShot(true);
+
+ KIcon razorIcon("edit-cut");
+ m_razorCursor = QCursor(razorIcon.pixmap(22, 22));
+
+ KIcon spacerIcon("kdenlive-spacer-tool");
+ m_spacerCursor = QCursor(spacerIcon.pixmap(22, 22));
}
CustomTrackView::~CustomTrackView()
{
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);
if (!m_controlModifier && m_dragItem->type() == AVWIDGET && m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
AbstractGroupItem *parent = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
if (parent)
- parent->resizeStart((int)(snappedPos) - m_dragItemInfo.startPos.frames(m_document->fps()));
+ parent->resizeStart((int)(snappedPos - m_dragItemInfo.startPos.frames(m_document->fps())));
} else {
m_dragItem->resizeStart((int)(snappedPos));
}
+ QString crop = m_document->timecode().getDisplayTimecode(m_dragItem->cropStart(), KdenliveSettings::frametimecode());
+ QString duration = m_document->timecode().getDisplayTimecode(m_dragItem->cropDuration(), KdenliveSettings::frametimecode());
+ QString offset = m_document->timecode().getDisplayTimecode(m_dragItem->cropStart() - m_dragItemInfo.cropStart, KdenliveSettings::frametimecode());
+ emit displayMessage(i18n("Crop from start:") + ' ' + crop + ' ' + i18n("Duration:") + ' ' + duration + ' ' + i18n("Offset:") + ' ' + offset, InformationMessage);
} else if (m_operationMode == RESIZEEND && move) {
m_document->renderer()->pause();
if (!m_controlModifier && m_dragItem->type() == AVWIDGET && m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
AbstractGroupItem *parent = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
if (parent)
- parent->resizeEnd((int)(snappedPos) - m_dragItemInfo.endPos.frames(m_document->fps()));
+ parent->resizeEnd((int)(snappedPos - m_dragItemInfo.endPos.frames(m_document->fps())));
} else {
m_dragItem->resizeEnd((int)(snappedPos));
}
+ QString duration = m_document->timecode().getDisplayTimecode(m_dragItem->cropDuration(), KdenliveSettings::frametimecode());
+ QString offset = m_document->timecode().getDisplayTimecode(m_dragItem->cropDuration() - m_dragItemInfo.cropDuration, KdenliveSettings::frametimecode());
+ emit displayMessage(i18n("Duration:") + ' ' + duration + ' ' + i18n("Offset:") + ' ' + offset, InformationMessage);
} else if (m_operationMode == FADEIN && move) {
((ClipItem*) m_dragItem)->setFadeIn((int)(mappedXPos - m_dragItem->startPos().frames(m_document->fps())));
} else if (m_operationMode == FADEOUT && move) {
double maxh = 100.0 / br.height();
pos = (br.bottom() - pos) * maxh;
m_dragItem->updateKeyFramePos(keyFramePos, pos);
+ QString position = m_document->timecode().getDisplayTimecodeFromFrames(m_dragItem->editedKeyFramePos(), KdenliveSettings::frametimecode());
+ emit displayMessage(position + " : " + QString::number(m_dragItem->editedKeyFrameValue()), InformationMessage);
}
removeTipAnimation();
return;
}
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();
} else resetSelectionGroup();
dragGroup = NULL;
if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET) {
- //kDebug()<<"// KLIK FOUND GRP: "<<m_dragItem->sceneBoundingRect();
dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
}
bool selected = !m_dragItem->isSelected();
children.at(i)->setSelected(selectItems);
}
}
+
m_selectionGroup = NULL;
KdenliveSettings::setSnaptopoints(snap);
}
clipInfo.endPos = clipInfo.startPos + d.duration();
clipInfo.track = item->track();
MoveTransitionCommand *command = new MoveTransitionCommand(this, startInfo, clipInfo, true);
+ updateTrackDuration(clipInfo.track, command);
m_commandStack->push(command);
} else {
// move and resize clip
clipInfo.cropStart = d.cropStart();
new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
}
+ updateTrackDuration(clipInfo.track, moveCommand);
m_commandStack->push(moveCommand);
}
}
}
AddTimelineClipCommand *command = new AddTimelineClipCommand(this, clip->toXML(), clip->getId(), pasteInfo, EffectsList(), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT, true, false);
+ updateTrackDuration(pasteInfo.track, command);
m_commandStack->push(command);
selectClip(true, false);
kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << list.at(0);
return false;
}
+ if (clip->producer() == NULL) {
+ emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+ return false;
+ }
QPointF framePos = mapToScene(pos);
ItemInfo info;
info.startPos = GenTime();
kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << ids.at(i);
return false;
}
+ if (clip->producer() == NULL) {
+ emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+ return false;
+ }
ItemInfo info;
info.startPos = start;
info.cropDuration = clip->duration();
{
if (pos < GenTime()) {
// Add track effect
+ clearSelection();
m_document->addTrackEffect(track - 1, effect);
m_document->renderer()->mltAddTrackEffect(track, getEffectArgs(effect));
emit updateTrackEffectState(track - 1);
QString index = effect.attribute("kdenlive_ix");
if (pos < GenTime()) {
// Delete track effect
- m_document->removeTrackEffect(track - 1, effect);
- m_document->renderer()->mltRemoveTrackEffect(track, index, true);
+ if (m_document->renderer()->mltRemoveTrackEffect(track, index, true)) {
+ m_document->removeTrackEffect(track - 1, effect);
+ }
+ else emit displayMessage(i18n("Problem deleting effect"), ErrorMessage);
emit updateTrackEffectState(track - 1);
emit showTrackEffects(track, m_document->trackInfoAt(track - 1));
return;
if (effectCommand->childCount() > 0) {
m_commandStack->push(effectCommand);
setDocumentModified();
+ if (effectCommand->childCount() == 1) {
+ // Display newly added clip effect
+ for (int i = 0; i < itemList.count(); i++) {
+ if (itemList.at(i)->type() == AVWIDGET) {
+ ClipItem *clip = static_cast<ClipItem *>(itemList.at(i));
+ if (!clip->isSelected()) {
+ clearSelection();
+ clip->setSelected(true);
+ }
+ clip->setSelectedEffect(clip->effectsCount() - 1);
+ emit clipItemSelected(clip, clip->effectsCount() - 1);
+ break;
+ }
+ }
+ }
} else delete effectCommand;
}
}
}
}
- if (delCommand->childCount() > 0) m_commandStack->push(delCommand);
- else delete delCommand;
+ if (delCommand->childCount() > 0)
+ m_commandStack->push(delCommand);
+ else
+ delete delCommand;
+ setDocumentModified();
return;
}
AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, false);
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
-
+ m_waitingThumbs.removeAll(dup);
if (dup->isSelected()) 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;
return;
}
EditTransitionCommand *command = new EditTransitionCommand(this, tr->track(), tr->startPos(), old, xml, false);
+ updateTrackDuration(tr->track(), command);
m_commandStack->push(command);
setDocumentModified();
}
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;
adjustTimelineClips(m_scene->editMode(), item, ItemInfo(), addCommand);
new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT, false, false, addCommand);
+ updateTrackDuration(info.track, addCommand);
if (item->baseClip()->isTransparent() && getTransitionItemAtStart(info.startPos, info.track) == NULL) {
// add transparency transition
}
} 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;
lockTrack(m_document->tracksCount() - i - 1, m_document->trackInfoAt(i).isLocked, false);
}
- QTimer::singleShot(300, this, SIGNAL(trackHeightChanged()));
viewport()->update();
+ emit trackHeightChanged();
}
void CustomTrackView::slotSwitchTrackAudio(int ix)
}
InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, GenTime(-length, m_document->fps()), true);
+ updateTrackDuration(track, command);
m_commandStack->push(command);
}
track = d.selectedTrack();
QList<QGraphicsItem *> items;
- if (track > 0) {
+ if (track >= 0) {
if (m_document->isTrackLocked(m_document->tracksCount() - track - 1)) {
emit displayMessage(i18n("Cannot insert space in a locked track"), ErrorMessage);
return;
if (!clipsToMove.isEmpty() || !transitionsToMove.isEmpty()) {
InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, spaceDuration, true);
+ updateTrackDuration(track, command);
m_commandStack->push(command);
}
}
}
}
deleteCommand->setText(i18np("Delete timeline clip", "Delete timeline clips", count));
- if (count == 0) delete deleteCommand;
- else m_commandStack->push(deleteCommand);
+ if (count == 0) {
+ delete deleteCommand;
+ } else {
+ updateTrackDuration(-1, deleteCommand);
+ m_commandStack->push(deleteCommand);
+ }
}
void CustomTrackView::setCursorPos(int pos, bool seek)
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 (!clipsToMove.isEmpty() || !transitionsToMove.isEmpty()) {
InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, timeOffset, false);
+ updateTrackDuration(track, command);
m_commandStack->push(command);
if (track != -1) track = m_document->tracksCount() - track;
kDebug() << "SPACER TRACK:" << track;
resetSelectionGroup(false);
m_operationMode = NONE;
} else if (m_operationMode == RUBBERSELECTION) {
- //kDebug() << "// END RUBBER SELECT";
resetSelectionGroup();
groupSelectedItems();
m_operationMode = NONE;
}
}
}
+ updateTrackDuration(info.track, moveCommand);
+ if (m_dragItemInfo.track != info.track)
+ updateTrackDuration(m_dragItemInfo.track, moveCommand);
m_commandStack->push(moveCommand);
//checkTrackSequence(m_dragItem->track());
} else {
moveCommand->setText(i18n("Move transition"));
adjustTimelineTransitions(m_scene->editMode(), transition, moveCommand);
new MoveTransitionCommand(this, m_dragItemInfo, info, false, moveCommand);
+ updateTrackDuration(info.track, moveCommand);
+ if (m_dragItemInfo.track != info.track)
+ updateTrackDuration(m_dragItemInfo.track, moveCommand);
m_commandStack->push(moveCommand);
setDocumentModified();
}
GenTime timeOffset = GenTime(m_dragItem->scenePos().x(), m_document->fps()) - m_dragItemInfo.startPos;
const int trackOffset = (int)(m_dragItem->scenePos().y() / m_tracksHeight) - m_dragItemInfo.track;
- //kDebug() << "// MOVED SEVERAL CLIPS" << timeOffset.frames(25);
+
QUndoCommand *moveGroup = new QUndoCommand();
moveGroup->setText(i18n("Move group"));
if (timeOffset != GenTime() || trackOffset != 0) {
}
}
new MoveGroupCommand(this, clipsToMove, transitionsToMove, timeOffset, trackOffset, false, moveGroup);
+ updateTrackDuration(-1, moveGroup);
m_commandStack->push(moveGroup);
//QPointF top = group->sceneBoundingRect().topLeft();
items.at(i)->parentItem()->setSelected(true);
}
}
+ resetSelectionGroup();
groupSelectedItems();
} else {
rebuildGroup((AbstractGroupItem *)group);
++itemcount;
}
}
+ updateTrackDuration(-1, resizeCommand);
m_commandStack->push(resizeCommand);
}
} else {
int start = item->cropStart().frames(m_document->fps());
int end = (item->cropStart() + item->cropDuration()).frames(m_document->fps()) - 1;
- if ((val < -50 || val > 150) && item->editedKeyFramePos() != start && item->editedKeyFramePos() != end) {
+ if ((val < -50 || val > 150) && item->editedKeyFramePos() != start && item->editedKeyFramePos() != end && item->keyFrameNumber() > 1) {
//delete keyframe
item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), -1, 0);
} else {
emit displayMessage(i18n("Error removing clip at %1 on track %2", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps())), info.track), ErrorMessage);
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();
else if (transitionCount > 0 && groupCount == 0 && clipCount == 0)
deleteSelected->setText(i18np("Delete selected transition", "Delete selected transitions", transitionCount));
else deleteSelected->setText(i18n("Delete selected items"));
+ updateTrackDuration(-1, deleteSelected);
m_commandStack->push(deleteSelected);
}
clip->setSelected(true);
}
}
-
groupSelectedItems(false, true);
setDocumentModified();
}
if (clip->clipProducer() == clipId) {
ItemInfo info = clip->info();
info.track = m_document->tracksCount() - clip->track();
- if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer())) {
+ if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer(info.track))) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
}
- clip->refreshClip(true);
- clip->update();
+ clip->refreshClip(true, true);
}
}
}
emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(end.startPos.frames(m_document->fps()))), ErrorMessage);
}
if (refresh) m_document->renderer()->doRefresh();
- //kDebug() << " // MOVED CLIP TO: " << end.startPos.frames(25) << ", ITEM START: " << item->startPos().frames(25);
}
void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime offset, const int trackOffset, bool reverseMove)
{
// Group Items
- /*kDebug() << "//GRP MOVE, REVERS:" << reverseMove;
- kDebug() << "// GROUP MOV; OFFSET: " << offset.frames(25) << ", TK OFF: " << trackOffset;*/
resetSelectionGroup();
m_scene->clearSelection();
startClip[i].startPos = startClip.at(i).startPos - offset;
startClip[i].track = startClip.at(i).track - trackOffset;
}
- //kDebug()<<"//LKING FR CLIP AT:"<<startClip.at(i).startPos.frames(25)<<", TK:"<<startClip.at(i).track;
ClipItem *clip = getClipItemAt(startClip.at(i).startPos, startClip.at(i).track);
if (clip) {
clip->setItemLocked(false);
kDebug() << "---------------- ERROR, CANNOT find transition to move... ";// << startPos.x() * m_scale * FRAME_SIZE + 1 << ", " << startPos.y() * m_tracksHeight + m_tracksHeight / 2;
return;
}
- //kDebug() << "---------------- Move TRANSITION FROM: " << startPos.x() << ", END:" << endPos.x() << ",TRACKS: " << oldtrack << " TO " << newtrack;
+
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
- //kDebug()<<"/// RESIZE TRANS START: ("<< startPos.x()<<"x"<< startPos.y()<<") / ("<<endPos.x()<<"x"<< endPos.y()<<")";
+
if (end.endPos - end.startPos == start.endPos - start.startPos) {
// Transition was moved
item->setPos((int) end.startPos.frames(m_document->fps()), (end.track) * m_tracksHeight + 1);
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
+
if (resizeClipStart) {
ItemInfo clipinfo = item->info();
clipinfo.track = m_document->tracksCount() - clipinfo.track;
}
/*
- TODO: cleanup the effect update process
+ * TODO: cleanup the effect update process
*/
ClipItem *clip = static_cast < ClipItem * >(item);
hasParentCommand = true;
} else {
command = new QUndoCommand();
- command->setText(i18n("Resize clip end"));
}
// do this here, too, because otherwise undo won't update the group
ItemInfo info = item->info();
if (item->type() == AVWIDGET) {
+ if (!hasParentCommand) command->setText(i18n("Resize clip end"));
ItemInfo resizeinfo = info;
resizeinfo.track = m_document->tracksCount() - resizeinfo.track;
bool success = m_document->renderer()->mltResizeClipEnd(resizeinfo, resizeinfo.cropDuration);
emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
}
} else if (item->type() == TRANSITIONWIDGET) {
+ if (!hasParentCommand) command->setText(i18n("Resize transition end"));
Transition *transition = static_cast <Transition *>(item);
if (!m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_document->tracksCount() - oldInfo.track), (int)(m_document->tracksCount() - oldInfo.track), transition->transitionEndTrack(), oldInfo.startPos, oldInfo.endPos, info.startPos, info.endPos)) {
// Cannot resize transition
KdenliveSettings::setSnaptopoints(true);
emit displayMessage(i18n("Cannot resize transition"), ErrorMessage);
} else {
- MoveTransitionCommand *moveCommand = new MoveTransitionCommand(this, oldInfo, info, false, command);
- if (command == NULL)
- m_commandStack->push(moveCommand);
+ // Check transition keyframes
+ QDomElement old = transition->toXML();
+ if (transition->updateKeyframes()) {
+ QDomElement xml = transition->toXML();
+ m_document->renderer()->mltUpdateTransition(xml.attribute("tag"), xml.attribute("tag"), xml.attribute("transition_btrack").toInt(), m_document->tracksCount() - xml.attribute("transition_atrack").toInt(), transition->startPos(), transition->endPos(), xml);
+ new EditTransitionCommand(this, transition->track(), transition->startPos(), old, xml, false, command);
+ }
+ new MoveTransitionCommand(this, oldInfo, info, false, command);
}
}
if (item->parentItem() && item->parentItem() != m_selectionGroup)
new RebuildGroupCommand(this, item->info().track, item->startPos(), command);
- if (!hasParentCommand)
+ if (!hasParentCommand) {
+ updateTrackDuration(oldInfo.track, command);
m_commandStack->push(command);
+ }
}
void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
return true;
}
-void CustomTrackView::slotAddGuide()
+void CustomTrackView::slotAddGuide(bool dialog)
{
CommentedTime marker(GenTime(m_cursorPos, m_document->fps()), i18n("Guide"));
- MarkerDialog d(NULL, marker, m_document->timecode(), i18n("Add Guide"), this);
- if (d.exec() != QDialog::Accepted) return;
- if (addGuide(d.newMarker().time(), d.newMarker().comment())) {
- EditGuideCommand *command = new EditGuideCommand(this, GenTime(), QString(), d.newMarker().time(), d.newMarker().comment(), false);
+ if (dialog) {
+ MarkerDialog d(NULL, marker, m_document->timecode(), i18n("Add Guide"), this);
+ if (d.exec() != QDialog::Accepted) return;
+ marker = d.newMarker();
+
+ } else {
+ marker.setComment(m_document->timecode().getDisplayTimecodeFromFrames(m_cursorPos, false));
+ }
+ if (addGuide(marker.time(), marker.comment())) {
+ EditGuideCommand *command = new EditGuideCommand(this, GenTime(), QString(), marker.time(), marker.comment(), false);
m_commandStack->push(command);
}
}
} else emit displayMessage(i18n("Cannot paste transition to selected place"), ErrorMessage);
}
}
+ updateTrackDuration(-1, pasteClips);
m_commandStack->push(pasteClips);
}
}
}
-
for (int i = 0; i < clips.count(); ++i) {
if (clips.at(i)->type() == AVWIDGET) {
ClipItem *item = static_cast < ClipItem *>(clips.at(i));
item->slotSetEndThumb(pix);
}
}
- item->refreshClip(false);
+ item->refreshClip(false, false);
}
}
}
if (d.before_select->currentIndex() == 1)
ix++;
TrackInfo info;
+ info.duration = 0;
info.isMute = false;
info.isLocked = false;
if (d.video_track->isChecked()) {
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;
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 (splitCommand->childCount() > 0)
+ if (splitCommand->childCount()) {
+ updateTrackDuration(-1, splitCommand);
m_commandStack->push(splitCommand);
+ }
}
void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
return;
for (; freetrack > 0; freetrack--) {
- kDebug() << "// CHK DOC TRK:" << freetrack << ", DUR:" << m_document->renderer()->mltTrackDuration(freetrack);
+ //kDebug() << "// CHK DOC TRK:" << freetrack << ", DUR:" << m_document->renderer()->mltTrackDuration(freetrack);
if (m_document->trackInfoAt(freetrack - 1).type == AUDIOTRACK && !m_document->trackInfoAt(freetrack - 1).isLocked) {
- kDebug() << "// CHK DOC TRK:" << freetrack << ", DUR:" << m_document->renderer()->mltTrackDuration(freetrack);
+ //kDebug() << "// CHK DOC TRK:" << freetrack << ", DUR:" << m_document->renderer()->mltTrackDuration(freetrack);
if (m_document->renderer()->mltTrackDuration(freetrack) < start || m_document->renderer()->mltGetSpaceLength(pos, freetrack, false) >= clip->cropDuration().frames(m_document->fps())) {
- kDebug() << "FOUND SPACE ON TRK: " << freetrack;
+ //kDebug() << "FOUND SPACE ON TRK: " << freetrack;
break;
}
}
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);
addCommand->setText(i18n("Insert clip"));
adjustTimelineClips(OVERWRITEEDIT, NULL, info, addCommand);
new AddTimelineClipCommand(this, clip->toXML(), clip->getId(), info, EffectsList(), true, false, true, false, addCommand);
+ updateTrackDuration(info.track, addCommand);
m_commandStack->push(addCommand);
selectClip(true, false, m_selectedTrack, in);
}
}
}
-
emit tracksChanged();
}
+void CustomTrackView::updateTrackDuration(int track, QUndoCommand *command)
+{
+ Q_UNUSED(command);
+
+ QList<int> tracks;
+ if (track >= 0) {
+ tracks << m_document->tracksCount() - track - 1;
+ } else {
+ // negative track number -> update all tracks
+ for (int i = 0; i < m_document->tracksCount(); ++i)
+ tracks << i;
+ }
+ int t, duration;
+ for (int i = 0; i < tracks.count(); ++i) {
+ t = tracks.at(i);
+ // t + 1 because of black background track
+ duration = m_document->renderer()->mltTrackDuration(t + 1);
+ if (duration != m_document->trackDuration(t)) {
+ m_document->setTrackDuration(t, duration);
+
+ // update effects
+ EffectsList effects = m_document->getTrackEffects(t);
+ for (int j = 0; j < effects.count(); ++j) {
+ /* TODO
+ * - lookout for keyframable parameters and update them so all keyframes are in the new range (0 - duration)
+ * - update the effectstack if necessary
+ */
+ }
+ }
+ }
+}
+
+void CustomTrackView::slotRefreshThumbs(const QString &id, bool resetThumbs)
+{
+ QList<QGraphicsItem *> list = scene()->items();
+ ClipItem *clip = NULL;
+ for (int i = 0; i < list.size(); ++i) {
+ if (list.at(i)->type() == AVWIDGET) {
+ clip = static_cast <ClipItem *>(list.at(i));
+ if (clip->clipProducer() == id) {
+ clip->refreshClip(true, resetThumbs);
+ }
+ }
+ }
+}