[vlmc-devel] Track.qml: Remove scrollToTarget

Yikai Lu git at videolan.org
Wed Jul 5 18:56:05 CEST 2017


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Thu Jul  6 00:34:11 2017 +0900| [2524489f966fff88ce0d2874c8e43ada8b1f243d] | committer: Yikai Lu

Track.qml: Remove scrollToTarget

> https://code.videolan.org/videolan/vlmc/commit/2524489f966fff88ce0d2874c8e43ada8b1f243d
---

 src/Gui/timeline/Clip.qml  | 15 +++++++++++++++
 src/Gui/timeline/Track.qml | 19 ++-----------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/Gui/timeline/Clip.qml b/src/Gui/timeline/Clip.qml
index af2a544c..ea3d2f8d 100644
--- a/src/Gui/timeline/Clip.qml
+++ b/src/Gui/timeline/Clip.qml
@@ -113,6 +113,21 @@ Rectangle {
         }
     }
 
+    function scrollToThis() {
+        if ( width > sView.width )
+            return;
+
+        var newContentX = sView.flickableItem.contentX;
+
+        if ( sView.flickableItem.contentX + sView.width <
+                x + mouseX + initPosOfCursor + sView.sViewPadding )
+            newContentX = x + mouseX + initPosOfCursor + sView.sViewPadding - sView.width;
+        else if ( sView.flickableItem.contentX + sView.sViewPadding > x + mouseX )
+            newContentX = x + mouseX - sView.sViewPadding;
+
+        sView.flickableItem.contentX = Math.max( newContentX, 0 );
+    }
+
     onXChanged: {
         if ( sView.width - initPosOfCursor < width )
             return;
diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index f240e0f3..f3f3369c 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -122,21 +122,6 @@ Item {
                 return newX;
             }
 
-            function scrollToTarget( target ) {
-                if ( target.width > sView.width )
-                    return;
-
-                var newContentX = sView.flickableItem.contentX;
-
-                if ( sView.flickableItem.contentX + sView.width <
-                        target.x + target.mouseX + initPosOfCursor + sView.sViewPadding )
-                    newContentX = target.x + target.mouseX + initPosOfCursor + sView.sViewPadding - sView.width;
-                else if ( sView.flickableItem.contentX + sView.sViewPadding > target.x + target.mouseX )
-                    newContentX = target.x + target.mouseX - sView.sViewPadding;
-
-                sView.flickableItem.contentX = Math.max( newContentX, 0 );
-            }
-
             onDropped: {
                 if ( drop.keys.indexOf( "vlmc/uuid" ) >= 0 ) {
                     aClipInfo = findClipFromTrack( "Audio", trackId, "audioUuid" );
@@ -225,7 +210,7 @@ Item {
                         }
                     }
 
-                    scrollToTarget( drag.source );
+                    drag.source.scrollToThis();
 
                     if ( drag.source.x !== findNewPosition( drag.source.x, drag.source, false ) )
                         deltaX = 0;
@@ -303,7 +288,7 @@ Item {
 
                     // Scroll if needed
                     if ( drag.source === target || dMode === dropMode.New )
-                        scrollToTarget( target );
+                        target.scrollToThis();
 
                     // Let's move to the new tracks
                     if ( dMode === dropMode.Move ) {



More information about the Vlmc-devel mailing list