[vlmc-devel] save
Yikai Lu
git at videolan.org
Wed Jul 13 09:33:04 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Tue Jul 12 15:33:47 2016 +0900| [c3e338b094e9e86bb6007da1e42d40206c784ca2] | committer: Yikai Lu
save
> https://code.videolan.org/videolan/vlmc/commit/c3e338b094e9e86bb6007da1e42d40206c784ca2
---
src/Gui/timeline/Clip.qml | 24 ++++++------------------
src/Gui/timeline/Track.qml | 14 ++++++++------
src/Gui/timeline/main.qml | 26 +++++++++++++++++++++-----
3 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/src/Gui/timeline/Clip.qml b/src/Gui/timeline/Clip.qml
index dd4b3ab..dfe8d6b 100644
--- a/src/Gui/timeline/Clip.qml
+++ b/src/Gui/timeline/Clip.qml
@@ -57,10 +57,6 @@ Rectangle {
}
Component.onCompleted: {
-
- clipInfo["item"] = clip;
- clipInfo["track"] = track;
-
selected = true;
}
@@ -144,13 +140,10 @@ Rectangle {
}
onReleased: {
- for ( var i = 0; i < selectedClips.length; ++i )
- if ( selectedClips[i]["item"] ) {
- if ( resizing === true )
- selectedClips[i]["item"].resize();
- else
- selectedClips[i]["item"].move();
- }
+ if ( resizing === true )
+ resize();
+ else
+ dragFinished();
}
states: [
@@ -172,11 +165,6 @@ Rectangle {
]
}
- onXChanged: {
- if ( x < 0 )
- setPixelPosition( 0 );
- }
-
onYChanged: {
// Don't move outside its TrackContainer
// For Top
@@ -190,11 +178,11 @@ Rectangle {
onSelectedChanged: {
if ( selected === true ) {
- selectedClips.push( clipInfo );
+ selectedClips.push( clip );
}
else {
for ( var i = 0; i < selectedClips.length; ++i )
- if ( !selectedClips[i]["item"] || selectedClips[i]["item"] === clip ) {
+ if ( !selectedClips[i] || selectedClips[i].uuid === clip.uuid) {
selectedClips.splice( i, 1 );
--i;
}
diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index 402ca14..a77bd2a 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -142,7 +142,7 @@ Item {
// Find the previous X of the clip
var newX = drag.x;
for ( var i = 0; i < selectedClips.length; ++i ) {
- var target = selectedClips[i]["item"];
+ var target = selectedClips[i];
if ( !target )
{
@@ -159,7 +159,7 @@ Item {
// Collision detection
var isCollided = true;
- var clips = trackContainer( target.type )["tracks"].get( trackId )["clips"];
+ var clips = trackContainer( target.type )["tracks"].get( target.trackId )["clips"];
for ( var j = 0; j < clips.count + 2 && isCollided; ++j ) {
isCollided = false;
for ( var k = 0; k < clips.count; ++k ) {
@@ -167,8 +167,8 @@ Item {
if ( clip.uuid === target.uuid )
continue;
var sw = target.width; // Width of the source clip
- var cx = clip["item"].x;
- var cw = clip["item"].width;
+ var cx = ftop( clip["position"] );
+ var cw = ftop( clip["end"] - clip["begin"] + 1);
// Set a right position
if ( cx + cw > newX && newX + sw > cx ) {
isCollided = true;
@@ -191,8 +191,10 @@ Item {
if ( isCollided ) {
for ( k = 0; k < clips.count; ++k ) {
clip = clips.get( k );
- if ( clip["item"].x + clip["item"].width > target.pixelPosition() )
- target.setPixelPosition( clip["item"].x + clip["item"].width );
+ cx = ftop( clip["position"] );
+ cw = ftop( clip["end"] - clip["begin"] + 1);
+ if ( cx + cw > target.pixelPosition() )
+ target.setPixelPosition( cx + cw );
}
}
diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
index baa28cf..38791ce 100644
--- a/src/Gui/timeline/main.qml
+++ b/src/Gui/timeline/main.qml
@@ -20,9 +20,9 @@ Rectangle {
function clearSelectedClips() {
while ( selectedClips.length ) {
- var clipInfo = selectedClips.pop();
- if ( clipInfo["item"] )
- clipInfo["item"].selected = false;
+ var clip = selectedClips.pop();
+ if ( clip )
+ clip.selected = false;
}
}
@@ -149,6 +149,22 @@ Rectangle {
removeClipFromTrack( trackType, oldId, uuid );
}
+ function dragFinished() {
+ var length = selectedClips.length;
+ for ( var i = 0; i < length; ++i ) {
+ if ( selectedClips[i] ) {
+ var originalUuid = selectedClips[i].uuid;
+ selectedClips[i].move();
+
+ // Check if removed
+ if ( !selectedClips[i] || originalUuid !== selectedClips[i].uuid ) {
+ --length;
+ --i;
+ }
+ }
+ }
+ }
+
ListModel {
id: trackContainers
@@ -276,8 +292,8 @@ Rectangle {
standardButtons: StandardButton.Yes | StandardButton.No
onYes: {
while ( selectedClips.length ) {
- workflow.removeClip( selectedClips[0]["uuid"] );
- removeClipFromTrackContainer( selectedClips[0]["item"].type, selectedClips[0]["uuid"] );
+ workflow.removeClip( selectedClips[0] );
+ removeClipFromTrackContainer( selectedClips[0].type, selectedClips[0].uuid );
}
}
}
More information about the Vlmc-devel
mailing list