Center view when seeking to timeline clip.

Fixes #844
parent 8fc74398
......@@ -201,6 +201,10 @@ Rectangle {
}
return col
}
function centerViewOnCursor() {
scrollView.contentX = Math.max(0, root.consumerPosition * timeline.scaleFactor - (scrollView.width / 2))
}
function clearDropData() {
clipBeingDroppedId = -1
......
......@@ -1653,6 +1653,7 @@ void TimelineController::focusItem(int itemId)
{
int start = m_model->getItemPosition(itemId);
setPosition(start);
emit centerView();
}
int TimelineController::headerWidth() const
......
......@@ -697,6 +697,9 @@ signals:
/* @brief User enabled / disabled snapping, update timeline behavior
*/
void snapChanged();
/* @brief Center timeline view on current position
*/
void centerView();
Q_INVOKABLE void ungrabHack();
};
......
......@@ -87,6 +87,7 @@ void TimelineTabs::connectTimeline(TimelineWidget *timeline)
connect(timeline->controller(), &TimelineController::updateZoom, this, [&](double value) { emit updateZoom(getCurrentTimeline()->zoomForScale(value)); });
connect(timeline->controller(), &TimelineController::showItemEffectStack, this, &TimelineTabs::showItemEffectStack);
connect(timeline->controller(), &TimelineController::showSubtitle, this, &TimelineTabs::showSubtitle);
connect(timeline->controller(), &TimelineController::centerView, timeline, &TimelineWidget::slotCenterView);
}
void TimelineTabs::disconnectTimeline(TimelineWidget *timeline)
......
......@@ -365,6 +365,11 @@ void TimelineWidget::slotChangeZoom(int value, bool zoomOnMouse)
m_proxy->setScaleFactorOnMouse(pixelScale / comboScale[value], zoomOnMouse);
}
void TimelineWidget::slotCenterView()
{
QMetaObject::invokeMethod(rootObject(), "centerViewOnCursor");
}
void TimelineWidget::slotFitZoom()
{
QVariant returnedValue;
......
......@@ -66,6 +66,8 @@ protected:
public slots:
void slotChangeZoom(int value, bool zoomOnMouse);
void slotFitZoom();
/* @brief Center timeline view on current timeline cursor position */
void slotCenterView();
void zoneUpdated(const QPoint &zone);
void zoneUpdatedWithUndo(const QPoint &oldZone, const QPoint &newZone);
/* @brief Favorite effects have changed, reload model for context menu */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment