Nicer ui for timeline clip ctrl speed change

parent 2e9710f8
Pipeline #14106 passed with stage
in 16 minutes and 15 seconds
......@@ -361,8 +361,7 @@ Rectangle {
MouseArea {
// Left resize handle
id: trimInMouseArea
anchors.left: container.left
anchors.leftMargin: -clipRoot.border.width
x: -clipRoot.border.width
height: parent.height
width: root.baseUnit / 2
enabled: !isLocked
......@@ -378,7 +377,6 @@ Rectangle {
root.autoScrolling = false
clipRoot.originalX = clipRoot.x
clipRoot.originalDuration = clipDuration
anchors.left = undefined
shiftTrim = mouse.modifiers & Qt.ShiftModifier
controlTrim = mouse.modifiers & Qt.ControlModifier
if (!shiftTrim && clipRoot.grouped) {
......@@ -388,7 +386,7 @@ Rectangle {
}
onReleased: {
root.autoScrolling = timeline.autoScroll
anchors.left = parent.left
x = -clipRoot.border.width
if (sizeChanged) {
clipRoot.trimmedIn(clipRoot, shiftTrim, controlTrim)
sizeChanged = false
......@@ -396,7 +394,9 @@ Rectangle {
}
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
var delta = Math.round(x / timeScale)
var currentFrame = Math.round((clipRoot.x + (x + clipRoot.border.width)) / timeScale)
var currentClipPos = clipRoot.modelStart
var delta = currentFrame - currentClipPos
if (delta !== 0) {
if (maxDuration > 0 && delta < -inPoint && !(mouse.modifiers & Qt.ControlModifier)) {
delta = -inPoint
......
......@@ -20,7 +20,7 @@ import QtQuick 2.11
import QtQml.Models 2.11
import com.enums 1.0
Column{
Item{
id: trackRoot
property alias trackModel: trackModel.model
property alias rootIndex : trackModel.rootIndex
......@@ -271,10 +271,16 @@ Column{
onTrimmingIn: {
if (controlTrim) {
newDuration = controller.requestItemSpeedChange(clip.clipId, newDuration, false, root.snapping)
speedController.x = clip.x + clip.width - newDuration * trackRoot.timeScale
speedController.width = newDuration * root.timeScale
if (!speedController.visible) {
// Store original speed
speedController.originalSpeed = clip.speed
}
clip.x += clip.width - (newDuration * trackRoot.timeScale)
clip.width = newDuration * root.timeScale
speedController.x = clip.x + clip.border.width
speedController.width = clip.width - 2 * clip.border.width
speedController.lastValidDuration = newDuration
speedController.speedText = (100 * clip.originalDuration * clip.speed / speedController.lastValidDuration).toFixed(2) + '%'
clip.speed = clip.originalDuration * speedController.originalSpeed / newDuration
speedController.visible = true
return
}
......@@ -294,15 +300,14 @@ Column{
}
onTrimmedIn: {
bubbleHelp.hide()
if (controlTrim) {
speedController.visible = false
}
if (shiftTrim || clip.groupTrimData == undefined || controlTrim) {
// We only resize one element
controller.requestItemResize(clip.clipId, clip.originalDuration, false, false, 0, shiftTrim)
if (controlTrim) {
// Update speed
controller.requestClipResizeAndTimeWarp(clip.clipId, speedController.lastValidDuration, false, root.snapping, shiftTrim, clip.originalDuration * clip.speed / speedController.lastValidDuration)
speedController.visible = false
controller.requestClipResizeAndTimeWarp(clip.clipId, speedController.lastValidDuration, false, root.snapping, shiftTrim, clip.originalDuration * speedController.originalSpeed / speedController.lastValidDuration)
speedController.originalSpeed = 1
} else {
controller.requestItemResize(clip.clipId, clip.lastValidDuration, false, true, 0, shiftTrim)
}
......@@ -314,11 +319,16 @@ Column{
}
onTrimmingOut: {
if (controlTrim) {
speedController.x = clip.x
if (!speedController.visible) {
// Store original speed
speedController.originalSpeed = clip.speed
}
speedController.x = clip.x + clip.border.width
newDuration = controller.requestItemSpeedChange(clip.clipId, newDuration, true, root.snapping)
speedController.width = newDuration * trackRoot.timeScale
clip.width = newDuration * trackRoot.timeScale
speedController.width = clip.width - 2 * clip.border.width
speedController.lastValidDuration = newDuration
speedController.speedText = (100 * clip.originalDuration * clip.speed / speedController.lastValidDuration).toFixed(2) + '%'
clip.speed = clip.originalDuration * speedController.originalSpeed / newDuration
speedController.visible = true
return
}
......@@ -337,14 +347,13 @@ Column{
}
onTrimmedOut: {
bubbleHelp.hide()
if (controlTrim) {
speedController.visible = false
}
if (shiftTrim || clip.groupTrimData == undefined || controlTrim) {
controller.requestItemResize(clip.clipId, clip.originalDuration, true, false, 0, shiftTrim)
if (controlTrim) {
speedController.visible = false
// Update speed
controller.requestClipResizeAndTimeWarp(clip.clipId, speedController.lastValidDuration, true, root.snapping, shiftTrim, clip.originalDuration * clip.speed / speedController.lastValidDuration)
controller.requestClipResizeAndTimeWarp(clip.clipId, speedController.lastValidDuration, true, root.snapping, shiftTrim, clip.originalDuration * speedController.originalSpeed / speedController.lastValidDuration)
speedController.originalSpeed = 1
} else {
controller.requestItemResize(clip.clipId, clip.lastValidDuration, true, true, 0, shiftTrim)
}
......@@ -403,21 +412,23 @@ Column{
}
Rectangle {
id: speedController
color: '#aaff0000'
anchors.bottom: parent.bottom
color: activePalette.highlight //'#cccc0000'
visible: false
height: root.baseUnit * 3
height: root.baseUnit * 1.5
property int lastValidDuration: 0
property string speedText: '100%'
property real originalSpeed: 1
Text {
id: speedLabel
text: i18n("Adjusting speed:\n") + speedController.speedText
font.pixelSize: root.baseUnit * 1.2
text: i18n("Adjusting speed")
font.pointSize: root.fontUnit
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
color: 'white'
style: Text.Outline
styleColor: 'black'
color: activePalette.highlightedText
}
transitions: [ Transition {
NumberAnimation { property: "opacity"; duration: 300}
} ]
}
}
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