Monitor zoombar: zoom audio thumbs too (audio thumb resolution is still bad on...

Monitor zoombar: zoom audio thumbs too (audio thumb resolution is still bad on zoom), fix some regressions caused by zoombar
Related to #651
parent b43c0aba
Pipeline #25081 passed with stage
in 9 minutes and 45 seconds
......@@ -8,7 +8,9 @@ Rectangle {
color: activePalette.base
property bool containsMouse: rulerMouseArea.containsMouse
property bool seekingFinished : controller.seekFinished
// The width of the visible part
property double rulerZoomWidth: root.zoomFactor * width
// The pixel offset
property double rulerZoomOffset: root.zoomStart * width / root.zoomFactor
Rectangle {
color: activePalette.light
......@@ -16,6 +18,38 @@ Rectangle {
height: 1
}
function zoomInRuler(xPos)
{
root.showZoomBar = true
var middle = xPos / rulerMouseArea.width / 1.2
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
}
root.zoomStart = startPos
zoomBar.x = root.zoomStart * zoomHandleContainer.width
zoomBar.width = root.zoomFactor * zoomHandleContainer.width
}
function zoomOutRuler(xPos)
{
root.zoomFactor = Math.min(1, root.zoomFactor * 1.2)
if (root.zoomFactor == 1) {
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
}
root.zoomStart = middle
}
zoomBar.x = root.zoomStart * zoomHandleContainer.width
zoomBar.width = root.zoomFactor * zoomHandleContainer.width
}
// Zoom bar container
Rectangle {
height: root.baseUnit
......@@ -70,6 +104,17 @@ Rectangle {
root.zoomFactor = 1
}
}
onWheel: {
if (wheel.modifiers & Qt.ControlModifier) {
if (wheel.angleDelta.y < 0) {
// zoom out
zoomOutRuler(wheel.x)
} else {
// zoom in
zoomInRuler(wheel.x)
}
}
}
}
}
MouseArea {
......@@ -199,8 +244,8 @@ Rectangle {
id: zone
visible: controller.zoneOut > controller.zoneIn
color: activePalette.highlight
x: controller.zoneIn * root.timeScale - ruler.rulerZoomOffset
width: (controller.zoneOut - controller.zoneIn) * root.timeScale
x: controller.zoneIn * root.timeScale / root.zoomFactor - ruler.rulerZoomOffset
width: (controller.zoneOut - controller.zoneIn) * root.timeScale / root.zoomFactor
anchors.bottom: parent.bottom
height: ruler.height / 2
opacity: 0.8
......@@ -228,7 +273,7 @@ Rectangle {
onPressed: {
if (mouse.buttons === Qt.LeftButton) {
var pos = Math.max(mouseX, 0)
controller.position = Math.min((pos + ruler.rulerZoomOffset) / root.timeScale, root.duration);
controller.position = Math.min((pos + ruler.rulerZoomOffset)*root.zoomFactor / root.timeScale, root.duration);
}
}
onPositionChanged: {
......@@ -236,7 +281,7 @@ Rectangle {
var pos = Math.max(mouseX, 0)
root.mouseRulerPos = pos
if (pressed) {
controller.position = Math.min((pos + ruler.rulerZoomOffset) / root.timeScale, root.duration);
controller.position = Math.min((pos + ruler.rulerZoomOffset)*root.zoomFactor / root.timeScale, root.duration);
}
}
}
......@@ -244,31 +289,11 @@ Rectangle {
if (wheel.modifiers & Qt.ControlModifier) {
if (wheel.angleDelta.y < 0) {
// zoom out
root.zoomFactor = Math.min(1, root.zoomFactor * 1.2)
if (root.zoomFactor == 1) {
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
}
root.zoomStart = middle
}
zoomOutRuler(wheel.x)
} else {
// zoom in
root.showZoomBar = true
var middle = wheel.x / rulerMouseArea.width / 1.2 //root.zoomStart + root.zoomFactor / 2
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
}
root.zoomStart = startPos
zoomInRuler(wheel.x)
}
zoomBar.x = root.zoomStart * zoomHandleContainer.width
zoomBar.width = root.zoomFactor * zoomHandleContainer.width
}
}
}
......@@ -294,7 +319,7 @@ Rectangle {
// monitor zone
Rectangle {
id: inZoneMarker
x: controller.zoneIn * root.timeScale - ruler.rulerZoomOffset
x: controller.zoneIn * root.timeScale/ root.zoomFactor - ruler.rulerZoomOffset
anchors.bottom: parent.bottom
anchors.top: parent.top
width: 1
......@@ -302,7 +327,7 @@ Rectangle {
visible: controller.zoneOut > controller.zoneIn && (rulerMouseArea.containsMouse || trimOutMouseArea.containsMouse || trimOutMouseArea.pressed || trimInMouseArea.containsMouse)
}
Rectangle {
x: controller.zoneOut * root.timeScale - ruler.rulerZoomOffset
x: controller.zoneOut * root.timeScale/ root.zoomFactor - ruler.rulerZoomOffset
anchors.bottom: parent.bottom
anchors.top: parent.top
width: 1
......@@ -317,7 +342,7 @@ Rectangle {
opacity: 1
anchors.top: ruler.top
fillColor: activePalette.windowText
x: controller.position * root.timeScale - (width / 2) - ruler.rulerZoomOffset
x: controller.position * root.timeScale / root.zoomFactor - (width / 2) - ruler.rulerZoomOffset
}
Rectangle {
id: trimIn
......
......@@ -19,8 +19,11 @@ Item {
property double scalex
property double scaley
// Zoombar properties
// The start position of the zoomed area, between 0 and 1
property double zoomStart: 0
// The zoom factor (between 0 and 1). 0.5 means 2x zoom
property double zoomFactor: 1
// The pixel height of zoom bar, used to offset markers info
property int zoomOffset: 0
property bool showZoomBar: false
property bool dropped: false
......@@ -41,7 +44,7 @@ Item {
property color overlayColor: 'cyan'
property bool isClipMonitor: true
property int dragType: 0
FontMetrics {
id: fontMetrics
font: fixedFont
......@@ -56,6 +59,11 @@ Item {
onDurationChanged: {
clipMonitorRuler.updateRuler()
// Reset zoom on clip change
root.zoomStart = 0
root.zoomFactor = 1
root.showZoomBar = false
root.zoomOffset = 0
}
onWidthChanged: {
clipMonitorRuler.updateRuler()
......@@ -183,8 +191,8 @@ Item {
color: "yellow"
opacity: 0.3
height: parent.height
x: controller.zoneIn * timeScale
width: (controller.zoneOut - controller.zoneIn) * timeScale
x: controller.zoneIn * timeScale / root.zoomFactor - (audioThumb.width/root.zoomFactor * root.zoomStart)
width: (controller.zoneOut - controller.zoneIn) * timeScale / root.zoomFactor
visible: controller.zoneIn > 0 || controller.zoneOut < duration - 1
}
Repeater {
......@@ -202,6 +210,10 @@ Item {
height: streamThumb.streamHeight
y: model.index * height
source: controller.audioThumb[model.index]
transform: [
Translate { x: (-audioThumb.width * root.zoomStart)},
Scale {xScale: 1/root.zoomFactor}
]
asynchronous: true
}
Rectangle {
......@@ -217,19 +229,38 @@ Item {
color: "red"
width: 1
height: parent.height
x: controller.position * timeScale
x: controller.position * timeScale / root.zoomFactor - (audioThumb.width/root.zoomFactor * root.zoomStart)
}
MouseArea {
id: thumbMouseArea
anchors.fill: parent
acceptedButtons: Qt.NoButton
acceptedButtons: audioThumb.isAudioClip ? Qt.NoButton : Qt.LeftButton
hoverEnabled: true
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) {
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));
}
}
onWheel: {
if (wheel.modifiers & Qt.ControlModifier) {
if (wheel.angleDelta.y < 0) {
// zoom out
clipMonitorRuler.zoomOutRuler(wheel.x)
} else {
// zoom in
clipMonitorRuler.zoomInRuler(wheel.x)
}
}
}
}
}
Label {
......
......@@ -135,6 +135,7 @@ Item {
anchors {
right: parent.right
bottom: parent.bottom
bottomMargin: root.zoomOffset
}
}
Label {
......@@ -152,6 +153,7 @@ Item {
anchors {
right: timecode.visible ? timecode.left : parent.right
bottom: parent.bottom
bottomMargin: root.zoomOffset
}
}
Label {
......@@ -160,6 +162,7 @@ Item {
anchors {
left: parent.left
bottom: parent.bottom
bottomMargin: root.zoomOffset
}
visible: root.showMarkers && controller.position == controller.zoneIn
text: i18n("In Point")
......@@ -176,6 +179,7 @@ Item {
anchors {
left: inPoint.visible ? inPoint.right : parent.left
bottom: parent.bottom
bottomMargin: root.zoomOffset
}
visible: root.showMarkers && controller.position + 1 == controller.zoneOut
text: i18n("Out Point")
......@@ -199,6 +203,7 @@ Item {
anchors {
left: outPoint.visible ? outPoint.right : inPoint.visible ? inPoint.right : parent.left
bottom: parent.bottom
bottomMargin: root.zoomOffset
}
visible: root.showMarkers && text != ""
text: controller.markerComment
......
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