[vlmc-devel] Timeline: Scroll also before clips being set new position
Yikai Lu
git at videolan.org
Tue Jul 26 16:12:50 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Tue Jul 26 23:05:54 2016 +0900| [04e6951bb14516ad2a3b804b122a8313f53d63db] | committer: Yikai Lu
Timeline: Scroll also before clips being set new position
> https://code.videolan.org/videolan/vlmc/commit/04e6951bb14516ad2a3b804b122a8313f53d63db
---
src/Gui/timeline/Track.qml | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/Gui/timeline/Track.qml b/src/Gui/timeline/Track.qml
index d38aff2..472e175 100644
--- a/src/Gui/timeline/Track.qml
+++ b/src/Gui/timeline/Track.qml
@@ -174,6 +174,24 @@ Item {
return newX;
}
+ function scrollToTarget( target ) {
+ while ( target.width > sView.width )
+ zoomIn( 0.5 );
+
+ if ( sView.flickableItem.contentX + sView.width <
+ target.x + target.width + initPosOfCursor + sView.sViewPadding ) {
+ // Never show the background behind the timeline
+ var newContentX = sView.flickableItem.contentWidth - sView.width;
+ if ( newContentX >= 0 ) {
+ drag.source.Drag.hotSpot.x = 0;
+ sView.flickableItem.contentX = newContentX;
+ }
+ }
+ else if ( sView.flickableItem.contentX + sView.sViewPadding > target.x + initPosOfCursor ) {
+ sView.flickableItem.contentX = target.x + initPosOfCursor - sView.sViewPadding;
+ }
+ }
+
onDropped: {
if ( drop.keys.indexOf( "vlmc/uuid" ) >= 0 ) {
aClipInfo = findClipFromTrack( "Audio", trackId, "audioUuid" );
@@ -260,6 +278,8 @@ Item {
}
}
+ scrollToTarget( drag.source );
+
// Optimization: Delta delta X should be different
if ( deltaX === drag.source.x - lastX ) {
lastX = drag.source.x;
@@ -337,24 +357,8 @@ Item {
}
// Scroll if needed
- if ( drag.source === target || dMode === dropMode.New ) {
-
- while ( target.width > sView.width )
- zoomIn( 0.5 );
-
- if ( sView.flickableItem.contentX + sView.width <
- newX + target.width + initPosOfCursor + sView.sViewPadding ) {
- // Never show the background behind the timeline
- var newContentX = sView.flickableItem.contentWidth - sView.width;
- if ( newContentX >= 0 ) {
- drag.source.Drag.hotSpot.x = 0;
- sView.flickableItem.contentX = newContentX;
- }
- }
- else if ( sView.flickableItem.contentX + sView.sViewPadding > newX + initPosOfCursor ) {
- sView.flickableItem.contentX = newX + initPosOfCursor - sView.sViewPadding;
- }
- }
+ if ( drag.source === target || dMode === dropMode.New )
+ scrollToTarget( target );
// Let's move to the new tracks
if ( dMode === dropMode.Move ) {
More information about the Vlmc-devel
mailing list