}
}
+void CustomTrackView::slotAlignPlayheadToMousePos()
+{
+ /* get curser point ref in screen coord */
+ QPoint ps = QCursor::pos();
+ /* get xPos in scene coord */
+ int mappedXPos = qMax((int)(mapToScene(mapFromGlobal(ps)).x() + 0.5), 0);
+ /* move playhead to new xPos*/
+ seekCursorPos(mappedXPos);
+}
// virtual
void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
// context menu requested
if (event->button() == Qt::RightButton) {
- if (m_dragItem) {
- if (dragGroup) dragGroup->setSelected(true);
- else if (!m_dragItem->isSelected()) {
- resetSelectionGroup(false);
- m_scene->clearSelection();
- m_dragItem->setSelected(true);
- }
- } else if (!m_dragGuide) {
+ if (!m_dragItem && !m_dragGuide) {
// check if there is a guide close to mouse click
QList<QGraphicsItem *> guidesCollisionList = items(event->pos().x() - 5, event->pos().y(), 10, 2); // a rect of height < 2 does not always collide with the guide
for (int i = 0; i < guidesCollisionList.count(); i++) {
m_operationMode = NONE;
displayContextMenu(event->globalPos(), m_dragItem, dragGroup);
m_menuPosition = m_clickEvent;
- m_dragItem = NULL;
- event->accept();
- return;
}
// No item under click
updateSnapPoints(NULL, cleandOffsetList, true);
}
m_operationMode = SPACER;
- } else {
+ } else if (event->button() != Qt::RightButton) {
setCursor(Qt::ArrowCursor);
seekCursorPos((int)(mapToScene(event->x(), 0).x()));
}
}
}
if (itemsList.isEmpty() && groupsList.isEmpty()) return;
+ if (itemsList.count() == 1) {
+ // only one item selected:
+ QSetIterator<QGraphicsItem *> it(itemsList);
+ m_dragItem = static_cast<AbstractClipItem *>(it.next());
+ m_dragItem->setSelected(true);
+ emit clipItemSelected(static_cast<ClipItem *>(m_dragItem));
+ }
QRectF rectUnion;
// Find top left position of selection
}
} else {
prepareResizeClipStart(m_dragItem, m_dragItemInfo, m_dragItem->startPos().frames(m_document->fps()));
+ if (m_dragItem->type() == AVWIDGET) static_cast <ClipItem*>(m_dragItem)->slotUpdateRange();
}
} else if (m_operationMode == RESIZEEND && m_dragItem->endPos() != m_dragItemInfo.endPos) {
// resize end
}
} else {
prepareResizeClipEnd(m_dragItem, m_dragItemInfo, m_dragItem->endPos().frames(m_document->fps()));
+ if (m_dragItem->type() == AVWIDGET) static_cast <ClipItem*>(m_dragItem)->slotUpdateRange();
}
} else if (m_operationMode == FADEIN) {
// resize fade in effect
void CustomTrackView::slotImportClipKeyframes(GRAPHICSRECTITEM type)
{
- if (!m_selectionGroup) {
- emit displayMessage(i18n("You need to select one clip and one transition"), ErrorMessage);
- return;
- }
- // Make sure there is no collision
- QList<QGraphicsItem *> children = m_selectionGroup->childItems();
ClipItem *item = NULL;
- for (int i = 0; i < children.count(); i++) {
- if (children.at(i)->type() == AVWIDGET) {
- item = (ClipItem*) children.at(i);
- break;
- }
+ if (type == TRANSITIONWIDGET) {
+ // We want to import keyframes to a transition
+ if (!m_selectionGroup) {
+ emit displayMessage(i18n("You need to select one clip and one transition"), ErrorMessage);
+ return;
+ }
+ // Make sure there is no collision
+ QList<QGraphicsItem *> children = m_selectionGroup->childItems();
+ for (int i = 0; i < children.count(); i++) {
+ if (children.at(i)->type() == AVWIDGET) {
+ item = (ClipItem*) children.at(i);
+ break;
+ }
+ }
+ }
+ else {
+ // Import keyframes from current clip to its effect
+ if (m_dragItem) item = static_cast<ClipItem*> (m_dragItem);
}
+
if (!item) {
emit displayMessage(i18n("No clip found"), ErrorMessage);
return;
return;
}
QString keyframeData = ui.data_list->itemData(ui.data_list->currentIndex()).toString();
- QStringList keyframeList = keyframeData.split(';', QString::SkipEmptyParts);
+
+ int offset = item->cropStart().frames(m_document->fps());
+ Mlt::Geometry geometry(keyframeData.toUtf8().data(), item->baseClip()->maxDuration().frames(m_document->fps()), m_document->mltProfile().width, m_document->mltProfile().height);
+ Mlt::Geometry newGeometry(QString().toUtf8().data(), item->baseClip()->maxDuration().frames(m_document->fps()), m_document->mltProfile().width, m_document->mltProfile().height);
+ Mlt::GeometryItem gitem;
+ geometry.fetch(&gitem, offset);
+ gitem.frame(0);
+ newGeometry.insert(gitem);
+ int pos = offset + 1;
+ while (!geometry.next_key(&gitem, pos)) {
+ pos = gitem.frame();
+ gitem.frame(pos - offset);
+ pos++;
+ newGeometry.insert(gitem);
+ }
+ QStringList keyframeList = QString(newGeometry.serialise()).split(';', QString::SkipEmptyParts);
+
QString result;
if (ui.import_position->isChecked()) {
if (ui.import_size->isChecked()) {