[vlmc-devel] Track.qml: Fix some errors and strange behavior on locating clips

Yikai Lu git at videolan.org
Thu Jul 28 18:55:45 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Fri Jul 29 01:54:32 2016 +0900| [85c26318cdb49346af2326182a4a6b071e095fae] | committer: Yikai Lu

Track.qml: Fix some errors and strange behavior on locating clips

> https://code.videolan.org/videolan/vlmc/commit/85c26318cdb49346af2326182a4a6b071e095fae
---

 src/Gui/timeline/Track.qml | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index c590755..86f94a7 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -77,7 +77,7 @@ Item {
                 if ( currentTrack )
                     var clips = currentTrack["clips"];
                 else
-                    currentTrack.append( { "clips": [] } );
+                    return oldX;
                 for ( j = 0; j < clips.count + 2 && isCollided; ++j ) {
                     isCollided = false;
                     for ( k = 0; k < clips.count; ++k ) {
@@ -239,14 +239,17 @@ Item {
 
                     scrollToTarget( drag.source );
 
-                    // Optimization: Delta delta X should be 0
-                    if ( ptof( deltaX ) === ptof( drag.source.x - lastX ) && drag.source.x !== 0 ) {
-                        lastX = drag.source.x;
-                        return;
+                    if ( drag.source.x !== findNewPosition( drag.source.x, drag.source, false ) )
+                        deltaX = 0;
+                    else {
+                        // Optimization: Delta delta X should be 0
+                        if ( ptof( deltaX ) === ptof( drag.source.x - lastX ) && drag.source.x !== 0 ) {
+                            lastX = drag.source.x;
+                            return;
+                        }
+                        else
+                            deltaX = drag.source.x - lastX;
                     }
-                    else
-                        deltaX = drag.source.x - lastX;
-
                 }
                 else
                     deltaX = drag.x - lastX;
@@ -259,7 +262,7 @@ Item {
                         target.newTrackId = trackId;
                         for ( var j = 0; j < selectedClips.length; ++j ) {
                             if ( drag.source !== selectedClips[j] )
-                                selectedClips[j].newTrackId = trackId - oldTrackId + selectedClips[j].trackId;
+                                selectedClips[j].newTrackId = Math.max( 0, trackId - oldTrackId + selectedClips[j].trackId );
                         }
                     }
 
@@ -267,15 +270,6 @@ Item {
                         var oldX = target.pixelPosition();
                         var newX = Math.max( oldX + deltaX, 0 );
 
-                        // 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;
-                        }
-
                         newX = findNewPosition( newX, target, isMagneticMode );
 
                         // Let's find newX of the linked clip
@@ -311,6 +305,15 @@ Item {
                             length = ptof( newX + target.width );
                         }
 
+                        // Recalculate deltaX in case of drag.source being moved
+                        if ( drag.source === target ) {
+                            if ( oldTrackId === target.newTrackId )
+                                deltaX = newX - oldX;
+                            else
+                                // Don't move other clips if drag.source's track is changed
+                                deltaX = 0;
+                        }
+
                         target.setPixelPosition( newX );
                         alreadyCalculated.push( target.uuid );
                     }



More information about the Vlmc-devel mailing list