Commit 48a5ba61 authored by luyikei's avatar luyikei

Timeline: Imeplement grouping

parent 924c0480
......@@ -84,11 +84,19 @@ Rectangle {
Component.onCompleted: {
selected = true;
newTrackId = trackId;
allClips.push( clip );
}
Component.onDestruction: {
Drag.drop();
selected = false;
for ( var i = 0; i < allClips.length; ++i ) {
if ( allClips[i] === clip ) {
allClips.splice( i, 1 );
return;
}
}
}
Text {
......@@ -165,8 +173,7 @@ Rectangle {
onClicked: {
if ( mouse.button & Qt.RightButton ) {
var menu = Qt.createComponent( "ClipContextMenu.qml" ).createObject( parent );
menu.popup();
clipContextMenu.popup();
}
}
......@@ -196,6 +203,11 @@ Rectangle {
]
}
ClipContextMenu {
id: clipContextMenu
uuid: clip.uuid
}
onYChanged: {
// Don't move outside its TrackContainer
// For Top
......@@ -210,9 +222,17 @@ Rectangle {
onSelectedChanged: {
if ( selected === true ) {
selectedClips.push( clip );
var group = findGroup( uuid );
for ( var i = 0; i < ( group ? group.length : 0 ); ++i ) {
for ( var j = 0; j < allClips.length; ++j ) {
if ( group[i] === allClips[j].uuid )
allClips[j].selected = true;
}
}
}
else {
for ( var i = 0; i < selectedClips.length; ++i )
for ( i = 0; i < selectedClips.length; ++i )
if ( !selectedClips[i] || selectedClips[i] === clip ) {
selectedClips.splice( i, 1 );
--i;
......
......@@ -5,28 +5,28 @@ Menu {
id: clipContextMenu
title: "Edit"
MenuItem {
text: "Cut"
shortcut: "Ctrl+X"
}
MenuItem {
text: "Copy"
shortcut: "Ctrl+C"
}
property string uuid
MenuItem {
text: "Paste"
shortcut: "Ctrl+V"
}
text: isGrouped ? "Ungroup" : "Group"
MenuSeparator { }
property bool isGrouped: findGroup( uuid )
Menu {
title: "More Stuff"
onTriggered: {
if ( selectedClips.length <= 1 )
return;
MenuItem {
text: "Do Nothing"
if ( isGrouped ) {
removeGroup( uuid );
}
else {
var l = [];
for ( var i = 0; i < selectedClips.length; ++i ) {
l.push( "" + selectedClips[i].uuid );
}
addGroup( l );
}
isGrouped = Qt.binding( function(){ return findGroup( uuid ); } );
}
}
}
......@@ -17,7 +17,9 @@ Rectangle {
property double fps: 29.97
property int maxZ: 100
property int scale: 10
property var selectedClips: []
property var allClips: [] // Actual clip item objects
property var selectedClips: [] // Actual clip item objects
property var groups: [] // list of lists of clip uuids
property alias isMagneticMode: magneticModeButton.selected
property int trackHeight: 30
......@@ -182,13 +184,39 @@ Rectangle {
addTrack( trackType );
}
function addMarker( pos )
{
function addMarker( pos ) {
markers.append( {
"position": pos
} );
}
function addGroup( clips ) {
groups.push( clips );
}
function findGroup( uuid ) {
for ( var i = 0; i < groups.length; ++i ) {
var group = groups[i];
for ( var j = 0; j < group.length; ++j ) {
if ( group[j] === uuid )
return group;
}
}
return null;
}
function removeGroup( uuid ) {
for ( var i = 0; i < groups.length; ++i ) {
var group = groups[i];
for ( var j = 0; j < group.length; ++j ) {
if ( group[j] === uuid ) {
groups.splice( i, 1 );
return;
}
}
}
}
function zoomIn( ratio ) {
var newPpu = ppu;
var newUnit = unit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment