[vlmc-devel] Timeline: Use delta X to determine clips' new x position
Yikai Lu
git at videolan.org
Tue Jul 19 19:41:56 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Tue Jul 19 23:13:02 2016 +0900| [924c0480e770f1852c0e3b16af6c7269efe1cf84] | committer: Yikai Lu
Timeline: Use delta X to determine clips' new x position
> https://code.videolan.org/videolan/vlmc/commit/924c0480e770f1852c0e3b16af6c7269efe1cf84
---
src/Gui/timeline/Track.qml | 26 ++++++++++++++++++--------
src/Gui/timeline/main.qml | 2 ++
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index f64663a..a24b048 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -133,6 +133,7 @@ Item {
if ( newClipInfo["video"] )
vClipInfo = addClip( "Video", trackId, newClipInfo );
}
+ lastX = drag.x;
}
}
@@ -142,18 +143,22 @@ Item {
return;
if ( drag.keys.indexOf( "vlmc/uuid" ) < 0 ) {
- var newX = drag.source.mapToItem( clipArea, 0, 0 ).x; // FIXME: Mysterious QML Bug, you can't use drag.x
- drag.source.y = drag.source.y - drag.y + track.height / 2 - 1;
+ drag.source.y = drag.source.y - drag.y + track.height / 2 - 1; // Adjust to the center
+ var currentX = drag.source.x;
}
else
- newX = Math.max( drag.x, 0 );
+ currentX = drag.x;
+
+ var deltaX = currentX - lastX;
+ lastX = currentX;
for ( var i = 0; i < selectedClips.length; ++i ) {
var target = selectedClips[i];
-
var oldx = target.pixelPosition();
if ( drag.source === target ) {
+ var newX = drag.source.x;
+
var oldTrackId = target.newTrackId;
target.newTrackId = trackId;
for ( var j = 0; j < selectedClips.length; ++j ) {
@@ -161,6 +166,8 @@ Item {
selectedClips[j].newTrackId = trackId - oldTrackId + selectedClips[j].trackId;
}
}
+ else
+ newX = Math.max( target.pixelPosition() + deltaX, 0 );
if ( isMagneticMode === true ) {
var leastDestance = 25;
@@ -243,18 +250,20 @@ Item {
sView.flickableItem.contentX = newContentX;
}
- target.setPixelPosition( newX );
-
if ( isCollided ) {
for ( k = 0; k < clips.count; ++k ) {
clip = clips.get( k );
cx = ftop( clip["position"] );
cw = ftop( clip["end"] - clip["begin"] + 1);
- if ( cx + cw > target.pixelPosition() )
- target.setPixelPosition( cx + cw );
+ newX = Math.max( newX, cx + cw );
}
}
+ if ( target === drag.source )
+ lastX = drag.source.x;
+
+ target.setPixelPosition( newX );
+
if ( drag.keys.indexOf( "vlmc/uuid" ) < 0 ) {
if ( target.newTrackId !== target.trackId ) {
drag.source.parent.parent.parent.z = ++maxZ;
@@ -266,6 +275,7 @@ Item {
}
}
}
+ // END of for ( var i = 0; i < selectedClips.length; ++i )
}
}
diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
index b7673c1..28c0c75 100644
--- a/src/Gui/timeline/main.qml
+++ b/src/Gui/timeline/main.qml
@@ -22,6 +22,8 @@ Rectangle {
property int trackHeight: 30
+ property int lastX: 0
+
function clearSelectedClips() {
while ( selectedClips.length ) {
var clip = selectedClips.pop();
More information about the Vlmc-devel
mailing list