[vlmc-devel] Timeline: Don't do operations related to transitions in findNewPosition
Yikai Lu
git at videolan.org
Thu Aug 10 20:15:30 CEST 2017
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Fri Aug 11 02:49:54 2017 +0900| [81ad008f44998b5bdfa1c19175957534b7370cb6] | committer: Yikai Lu
Timeline: Don't do operations related to transitions in findNewPosition
> https://code.videolan.org/videolan/vlmc/commit/81ad008f44998b5bdfa1c19175957534b7370cb6
---
src/Gui/timeline/Track.qml | 43 +++++++++++++++++++++++++++++++++++++++++++
src/Gui/timeline/main.qml | 29 -----------------------------
2 files changed, 43 insertions(+), 29 deletions(-)
diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index 9e64bd99..e200e665 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -290,6 +290,49 @@ Item {
target = findClipItem( selectedClips[i] );
newPos = target.position + deltaPos;
+ var currentTrack = trackContainer( target.type )["tracks"].get( target.newTrackId );
+ if ( currentTrack )
+ {
+ var clips = currentTrack["clips"];
+ for ( var j = 0; j < clips.count; ++j ) {
+ var clip = clips.get( j );
+ if ( clip.uuid === target.uuid ||
+ ( clip.uuid === drag.source.uuid && target.newTrackId !== drag.source.newTrackId )
+ )
+ continue;
+ var cPos = clip.uuid === drag.source.uuid ? ptof( drag.source.x ) : clip["position"];
+ var cEndPos = clip["position"] + clip["length"] - 1;
+ // If they overlap, create a cross-dissolve transition
+ if ( cEndPos >= newPos && newPos + target.length - 1 >= cPos )
+ {
+ var toCreate = true;
+ for ( var k = 0; k < allTransitions.length; ++k ) {
+ var transitionItem = allTransitions[k];
+ if ( transitionItem.trackId === clip.trackId &&
+ transitionItem.type === clip.type &&
+ transitionItem.isCrossDissolve === true &&
+ transitionItem.clips.indexOf( clip.uuid ) !== -1 &&
+ transitionItem.clips.indexOf( target.uuid ) !== -1
+ ) {
+ transitionItem.begin = Math.max( newPos, cPos );
+ transitionItem.end = Math.min( newPos + target.length - 1, cEndPos );
+ toCreate = false;
+ }
+ }
+ if ( toCreate === true ) {
+ addTransition( target.type, target.newTrackId,
+ { "begin": Math.max( newPos, cPos ),
+ "end": Math.min( newPos + target.length - 1, cEndPos ),
+ "identifier": "dissolve",
+ "uuid": "transitionUuid" } );
+ transitionItem = allTransitions[allTransitions.length - 1];
+ transitionItem.clips.push( clip.uuid );
+ transitionItem.clips.push( target.uuid );
+ }
+ }
+ }
+ }
+
// We only want to update the length when the right edge of the timeline
// is exposed.
if ( sView.flickableItem.contentX + page.width > sView.width &&
diff --git a/src/Gui/timeline/main.qml b/src/Gui/timeline/main.qml
index d619ddcd..2d127fdb 100644
--- a/src/Gui/timeline/main.qml
+++ b/src/Gui/timeline/main.qml
@@ -91,35 +91,6 @@ Rectangle {
leastDistance = Math.abs( newPos + target.length - 1 - cEndPos );
newPos = cEndPos - target.length + 1;
}
-
- // If they overlap, create a cross-dissolve transition
- if ( cEndPos >= newPos && newPos + target.length - 1 >= cPos )
- {
- var toCreate = true;
- for ( var i = 0; i < allTransitions.length; ++i ) {
- var transitionItem = allTransitions[i];
- if ( transitionItem.trackId === clip.trackId &&
- transitionItem.type === clip.type &&
- transitionItem.isCrossDissolve === true &&
- transitionItem.clips.indexOf( clip.uuid ) !== -1 &&
- transitionItem.clips.indexOf( target.uuid ) !== -1
- ) {
- transitionItem.begin = Math.max( newPos, clip["position"] );
- transitionItem.end = Math.min( newPos + target.length - 1, clip["position"] + clip["length"] - 1 );
- toCreate = false;
- }
- }
- if ( toCreate === true ) {
- addTransition( target.type, target.newTrackId,
- { "begin": Math.max( newPos, cPos ),
- "end": Math.min( newPos + target.length - 1, cEndPos ),
- "identifier": "dissolve",
- "uuid": "transitionUuid" } );
- transitionItem = allTransitions[allTransitions.length - 1];
- transitionItem.clips.push( clip.uuid );
- transitionItem.clips.push( target.uuid );
- }
- }
}
else {
// In theory, they share the same deltaPos, therefore unable to collide each other.
More information about the Vlmc-devel
mailing list