[vlmc-devel] Timelie: Avoid colliding markers

Yikai Lu git at videolan.org
Sat Jul 23 17:12:30 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sun Jul 24 00:07:30 2016 +0900| [70814fb7ae1bda02d75625ae73cf1fc7547ff312] | committer: Yikai Lu

Timelie: Avoid colliding markers

> https://code.videolan.org/videolan/vlmc/commit/70814fb7ae1bda02d75625ae73cf1fc7547ff312
---

 src/Gui/timeline/Ruler.qml | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/Gui/timeline/Ruler.qml b/src/Gui/timeline/Ruler.qml
index ce4beeb..2354b53 100644
--- a/src/Gui/timeline/Ruler.qml
+++ b/src/Gui/timeline/Ruler.qml
@@ -127,7 +127,19 @@ Rectangle {
         keys: ["Marker"]
 
         onPositionChanged: {
-            drag.source.position = ptof( drag.x );
+            var newPosition = ptof( drag.x );
+
+            var samePosMarkersCount = 0;
+            for ( var i = 0; i < markers.count; ++i ) {
+                if ( markers.get( i )["position"] === newPosition )
+                    samePosMarkersCount++;
+            }
+
+            // Move the marker to the right a bit
+            if ( samePosMarkersCount >= 2 )
+                newPosition += Math.max( ptof( 1 ), 1 );
+
+            drag.source.position = newPosition;
         }
     }
 



More information about the Vlmc-devel mailing list