Commit 714e90d0 authored by Pistos Pi's avatar Pistos Pi Committed by Jean-Baptiste Mardelle
Browse files

Refactor: DRY up some code

parent 2c6b5b18
Pipeline #46616 passed with stage
in 10 minutes and 39 seconds
......@@ -105,28 +105,36 @@ Rectangle {
}
} else if (wheel.modifiers & Qt.ShiftModifier) {
if (scrollVertically) {
// Horizontal scroll
var newScroll = Math.min(scrollView.contentX - wheel.angleDelta.y, timeline.fullDuration * root.timeScale - scrollView.width)
scrollView.contentX = Math.max(newScroll, 0)
horizontalScroll(wheel)
} else {
// Vertical scroll
var newScroll = Math.min(scrollView.contentY - wheel.angleDelta.y, trackHeaders.height - tracksArea.height + horScroll.height + ruler.height)
scrollView.contentY = Math.max(newScroll, 0)
verticalScroll(wheel)
}
} else {
if (scrollVertically) {
// Vertical scroll
var newScroll = Math.min(scrollView.contentY - wheel.angleDelta.y, trackHeaders.height - tracksArea.height + horScroll.height + ruler.height)
scrollView.contentY = Math.max(newScroll, 0)
verticalScroll(wheel)
} else {
// Horizontal scroll
var newScroll = Math.min(scrollView.contentX - wheel.angleDelta.y, timeline.fullDuration * root.timeScale - scrollView.width)
scrollView.contentX = Math.max(newScroll, 0)
horizontalScroll(wheel)
}
}
wheel.accepted = true
}
function horizontalScroll(wheel) {
var newScroll = Math.min(
scrollView.contentX - wheel.angleDelta.y,
timeline.fullDuration * root.timeScale - scrollView.width
)
scrollView.contentX = Math.max(newScroll, 0)
}
function verticalScroll(wheel) {
var newScroll = Math.min(
scrollView.contentY - wheel.angleDelta.y,
trackHeaders.height - tracksArea.height + horScroll.height + ruler.height
)
scrollView.contentY = Math.max(newScroll, 0)
}
function continuousScrolling(x, y) {
// This provides continuous scrolling at the left/right edges.
if (x > scrollView.contentX + scrollView.width - root.baseUnit * 3) {
......
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