Skip to content

Commit

Permalink
add Scroll to Playhead on Zoom to Keyframes menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Oct 23, 2020
1 parent c8e2814 commit 5f5cf96
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/qml/views/keyframes/Keyframes.js
Expand Up @@ -19,10 +19,10 @@ function trackHeight(isCurves) {
return isCurves? (multitrack.trackHeight * 2) : (multitrack.trackHeight < 30)? 20 : 36
}

function scrollIfNeeded() {
function scrollIfNeeded(center) {
var x = producer.position * timeScale;
if (!scrollView) return;
if (settings.timelineCenterPlayhead) {
if (settings.timelineCenterPlayhead || center) {
if (x > scrollView.flickableItem.contentX + scrollView.width * 0.5)
scrollView.flickableItem.contentX = x - scrollView.width * 0.5;
else if (x < scrollView.width * 0.5)
Expand Down
3 changes: 3 additions & 0 deletions src/qml/views/keyframes/ZoomSlider.qml
Expand Up @@ -58,6 +58,9 @@ Rectangle {
scrollView.flickableItem.contentX = (targetX * timeScale / before) - offset

redrawWaveforms()

if (settings.timelineScrollZoom)
scrollZoomTimer.restart()
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/qml/views/keyframes/keyframes.qml
Expand Up @@ -60,8 +60,18 @@ Rectangle {
scrollView.flickableItem.contentX = Logic.clamp((targetX * timeScale / before) - offset, 0, Logic.scrollMax().x)
}

Timer {
id: scrollZoomTimer
interval: 100
onTriggered: {
Logic.scrollIfNeeded(true)
}
}

function adjustZoom(by, targetX) {
setZoom(keyframesToolbar.scaleSlider.value + by, targetX)
if (settings.timelineScrollZoom)
scrollZoomTimer.restart()
}

function zoomIn() {
Expand Down Expand Up @@ -465,6 +475,12 @@ Rectangle {
checked: settings.timelineCenterPlayhead
onTriggered: settings.timelineCenterPlayhead = checked
}
MenuItem {
text: qsTr('Scroll to Playhead on Zoom')
checkable: true
checked: settings.timelineScrollZoom
onTriggered: settings.timelineScrollZoom = checked
}
MenuSeparator {}
MenuItem {
text: qsTr('Reload')
Expand Down

0 comments on commit 5f5cf96

Please sign in to comment.