[vlmc-devel] Timeline: Fix the wrong deltaX calculation
Yikai Lu
git at videolan.org
Thu Jul 21 10:14:17 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Thu Jul 21 17:13:45 2016 +0900| [bd460c7b9350a810842942f9063b67589a303231] | committer: Yikai Lu
Timeline: Fix the wrong deltaX calculation
> https://code.videolan.org/videolan/vlmc/commit/bd460c7b9350a810842942f9063b67589a303231
---
src/Gui/timeline/Track.qml | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index 72763aa..75b4345 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -150,6 +150,15 @@ Item {
return;
if ( drag.keys.indexOf( "vlmc/uuid" ) < 0 ) {
+
+ // Put drag.source top
+ for ( var i = 1; i < selectedClips.length; ++i ) {
+ if ( selectedClips[i] === drag.source ) {
+ selectedClips.splice( i, 1 );
+ selectedClips.unshift( drag.source );
+ }
+ }
+
drag.source.y = drag.source.y - drag.y + track.height / 2 - 1; // Adjust to the center
// Optimization: Delta delta X should be different
@@ -164,9 +173,10 @@ Item {
else
deltaX = drag.x - lastX;
- for ( var i = 0; i < selectedClips.length; ++i ) {
+ for ( i = 0; i < selectedClips.length; ++i ) {
var target = selectedClips[i];
var oldx = target.pixelPosition();
+ var newX = Math.max( oldx + deltaX, 0 );
if ( drag.source === target ) {
var oldTrackId = target.newTrackId;
@@ -177,8 +187,6 @@ Item {
}
}
- var newX = Math.max( target.pixelPosition() + deltaX, 0 );
-
if ( isMagneticMode === true ) {
var leastDestance = 25;
// Check two times
@@ -260,6 +268,16 @@ Item {
}
}
+ // Recalculate deltaX in case of drag.source being moved
+ if ( drag.source === target ) {
+ if ( oldTrackId === target.newTrackId )
+ deltaX = Math.round( newX - oldx );
+ else
+ // Don't move other clips if drag.source's track is changed
+ deltaX = 0;
+ }
+
+
target.setPixelPosition( newX );
// Scroll if needed
More information about the Vlmc-devel
mailing list