Commit ebf408ea authored by luyikei's avatar luyikei

Timeline: Use a property to set the position of cursor

parent bc7e6030
......@@ -3,9 +3,11 @@ import QtQuick 2.0
Rectangle {
width: 2
color: "#c24a00"
x: ftop( cursorPosition ) + initPosOfCursor
onXChanged: {
x = x > initPosOfCursor ? x : initPosOfCursor;
Component.onCompleted: {
// FIXME: Binding is lost
x = Qt.binding( function() { return ftop( cursorPosition ) + initPosOfCursor; } );
}
function position() {
......
......@@ -119,27 +119,28 @@ Rectangle {
anchors.fill: parent
onPressed: {
cursor.x = mouseX + initPosOfCursor;
cursorPosition = ptof( mouseX );
}
onReleased: {
workflow.setPosition( ptof( mouseX ) );
workflow.setPosition( cursorPosition );
}
onClicked: {
workflow.setPosition( ptof( mouseX ) );
cursorPosition = ptof( mouseX );
workflow.setPosition( cursorPosition );
}
onPositionChanged: {
cursor.x = mouseX + initPosOfCursor;
workflow.setPosition( ptof( mouseX ) );
cursorPosition = ptof( mouseX );
workflow.setPosition( cursorPosition );
}
}
Connections {
target: workflow
onFrameChanged: {
cursor.x = ftop( newFrame ) + initPosOfCursor;
cursorPosition = newFrame;
}
}
}
......
......@@ -10,6 +10,7 @@ Rectangle {
focus: true
property int length // in frames
property int cursorPosition: 0 // in frames
property int initPosOfCursor: 100
property double ppu: 10 // Pixels Per minimum Unit
property double unit: 3000 // In milliseconds therefore ppu / unit = Pixels Per milliseconds
......@@ -187,8 +188,6 @@ Rectangle {
// Make unit a multiple of fps. This can change the scale but let's ignore it.
newUnit -= newUnit % mUnit;
var cursorPos = cursor.position();
// If "almost" the same value, don't bother redrawing the ruler.
if ( Math.abs( unit - newUnit ) > 0.01 )
unit = newUnit;
......@@ -196,8 +195,6 @@ Rectangle {
if ( Math.abs( ppu - newPpu ) > 0.0001 )
ppu = newPpu;
cursor.x = ftop( cursorPos ) + initPosOfCursor;
// Let's scroll to the cursor position!
var newContentX = cursor.x - sView.width / 2;
// Never show the background behind the timeline
......
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