Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix cursor position on zoombar, always center zoom on current cursor position.

Related to #651
parent 6a5ec56a
Pipeline #25609 passed with stage
in 9 minutes and 30 seconds
......@@ -21,13 +21,21 @@ Rectangle {
function zoomInRuler(xPos)
{
root.showZoomBar = true
var middle = xPos / rulerMouseArea.width / 1.2
var currentX = playhead.x
var currentCursor = playhead.x + playhead.width / 2 + ruler.rulerZoomOffset
// Adjust zoom factor
root.zoomFactor = Math.min(1, root.zoomFactor / 1.2)
var startPos = Math.max(0, middle - root.zoomFactor / 2)
if (startPos + root.zoomFactor > 1) {
startPos = 1 - root.zoomFactor
if (root.zoomFactor * zoomHandleContainer.width < root.baseUnit / 2) {
// Don't allow too large zoom
root.zoomFactor = root.baseUnit / 2 / zoomHandleContainer.width
}
root.zoomStart = startPos
// Always try to have cursor pos centered in zoom
var cursorPos = Math.max(0, controller.position / root.duration - root.zoomFactor / 2)
if (cursorPos + root.zoomFactor > 1) {
cursorPos = 1 - root.zoomFactor
}
root.zoomStart = cursorPos
zoomBar.x = root.zoomStart * zoomHandleContainer.width
zoomBar.width = root.zoomFactor * zoomHandleContainer.width
}
......@@ -39,12 +47,12 @@ Rectangle {
root.zoomStart = 0
root.showZoomBar = false
} else {
var middle = root.zoomStart + root.zoomFactor / 2
middle = Math.max(0, middle - root.zoomFactor / 2)
if (middle + root.zoomFactor > 1) {
middle = 1 - root.zoomFactor
// Always try to have cursor pos centered in zoom
var cursorPos = Math.max(0, controller.position / root.duration - root.zoomFactor / 2)
if (cursorPos + root.zoomFactor > 1) {
cursorPos = 1 - root.zoomFactor
}
root.zoomStart = middle
root.zoomStart = cursorPos
}
zoomBar.x = root.zoomStart * zoomHandleContainer.width
zoomBar.width = root.zoomFactor * zoomHandleContainer.width
......@@ -273,7 +281,7 @@ Rectangle {
onPressed: {
if (mouse.buttons === Qt.LeftButton) {
var pos = Math.max(mouseX, 0)
controller.position = Math.min((pos + ruler.rulerZoomOffset)*root.zoomFactor / root.timeScale, root.duration);
controller.position = Math.min((pos + ruler.rulerZoomOffset) / root.timeScale, root.duration);
}
}
onPositionChanged: {
......@@ -281,7 +289,7 @@ Rectangle {
var pos = Math.max(mouseX, 0)
root.mouseRulerPos = pos
if (pressed) {
controller.position = Math.min((pos + ruler.rulerZoomOffset)*root.zoomFactor / root.timeScale, root.duration);
controller.position = Math.min((pos + ruler.rulerZoomOffset) / root.timeScale, root.duration);
}
}
}
......@@ -342,7 +350,7 @@ Rectangle {
opacity: 1
anchors.top: ruler.top
fillColor: activePalette.windowText
x: controller.position * root.timeScale / root.zoomFactor - (width / 2) - ruler.rulerZoomOffset
x: controller.position * root.timeScale - (width / 2) - ruler.rulerZoomOffset
}
Rectangle {
id: trimIn
......
......@@ -191,8 +191,8 @@ Item {
color: "yellow"
opacity: 0.3
height: parent.height
x: controller.zoneIn * timeScale / root.zoomFactor - (audioThumb.width/root.zoomFactor * root.zoomStart)
width: (controller.zoneOut - controller.zoneIn) * timeScale / root.zoomFactor
x: controller.zoneIn * timeScale - (audioThumb.width/root.zoomFactor * root.zoomStart)
width: (controller.zoneOut - controller.zoneIn) * timeScale
visible: controller.zoneIn > 0 || controller.zoneOut < duration - 1
}
Repeater {
......@@ -229,7 +229,7 @@ Item {
color: "red"
width: 1
height: parent.height
x: controller.position * timeScale / root.zoomFactor - (audioThumb.width/root.zoomFactor * root.zoomStart)
x: controller.position * timeScale - (audioThumb.width/root.zoomFactor * root.zoomStart)
}
MouseArea {
id: thumbMouseArea
......@@ -239,14 +239,12 @@ Item {
onPressed: {
var pos = Math.max(mouseX, 0)
pos += audioThumb.width/root.zoomFactor * root.zoomStart
pos *= root.zoomFactor
controller.setPosition(Math.min(pos / root.timeScale, root.duration));
}
onPositionChanged: {
if (mouse.modifiers & Qt.ShiftModifier || (pressed && !audioThumb.isAudioClip)) {
var pos = Math.max(mouseX, 0)
pos += audioThumb.width/root.zoomFactor * root.zoomStart
pos *= root.zoomFactor
controller.setPosition(Math.min(pos / root.timeScale, root.duration));
}
}
......
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