[vlmc-devel] Track.qml: Fix unstable position changing when MagneticMode is on

Yikai Lu git at videolan.org
Wed Jul 19 15:29:41 CEST 2017


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed Jul 19 13:38:18 2017 +0200| [96a938924f7a67adeced3b1d9733b61788bdf5bf] | committer: Yikai Lu

Track.qml: Fix unstable position changing when MagneticMode is on

Since I'm not sure when I could implement transitions, I fix the current collision detection now.

> https://code.videolan.org/videolan/vlmc/commit/96a938924f7a67adeced3b1d9733b61788bdf5bf
---

 src/Gui/timeline/Track.qml | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index 5d4e6914..239ae420 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -114,11 +114,14 @@ Item {
                 if ( isCollided ) {
                     for ( k = 0; k < clips.count; ++k ) {
                         clip = clips.get( k );
+                        if ( clip.uuid === target.uuid )
+                            continue;
                         cx = ftop( clip["position"] );
                         cw = ftop( clip["end"] - clip["begin"] + 1);
                         newX = Math.max( newX, cx + cw );
                     }
                 }
+
                 return newX;
             }
 
@@ -222,10 +225,7 @@ Item {
                         }
                     }
 
-                    if ( drag.source.x !== findNewPosition( drag.source.x, drag.source, false ) )
-                        deltaX = 0;
-                    else
-                        deltaX = drag.source.x - lastX;
+                    deltaX = drag.source.x - lastX;
                 }
                 else
                     deltaX = drag.x - lastX;
@@ -247,14 +247,18 @@ Item {
 
                             // If linked clip collides
                             if ( ptof( Math.abs( newLinkedClipX - newX ) ) !== 0 ) {
-
                                 // Recalculate target's newX
                                 // This time, don't use magnets
-                                newX = findNewPosition( newLinkedClipX, target, false );
-                                newLinkedClipX = findNewPosition( newX, target, false );
+                                if ( isMagneticMode === true )
+                                {
+                                    newX = findNewPosition( newLinkedClipX, target, false );
+                                    newLinkedClipX = findNewPosition( newX, target, false );
 
-                                // And if newX collides again, we don't move
-                                if ( ptof( Math.abs( newLinkedClipX - newX ) ) !== 0 )
+                                    // And if newX collides again, we don't move
+                                    if ( ptof( Math.abs( newLinkedClipX - newX ) ) !== 0 )
+                                        newX = oldX;
+                                }
+                                else
                                     newX = oldX;
                             }
 



More information about the Vlmc-devel mailing list