[vlmc-devel] Timeline: Fix wrong calculation of the scale

Yikai Lu git at videolan.org
Thu Jul 28 14:39:17 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed Jul 27 21:47:56 2016 +0900| [8300b049eb70b63c2029bfb83540ba703ed8a539] | committer: Yikai Lu

Timeline: Fix wrong calculation of the scale

> https://code.videolan.org/videolan/vlmc/commit/8300b049eb70b63c2029bfb83540ba703ed8a539
---

 src/Gui/timeline/Clip.qml |  3 +++
 src/Gui/timeline/main.qml | 21 +++++++++++----------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/Gui/timeline/Clip.qml b/src/Gui/timeline/Clip.qml
index 921726f..34b5d5c 100644
--- a/src/Gui/timeline/Clip.qml
+++ b/src/Gui/timeline/Clip.qml
@@ -64,6 +64,9 @@ Rectangle {
     }
 
     onXChanged: {
+        if ( sView.width - initPosOfCursor < width )
+            return;
+
         if ( sView.flickableItem.contentX + sView.width <
                 x + width + initPosOfCursor + sView.sViewPadding )
             Drag.hotSpot.x = 0;
diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
index df131c2..45ea33e 100644
--- a/src/Gui/timeline/main.qml
+++ b/src/Gui/timeline/main.qml
@@ -270,11 +270,11 @@ Rectangle {
 
         if ( newUnit < mUnit ) {
             newPpu /= ratio; // Restore the original scale.
-            newPpu *= mUnit / newPpu;
+            newPpu *= mUnit / newUnit;
             newUnit = mUnit;
         }
 
-        // Make unit a multiple of fps.
+        // Make unit a multiple of 1 / fps.
         newPpu *= ( newUnit - ( newUnit % mUnit ) ) / newUnit;
         newUnit -= newUnit % mUnit;
 
@@ -291,10 +291,9 @@ Rectangle {
         if ( newContentX >= 0 && sView.flickableItem.contentWidth - newContentX > sView.width  )
             sView.flickableItem.contentX = newContentX;
 
-        if ( ratio > 1 )
-            scale++;
-        else
-            scale--;
+        scale = Math.floor( Math.log( newUnit / mUnit ) / Math.log( 2 ) - 1 );
+        scale = Math.min( 9, scale );
+        scale = Math.max( 0, scale );
         mainwindow.setScale( scale );
     }
 
@@ -511,12 +510,14 @@ Rectangle {
         if ( event.key === Qt.Key_Delete ) {
             removeSelectedClipsDialog.visible = true;
         }
-        else if ( event.key === Qt.Key_Plus && event.modifiers & Qt.ControlModifier )
-        {
+        else if ( event.key === Qt.Key_Plus &&
+                 event.modifiers & Qt.ControlModifier
+                 && scale > 0 ) {
             zoomIn( 2 );
         }
-        else if ( event.key === Qt.Key_Minus && event.modifiers & Qt.ControlModifier )
-        {
+        else if ( event.key === Qt.Key_Minus &&
+                 event.modifiers & Qt.ControlModifier &&
+                 scale < 9 ) {
             zoomIn( 0.5 );
         }
         event.accepted = true;



More information about the Vlmc-devel mailing list