#include "trackdialog.h"
#include "tracksconfigdialog.h"
#include "configtrackscommand.h"
+#include "rebuildgroupcommand.h"
+#include "razorgroupcommand.h"
+#include "profilesdialog.h"
#include <KDebug>
#include <KLocale>
#include <KUrl>
#include <KIcon>
#include <KCursor>
-#include <KColorScheme>
#include <KMessageBox>
#include <KIO/NetAccess>
m_menuPosition(),
m_blockRefresh(false),
m_selectionGroup(NULL),
- m_selectedTrack(0)
+ m_selectedTrack(0),
+ m_controlModifier(false)
{
if (doc) m_commandStack = doc->commandStack();
else m_commandStack = NULL;
setLineWidth(0);
//setCacheMode(QGraphicsView::CacheBackground);
//setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+ setAutoFillBackground(false);
setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
-
+ 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);
}
}
double newHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22();
- m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), newHeight);
+ m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), newHeight - 1);
for (int i = 0; i < m_guides.count(); i++) {
QLineF l = m_guides.at(i)->line();
emit mousePosition(mappedXPos);
if (event->buttons() & Qt::MidButton) return;
- if (dragMode() == QGraphicsView::RubberBandDrag || (event->modifiers() == Qt::ControlModifier && m_tool != SPACERTOOL)) {
+ if (dragMode() == QGraphicsView::RubberBandDrag || (event->modifiers() == Qt::ControlModifier && m_tool != SPACERTOOL && m_operationMode != RESIZESTART && m_operationMode != RESIZEEND)) {
event->setAccepted(true);
m_moveOpMode = NONE;
QGraphicsView::mouseMoveEvent(event);
} else if (viewport()->width() - pos < 10) {
m_scrollOffset = 30;
m_scrollTimer.start();
- } else if (m_scrollTimer.isActive()) m_scrollTimer.stop();
-
+ } else if (m_scrollTimer.isActive()) {
+ m_scrollTimer.stop();
+ }
} else if (m_operationMode == RESIZESTART && move) {
m_document->renderer()->pause();
- m_dragItem->resizeStart((int)(snappedPos));
+ 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())));
+ } 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();
- m_dragItem->resizeEnd((int)(snappedPos));
+ 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())));
+ } 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);
}
- if (m_visualTip) {
- scene()->removeItem(m_visualTip);
- m_animationTimer->stop();
- delete m_animation;
- m_animation = NULL;
- delete m_visualTip;
- m_visualTip = NULL;
- }
+ removeTipAnimation();
return;
} else if (m_operationMode == MOVEGUIDE) {
- if (m_visualTip) {
- scene()->removeItem(m_visualTip);
- m_animationTimer->stop();
- delete m_animation;
- m_animation = NULL;
- delete m_visualTip;
- m_visualTip = NULL;
- }
+ removeTipAnimation();
QGraphicsView::mouseMoveEvent(event);
return;
} else if (m_operationMode == SPACER && move && m_selectionGroup) {
for (int i = 0; i < children.count(); i++) {
if (children.at(i)->type() == GROUPWIDGET) {
QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
- for (int j = 0; j < subchildren.count(); j++) {
+ for (int j = 0; j < subchildren.count(); j++)
collidingItems.removeAll(subchildren.at(j));
- }
}
collidingItems.removeAll(children.at(i));
}
for (int i = 0; i < children.count(); i++) {
if (children.at(i)->type() == GROUPWIDGET) {
QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
- for (int j = 0; j < subchildren.count(); j++) {
+ for (int j = 0; j < subchildren.count(); j++)
collidingItems.removeAll(subchildren.at(j));
- }
}
collidingItems.removeAll(children.at(i));
}
for (int i = 0; i < children.count(); i++) {
if (children.at(i)->type() == GROUPWIDGET) {
QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
- for (int j = 0; j < subchildren.count(); j++) {
+ for (int j = 0; j < subchildren.count(); j++)
collidingItems.removeAll(subchildren.at(j));
- }
}
collidingItems.removeAll(children.at(i));
}
for (int i = 0; i < children.count(); i++) {
if (children.at(i)->type() == GROUPWIDGET) {
QList<QGraphicsItem *> subchildren = children.at(i)->childItems();
- for (int j = 0; j < subchildren.count(); j++) {
+ for (int j = 0; j < subchildren.count(); j++)
collidingItems.removeAll(subchildren.at(j));
- }
}
collidingItems.removeAll(children.at(i));
}
QGraphicsView::mouseMoveEvent(event);
return;
} else {
- if (m_visualTip) {
- scene()->removeItem(m_visualTip);
- m_animationTimer->stop();
- delete m_animation;
- m_animation = NULL;
- delete m_visualTip;
- m_visualTip = NULL;
- }
+ removeTipAnimation();
}
m_moveOpMode = opMode;
+ setTipAnimation(clip, opMode, size);
if (opMode == MOVE) {
setCursor(Qt::OpenHandCursor);
+ if (item->type() == AVWIDGET) {
+ ClipItem *ci = static_cast <ClipItem *>(item);
+ QString 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) {
+ AbstractGroupItem *parent = static_cast <AbstractGroupItem *>(clip->parentItem());
+ if (clip->parentItem() == m_selectionGroup)
+ message.append(i18n(" Selection duration:"));
+ else
+ message.append(i18n(" Group duration:"));
+ message.append(m_document->timecode().getDisplayTimecode(parent->duration(), KdenliveSettings::frametimecode()));
+ if (parent->parentItem() && parent->parentItem()->type() == GROUPWIDGET) {
+ AbstractGroupItem *parent2 = static_cast <AbstractGroupItem *>(parent->parentItem());
+ 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 (m_visualTip == NULL) {
- QRectF rect = clip->sceneBoundingRect();
- QPolygon polygon;
- polygon << QPoint(0, - size * 2);
- polygon << QPoint(size * 2, 0);
- polygon << QPoint(0, size * 2);
- polygon << QPoint(0, - size * 2);
-
- m_visualTip = new QGraphicsPolygonItem(polygon);
- ((QGraphicsPolygonItem*) m_visualTip)->setBrush(m_tipColor);
- ((QGraphicsPolygonItem*) m_visualTip)->setPen(m_tipPen);
- m_visualTip->setPos(rect.x(), rect.y() + rect.height() / 2);
- m_visualTip->setFlags(QGraphicsItem::ItemIgnoresTransformations);
- m_visualTip->setZValue(100);
- m_animation = new QGraphicsItemAnimation;
- m_animation->setItem(m_visualTip);
- m_animation->setTimeLine(m_animationTimer);
- m_animation->setScaleAt(.5, 2, 1);
- m_animation->setScaleAt(1, 1, 1);
- scene()->addItem(m_visualTip);
- m_animationTimer->start();
- }
+ 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);
} else if (opMode == RESIZEEND) {
setCursor(KCursor("right_side", Qt::SizeHorCursor));
- if (m_visualTip == NULL) {
- QRectF rect = clip->sceneBoundingRect();
- QPolygon polygon;
- polygon << QPoint(0, - size * 2);
- polygon << QPoint(- size * 2, 0);
- polygon << QPoint(0, size * 2);
- polygon << QPoint(0, - size * 2);
-
- m_visualTip = new QGraphicsPolygonItem(polygon);
- ((QGraphicsPolygonItem*) m_visualTip)->setBrush(m_tipColor);
- ((QGraphicsPolygonItem*) m_visualTip)->setPen(m_tipPen);
- m_visualTip->setFlags(QGraphicsItem::ItemIgnoresTransformations);
- m_visualTip->setPos(rect.right(), rect.y() + rect.height() / 2);
- m_visualTip->setZValue(100);
- m_animation = new QGraphicsItemAnimation;
- m_animation->setItem(m_visualTip);
- m_animation->setTimeLine(m_animationTimer);
- m_animation->setScaleAt(.5, 2, 1);
- m_animation->setScaleAt(1, 1, 1);
- scene()->addItem(m_visualTip);
- m_animationTimer->start();
- }
- } else if (opMode == FADEIN) {
- if (m_visualTip == NULL) {
- ClipItem *item = (ClipItem *) clip;
- QRectF rect = clip->sceneBoundingRect();
- m_visualTip = new QGraphicsEllipseItem(-size, -size, size * 2, size * 2);
- ((QGraphicsEllipseItem*) m_visualTip)->setBrush(m_tipColor);
- ((QGraphicsEllipseItem*) m_visualTip)->setPen(m_tipPen);
- m_visualTip->setPos(rect.x() + item->fadeIn(), rect.y());
- m_visualTip->setFlags(QGraphicsItem::ItemIgnoresTransformations);
- m_visualTip->setZValue(100);
- m_animation = new QGraphicsItemAnimation;
- m_animation->setItem(m_visualTip);
- m_animation->setTimeLine(m_animationTimer);
- m_animation->setScaleAt(.5, 2, 2);
- m_animation->setScaleAt(1, 1, 1);
- scene()->addItem(m_visualTip);
- m_animationTimer->start();
- }
+ 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);
+ } else if (opMode == FADEIN || opMode == FADEOUT) {
setCursor(Qt::PointingHandCursor);
- } else if (opMode == FADEOUT) {
- if (m_visualTip == NULL) {
- ClipItem *item = (ClipItem *) clip;
- QRectF rect = clip->sceneBoundingRect();
- m_visualTip = new QGraphicsEllipseItem(-size, -size, size * 2, size * 2);
- ((QGraphicsEllipseItem*) m_visualTip)->setBrush(m_tipColor);
- ((QGraphicsEllipseItem*) m_visualTip)->setPen(m_tipPen);
- m_visualTip->setPos(rect.right() - item->fadeOut(), rect.y());
- m_visualTip->setFlags(QGraphicsItem::ItemIgnoresTransformations);
- m_visualTip->setZValue(100);
- m_animation = new QGraphicsItemAnimation;
- m_animation->setItem(m_visualTip);
- m_animation->setTimeLine(m_animationTimer);
- m_animation->setScaleAt(.5, 2, 2);
- m_animation->setScaleAt(1, 1, 1);
- scene()->addItem(m_visualTip);
- m_animationTimer->start();
- }
- setCursor(Qt::PointingHandCursor);
- } else if (opMode == TRANSITIONSTART) {
- if (m_visualTip == NULL) {
- QRectF rect = clip->sceneBoundingRect();
- QPolygon polygon;
- polygon << QPoint(0, - size * 2);
- polygon << QPoint(size * 2, 0);
- polygon << QPoint(0, 0);
- polygon << QPoint(0, - size * 2);
-
- m_visualTip = new QGraphicsPolygonItem(polygon);
- ((QGraphicsPolygonItem*) m_visualTip)->setBrush(m_tipColor);
- ((QGraphicsPolygonItem*) m_visualTip)->setPen(m_tipPen);
- m_visualTip->setPos(rect.x(), rect.bottom());
- m_visualTip->setFlags(QGraphicsItem::ItemIgnoresTransformations);
- m_visualTip->setZValue(100);
- m_animation = new QGraphicsItemAnimation;
- m_animation->setItem(m_visualTip);
- m_animation->setTimeLine(m_animationTimer);
- m_animation->setScaleAt(.5, 2, 2);
- m_animation->setScaleAt(1, 1, 1);
- scene()->addItem(m_visualTip);
- m_animationTimer->start();
- }
- setCursor(Qt::PointingHandCursor);
- } else if (opMode == TRANSITIONEND) {
- if (m_visualTip == NULL) {
- QRectF rect = clip->sceneBoundingRect();
- QPolygon polygon;
- polygon << QPoint(0, - size * 2);
- polygon << QPoint(- size * 2, 0);
- polygon << QPoint(0, 0);
- polygon << QPoint(0, - size * 2);
-
- m_visualTip = new QGraphicsPolygonItem(polygon);
- ((QGraphicsPolygonItem*) m_visualTip)->setBrush(m_tipColor);
- ((QGraphicsPolygonItem*) m_visualTip)->setPen(m_tipPen);
- m_visualTip->setPos(rect.right(), rect.bottom());
- m_visualTip->setFlags(QGraphicsItem::ItemIgnoresTransformations);
- m_visualTip->setZValue(100);
- m_animation = new QGraphicsItemAnimation;
- m_animation->setItem(m_visualTip);
- m_animation->setTimeLine(m_animationTimer);
- m_animation->setScaleAt(.5, 2, 2);
- m_animation->setScaleAt(1, 1, 1);
- scene()->addItem(m_visualTip);
- m_animationTimer->start();
- }
+ emit displayMessage(i18n("Drag to add or resize a fade effect."), InformationMessage);
+ } else if (opMode == TRANSITIONSTART || opMode == TRANSITIONEND) {
setCursor(Qt::PointingHandCursor);
+ emit displayMessage(i18n("Click to add a transition."), InformationMessage);
} 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);
}
} // no clip under mouse
else if (m_tool == RAZORTOOL) {
m_moveOpMode = opMode;
setCursor(Qt::SplitHCursor);
} else {
- if (m_visualTip) {
- scene()->removeItem(m_visualTip);
- m_animationTimer->stop();
- delete m_animation;
- m_animation = NULL;
- delete m_visualTip;
- m_visualTip = NULL;
-
- }
+ removeTipAnimation();
setCursor(Qt::ArrowCursor);
if (event->buttons() != Qt::NoButton && event->modifiers() == Qt::NoModifier) {
QGraphicsView::mouseMoveEvent(event);
}
#if QT_VERSION >= 0x040600
// Add shadow to dragged item, currently disabled because of painting artifacts
- //TODO:Â re-enable when fixed
+ //TODO: re-enable when fixed
/*QGraphicsDropShadowEffect *eff = new QGraphicsDropShadowEffect();
eff->setBlurRadius(5);
eff->setOffset(3, 3);
// Razor tool
if (m_tool == RAZORTOOL && m_dragItem) {
+ GenTime cutPos = GenTime((int)(mapToScene(event->pos()).x()), m_document->fps());
if (m_dragItem->type() == TRANSITIONWIDGET) {
emit displayMessage(i18n("Cannot cut a transition"), ErrorMessage);
- event->accept();
- m_dragItem = NULL;
- return;
- } else if (m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
- emit displayMessage(i18n("Cannot cut a clip in a group"), ErrorMessage);
- event->accept();
- m_dragItem = NULL;
- return;
+ } else {
+ m_document->renderer()->pause();
+ if (m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
+ razorGroup((AbstractGroupItem *)m_dragItem->parentItem(), cutPos);
+ } else {
+ AbstractClipItem *clip = static_cast <AbstractClipItem *>(m_dragItem);
+ RazorClipCommand* command = new RazorClipCommand(this, clip->info(), cutPos);
+ m_commandStack->push(command);
+ }
+ setDocumentModified();
}
- AbstractClipItem *clip = static_cast <AbstractClipItem *>(m_dragItem);
- RazorClipCommand* command = new RazorClipCommand(this, clip->info(), GenTime((int)(mapToScene(event->pos()).x()), m_document->fps()));
- m_document->renderer()->pause();
- m_commandStack->push(command);
- setDocumentModified();
m_dragItem = NULL;
event->accept();
return;
}
bool itemSelected = false;
- if (m_dragItem->isSelected()) itemSelected = true;
- else if (m_dragItem->parentItem() && m_dragItem->parentItem()->isSelected()) itemSelected = true;
- else if (dragGroup && dragGroup->isSelected()) itemSelected = true;
+ if (m_dragItem->isSelected())
+ itemSelected = true;
+ else if (m_dragItem->parentItem() && m_dragItem->parentItem()->isSelected())
+ itemSelected = true;
+ else if (dragGroup && dragGroup->isSelected())
+ itemSelected = true;
if (event->modifiers() == Qt::ControlModifier || itemSelected == false) {
if (event->modifiers() != Qt::ControlModifier) {
dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
}
bool selected = !m_dragItem->isSelected();
- if (dragGroup) dragGroup->setSelected(selected);
- else m_dragItem->setSelected(selected);
+ if (dragGroup)
+ dragGroup->setSelected(selected);
+ else
+ m_dragItem->setSelected(selected);
groupSelectedItems();
ClipItem *clip = static_cast <ClipItem *>(m_dragItem);
if (m_dragItem && m_dragItem->type() == AVWIDGET && !m_dragItem->isItemLocked()) {
ClipItem *selected = static_cast <ClipItem*>(m_dragItem);
emit clipItemSelected(selected);
- } else emit clipItemSelected(NULL);
+ } else {
+ emit clipItemSelected(NULL);
+ }
}
// If clicked item is selected, allow move
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()));
+ m_controlModifier = (event->modifiers() == Qt::ControlModifier);
// Update snap points
if (m_selectionGroup == NULL) {
- if (m_operationMode == RESIZEEND || m_operationMode == RESIZESTART) updateSnapPoints(NULL);
- else updateSnapPoints(m_dragItem);
+ if (m_operationMode == RESIZEEND || m_operationMode == RESIZESTART)
+ updateSnapPoints(NULL);
+ else
+ updateSnapPoints(m_dragItem);
} else {
QList <GenTime> offsetList;
QList<QGraphicsItem *> children = m_selectionGroup->childItems();
info.endPos = transitionClip->endPos();
} else {
GenTime transitionDuration(65, m_document->fps());
- if (m_dragItem->cropDuration() < transitionDuration) info.endPos = m_dragItem->endPos();
- else info.endPos = info.startPos + transitionDuration;
+ if (m_dragItem->cropDuration() < transitionDuration)
+ info.endPos = m_dragItem->endPos();
+ else
+ info.endPos = info.startPos + transitionDuration;
}
if (info.endPos == info.startPos) info.endPos = info.startPos + GenTime(65, m_document->fps());
// Check there is no other transition at that place
QGraphicsView::mousePressEvent(event);
}
+void CustomTrackView::rebuildGroup(int childTrack, GenTime childPos)
+{
+ const QPointF p((int)childPos.frames(m_document->fps()), childTrack * m_tracksHeight + m_tracksHeight / 2);
+ QList<QGraphicsItem *> list = scene()->items(p);
+ AbstractGroupItem *group = NULL;
+ for (int i = 0; i < list.size(); i++) {
+ if (!list.at(i)->isEnabled()) continue;
+ if (list.at(i)->type() == GROUPWIDGET) {
+ group = static_cast <AbstractGroupItem *>(list.at(i));
+ break;
+ }
+ }
+ rebuildGroup(group);
+}
+
+void CustomTrackView::rebuildGroup(AbstractGroupItem *group)
+{
+ if (group) {
+ resetSelectionGroup(false);
+ m_scene->clearSelection();
+
+ QList <QGraphicsItem *> children = group->childItems();
+ m_document->clipManager()->removeGroup(group);
+ scene()->destroyItemGroup(group);
+ for (int i = 0; i < children.count(); i++)
+ children.at(i)->setSelected(true);
+ groupSelectedItems(false, true);
+ }
+}
+
void CustomTrackView::resetSelectionGroup(bool selectItems)
{
if (m_selectionGroup) {
scene()->addItem(newGroup);
- // CHeck if we are trying to include a group in a group
+ // Check if we are trying to include a group in a group
QList <AbstractGroupItem *> groups;
for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->type() == GROUPWIDGET && !groups.contains(static_cast<AbstractGroupItem *>(selection.at(i)))) {
+ if (selection.at(i)->type() == GROUPWIDGET && !groups.contains(static_cast<AbstractGroupItem *>(selection.at(i))))
groups.append(static_cast<AbstractGroupItem *>(selection.at(i)));
- } else if (selection.at(i)->parentItem() && !groups.contains(static_cast<AbstractGroupItem *>(selection.at(i)->parentItem()))) groups.append(static_cast<AbstractGroupItem *>(selection.at(i)->parentItem()));
+ else if (selection.at(i)->parentItem() && !groups.contains(static_cast<AbstractGroupItem *>(selection.at(i)->parentItem())))
+ groups.append(static_cast<AbstractGroupItem *>(selection.at(i)->parentItem()));
}
if (!groups.isEmpty()) {
// ungroup previous groups
if (m_dragItem && m_dragItem->hasKeyFrames()) {
/*if (m_moveOpMode == KEYFRAME) {
// user double clicked on a keyframe, open edit dialog
- //TODO:Â update for effects with several values per keyframe
+ //TODO: update for effects with several values per keyframe
QDialog d(parentWidget());
Ui::KeyFrameDialog_UI view;
view.setupUi(&d);
if (m_scene->selectedItems().count() == 1) {
item = static_cast <AbstractClipItem *>(m_scene->selectedItems().at(0));
} else {
- if (m_scene->selectedItems().empty()) {
+ if (m_scene->selectedItems().empty())
emit displayMessage(i18n("Cannot find clip to edit"), ErrorMessage);
- } else {
+ else
emit displayMessage(i18n("Cannot edit the duration of multiple items"), ErrorMessage);
- }
return;
}
}
+ if (!item) {
+ emit displayMessage(i18n("Cannot find clip to edit"), ErrorMessage);
+ return;
+ }
+
+ if (item->type() == GROUPWIDGET || (item->parentItem() && item->parentItem()->type() == GROUPWIDGET)) {
+ emit displayMessage(i18n("Cannot edit an item in a group"), ErrorMessage);
+ return;
+ }
+
if (!item->isItemLocked()) {
GenTime minimum;
GenTime maximum;
- if (item->type() == TRANSITIONWIDGET) {
+ if (item->type() == TRANSITIONWIDGET)
getTransitionAvailableSpace(item, minimum, maximum);
- } else {
+ else
getClipAvailableSpace(item, minimum, maximum);
- }
- //kDebug()<<"// GOT MOVE POS: "<<minimum.frames(25)<<" - "<<maximum.frames(25);
+
ClipDurationDialog d(item, m_document->timecode(), minimum, maximum, this);
if (d.exec() == QDialog::Accepted) {
+ ItemInfo clipInfo = item->info();
+ ItemInfo startInfo = clipInfo;
if (item->type() == TRANSITIONWIDGET) {
// move & resize transition
- ItemInfo startInfo;
- startInfo.startPos = item->startPos();
- startInfo.endPos = item->endPos();
- startInfo.track = item->track();
- ItemInfo endInfo;
- endInfo.startPos = d.startPos();
- endInfo.endPos = endInfo.startPos + d.duration();
- endInfo.track = item->track();
- MoveTransitionCommand *command = new MoveTransitionCommand(this, startInfo, endInfo, true);
+ clipInfo.startPos = d.startPos();
+ clipInfo.endPos = clipInfo.startPos + d.duration();
+ clipInfo.track = item->track();
+ MoveTransitionCommand *command = new MoveTransitionCommand(this, startInfo, clipInfo, true);
m_commandStack->push(command);
} else {
// move and resize clip
QUndoCommand *moveCommand = new QUndoCommand();
moveCommand->setText(i18n("Edit clip"));
- ItemInfo clipInfo = item->info();
if (d.duration() < item->cropDuration() || d.cropStart() != clipInfo.cropStart) {
// duration was reduced, so process it first
- ItemInfo startInfo = clipInfo;
clipInfo.endPos = clipInfo.startPos + d.duration();
clipInfo.cropStart = d.cropStart();
new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
}
if (d.startPos() != clipInfo.startPos) {
- ItemInfo startInfo = clipInfo;
+ 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
- ItemInfo startInfo = clipInfo;
+ startInfo = clipInfo;
clipInfo.endPos = clipInfo.startPos + d.duration();
clipInfo.cropStart = d.cropStart();
new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
m_commandStack->push(moveCommand);
}
}
- } else emit displayMessage(i18n("Item is locked"), ErrorMessage);
+ } else {
+ emit displayMessage(i18n("Item is locked"), ErrorMessage);
+ }
}
-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);
+ /*ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track);
if (clip) {
clip->setKeyframes(index, keyframes);
updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(index), index, false);
- } else emit displayMessage(i18n("Cannot find clip with keyframe"), ErrorMessage);
+ } else emit displayMessage(i18n("Cannot find clip with keyframe"), ErrorMessage);*/
}
}
bool success = true;
for (int i = 0; i < clip->effectsCount(); i++) {
- if (!m_document->renderer()->mltAddEffect(track, pos, clip->getEffectArgs(clip->effectAt(i)), false)) success = false;
+ if (!m_document->renderer()->mltAddEffect(track, pos, getEffectArgs(clip->effectAt(i)), false)) success = false;
}
if (!success) emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage);
m_document->renderer()->doRefresh();
void CustomTrackView::addEffect(int track, GenTime pos, QDomElement effect)
{
+ if (pos < GenTime()) {
+ // Add track effect
+ m_document->addTrackEffect(track - 1, effect);
+ m_document->renderer()->mltAddTrackEffect(track, getEffectArgs(effect));
+ emit updateTrackEffectState(track - 1);
+ emit showTrackEffects(track, m_document->trackInfoAt(track - 1));
+ return;
+ }
ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), m_document->tracksCount() - track);
if (clip) {
// Special case: speed effect
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)) {
+ 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;
+ }
// Special case: speed effect
if (effect.attribute("id") == "speed") {
ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), m_document->tracksCount() - track);
if (effect.attribute("type") == "audio") {
// Don't add audio effects on video clips
if (item->isVideoOnly() || (item->clipType() != AUDIO && item->clipType() != AV && item->clipType() != PLAYLIST)) {
- emit displayMessage(i18n("Cannot add an audio effect to this clip"), ErrorMessage);
+ /* do not show error message when item is part of a group as the user probably knows what he does then
+ * and the message is annoying when working with the split audio feature */
+ if (!item->parentItem() || item->parentItem() == m_selectionGroup)
+ emit displayMessage(i18n("Cannot add an audio effect to this clip"), ErrorMessage);
continue;
}
- } else if (effect.hasAttribute("type") == false) {
+ } else if (effect.attribute("type") == "video" || !effect.hasAttribute("type")) {
// Don't add video effect on audio clips
if (item->isAudioOnly() || item->clipType() == AUDIO) {
- emit displayMessage(i18n("Cannot add a video effect to this clip"), ErrorMessage);
+ /* do not show error message when item is part of a group as the user probably knows what he does then
+ * and the message is annoying when working with the split audio feature */
+ if (!item->parentItem() || item->parentItem() == m_selectionGroup)
+ emit displayMessage(i18n("Cannot add a video effect to this clip"), ErrorMessage);
continue;
}
}
if (item->isItemLocked()) {
continue;
}
+
if (effect.attribute("id") == "freeze" && m_cursorPos > item->startPos().frames(m_document->fps()) && m_cursorPos < item->endPos().frames(m_document->fps())) {
item->initEffect(effect, m_cursorPos - item->startPos().frames(m_document->fps()));
- } else item->initEffect(effect);
+ } else {
+ item->initEffect(effect);
+ }
+
if (effect.attribute("tag") == "ladspa") {
QString ladpsaFile = m_document->getLadspaFile();
initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
} else delete effectCommand;
}
-void CustomTrackView::slotDeleteEffect(ClipItem *clip, QDomElement effect, bool affectGroup)
+void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement effect, bool affectGroup)
{
+ if (clip == NULL) {
+ // delete track effect
+ AddEffectCommand *command = new AddEffectCommand(this, track, GenTime(-1), effect, false);
+ m_commandStack->push(command);
+ setDocumentModified();
+ return;
+ }
if (affectGroup && clip->parentItem() && clip->parentItem() == m_selectionGroup) {
//clip is in a group, also remove the effect in other clips of the group
QList<QGraphicsItem *> items = m_selectionGroup->childItems();
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
return;
}
- ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), m_document->tracksCount() - track);
QDomElement effect = insertedEffect.cloneNode().toElement();
+ //kDebug() << "// update effect ix: " << effect.attribute("kdenlive_ix")<<", TRACK: "<<track;
+ 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);
+ 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);
+ emit updateTrackEffectState(track);
+ setDocumentModified();
+ return;
+
+ }
+ ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), m_document->tracksCount() - track);
if (clip) {
// Special case: speed effect
if (effect.attribute("id") == "speed") {
return;
}
- EffectsParameterList effectParams = clip->getEffectArgs(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);
- effectParams = clip->getEffectArgs(effect);
+ effectParams = getEffectArgs(effect);
}
if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams))
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
void CustomTrackView::moveEffect(int track, GenTime pos, int oldPos, int newPos)
{
+ if (pos < GenTime()) {
+ // Moving track effect
+ QDomElement act = m_document->getTrackEffect(m_document->tracksCount() - track - 1, newPos - 1);
+ QDomElement before = m_document->getTrackEffect(m_document->tracksCount() - track - 1, oldPos - 1);
+
+ if (!act.isNull() && !before.isNull()) {
+ m_document->setTrackEffect(m_document->tracksCount() - track - 1, oldPos - 1, act);
+ m_document->setTrackEffect(m_document->tracksCount() - track - 1, newPos - 1, before);
+ m_document->renderer()->mltMoveEffect(m_document->tracksCount() - track, pos, oldPos, newPos);
+ emit showTrackEffects(m_document->tracksCount() - track, m_document->trackInfoAt(m_document->tracksCount() - track - 1));
+ } else emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
+ return;
+ }
ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), m_document->tracksCount() - track);
if (clip && !clip->effectAt(newPos - 1).isNull() && !clip->effectAt(oldPos - 1).isNull()) {
QDomElement act = clip->effectAt(newPos - 1);
} else emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
}
-void CustomTrackView::slotChangeEffectState(ClipItem *clip, int effectPos, bool disable)
+void CustomTrackView::slotChangeEffectState(ClipItem *clip, int track, int effectPos, bool disable)
{
- QDomElement effect = clip->effectAt(effectPos);
+ EditEffectCommand *command;
+ QDomElement effect;
+ if (clip == NULL) effect = m_document->getTrackEffect(track - 1, effectPos);
+ else effect = clip->effectAt(effectPos);
QDomElement oldEffect = effect.cloneNode().toElement();
-
effect.setAttribute("disable", (int) disable);
- EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldEffect, effect, effectPos, true);
+
+
+ if (clip == NULL) {
+ // editing track effect
+ command = new EditEffectCommand(this, m_document->tracksCount() - track, GenTime(-1), oldEffect, effect, effectPos, true);
+ } else {
+ command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldEffect, effect, effectPos, true);
+ }
m_commandStack->push(command);
setDocumentModified();;
}
-void CustomTrackView::slotChangeEffectPosition(ClipItem *clip, int currentPos, int newPos)
+void CustomTrackView::slotChangeEffectPosition(ClipItem *clip, int track, int currentPos, int newPos)
{
- MoveEffectCommand *command = new MoveEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), currentPos, newPos);
+ MoveEffectCommand *command;
+ if (clip == NULL) {
+ // editing track effect
+ command = new MoveEffectCommand(this, m_document->tracksCount() - track, GenTime(-1), currentPos, newPos);
+ } else command = new MoveEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), currentPos, newPos);
m_commandStack->push(command);
setDocumentModified();
}
-void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect, int ix)
+void CustomTrackView::slotUpdateClipEffect(ClipItem *clip, int track, QDomElement oldeffect, QDomElement effect, int ix)
+{
+ EditEffectCommand *command;
+ if (clip) command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldeffect, effect, ix, true);
+ else command = new EditEffectCommand(this, m_document->tracksCount() - track, GenTime(-1), oldeffect, effect, ix, true);
+ m_commandStack->push(command);
+}
+
+void CustomTrackView::slotUpdateClipRegion(ClipItem *clip, int ix, QString region)
{
+ QDomElement effect = clip->getEffectAt(ix);
+ QDomElement oldeffect = effect.cloneNode().toElement();
+ effect.setAttribute("region", region);
EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldeffect, effect, ix, true);
m_commandStack->push(command);
}
ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
if (!item || cutTime >= item->endPos() || cutTime <= item->startPos()) {
emit displayMessage(i18n("Cannot find clip to cut"), ErrorMessage);
- if (item) kDebug() << "///////// ERROR CUTTING CLIP : (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), INFO: (" << info.startPos.frames(25) << "-" << info.endPos.frames(25) << ")" << ", CUT: " << cutTime.frames(25);
- else kDebug() << "/// ERROR NO CLIP at: " << info.startPos.frames(m_document->fps()) << ", track: " << info.track;
+ if (item)
+ kDebug() << "///////// ERROR CUTTING CLIP : (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), INFO: (" << info.startPos.frames(25) << "-" << info.endPos.frames(25) << ")" << ", CUT: " << cutTime.frames(25);
+ else
+ kDebug() << "/// ERROR NO CLIP at: " << info.startPos.frames(m_document->fps()) << ", track: " << info.track;
m_blockRefresh = false;
return NULL;
}
- if (item->parentItem()) {
- // Item is part of a group, reset group
- resetSelectionGroup();
- }
+
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);
}
item->resizeEnd(cutPos);
scene()->addItem(dup);
- if (item->checkKeyFrames()) slotRefreshEffects(item);
- if (dup->checkKeyFrames()) slotRefreshEffects(dup);
+ if (item->checkKeyFrames())
+ slotRefreshEffects(item);
+ if (dup->checkKeyFrames())
+ slotRefreshEffects(dup);
+
+ updatePanZoom(item);
+ updatePanZoom(dup, cutTime - item->startPos());
+
item->baseClip()->addReference();
m_document->updateClip(item->baseClip()->getId());
setDocumentModified();
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
+ } else {
emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
+ }
KdenliveSettings::setSnaptopoints(snap);
return item;
-
}
//QTimer::singleShot(3000, this, SLOT(slotEnableRefresh()));
}
return;
}
bool force = false;
- if (oldTransition.attribute("transition_atrack") != transition.attribute("transition_atrack") || oldTransition.attribute("transition_btrack") != transition.attribute("transition_btrack")) force = true;
+ if (oldTransition.attribute("transition_atrack") != transition.attribute("transition_atrack") || oldTransition.attribute("transition_btrack") != transition.attribute("transition_btrack"))
+ force = true;
m_document->renderer()->mltUpdateTransition(oldTransition.attribute("tag"), transition.attribute("tag"), transition.attribute("transition_btrack").toInt(), m_document->tracksCount() - transition.attribute("transition_atrack").toInt(), item->startPos(), item->endPos(), transition, force);
//kDebug() << "ORIGINAL TRACK: "<< oldTransition.attribute("transition_btrack") << ", NEW TRACK: "<<transition.attribute("transition_btrack");
item->setTransitionParameters(transition);
if (isLocked) item->setItemLocked(true);
ItemInfo clipInfo = info;
clipInfo.track = m_document->tracksCount() - item->track();
- if (m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->producer(item->track()), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT) == -1) {
+
+ int worked = m_document->renderer()->mltInsertClip(clipInfo, item->xml(), item->baseClip()->producer(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);
continue;
setDocumentModified();
/*
- //Â debug info
+ // debug info
QRectF rect(0, 1 * m_tracksHeight + m_tracksHeight / 2, sceneRect().width(), 2);
QList<QGraphicsItem *> selection = m_scene->items(rect);
QStringList timelineList;
*/
m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
- if (items.count() > 1) groupSelectedItems(true);
+ if (items.count() > 1) {
+ groupSelectedItems(true);
+ } else if (items.count() == 1) {
+ m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
+ emit clipItemSelected((ClipItem*)m_dragItem);
+ }
event->setDropAction(Qt::MoveAction);
event->accept();
} else QGraphicsView::dropEvent(event);
if (clip->speed() != 1.0) continue;
// 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;
- if (clip->isAudioOnly()) prod = clip->baseClip()->audioProducer(clipinfo.track);
- else if (clip->isVideoOnly()) prod = clip->baseClip()->videoProducer();
- else prod = clip->baseClip()->producer(clipinfo.track);
+ 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) {
// problem updating clip
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", clipinfo.startPos.frames(m_document->fps()), clipinfo.track), ErrorMessage);
l.setP2(QPointF(l.x2(), maxHeight));
m_guides.at(i)->setLine(l);
}
- m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight);
+
+ m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight - 1);
setSceneRect(0, 0, sceneRect().width(), m_tracksHeight * m_document->tracksCount());
viewport()->update();
- emit tracksChanged();
//QTimer::singleShot(500, this, SIGNAL(trackHeightChanged()));
//setFixedHeight(50 * m_tracksCount);
+
+ updateTrackNames(ix, true);
}
void CustomTrackView::removeTrack(int ix)
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) {
- Mlt::Producer *prod;
- if (clip->isAudioOnly()) prod = clip->baseClip()->audioProducer(clipinfo.track);
- else if (clip->isVideoOnly()) prod = clip->baseClip()->videoProducer();
- else prod = clip->baseClip()->producer(clipinfo.track);
+ 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)) {
emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", clipinfo.startPos.frames(m_document->fps()), clipinfo.track), ErrorMessage);
}
l.setP2(QPointF(l.x2(), maxHeight));
m_guides.at(i)->setLine(l);
}
- m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight);
+ m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight - 1);
setSceneRect(0, 0, sceneRect().width(), m_tracksHeight * m_document->tracksCount());
m_selectedTrack = qMin(m_selectedTrack, m_document->tracksCount() - 1);
viewport()->update();
- emit tracksChanged();
+
+ updateTrackNames(ix, false);
//QTimer::singleShot(500, this, SIGNAL(trackHeightChanged()));
}
for (int i = 0; i < trackInfos.count(); ++i) {
m_document->setTrackType(i, trackInfos.at(i));
m_document->renderer()->mltChangeTrackState(i + 1, m_document->trackInfoAt(i).isMute, m_document->trackInfoAt(i).isBlind);
+ 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)
}
-void CustomTrackView::lockTrack(int ix, bool lock)
+void CustomTrackView::lockTrack(int ix, bool lock, bool requestUpdate)
{
int tracknumber = m_document->tracksCount() - ix - 1;
m_document->switchTrackLock(tracknumber, lock);
- emit doTrackLock(ix, lock);
+ if (requestUpdate)
+ emit doTrackLock(ix, lock);
AbstractClipItem *clip = NULL;
QList<QGraphicsItem *> selection = m_scene->items(0, ix * m_tracksHeight + m_tracksHeight / 2, sceneRect().width(), m_tracksHeight / 2 - 2);
for (int i = 0; i < selection.count(); i++) {
- if (selection.at(i)->type() != AVWIDGET && selection.at(i)->type() != TRANSITIONWIDGET) continue;
- if (selection.at(i)->isSelected()) {
- if (selection.at(i)->type() == AVWIDGET) emit clipItemSelected(NULL);
- else emit transitionItemSelected(NULL);
+ if (selection.at(i)->type() == GROUPWIDGET && (AbstractGroupItem *)selection.at(i) != m_selectionGroup) {
+ if (selection.at(i)->parentItem() && m_selectionGroup) {
+ selection.removeAll((QGraphicsItem*)m_selectionGroup);
+ resetSelectionGroup();
+ }
+
+ bool changeGroupLock = true;
+ bool hasClipOnTrack = false;
+ QList <QGraphicsItem *> children = selection.at(i)->childItems();
+ for (int j = 0; j < children.count(); ++j) {
+ if (children.at(j)->isSelected()) {
+ if (children.at(j)->type() == AVWIDGET)
+ emit clipItemSelected(NULL);
+ else if (children.at(j)->type() == TRANSITIONWIDGET)
+ emit transitionItemSelected(NULL);
+ else
+ continue;
+ }
+
+ AbstractClipItem * child = static_cast <AbstractClipItem *>(children.at(j));
+ if (child == m_dragItem)
+ m_dragItem = NULL;
+
+ // only unlock group, if it is not locked by another track too
+ if (!lock && child->track() != ix && m_document->trackInfoAt(m_document->tracksCount() - child->track() - 1).isLocked)
+ changeGroupLock = false;
+
+ // only (un-)lock if at least one clip is on the track
+ if (child->track() == ix)
+ hasClipOnTrack = true;
+ }
+ if (changeGroupLock && hasClipOnTrack)
+ ((AbstractGroupItem*)selection.at(i))->setItemLocked(lock);
+ } else if((selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET)) {
+ if (selection.at(i)->parentItem()) {
+ if (selection.at(i)->parentItem() == m_selectionGroup) {
+ selection.removeAll((QGraphicsItem*)m_selectionGroup);
+ resetSelectionGroup();
+ } else {
+ // groups are handled separately
+ continue;
+ }
+ }
+
+ if (selection.at(i)->isSelected()) {
+ if (selection.at(i)->type() == AVWIDGET)
+ emit clipItemSelected(NULL);
+ else
+ emit transitionItemSelected(NULL);
+ }
+ clip = static_cast <AbstractClipItem *>(selection.at(i));
+ clip->setItemLocked(lock);
+ if (clip == m_dragItem)
+ m_dragItem = NULL;
}
- clip = static_cast <AbstractClipItem *>(selection.at(i));
- clip->setItemLocked(lock);
- if (clip == m_dragItem)
- m_dragItem = NULL;
}
kDebug() << "NEXT TRK STATE: " << m_document->trackInfoAt(tracknumber).isLocked;
viewport()->update();
pos = GenTime((int)(mapToScene(m_menuPosition).x()), m_document->fps());
track = (int)(mapToScene(m_menuPosition).y() / m_tracksHeight) + 1;
}
- SpacerDialog d(GenTime(65, m_document->fps()), m_document->timecode(), track, m_document->tracksCount() + 1, this);
+ SpacerDialog d(GenTime(65, m_document->fps()), m_document->timecode(), track, m_document->tracksList(), this);
if (d.exec() != QDialog::Accepted) return;
GenTime spaceDuration = d.selectedDuration();
track = d.selectedTrack();
- // TODO: Make "All Tracks" work
- if (track == -1)
- return;
-
- if (m_document->isTrackLocked(m_document->tracksCount() - track - 1)) {
- emit displayMessage(i18n("Cannot insert space in a locked track"), ErrorMessage);
- return;
- }
+ QList<QGraphicsItem *> items;
+ if (track > 0) {
+ if (m_document->isTrackLocked(m_document->tracksCount() - track - 1)) {
+ emit displayMessage(i18n("Cannot insert space in a locked track"), ErrorMessage);
+ return;
+ }
- ClipItem *item = getClipItemAt(pos, track);
- if (item) pos = item->startPos();
+ ClipItem *item = getClipItemAt(pos, track);
+ if (item) pos = item->startPos();
- // Make sure there is no group in the way
- QRectF rect(pos.frames(m_document->fps()), track * m_tracksHeight + m_tracksHeight / 2, sceneRect().width() - pos.frames(m_document->fps()), m_tracksHeight / 2 - 2);
- bool isOk;
- QList<QGraphicsItem *> items = checkForGroups(rect, &isOk);
- if (!isOk) {
- // groups found on track, do not allow the move
- emit displayMessage(i18n("Cannot insert space in a track with a group"), ErrorMessage);
- return;
+ // Make sure there is no group in the way
+ QRectF rect(pos.frames(m_document->fps()), track * m_tracksHeight + m_tracksHeight / 2, sceneRect().width() - pos.frames(m_document->fps()), m_tracksHeight / 2 - 2);
+ bool isOk;
+ items = checkForGroups(rect, &isOk);
+ if (!isOk) {
+ // groups found on track, do not allow the move
+ emit displayMessage(i18n("Cannot insert space in a track with a group"), ErrorMessage);
+ return;
+ }
+ } else {
+ QRectF rect(pos.frames(m_document->fps()), 0, sceneRect().width() - pos.frames(m_document->fps()), m_document->tracksCount() * m_tracksHeight);
+ items = scene()->items(rect);
}
QList<ItemInfo> clipsToMove;
if (items.at(i)->type() == AVWIDGET || items.at(i)->type() == TRANSITIONWIDGET) {
AbstractClipItem *item = static_cast <AbstractClipItem *>(items.at(i));
ItemInfo info = item->info();
- if (item->type() == AVWIDGET) {
+ if (item->type() == AVWIDGET)
clipsToMove.append(info);
- } else if (item->type() == TRANSITIONWIDGET) {
+ else if (item->type() == TRANSITIONWIDGET)
transitionsToMove.append(info);
- }
}
}
- InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, spaceDuration, true);
- m_commandStack->push(command);
+ if (!clipsToMove.isEmpty() || !transitionsToMove.isEmpty()) {
+ InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, spaceDuration, true);
+ m_commandStack->push(command);
+ }
}
void CustomTrackView::insertSpace(QList<ItemInfo> clipsToMove, QList<ItemInfo> transToMove, int track, const GenTime duration, const GenTime offset)
}
}
resetSelectionGroup(false);
- if (track != -1) track = m_document->tracksCount() - track;
+ if (track != -1)
+ track = m_document->tracksCount() - track;
m_document->renderer()->mltInsertSpace(trackClipStartList, trackTransitionStartList, track, duration, offset);
}
trackTransitionStartList[m_document->tracksCount() - info.track] = info.startPos.frames(m_document->fps());
}
}
-
- InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, timeOffset, false);
- m_commandStack->push(command);
- if (track != -1) track = m_document->tracksCount() - track;
- kDebug() << "SPACER TRACK:" << track;
- m_document->renderer()->mltInsertSpace(trackClipStartList, trackTransitionStartList, track, timeOffset, GenTime());
+ if (!clipsToMove.isEmpty() || !transitionsToMove.isEmpty()) {
+ InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, timeOffset, false);
+ m_commandStack->push(command);
+ if (track != -1) track = m_document->tracksCount() - track;
+ kDebug() << "SPACER TRACK:" << track;
+ m_document->renderer()->mltInsertSpace(trackClipStartList, trackTransitionStartList, track, timeOffset, GenTime());
+ setDocumentModified();
+ }
}
resetSelectionGroup(false);
m_operationMode = NONE;
// we are moving one clip, easy
if (m_dragItem->type() == AVWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) {
ClipItem *item = static_cast <ClipItem *>(m_dragItem);
- Mlt::Producer *prod;
- if (item->isAudioOnly()) prod = item->baseClip()->audioProducer(m_dragItemInfo.track);
- else if (item->isVideoOnly()) prod = item->baseClip()->videoProducer();
- else prod = item->baseClip()->producer(m_dragItemInfo.track);
- bool success = m_document->renderer()->mltMoveClip((int)(m_document->tracksCount() - m_dragItemInfo.track), (int)(m_document->tracksCount() - m_dragItem->track()), (int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItem->startPos().frames(m_document->fps())), prod, m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
+ Mlt::Producer *prod = item->getProducer(info.track);
+ bool success = m_document->renderer()->mltMoveClip((int)(m_document->tracksCount() - m_dragItemInfo.track), (int)(m_document->tracksCount() - info.track), (int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(info.startPos.frames(m_document->fps())), prod, m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
if (success) {
QUndoCommand *moveCommand = new QUndoCommand();
emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(m_dragItemInfo.startPos.frames(m_document->fps()))), ErrorMessage);
}
setDocumentModified();
- }
- if (m_dragItem->type() == TRANSITIONWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) {
+ } else if (m_dragItem->type() == TRANSITIONWIDGET && (m_dragItemInfo.startPos != info.startPos || m_dragItemInfo.track != info.track)) {
Transition *transition = static_cast <Transition *>(m_dragItem);
transition->updateTransitionEndTrack(getPreviousVideoTrack(m_dragItem->track()));
if (!m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_document->tracksCount() - m_dragItemInfo.track), (int)(m_document->tracksCount() - m_dragItem->track()), transition->transitionEndTrack(), m_dragItemInfo.startPos, m_dragItemInfo.endPos, info.startPos, info.endPos)) {
adjustTimelineTransitions(m_scene->editMode(), transition, moveCommand);
new MoveTransitionCommand(this, m_dragItemInfo, info, false, moveCommand);
m_commandStack->push(moveCommand);
+ setDocumentModified();
}
}
} else {
// Moving several clips. We need to delete them and readd them to new position,
// or they might overlap each other during the move
- QGraphicsItemGroup *group = static_cast <QGraphicsItemGroup *>(m_dragItem->parentItem());
+ QGraphicsItemGroup *group;
+ if (m_selectionGroup)
+ group = static_cast <QGraphicsItemGroup *>(m_selectionGroup);
+ else
+ group = static_cast <QGraphicsItemGroup *>(m_dragItem->parentItem());
QList<QGraphicsItem *> items = group->childItems();
QList<ItemInfo> clipsToMove;
if (item->type() == AVWIDGET) {
ClipItem *clip = static_cast <ClipItem*>(item);
info.track = m_document->tracksCount() - info.track;
- Mlt::Producer *prod;
adjustTimelineClips(m_scene->editMode(), clip, ItemInfo(), moveGroup);
- if (clip->isAudioOnly()) prod = clip->baseClip()->audioProducer(info.track);
- else if (clip->isVideoOnly()) prod = clip->baseClip()->videoProducer();
- else prod = clip->baseClip()->producer(info.track);
- m_document->renderer()->mltInsertClip(info, clip->xml(), prod, m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
+ m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(info.track), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
for (int i = 0; i < clip->effectsCount(); i++) {
- m_document->renderer()->mltAddEffect(info.track, info.startPos, clip->getEffectArgs(clip->effectAt(i)), false);
+ m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false);
}
} else {
Transition *tr = static_cast <Transition*>(item);
m_document->renderer()->mltAddTransition(tr->transitionTag(), newTrack, m_document->tracksCount() - info.track, info.startPos, info.endPos, tr->toXML());
}
}
-
new MoveGroupCommand(this, clipsToMove, transitionsToMove, timeOffset, trackOffset, false, moveGroup);
m_commandStack->push(moveGroup);
if (m_selectionGroup) {
m_selectionGroupInfo.startPos = GenTime(m_selectionGroup->scenePos().x(), m_document->fps());
m_selectionGroupInfo.track = m_selectionGroup->track();
+
+ for (int i = 0; i < items.count(); ++i) {
+ if (items.at(i)->type() == GROUPWIDGET) {
+ rebuildGroup((AbstractGroupItem*)items.at(i));
+ items.removeAt(i);
+ --i;
+ }
+ }
+ for (int i = 0; i < items.count(); ++i) {
+ if (items.at(i)) {
+ items.at(i)->setSelected(true);
+ if (items.at(i)->parentItem())
+ items.at(i)->parentItem()->setSelected(true);
+ }
+ }
+ groupSelectedItems();
+ } else {
+ rebuildGroup((AbstractGroupItem *)group);
}
setDocumentModified();
}
m_document->renderer()->doRefresh();
} else if (m_operationMode == RESIZESTART && m_dragItem->startPos() != m_dragItemInfo.startPos) {
// resize start
- if (m_dragItem->type() == AVWIDGET) {
- ItemInfo resizeinfo = m_dragItemInfo;
- resizeinfo.track = m_document->tracksCount() - resizeinfo.track;
- bool success = m_document->renderer()->mltResizeClipStart(resizeinfo, m_dragItem->startPos() - m_dragItemInfo.startPos);
- if (success) {
+ 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) {
QUndoCommand *resizeCommand = new QUndoCommand();
- resizeCommand->setText(i18n("Resize clip"));
-
- // Check if there is an automatic transition on that clip (lower track)
- Transition *transition = getTransitionItemAtStart(m_dragItemInfo.startPos, m_dragItemInfo.track);
- if (transition && transition->isAutomatic()) {
- ItemInfo trInfo = transition->info();
- ItemInfo newTrInfo = trInfo;
- newTrInfo.startPos = m_dragItem->startPos();
- if (newTrInfo.startPos < newTrInfo.endPos)
- new MoveTransitionCommand(this, trInfo, newTrInfo, true, resizeCommand);
- }
- // Check if there is an automatic transition on that clip (upper track)
- transition = getTransitionItemAtStart(m_dragItemInfo.startPos, m_dragItemInfo.track - 1);
- if (transition && transition->isAutomatic() && (m_document->tracksCount() - transition->transitionEndTrack()) == m_dragItemInfo.track) {
- ItemInfo trInfo = transition->info();
- ItemInfo newTrInfo = trInfo;
- newTrInfo.startPos = m_dragItem->startPos();
- ClipItem * upperClip = getClipItemAt(m_dragItemInfo.startPos, m_dragItemInfo.track - 1);
- if ((!upperClip || !upperClip->baseClip()->isTransparent()) && newTrInfo.startPos < newTrInfo.endPos) {
- new MoveTransitionCommand(this, trInfo, newTrInfo, true, resizeCommand);
+ resizeCommand->setText(i18n("Resize group"));
+ QList <QGraphicsItem *> items = parent->childItems();
+ QList <ItemInfo> infos = parent->resizeInfos();
+ parent->clearResizeInfos();
+ int itemcount = 0;
+ for (int i = 0; i < items.count(); ++i) {
+ AbstractClipItem *item = static_cast<AbstractClipItem *>(items.at(i));
+ if (item && item->type() == AVWIDGET) {
+ ItemInfo info = infos.at(itemcount);
+ prepareResizeClipStart(item, info, item->startPos().frames(m_document->fps()), false, resizeCommand);
+ ++itemcount;
}
}
-
- ClipItem *clip = static_cast < ClipItem * >(m_dragItem);
- updatePositionEffects(clip, m_dragItemInfo);
-
- // 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(m_dragItemInfo.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, m_dragItemInfo, info, false, true, resizeCommand);
- 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, resizeCommand);
- updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
- }
- new ResizeClipCommand(this, m_dragItemInfo, info, false, true, resizeCommand);
- emit clipItemSelected(clip);
- } else new ResizeClipCommand(this, m_dragItemInfo, info, false, false, resizeCommand);
-
m_commandStack->push(resizeCommand);
- } else {
- bool snap = KdenliveSettings::snaptopoints();
- KdenliveSettings::setSnaptopoints(false);
- m_dragItem->resizeStart((int) m_dragItemInfo.startPos.frames(m_document->fps()));
- KdenliveSettings::setSnaptopoints(snap);
- emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
- }
- } else if (m_dragItem->type() == TRANSITIONWIDGET) {
- Transition *transition = static_cast <Transition *>(m_dragItem);
- if (!m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_document->tracksCount() - m_dragItemInfo.track), (int)(m_document->tracksCount() - m_dragItemInfo.track), transition->transitionEndTrack(), m_dragItemInfo.startPos, m_dragItemInfo.endPos, info.startPos, info.endPos)) {
- // Cannot resize transition
- bool snap = KdenliveSettings::snaptopoints();
- KdenliveSettings::setSnaptopoints(false);
- transition->resizeStart((int) m_dragItemInfo.startPos.frames(m_document->fps()));
- KdenliveSettings::setSnaptopoints(snap);
- emit displayMessage(i18n("Cannot resize transition"), ErrorMessage);
- } else {
- MoveTransitionCommand *command = new MoveTransitionCommand(this, m_dragItemInfo, info, false);
- m_commandStack->push(command);
- }
-
- }
- if (m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
- // Item was resized, rebuild group;
- AbstractGroupItem *group = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
- QList <QGraphicsItem *> children = group->childItems();
- m_document->clipManager()->removeGroup(group);
- scene()->destroyItemGroup(group);
- for (int i = 0; i < children.count(); i++) {
- children.at(i)->setSelected(true);
}
- groupSelectedItems(false, true);
+ } else {
+ prepareResizeClipStart(m_dragItem, m_dragItemInfo, m_dragItem->startPos().frames(m_document->fps()));
}
- //m_document->renderer()->doRefresh();
} else if (m_operationMode == RESIZEEND && m_dragItem->endPos() != m_dragItemInfo.endPos) {
// resize end
- if (m_dragItem->type() == AVWIDGET) {
- ItemInfo resizeinfo = info;
- resizeinfo.track = m_document->tracksCount() - resizeinfo.track;
- bool success = m_document->renderer()->mltResizeClipEnd(resizeinfo, resizeinfo.endPos - resizeinfo.startPos);
- if (success) {
+ 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) {
QUndoCommand *resizeCommand = new QUndoCommand();
- resizeCommand->setText(i18n("Resize clip"));
-
- // Check if there is an automatic transition on that clip (lower track)
- Transition *tr = getTransitionItemAtEnd(m_dragItemInfo.endPos, m_dragItemInfo.track);
- if (tr && tr->isAutomatic()) {
- ItemInfo trInfo = tr->info();
- ItemInfo newTrInfo = trInfo;
- newTrInfo.endPos = m_dragItem->endPos();
- if (newTrInfo.endPos > newTrInfo.startPos) new MoveTransitionCommand(this, trInfo, newTrInfo, true, resizeCommand);
- }
-
- // Check if there is an automatic transition on that clip (upper track)
- tr = getTransitionItemAtEnd(m_dragItemInfo.endPos, m_dragItemInfo.track - 1);
- if (tr && tr->isAutomatic() && (m_document->tracksCount() - tr->transitionEndTrack()) == m_dragItemInfo.track) {
- ItemInfo trInfo = tr->info();
- ItemInfo newTrInfo = trInfo;
- newTrInfo.endPos = m_dragItem->endPos();
- ClipItem * upperClip = getClipItemAtEnd(m_dragItemInfo.endPos, m_dragItemInfo.track - 1);
- if ((!upperClip || !upperClip->baseClip()->isTransparent()) && newTrInfo.endPos > newTrInfo.startPos) {
- new MoveTransitionCommand(this, trInfo, newTrInfo, true, resizeCommand);
- }
- }
-
- // check keyframes
- ClipItem *clip = static_cast < ClipItem * >(m_dragItem);
- 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);
+ resizeCommand->setText(i18n("Resize group"));
+ QList <QGraphicsItem *> items = parent->childItems();
+ QList <ItemInfo> infos = parent->resizeInfos();
+ parent->clearResizeInfos();
+ int itemcount = 0;
+ for (int i = 0; i < items.count(); ++i) {
+ AbstractClipItem *item = static_cast<AbstractClipItem *>(items.at(i));
+ if (item && item->type() == AVWIDGET) {
+ ItemInfo info = infos.at(itemcount);
+ prepareResizeClipEnd(item, info, item->endPos().frames(m_document->fps()), false, resizeCommand);
+ ++itemcount;
}
}
-
- if (clip->checkEffectsKeyframesPos((m_dragItemInfo.cropStart + m_dragItemInfo.endPos - m_dragItemInfo.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, m_dragItemInfo, info, false, true, resizeCommand);
- 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, resizeCommand);
- updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
- }
- new ResizeClipCommand(this, m_dragItemInfo, info, false, true, resizeCommand);
- emit clipItemSelected(clip);
- } else new ResizeClipCommand(this, m_dragItemInfo, info, false, false, resizeCommand);
-
m_commandStack->push(resizeCommand);
- updatePositionEffects(clip, m_dragItemInfo);
- } else {
- m_dragItem->resizeEnd((int) m_dragItemInfo.endPos.frames(m_document->fps()));
- emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
- }
- } else if (m_dragItem->type() == TRANSITIONWIDGET) {
- Transition *transition = static_cast <Transition *>(m_dragItem);
- if (!m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_document->tracksCount() - m_dragItemInfo.track), (int)(m_document->tracksCount() - m_dragItemInfo.track), transition->transitionEndTrack(), m_dragItemInfo.startPos, m_dragItemInfo.endPos, info.startPos, info.endPos)) {
- // Cannot resize transition
- transition->resizeEnd((int) m_dragItemInfo.endPos.frames(m_document->fps()));
- emit displayMessage(i18n("Cannot resize transition"), ErrorMessage);
- } else {
- MoveTransitionCommand *command = new MoveTransitionCommand(this, m_dragItemInfo, info, false);
- m_commandStack->push(command);
- }
- }
- if (m_dragItem->parentItem() && m_dragItem->parentItem() != m_selectionGroup) {
- // Item was resized, rebuild group;
- AbstractGroupItem *group = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
- QList <QGraphicsItem *> children = group->childItems();
- m_document->clipManager()->removeGroup(group);
- scene()->destroyItemGroup(group);
- for (int i = 0; i < children.count(); i++) {
- children.at(i)->setSelected(true);
}
- groupSelectedItems(false, true);
+ } else {
+ prepareResizeClipEnd(m_dragItem, m_dragItemInfo, m_dragItem->endPos().frames(m_document->fps()));
}
- //m_document->renderer()->doRefresh();
} else if (m_operationMode == FADEIN) {
// resize fade in effect
ClipItem * item = static_cast <ClipItem *>(m_dragItem);
int start = item->cropStart().frames(m_document->fps());
int end = item->fadeIn();
if (end == 0) {
- slotDeleteEffect(item, oldeffect, false);
+ slotDeleteEffect(item, -1, oldeffect, false);
} else {
end += start;
QDomElement effect = oldeffect.cloneNode().toElement();
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
- slotUpdateClipEffect(item, effect, oldeffect, ix);
+ slotUpdateClipEffect(item, -1, effect, oldeffect, ix);
emit clipItemSelected(item, ix);
}
} else if (item->fadeIn() != 0 && ix2 == -1) {
int start = item->cropStart().frames(m_document->fps());
int end = item->fadeIn();
if (end == 0) {
- slotDeleteEffect(item, oldeffect, false);
+ slotDeleteEffect(item, -1, oldeffect, false);
} else {
end += start;
QDomElement effect = oldeffect.cloneNode().toElement();
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
- slotUpdateClipEffect(item, effect, oldeffect, ix2);
+ slotUpdateClipEffect(item, -1, effect, oldeffect, ix2);
emit clipItemSelected(item, ix2);
}
}
int end = (item->cropDuration() + item->cropStart()).frames(m_document->fps());
int start = item->fadeOut();
if (start == 0) {
- slotDeleteEffect(item, oldeffect, false);
+ slotDeleteEffect(item, -1, oldeffect, false);
} else {
start = end - start;
QDomElement effect = oldeffect.cloneNode().toElement();
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
// kDebug()<<"EDIT FADE OUT : "<<start<<"x"<<end;
- slotUpdateClipEffect(item, effect, oldeffect, ix);
+ slotUpdateClipEffect(item, -1, effect, oldeffect, ix);
emit clipItemSelected(item, ix);
}
} else if (item->fadeOut() != 0 && ix2 == -1) {
int end = (item->cropDuration() + item->cropStart()).frames(m_document->fps());
int start = item->fadeOut();
if (start == 0) {
- slotDeleteEffect(item, oldeffect, false);
+ slotDeleteEffect(item, -1, oldeffect, false);
} else {
start = end - start;
QDomElement effect = oldeffect.cloneNode().toElement();
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
// kDebug()<<"EDIT FADE OUT : "<<start<<"x"<<end;
- slotUpdateClipEffect(item, effect, oldeffect, ix2);
+ slotUpdateClipEffect(item, -1, effect, oldeffect, ix2);
emit clipItemSelected(item, ix2);
}
}
val = (br.bottom() - val) * maxh;
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
- kDebug() << "// DELETE KFR: " << item->editedKeyFramePos();
item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), -1, 0);
- } else item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), item->editedKeyFramePos(), item->editedKeyFrameValue());
+ } else {
+ item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), item->editedKeyFramePos(), item->editedKeyFrameValue());
+ }
+
QDomElement newEffect = item->selectedEffect().cloneNode().toElement();
//item->updateKeyframeEffect();
//QString next = item->keyframes(item->selectedEffectIndex());
void CustomTrackView::doChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, const double speed, const double oldspeed, int strobe, const QString &id)
{
- DocClipBase *baseclip = m_document->clipManager()->getClipById(id);
+ Q_UNUSED(id);
+ //DocClipBase *baseclip = m_document->clipManager()->getClipById(id);
+
ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
if (!item) {
kDebug() << "ERROR: Cannot find clip for speed change";
return;
}
info.track = m_document->tracksCount() - item->track();
- int endPos;
- if (item->isVideoOnly()) endPos = m_document->renderer()->mltChangeClipSpeed(info, speedIndependantInfo, speed, oldspeed, strobe, baseclip->videoProducer());
- else if (item->isAudioOnly()) endPos = m_document->renderer()->mltChangeClipSpeed(info, speedIndependantInfo, speed, oldspeed, strobe, baseclip->audioProducer(item->track()));
- else endPos = m_document->renderer()->mltChangeClipSpeed(info, speedIndependantInfo, speed, oldspeed, strobe, baseclip->producer());
+ int endPos = m_document->renderer()->mltChangeClipSpeed(info, speedIndependantInfo, speed, oldspeed, strobe, item->getProducer(item->track(), false));
if (endPos >= 0) {
item->setSpeed(speed, strobe);
item->updateRectGeometry();
- if (item->cropDuration().frames(m_document->fps()) != endPos) {
+ if (item->cropDuration().frames(m_document->fps()) != endPos)
item->resizeEnd((int) info.startPos.frames(m_document->fps()) + endPos - 1);
- }
updatePositionEffects(item, info);
setDocumentModified();
- } else emit displayMessage(i18n("Invalid clip"), ErrorMessage);
+ } else {
+ emit displayMessage(i18n("Invalid clip"), ErrorMessage);
+ }
}
void CustomTrackView::cutSelectedClips()
{
QList<QGraphicsItem *> itemList = scene()->selectedItems();
+ QList<AbstractGroupItem *> groups;
GenTime currentPos = GenTime(m_cursorPos, m_document->fps());
- for (int i = 0; i < itemList.count(); i++) {
+ for (int i = 0; i < itemList.count(); ++i) {
+ if (!itemList.at(i))
+ continue;
if (itemList.at(i)->type() == AVWIDGET) {
ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
if (item->parentItem() && item->parentItem() != m_selectionGroup) {
- emit displayMessage(i18n("Cannot cut a clip in a group"), ErrorMessage);
- } else if (currentPos > item->startPos() && currentPos < item->endPos()) {
+ AbstractGroupItem *group = static_cast <AbstractGroupItem *>(item->parentItem());
+ if (!groups.contains(group))
+ groups << group;
+ } else if (currentPos > item->startPos() && currentPos < item->endPos()) {
RazorClipCommand *command = new RazorClipCommand(this, item->info(), currentPos);
m_commandStack->push(command);
}
+ } else if (itemList.at(i)->type() == GROUPWIDGET && itemList.at(i) != m_selectionGroup) {
+ AbstractGroupItem *group = static_cast<AbstractGroupItem *>(itemList.at(i));
+ if (!groups.contains(group))
+ groups << group;
}
}
+
+ for (int i = 0; i < groups.count(); ++i)
+ razorGroup(groups.at(i), currentPos);
+}
+
+void CustomTrackView::razorGroup(AbstractGroupItem* group, GenTime cutPos)
+{
+ if (group) {
+ QList <QGraphicsItem *> children = group->childItems();
+ QList <ItemInfo> clips1, transitions1;
+ QList <ItemInfo> clipsCut, transitionsCut;
+ QList <ItemInfo> clips2, transitions2;
+ for (int i = 0; i < children.count(); ++i) {
+ children.at(i)->setSelected(false);
+ AbstractClipItem *child = static_cast <AbstractClipItem *>(children.at(i));
+ if (child->type() == AVWIDGET) {
+ if (cutPos > child->endPos())
+ clips1 << child->info();
+ else if (cutPos < child->startPos())
+ clips2 << child->info();
+ else
+ clipsCut << child->info();
+ } else {
+ if (cutPos > child->endPos())
+ transitions1 << child->info();
+ else if (cutPos < child->startPos())
+ transitions2 << child->info();
+ else
+ transitionsCut << child->info();
+ }
+ }
+ if (clipsCut.isEmpty() && transitionsCut.isEmpty() && ((clips1.isEmpty() && transitions1.isEmpty()) || (clips2.isEmpty() && transitions2.isEmpty())))
+ return;
+ RazorGroupCommand *command = new RazorGroupCommand(this, clips1, transitions1, clipsCut, transitionsCut, clips2, transitions2, cutPos);
+ m_commandStack->push(command);
+ }
+}
+
+void CustomTrackView::slotRazorGroup(QList <ItemInfo> clips1, QList <ItemInfo> transitions1, QList <ItemInfo> clipsCut, QList <ItemInfo> transitionsCut, QList <ItemInfo> clips2, QList <ItemInfo> transitions2, GenTime cutPos, bool cut)
+{
+ if (cut) {
+ for (int i = 0; i < clipsCut.count(); ++i) {
+ ClipItem *clip = getClipItemAt(clipsCut.at(i).startPos.frames(m_document->fps()), clipsCut.at(i).track);
+ if (clip) {
+ ClipItem *clipBehind = cutClip(clipsCut.at(i), cutPos, true);
+ clips1 << clip->info();
+ if (clipBehind != NULL)
+ clips2 << clipBehind->info();
+ }
+ }
+ /* TODO: cut transitionsCut
+ * For now just append them to group1 */
+ transitions1 << transitionsCut;
+ doGroupClips(clips1, transitions1, true);
+ doGroupClips(clips2, transitions2, true);
+ } else {
+ /* we might also just use clipsCut.at(0)->parentItem().
+ * Do this loop just in case something went wrong during cut */
+ for (int i = 0; i < clipsCut.count(); ++i) {
+ ClipItem *clip = getClipItemAt(cutPos.frames(m_document->fps()), clipsCut.at(i).track);
+ if (clip && clip->parentItem() && clip->parentItem()->type() == GROUPWIDGET) {
+ AbstractGroupItem *group = static_cast <AbstractGroupItem *>(clip->parentItem());
+ QList <QGraphicsItem *> children = group->childItems();
+ QList <ItemInfo> groupClips;
+ QList <ItemInfo> groupTrans;
+ for (int j = 0; j < children.count(); ++j) {
+ if (children.at(j)->type() == AVWIDGET)
+ groupClips << ((AbstractClipItem *)children.at(j))->info();
+ else if (children.at(j)->type() == TRANSITIONWIDGET)
+ groupTrans << ((AbstractClipItem *)children.at(j))->info();
+ }
+ doGroupClips(groupClips, groupTrans, false);
+ break;
+ }
+ }
+ for (int i = 0; i < clipsCut.count(); ++i)
+ cutClip(clipsCut.at(i), cutPos, false);
+ // TODO: uncut transitonsCut
+ doGroupClips(QList <ItemInfo>() << clips1 << clipsCut << clips2, QList <ItemInfo>() << transitions1 << transitionsCut << transitions2, true);
+ }
}
void CustomTrackView::groupClips(bool group)
emit displayMessage(i18n("No clip copied"), ErrorMessage);
return;
}
+
+ if (baseclip->producer() == 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) {
+ m_producerNotReady.wait(&m_mutex, 500 + 500 * i);
+ } else break;
+ }
+ if (baseclip->producer() == NULL) {
+ emit displayMessage(i18n("Cannot insert clip..."), ErrorMessage);
+ m_mutex.unlock();
+ return;
+ }
+ emit displayMessage(QString(), InformationMessage);
+ m_mutex.unlock();
+ }
+
ClipItem *item = new ClipItem(baseclip, info, m_document->fps(), xml.attribute("speed", "1").toDouble(), xml.attribute("strobe", "1").toInt());
item->setEffectList(effects);
if (xml.hasAttribute("audio_only")) item->setAudioOnly(true);
baseclip->addReference();
m_document->updateClip(baseclip->getId());
info.track = m_document->tracksCount() - info.track;
- Mlt::Producer *prod;
- if (item->isAudioOnly()) prod = baseclip->audioProducer(info.track);
- else if (item->isVideoOnly()) prod = baseclip->videoProducer();
- else prod = baseclip->producer(info.track);
- m_document->renderer()->mltInsertClip(info, xml, prod, overwrite, push);
+ m_document->renderer()->mltInsertClip(info, xml, item->getProducer(info.track), overwrite, push);
for (int i = 0; i < item->effectsCount(); i++) {
- m_document->renderer()->mltAddEffect(info.track, info.startPos, item->getEffectArgs(item->effectAt(i)), false);
+ m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(item->effectAt(i)), false);
}
setDocumentModified();
- if (refresh) m_document->renderer()->doRefresh();
- if (!baseclip->isPlaceHolder()) m_waitingThumbs.append(item);
+ if (refresh)
+ m_document->renderer()->doRefresh();
+ if (!baseclip->isPlaceHolder())
+ m_waitingThumbs.append(item);
m_thumbsTimer.start();
}
kDebug() << "---------------- ERROR, CANNOT find clip to move at.. ";
return;
}
- Mlt::Producer *prod;
- if (item->isAudioOnly()) prod = item->baseClip()->audioProducer(end.track);
- else if (item->isVideoOnly()) prod = item->baseClip()->videoProducer();
- else prod = item->baseClip()->producer(end.track);
+ Mlt::Producer *prod = item->getProducer(end.track);
bool success = m_document->renderer()->mltMoveClip((int)(m_document->tracksCount() - start.track), (int)(m_document->tracksCount() - end.track), (int) start.startPos.frames(m_document->fps()), (int)end.startPos.frames(m_document->fps()), prod);
if (success) {
ItemInfo info = item->info();
int tracknumber = m_document->tracksCount() - info.track - 1;
bool isLocked = m_document->trackInfoAt(tracknumber).isLocked;
- if (isLocked) item->setItemLocked(true);
- else if (item->isItemLocked()) item->setItemLocked(false);
+ if (isLocked)
+ item->setItemLocked(true);
+ else if (item->isItemLocked())
+ item->setItemLocked(false);
if (item->type() == AVWIDGET) {
ClipItem *clip = static_cast <ClipItem*>(item);
info.track = m_document->tracksCount() - info.track;
- Mlt::Producer *prod;
- if (clip->isAudioOnly()) prod = clip->baseClip()->audioProducer(info.track);
- else if (clip->isVideoOnly()) prod = clip->baseClip()->videoProducer();
- else prod = clip->baseClip()->producer(info.track);
- m_document->renderer()->mltInsertClip(info, clip->xml(), prod);
+ m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(info.track));
+ for (int i = 0; i < clip->effectsCount(); i++) {
+ m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false);
+ }
} else if (item->type() == TRANSITIONWIDGET) {
Transition *tr = static_cast <Transition*>(item);
int newTrack;
- if (!tr->forcedTrack()) newTrack = getPreviousVideoTrack(info.track);
- else {
+ if (!tr->forcedTrack()) {
+ newTrack = getPreviousVideoTrack(info.track);
+ } else {
newTrack = tr->transitionEndTrack() + trackOffset;
if (newTrack < 0 || newTrack > m_document->tracksCount()) newTrack = getPreviousVideoTrack(info.track);
}
m_document->renderer()->mltAddTransition(tr->transitionTag(), newTrack, m_document->tracksCount() - info.track, info.startPos, info.endPos, tr->toXML());
}
}
+
resetSelectionGroup(false);
+
+ for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->parentItem())
+ rebuildGroup((AbstractGroupItem*)children.at(i)->parentItem());
+ }
+ clearSelection();
+
KdenliveSettings::setSnaptopoints(snap);
m_document->renderer()->doRefresh();
} else kDebug() << "///////// WARNING; NO GROUP TO MOVE";
setDocumentModified();
}
+void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo oldInfo, int pos, bool check, QUndoCommand *command)
+{
+ if (pos == oldInfo.startPos.frames(m_document->fps()))
+ return;
+ bool snap = KdenliveSettings::snaptopoints();
+ if (check) {
+ KdenliveSettings::setSnaptopoints(false);
+ item->resizeStart(pos);
+ if (item->startPos().frames(m_document->fps()) != pos) {
+ item->resizeStart(oldInfo.startPos.frames(m_document->fps()));
+ emit displayMessage(i18n("Not possible to resize"), ErrorMessage);
+ KdenliveSettings::setSnaptopoints(snap);
+ return;
+ }
+ KdenliveSettings::setSnaptopoints(snap);
+ }
+
+ bool hasParentCommand = false;
+ if (command) {
+ hasParentCommand = true;
+ } else {
+ command = new QUndoCommand();
+ command->setText(i18n("Resize clip start"));
+ }
+
+ // do this here, too, because otherwise undo won't update the group
+ if (item->parentItem() && item->parentItem() != m_selectionGroup)
+ new RebuildGroupCommand(this, item->info().track, item->endPos() - GenTime(1, m_document->fps()), command);
+
+ ItemInfo info = item->info();
+ if (item->type() == AVWIDGET) {
+ ItemInfo resizeinfo = oldInfo;
+ resizeinfo.track = m_document->tracksCount() - resizeinfo.track;
+ bool success = m_document->renderer()->mltResizeClipStart(resizeinfo, item->startPos() - oldInfo.startPos);
+ if (success) {
+ // Check if there is an automatic transition on that clip (lower track)
+ Transition *transition = getTransitionItemAtStart(oldInfo.startPos, oldInfo.track);
+ if (transition && transition->isAutomatic()) {
+ ItemInfo trInfo = transition->info();
+ ItemInfo newTrInfo = trInfo;
+ newTrInfo.startPos = item->startPos();
+ if (newTrInfo.startPos < newTrInfo.endPos)
+ new MoveTransitionCommand(this, trInfo, newTrInfo, true, command);
+ }
+ // Check if there is an automatic transition on that clip (upper track)
+ transition = getTransitionItemAtStart(oldInfo.startPos, oldInfo.track - 1);
+ if (transition && transition->isAutomatic() && (m_document->tracksCount() - transition->transitionEndTrack()) == oldInfo.track) {
+ ItemInfo trInfo = transition->info();
+ ItemInfo newTrInfo = trInfo;
+ newTrInfo.startPos = item->startPos();
+ ClipItem * upperClip = getClipItemAt(oldInfo.startPos, oldInfo.track - 1);
+ if ((!upperClip || !upperClip->baseClip()->isTransparent()) && newTrInfo.startPos < newTrInfo.endPos)
+ 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);
+ }
+ } else {
+ KdenliveSettings::setSnaptopoints(false);
+ item->resizeStart((int) oldInfo.startPos.frames(m_document->fps()));
+ KdenliveSettings::setSnaptopoints(snap);
+ emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
+ }
+ } else if (item->type() == TRANSITIONWIDGET) {
+ 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(false);
+ transition->resizeStart((int) oldInfo.startPos.frames(m_document->fps()));
+ KdenliveSettings::setSnaptopoints(snap);
+ emit displayMessage(i18n("Cannot resize transition"), ErrorMessage);
+ } else {
+ MoveTransitionCommand *moveCommand = new MoveTransitionCommand(this, oldInfo, info, false, command);
+ if (command == NULL)
+ m_commandStack->push(moveCommand);
+ }
+
+ }
+ if (item->parentItem() && item->parentItem() != m_selectionGroup)
+ new RebuildGroupCommand(this, item->info().track, item->endPos() - GenTime(1, m_document->fps()), command);
+
+ if (!hasParentCommand)
+ m_commandStack->push(command);
+}
+
+void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldInfo, int pos, bool check, QUndoCommand *command)
+{
+ if (pos == oldInfo.endPos.frames(m_document->fps()))
+ return;
+ bool snap = KdenliveSettings::snaptopoints();
+ if (check) {
+ KdenliveSettings::setSnaptopoints(false);
+ item->resizeEnd(pos);
+ if (item->endPos().frames(m_document->fps()) != pos) {
+ item->resizeEnd(oldInfo.endPos.frames(m_document->fps()));
+ emit displayMessage(i18n("Not possible to resize"), ErrorMessage);
+ KdenliveSettings::setSnaptopoints(snap);
+ return;
+ }
+ KdenliveSettings::setSnaptopoints(snap);
+ }
+
+ bool hasParentCommand = false;
+ if (command) {
+ hasParentCommand = true;
+ } else {
+ command = new QUndoCommand();
+ command->setText(i18n("Resize clip end"));
+ }
+
+ // do this here, too, because otherwise undo won't update the group
+ if (item->parentItem() && item->parentItem() != m_selectionGroup)
+ new RebuildGroupCommand(this, item->info().track, item->startPos(), command);
+
+ ItemInfo info = item->info();
+ if (item->type() == AVWIDGET) {
+ ItemInfo resizeinfo = info;
+ resizeinfo.track = m_document->tracksCount() - resizeinfo.track;
+ bool success = m_document->renderer()->mltResizeClipEnd(resizeinfo, resizeinfo.cropDuration);
+ if (success) {
+ // Check if there is an automatic transition on that clip (lower track)
+ Transition *tr = getTransitionItemAtEnd(oldInfo.endPos, oldInfo.track);
+ if (tr && tr->isAutomatic()) {
+ ItemInfo trInfo = tr->info();
+ ItemInfo newTrInfo = trInfo;
+ newTrInfo.endPos = item->endPos();
+ if (newTrInfo.endPos > newTrInfo.startPos)
+ new MoveTransitionCommand(this, trInfo, newTrInfo, true, command);
+ }
+
+ // Check if there is an automatic transition on that clip (upper track)
+ tr = getTransitionItemAtEnd(oldInfo.endPos, oldInfo.track - 1);
+ if (tr && tr->isAutomatic() && (m_document->tracksCount() - tr->transitionEndTrack()) == oldInfo.track) {
+ ItemInfo trInfo = tr->info();
+ ItemInfo newTrInfo = trInfo;
+ newTrInfo.endPos = item->endPos();
+ ClipItem * upperClip = getClipItemAtEnd(oldInfo.endPos, oldInfo.track - 1);
+ if ((!upperClip || !upperClip->baseClip()->isTransparent()) && newTrInfo.endPos > newTrInfo.startPos)
+ new MoveTransitionCommand(this, trInfo, newTrInfo, true, command);
+
+ }
+
+ 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);
+ }
+ } else {
+ KdenliveSettings::setSnaptopoints(false);
+ item->resizeEnd((int) oldInfo.endPos.frames(m_document->fps()));
+ KdenliveSettings::setSnaptopoints(true);
+ emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
+ }
+ } else if (item->type() == TRANSITIONWIDGET) {
+ 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(false);
+ transition->resizeEnd((int) oldInfo.endPos.frames(m_document->fps()));
+ 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);
+ }
+ }
+ if (item->parentItem() && item->parentItem() != m_selectionGroup)
+ new RebuildGroupCommand(this, item->info().track, item->startPos(), command);
+
+ if (!hasParentCommand)
+ m_commandStack->push(command);
+}
+
void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
{
int 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(), item->getEffectArgs(oldeffect)))
+ 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);
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(), item->getEffectArgs(oldeffect)))
+ 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);
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(), item->getEffectArgs(oldeffect)))
+ 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);
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(), item->getEffectArgs(oldeffect)))
+ 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);
}
}
}
+
+ updatePanZoom(item);
}
double CustomTrackView::getSnapPointForPos(double pos)
}
}
+ // add render zone
+ QPoint z = m_document->zone();
+ snaps.append(GenTime(z.x(), m_document->fps()));
+ snaps.append(GenTime(z.y(), m_document->fps()));
+
qSort(snaps);
m_scene->setSnapList(snaps);
//for (int i = 0; i < m_snapPoints.size(); ++i)
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.setComment(d.newMarker().comment());
+ } 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);
}
}
QMatrix newmatrix;
newmatrix = newmatrix.scale(scaleFactor, verticalScale);
m_scene->setScale(scaleFactor, verticalScale);
- if (m_visualTip) {
- scene()->removeItem(m_visualTip);
- m_animationTimer->stop();
- delete m_animation;
- m_animation = NULL;
- delete m_visualTip;
- m_visualTip = NULL;
- }
- double verticalPos = mapToScene(QPoint(0, viewport()->height() / 2)).y();
+ removeTipAnimation();
bool adjust = false;
if (verticalScale != matrix().m22()) adjust = true;
setMatrix(newmatrix);
if (adjust) {
double newHeight = m_tracksHeight * m_document->tracksCount() * matrix().m22();
- m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), newHeight);
+ m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), newHeight - 1);
for (int i = 0; i < m_guides.count(); i++) {
QLineF l = m_guides.at(i)->line();
l.setP2(QPointF(l.x2(), newHeight));
int diff = sceneRect().width() - m_projectDuration;
if (diff * newmatrix.m11() < 50) {
- if (newmatrix.m11() < 0.4) setSceneRect(0, 0, (m_projectDuration + 100 / newmatrix.m11()), sceneRect().height());
- else setSceneRect(0, 0, (m_projectDuration + 300), sceneRect().height());
+ if (newmatrix.m11() < 0.4)
+ setSceneRect(0, 0, (m_projectDuration + 100 / newmatrix.m11()), sceneRect().height());
+ else
+ setSceneRect(0, 0, (m_projectDuration + 300), sceneRect().height());
}
+ double verticalPos = mapToScene(QPoint(0, viewport()->height() / 2)).y();
centerOn(QPointF(cursorPos(), verticalPos));
}
void CustomTrackView::slotRefreshGuides()
{
if (KdenliveSettings::showmarkers()) {
- for (int i = 0; i < m_guides.count(); i++) {
+ for (int i = 0; i < m_guides.count(); i++)
m_guides.at(i)->update();
- }
}
}
void CustomTrackView::drawBackground(QPainter * painter, const QRectF &rect)
{
- //kDebug() << "// DRAW BG: " << rect.width();
painter->setClipRect(rect);
- KColorScheme scheme(palette().currentColorGroup(), KColorScheme::Window);
QPen pen1 = painter->pen();
- pen1.setColor(scheme.shade(KColorScheme::DarkShade));
+ pen1.setColor(palette().dark().color());
painter->setPen(pen1);
double min = rect.left();
double max = rect.right();
painter->drawLine(QPointF(min, 0), QPointF(max, 0));
int maxTrack = m_document->tracksCount();
- QColor lockedColor = scheme.background(KColorScheme::NegativeBackground).color();
+ QColor lockedColor = palette().button().color();
QColor audioColor = palette().alternateBase().color();
- QColor base = scheme.background(KColorScheme::NormalBackground).color();
for (int i = 0; i < maxTrack; i++) {
TrackInfo info = m_document->trackInfoAt(maxTrack - i - 1);
if (info.isLocked || info.type == AUDIOTRACK || i == m_selectedTrack) {
const QRectF track(min, m_tracksHeight * i + 1, max - min, m_tracksHeight - 1);
- if (i == m_selectedTrack) painter->fillRect(track, scheme.background(KColorScheme::ActiveBackground).color());
- else painter->fillRect(track, info.isLocked ? lockedColor : audioColor);
+ if (i == m_selectedTrack)
+ painter->fillRect(track, m_activeTrackBrush.brush(this));
+ else
+ painter->fillRect(track, info.isLocked ? lockedColor : audioColor);
}
painter->drawLine(QPointF(min, m_tracksHeight *(i + 1)), QPointF(max, m_tracksHeight *(i + 1)));
}
- int lowerLimit = m_tracksHeight * maxTrack + 1;
- if (height() > lowerLimit) {
- const QRectF bg(min, lowerLimit, max - min, height() - lowerLimit);
- painter->fillRect(bg, base);
- }
}
bool CustomTrackView::findString(const QString &text)
}
// add guides
- for (int i = 0; i < m_guides.count(); i++) {
+ for (int i = 0; i < m_guides.count(); i++)
m_searchPoints.append(m_guides.at(i)->info());
- }
qSort(m_searchPoints);
}
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == AVWIDGET) {
ClipItem *item = (ClipItem *)itemList.at(i);
- if (item->clipProducer() == clipId) {
+ if (item->clipProducer() == clipId)
matchingInfo << item->info();
- }
}
}
return matchingInfo;
return;
}
QPoint position;
+ int track = -1;
+ GenTime pos = GenTime(-1);
if (m_menuPosition.isNull()) {
position = mapFromGlobal(QCursor::pos());
if (!contentsRect().contains(position) || mapToScene(position).y() / m_tracksHeight > m_document->tracksCount()) {
- emit displayMessage(i18n("Cannot paste selected clips"), ErrorMessage);
- return;
+ track = m_selectedTrack;
+ pos = GenTime(m_cursorPos, m_document->fps());
+ /*emit displayMessage(i18n("Cannot paste selected clips"), ErrorMessage);
+ return;*/
}
- } else position = m_menuPosition;
+ } else {
+ position = m_menuPosition;
+ }
- GenTime pos = GenTime((int)(mapToScene(position).x()), m_document->fps());
- int track = (int)(mapToScene(position).y() / m_tracksHeight);
+ if (pos == GenTime(-1))
+ pos = GenTime((int)(mapToScene(position).x()), m_document->fps());
+ if (track == -1)
+ track = (int)(mapToScene(position).y() / m_tracksHeight);
GenTime leftPos = m_copiedItems.at(0)->startPos();
int lowerTrack = m_copiedItems.at(0)->track();
return;
}
}
- ItemInfo startInfo = clip->info();
- ItemInfo endInfo = startInfo;
- endInfo.startPos = GenTime(m_cursorPos, m_document->fps());
- if (endInfo.startPos >= startInfo.endPos || endInfo.startPos < startInfo.startPos - startInfo.cropStart) {
- // Check for invalid resize
- emit displayMessage(i18n("Invalid action"), ErrorMessage);
- return;
- } else if (endInfo.startPos < startInfo.startPos) {
- int length = m_document->renderer()->mltGetSpaceLength(endInfo.startPos, m_document->tracksCount() - startInfo.track, false);
- if ((clip->type() == TRANSITIONWIDGET && itemCollision(clip, endInfo) == true) || (
- (clip->type() == AVWIDGET) && length < (startInfo.startPos - endInfo.startPos).frames(m_document->fps()))) {
- emit displayMessage(i18n("Invalid action"), ErrorMessage);
- return;
- }
- }
- if (clip->type() == TRANSITIONWIDGET) {
- m_commandStack->push(new MoveTransitionCommand(this, startInfo, endInfo, true));
- } else m_commandStack->push(new ResizeClipCommand(this, startInfo, endInfo, true, false));
+ prepareResizeClipStart(clip, clip->info(), m_cursorPos, true);
}
void CustomTrackView::setOutPoint()
return;
}
}
- ItemInfo startInfo = clip->info();
- ItemInfo endInfo = clip->info();
- endInfo.endPos = GenTime(m_cursorPos, m_document->fps());
- CLIPTYPE type = (CLIPTYPE) static_cast <ClipItem *>(clip)->clipType();
- if (endInfo.endPos <= startInfo.startPos || (type != IMAGE && type != COLOR && type != TEXT && endInfo.endPos > startInfo.startPos + clip->maxDuration() - startInfo.cropStart)) {
- // Check for invalid resize
- emit displayMessage(i18n("Invalid action"), ErrorMessage);
- return;
- } else if (endInfo.endPos > startInfo.endPos) {
- int length = m_document->renderer()->mltGetSpaceLength(startInfo.endPos, m_document->tracksCount() - startInfo.track, false);
- if ((clip->type() == TRANSITIONWIDGET && itemCollision(clip, endInfo) == true) || (clip->type() == AVWIDGET && length != -1 && length < (endInfo.endPos - startInfo.endPos).frames(m_document->fps()))) {
- kDebug() << " RESIZE ERROR, BLNK: " << length << ", RESIZE: " << (endInfo.endPos - startInfo.endPos).frames(m_document->fps());
- emit displayMessage(i18n("Invalid action"), ErrorMessage);
- return;
- }
- }
-
-
- if (clip->type() == TRANSITIONWIDGET) {
- m_commandStack->push(new MoveTransitionCommand(this, startInfo, endInfo, true));
- } else m_commandStack->push(new ResizeClipCommand(this, startInfo, endInfo, true, false));
+ prepareResizeClipEnd(clip, clip->info(), m_cursorPos, true);
}
void CustomTrackView::slotUpdateAllThumbs()
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == AVWIDGET) {
item = static_cast <ClipItem *>(itemList.at(i));
- if (item->clipType() != COLOR && item->clipType() != AUDIO) {
+ if (item && item->isEnabled() && item->clipType() != COLOR && item->clipType() != AUDIO) {
// Check if we have a cached thumbnail
if (item->clipType() == IMAGE || item->clipType() == TEXT) {
QString thumb = thumbBase + item->baseClip()->getClipHash() + "_0.png";
item->slotSetEndThumb(pix);
}
}
+ item->refreshClip(false);
}
- item->refreshClip(false);
- //qApp->processEvents();
}
}
viewport()->update();
void CustomTrackView::slotInsertTrack(int ix)
{
TrackDialog d(m_document, parentWidget());
+ d.comboTracks->setCurrentIndex(ix);
d.label->setText(i18n("Insert track"));
- d.track_nb->setMaximum(m_document->tracksCount() - 1);
- d.track_nb->setValue(ix);
d.setWindowTitle(i18n("Insert New Track"));
- d.slotUpdateName(ix);
if (d.exec() == QDialog::Accepted) {
- ix = d.track_nb->value();
- if (d.before_select->currentIndex() == 1) {
+ ix = d.comboTracks->currentIndex();
+ if (d.before_select->currentIndex() == 1)
ix++;
- }
TrackInfo info;
+ info.isMute = false;
+ info.isLocked = false;
if (d.video_track->isChecked()) {
info.type = VIDEOTRACK;
- info.isMute = false;
info.isBlind = false;
- info.isLocked = false;
} else {
info.type = AUDIOTRACK;
- info.isMute = false;
info.isBlind = true;
- info.isLocked = false;
}
AddTrackCommand *addTrack = new AddTrackCommand(this, ix, info, true);
m_commandStack->push(addTrack);
void CustomTrackView::slotDeleteTrack(int ix)
{
+ if (m_document->tracksCount() < 2) return;
TrackDialog d(m_document, parentWidget());
+ d.comboTracks->setCurrentIndex(ix);
d.label->setText(i18n("Delete track"));
d.before_select->setHidden(true);
- d.track_nb->setMaximum(m_document->tracksCount() - 1);
- d.track_nb->setValue(ix);
- d.slotUpdateName(ix);
d.setWindowTitle(i18n("Delete Track"));
d.video_track->setHidden(true);
d.audio_track->setHidden(true);
if (d.exec() == QDialog::Accepted) {
- ix = d.track_nb->value();
+ ix = d.comboTracks->currentIndex();
TrackInfo info = m_document->trackInfoAt(m_document->tracksCount() - ix - 1);
deleteTimelineTrack(ix, info);
setDocumentModified();
if (d.exec() == QDialog::Accepted) {
ConfigTracksCommand *configTracks = new ConfigTracksCommand(this, m_document->tracksList(), d.tracksList());
m_commandStack->push(configTracks);
+ QList <int> toDelete = d.deletedTracks();
+ for (int i = 0; i < toDelete.count(); ++i) {
+ TrackInfo info = m_document->trackInfoAt(m_document->tracksCount() - toDelete.at(i) + i - 1);
+ deleteTimelineTrack(toDelete.at(i) - i, info);
+ }
setDocumentModified();
}
}
void CustomTrackView::deleteTimelineTrack(int ix, TrackInfo trackinfo)
{
+ if (m_document->tracksCount() < 2) return;
double startY = ix * m_tracksHeight + 1 + m_tracksHeight / 2;
QRectF r(0, startY, sceneRect().width(), m_tracksHeight / 2 - 1);
QList<QGraphicsItem *> selection = m_scene->items(r);
if (split) {
int start = pos.frames(m_document->fps());
int freetrack = m_document->tracksCount() - track - 1;
+
+ // do not split audio when we are on an audio track
+ if (m_document->trackInfoAt(freetrack).type == AUDIOTRACK)
+ return;
+
for (; freetrack > 0; freetrack--) {
kDebug() << "// CHK DOC TRK:" << freetrack << ", DUR:" << m_document->renderer()->mltTrackDuration(freetrack);
- if (m_document->trackInfoAt(freetrack - 1).type == AUDIOTRACK) {
+ 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);
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;
emit clipItemSelected(NULL);
}
+void CustomTrackView::updatePalette()
+{
+ m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
+ if (m_cursorLine) {
+ QPen pen1 = QPen();
+ pen1.setWidth(1);
+ pen1.setColor(palette().text().color());
+ m_cursorLine->setPen(pen1);
+ }
+ emit tracksChanged();
+}
+
+void CustomTrackView::removeTipAnimation()
+{
+ if (m_visualTip) {
+ scene()->removeItem(m_visualTip);
+ m_animationTimer->stop();
+ delete m_animation;
+ m_animation = NULL;
+ delete m_visualTip;
+ m_visualTip = NULL;
+ }
+}
+
+void CustomTrackView::setTipAnimation(AbstractClipItem *clip, OPERATIONTYPE mode, const double size)
+{
+ if (m_visualTip == NULL) {
+ QRectF rect = clip->sceneBoundingRect();
+ m_animation = new QGraphicsItemAnimation;
+ m_animation->setTimeLine(m_animationTimer);
+ m_animation->setScaleAt(1, 1, 1);
+ QPolygon polygon;
+ switch (mode) {
+ case FADEIN:
+ case FADEOUT:
+ m_visualTip = new QGraphicsEllipseItem(-size, -size, size * 2, size * 2);
+ ((QGraphicsEllipseItem*) m_visualTip)->setBrush(m_tipColor);
+ ((QGraphicsEllipseItem*) m_visualTip)->setPen(m_tipPen);
+ if (mode == FADEIN)
+ m_visualTip->setPos(rect.x() + ((ClipItem *) clip)->fadeIn(), rect.y());
+ else
+ m_visualTip->setPos(rect.right() - ((ClipItem *) clip)->fadeOut(), rect.y());
+
+ m_animation->setScaleAt(.5, 2, 2);
+ break;
+ case RESIZESTART:
+ case RESIZEEND:
+ polygon << QPoint(0, - size * 2);
+ if (mode == RESIZESTART)
+ polygon << QPoint(size * 2, 0);
+ else
+ polygon << QPoint(- size * 2, 0);
+ polygon << QPoint(0, size * 2);
+ polygon << QPoint(0, - size * 2);
+
+ m_visualTip = new QGraphicsPolygonItem(polygon);
+ ((QGraphicsPolygonItem*) m_visualTip)->setBrush(m_tipColor);
+ ((QGraphicsPolygonItem*) m_visualTip)->setPen(m_tipPen);
+ if (mode == RESIZESTART)
+ m_visualTip->setPos(rect.x(), rect.y() + rect.height() / 2);
+ else
+ m_visualTip->setPos(rect.right(), rect.y() + rect.height() / 2);
+
+ m_animation->setScaleAt(.5, 2, 1);
+ break;
+ case TRANSITIONSTART:
+ case TRANSITIONEND:
+ polygon << QPoint(0, - size * 2);
+ if (mode == TRANSITIONSTART)
+ polygon << QPoint(size * 2, 0);
+ else
+ polygon << QPoint(- size * 2, 0);
+ polygon << QPoint(0, 0);
+ polygon << QPoint(0, - size * 2);
+
+ m_visualTip = new QGraphicsPolygonItem(polygon);
+ ((QGraphicsPolygonItem*) m_visualTip)->setBrush(m_tipColor);
+ ((QGraphicsPolygonItem*) m_visualTip)->setPen(m_tipPen);
+ if (mode == TRANSITIONSTART)
+ m_visualTip->setPos(rect.x(), rect.bottom());
+ else
+ m_visualTip->setPos(rect.right(), rect.bottom());
+
+ m_animation->setScaleAt(.5, 2, 2);
+ break;
+ default:
+ delete m_animation;
+ return;
+ }
+
+ m_visualTip->setFlags(QGraphicsItem::ItemIgnoresTransformations);
+ m_visualTip->setZValue(100);
+ scene()->addItem(m_visualTip);
+ m_animation->setItem(m_visualTip);
+ m_animationTimer->start();
+ }
+}
+
+bool CustomTrackView::hasAudio(int track) const
+{
+ QRectF rect(0, (double)(track * m_tracksHeight + 1), (double) sceneRect().width(), (double)(m_tracksHeight - 1));
+ QList<QGraphicsItem *> collisions = scene()->items(rect, Qt::IntersectsItemBoundingRect);
+ QGraphicsItem *item;
+ for (int i = 0; i < collisions.count(); i++) {
+ item = collisions.at(i);
+ if (!item->isEnabled()) continue;
+ if (item->type() == AVWIDGET) {
+ ClipItem *clip = static_cast <ClipItem *>(item);
+ if (!clip->isVideoOnly() && (clip->clipType() == AUDIO || clip->clipType() == AV || clip->clipType() == PLAYLIST)) return true;
+ }
+ }
+ return false;
+}
+
+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);
+ setDocumentModified();
+}
+
+
+EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
+{
+ EffectsParameterList parameters;
+ parameters.addParam("tag", effect.attribute("tag"));
+ if (effect.hasAttribute("region")) parameters.addParam("region", effect.attribute("region"));
+ parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
+ parameters.addParam("id", effect.attribute("id"));
+ if (effect.hasAttribute("src")) parameters.addParam("src", effect.attribute("src"));
+ if (effect.hasAttribute("disable")) parameters.addParam("disable", effect.attribute("disable"));
+ if (effect.hasAttribute("in")) parameters.addParam("in", effect.attribute("in"));
+ if (effect.hasAttribute("out")) parameters.addParam("out", effect.attribute("out"));
+
+ 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") == "simplekeyframe") {
+
+ QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
+ double factor = e.attribute("factor", "1").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);
+ }
+ // kDebug() << "/ / / /SENDING KEYFR:" << values;
+ parameters.addParam(e.attribute("name"), values.join(";"));
+ /*parameters.addParam(e.attribute("name"), e.attribute("keyframes").replace(":", "="));
+ parameters.addParam("max", e.attribute("max"));
+ parameters.addParam("min", e.attribute("min"));
+ parameters.addParam("factor", e.attribute("factor", "1"));*/
+ } else if (e.attribute("type") == "keyframe") {
+ kDebug() << "/ / / /SENDING KEYFR EFFECT TYPE";
+ parameters.addParam("keyframes", e.attribute("keyframes"));
+ parameters.addParam("max", e.attribute("max"));
+ parameters.addParam("min", e.attribute("min"));
+ parameters.addParam("factor", e.attribute("factor", "1"));
+ parameters.addParam("starttag", e.attribute("starttag", "start"));
+ parameters.addParam("endtag", e.attribute("endtag", "end"));
+ } else if (e.attribute("namedesc").contains(';')) {
+ QString format = e.attribute("format");
+ QStringList separators = format.split("%d", QString::SkipEmptyParts);
+ QStringList values = e.attribute("value").split(QRegExp("[,:;x]"));
+ QString neu;
+ QTextStream txtNeu(&neu);
+ if (values.size() > 0)
+ txtNeu << (int)values[0].toDouble();
+ for (int i = 0; i < separators.size() && i + 1 < values.size(); i++) {
+ txtNeu << separators[i];
+ txtNeu << (int)(values[i+1].toDouble());
+ }
+ parameters.addParam("start", neu);
+ } else {
+ if (e.attribute("factor", "1") != "1") {
+ double fact;
+ if (e.attribute("factor").startsWith('%')) {
+ 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 {
+ 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();
+ int max = tracks.count();
+ int docTrack = max - track - 1;
+
+ // count number of tracks of each type
+ int videoTracks = 0;
+ int audioTracks = 0;
+ for (int i = max - 1; i >= 0; --i) {
+ TrackInfo info = tracks.at(i);
+ if (info.type == VIDEOTRACK)
+ videoTracks++;
+ else
+ audioTracks++;
+
+ if (i <= docTrack) {
+ QString type = (info.type == VIDEOTRACK ? "Video " : "Audio ");
+ int typeNumber = (info.type == VIDEOTRACK ? videoTracks : audioTracks);
+
+ if (added) {
+ if (i == docTrack || info.trackName == type + QString::number(typeNumber - 1)) {
+ info.trackName = type + QString::number(typeNumber);
+ m_document->setTrackType(i, info);
+ }
+ } else {
+ if (info.trackName == type + QString::number(typeNumber + 1)) {
+ info.trackName = type + QString::number(typeNumber);
+ m_document->setTrackType(i, info);
+ }
+ }
+ }
+ }
+
+ emit tracksChanged();
+}
+