[vlmc-devel] Timeline: Move clips in a manner that clips won't overlap each other.
yikei lu
luyikei.qmltu at gmail.com
Thu Jul 13 11:29:25 CEST 2017
On Thu, Jul 13, 2017 at 5:01 PM, Hugo Beauzée-Luyssen <hugo at beauzee.fr> wrote:
>
>
> On Wed, Jun 28, 2017, at 06:45 PM, Yikai Lu wrote:
>> vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Thu Jun 29
>> 01:45:08 2017 +0900| [0667503bacf3057d3cdd46665d3e7c4624914faa] |
>> committer: Yikai Lu
>>
>> Timeline: Move clips in a manner that clips won't overlap each other.
>>
>> > https://code.videolan.org/videolan/vlmc/commit/0667503bacf3057d3cdd46665d3e7c4624914faa
>> ---
>>
>> src/Gui/timeline/Clip.qml | 3 ++-
>> src/Gui/timeline/Track.qml | 1 +
>> src/Gui/timeline/main.qml | 35
>> ++++++++++++++++++++++++++++++-----
>> src/Workflow/SequenceWorkflow.cpp | 3 +--
>> 4 files changed, 34 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/Gui/timeline/Clip.qml b/src/Gui/timeline/Clip.qml
>> index c6837a09..30069a84 100644
>> --- a/src/Gui/timeline/Clip.qml
>> +++ b/src/Gui/timeline/Clip.qml
>> @@ -27,6 +27,7 @@ Rectangle {
>> // Usualy it is trackId, the clip will be moved to the new track
>> immediately.
>> property int newTrackId
>> property int position
>> + property int lastPosition
>> property int begin
>> property int end
>> property string libraryUuid // Library UUID: For thumbnails
>> @@ -52,7 +53,7 @@ Rectangle {
>> }
>>
>> function move() {
>> - moveClipTo( track.type, uuid, newTrackId, position );
>> + moveClipTo( uuid, newTrackId, position );
>> }
>>
>> function resize() {
>> diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
>> index 407c458c..22c8469b 100644
>> --- a/src/Gui/timeline/Track.qml
>> +++ b/src/Gui/timeline/Track.qml
>> @@ -340,6 +340,7 @@ Item {
>> uuid: model.uuid
>> libraryUuid: model.libraryUuid
>> position: model.position
>> + lastPosition: model.lastPosition
>> begin: model.begin
>> end: model.end
>> linkedClip: model.linkedClip
>> diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
>> index 4a3ed7fe..8ec9aa8e 100644
>> --- a/src/Gui/timeline/main.qml
>> +++ b/src/Gui/timeline/main.qml
>> @@ -90,6 +90,7 @@ Rectangle {
>> newDict["begin"] = clipDict["begin"];
>> newDict["end"] = clipDict["end"];
>> newDict["position"] = clipDict["position"];
>> + newDict["lastPosition"] = clipDict["position"];
>> newDict["length"] = clipDict["length"];
>> newDict["libraryUuid"] = clipDict["libraryUuid"];
>> newDict["uuid"] = clipDict["uuid"];
>> @@ -172,7 +173,7 @@ Rectangle {
>> return null;
>> }
>>
>> - function moveClipTo( trackType, uuid, trackId, position )
>> + function moveClipTo( uuid, trackId, position )
>> {
>> var clip = findClipItem( uuid );
>> if ( !clip )
>> @@ -293,7 +294,32 @@ Rectangle {
>> }
>>
>> function dragFinished() {
>> - selectedClips[0].move();
>> + var toMove = [];
>> + for ( var i = 0; i < selectedClips.length; ++i )
>> + toMove.push( selectedClips[i] );
>> +
>> + // Move clips in a manner that clips won't overlap each other.
>> + toMove.sort(
>> + function( clipA, clipB )
>> + {
>> + if ( clipA.newTrackId !== clipB.newTrackId )
>> + {
>> + return clipA.newTrackId - clipB.newTrackId;
>> + }
>> + else if ( clipA.position > clipA.lastPosition )
>> + {
>> + return - ( clipA.position - clipB.position
>> );
>> + }
>> + else if ( clipA.position < clipA.position )
>> + {
>> + return clipA.position - clipB.position;
>> + }
>> + }
>> + );
>> +
>> + for ( i = 0; i < toMove.length; ++i )
>> + moveClipTo( toMove[i].uuid, toMove[i].newTrackId,
>> toMove[i].position );
>> +
>> adjustTracks( "Audio" );
>> adjustTracks( "Video" );
>> }
>> @@ -592,9 +618,8 @@ Rectangle {
>> addClip( type, clipInfo["trackId"], clipInfo );
>> removeClipFromTrack( type, oldClip["trackId"], uuid );
>> }
>> - else if ( oldClip["position"] !== clipInfo["position"] ) {
>> - findClipItem( uuid ).position = clipInfo["position"];
>> - }
>> + findClipItem( uuid ).position = clipInfo["position"];
>> + findClipItem( uuid ).lastPosition = clipInfo["position"];
>> adjustTracks( type );
>> }
>>
>> diff --git a/src/Workflow/SequenceWorkflow.cpp
>> b/src/Workflow/SequenceWorkflow.cpp
>> index 5c80dd1b..0461abb5 100644
>> --- a/src/Workflow/SequenceWorkflow.cpp
>> +++ b/src/Workflow/SequenceWorkflow.cpp
>> @@ -115,8 +115,7 @@ SequenceWorkflow::moveClip( const QUuid& uuid,
>> quint32 trackId, qint64 pos )
>> c->pos = pos;
>> }
>> emit clipMoved( uuid.toString() );
>> - // TODO: If we detect collision too strictly, there will be a
>> problem if we want to move multiple
>> - // clips at the same time.
>> + // CAUTION: You must not move a clip to a place where it would
>> overlap another clip!
>
> This seems like a risky requirement, especially if we are to add more
> UIs
I think it should be "fixed' by implementing transitions...
>
>> return true;
>> }
>>
>
>
> --
> Hugo Beauzée-Luyssen
> hugo at beauzee.fr
> _______________________________________________
> Vlmc-devel mailing list
> Vlmc-devel at videolan.org
> https://mailman.videolan.org/listinfo/vlmc-devel
More information about the Vlmc-devel
mailing list