[vlmc-devel] Timeline: Don't automatically center the cursor when zooming

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


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Thu Jul  6 01:55:21 2017 +0900| [ac7bf721eb9897c157e6c011f765c6ae010e2e09] | committer: Yikai Lu

Timeline: Don't automatically center the cursor when zooming

> https://code.videolan.org/videolan/vlmc/commit/ac7bf721eb9897c157e6c011f765c6ae010e2e09
---

 src/Gui/timeline/main.qml | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
index fcb0c497..b53e569b 100644
--- a/src/Gui/timeline/main.qml
+++ b/src/Gui/timeline/main.qml
@@ -241,10 +241,11 @@ Rectangle {
             item.linkedClips = linkedClipsDict[uuid];
     }
 
-    function zoomIn( ratio ) {
+    function zoomIn( ratio, scrollToCuror ) {
         var newPpu = ppu;
         var newUnit = unit;
         newPpu *= ratio;
+        var contentXPos = ptof( sView.flickableItem.contentX );
 
         // Don't be too narrow.
         while ( newPpu < 10 ) {
@@ -278,11 +279,17 @@ Rectangle {
         if ( Math.abs( ppu - newPpu ) > 0.0001 )
             ppu = newPpu;
 
-        // Let's scroll to the cursor position!
-        var newContentX = cursor.x - sView.width / 2;
-        // Never show the background behind the timeline
-        if ( newContentX >= 0 && sView.flickableItem.contentWidth - newContentX > sView.width  )
-            sView.flickableItem.contentX = newContentX;
+        if ( scrollToCuror === true ) {
+            // Let's scroll to the cursor position!
+            var newContentX = cursor.x - sView.width / 2;
+            // Never show the background behind the timeline
+            if ( newContentX >= 0 && sView.flickableItem.contentWidth - newContentX > sView.width  )
+                sView.flickableItem.contentX = newContentX;
+        }
+        else {
+            sView.flickableItem.contentX = ftop( contentXPos );
+        }
+
 
         scale = Math.floor( Math.log( newUnit / mUnit ) / Math.log( 2 ) - 1 );
         scale = Math.min( 9, scale );
@@ -521,7 +528,7 @@ Rectangle {
                             selected: false
 
                             onPressed: {
-                                zoomIn( 2.0 );
+                                zoomIn( 2.0, true );
                                 selected = false;
                             }
                         }
@@ -532,7 +539,7 @@ Rectangle {
                             selected: false
 
                             onPressed: {
-                                zoomIn( 0.5 );
+                                zoomIn( 0.5, true );
                                 selected = false;
                             }
                         }
@@ -588,12 +595,12 @@ Rectangle {
         else if ( event.key === Qt.Key_Plus &&
                  event.modifiers & Qt.ControlModifier
                  && scale > 0 ) {
-            zoomIn( 2 );
+            zoomIn( 2, true );
         }
         else if ( event.key === Qt.Key_Minus &&
                  event.modifiers & Qt.ControlModifier &&
                  scale < 9 ) {
-            zoomIn( 0.5 );
+            zoomIn( 0.5, true );
         }
         event.accepted = true;
     }
@@ -617,7 +624,7 @@ Rectangle {
             addClip( type, clipInfo["trackId"], clipInfo );
             adjustTracks( type );
 
-            zoomIn( page.width / sView.flickableItem.contentWidth );
+            zoomIn( page.width / sView.flickableItem.contentWidth, false );
         }
 
         onClipMoved: {
@@ -687,9 +694,9 @@ Rectangle {
         onScaleChanged: {
             // 10 levels
             if ( scale < scaleLevel )
-                zoomIn( 0.5 );
+                zoomIn( 0.5, false );
             else if ( scale > scaleLevel )
-                zoomIn( 2 );
+                zoomIn( 2, false );
             scale = scaleLevel;
         }
         onCutToolSelected: {



More information about the Vlmc-devel mailing list