Changeset View
Changeset View
Standalone View
Standalone View
src/timeline2/view/qml/Track.qml
Context not available. | |||||
21 | 21 | | |||
---|---|---|---|---|---|
22 | Column{ | 22 | Column{ | ||
23 | id: trackRoot | 23 | id: trackRoot | ||
24 | property alias model: trackModel.model | 24 | property alias trackModel: trackModel.model | ||
25 | property alias rootIndex: trackModel.rootIndex | 25 | property alias trackRootIndex: trackModel.rootIndex | ||
26 | property bool isAudio | 26 | property bool isAudio | ||
27 | property bool isMute | 27 | property bool isMute | ||
28 | property bool isHidden | 28 | property bool isHidden | ||
Context not available. | |||||
35 | 35 | | |||
36 | SystemPalette { id: activePalette } | 36 | SystemPalette { id: activePalette } | ||
37 | 37 | | |||
38 | signal clipClicked(var clip, var track, int shiftClick) | | |||
39 | signal clipDragged(var clip, int x, int y) | | |||
40 | signal clipDropped(var clip) | | |||
41 | signal compositionDropped(var clip) | | |||
42 | signal clipDraggedToTrack(var clip, int pos, int xpos) | | |||
43 | signal compositionDraggedToTrack(var composition, int pos, int xpos) | | |||
44 | 38 | | |||
45 | /*function redrawWaveforms() { | 39 | /*function redrawWaveforms() { | ||
46 | for (var i = 0; i < repeater.count; i++) | 40 | for (var i = 0; i < repeater.count; i++) | ||
Context not available. | |||||
51 | return repeater.itemAt(index) | 45 | return repeater.itemAt(index) | ||
52 | } | 46 | } | ||
53 | 47 | | |||
48 | onTrackRootIndexChanged: { | ||||
49 | console.log('====== * TRACK Index CHANGED: ', trackRoot.trackId, ' NEW IX: ',trackRoot.trackRootIndex,'\n__________') | ||||
50 | } | ||||
51 | | ||||
54 | width: clipRow.width | 52 | width: clipRow.width | ||
55 | 53 | | |||
56 | DelegateModel { | 54 | DelegateModel { | ||
Context not available. | |||||
66 | value: trackRoot.timeScale | 64 | value: trackRoot.timeScale | ||
67 | when: loader.status == Loader.Ready | 65 | when: loader.status == Loader.Ready | ||
68 | } | 66 | } | ||
67 | Binding { | ||||
68 | target: loader.item | ||||
69 | property: "trackId" | ||||
70 | value: model.trackId | ||||
71 | when: loader.status == Loader.Ready | ||||
72 | } | ||||
69 | Binding { | 73 | Binding { | ||
70 | target: loader.item | 74 | target: loader.item | ||
71 | property: "selected" | 75 | property: "selected" | ||
Context not available. | |||||
212 | } | 216 | } | ||
213 | } | 217 | } | ||
214 | onLoaded: { | 218 | onLoaded: { | ||
215 | item.clipId= model.item | 219 | item.clipId= model.itemId | ||
220 | item.parentTrack = trackRoot | ||||
216 | if (loader.item.isComposition === false) { | 221 | if (loader.item.isComposition === false) { | ||
217 | console.log('loaded clip: ', model.start, ', ID: ', model.item, ', index: ', trackRoot.DelegateModel.itemsIndex,', TYPE:', model.clipType) | 222 | console.log('loaded clip: ', model.start, ', ID: ', model.itemId, ', index: ', trackRoot.DelegateModel.itemsIndex,', TYPE:', model.clipType) | ||
218 | item.isAudio= model.audio | 223 | item.isAudio= model.audio | ||
219 | item.markers= model.markers | 224 | item.markers= model.markers | ||
220 | item.hasAudio = model.hasAudio | 225 | item.hasAudio = model.hasAudio | ||
Context not available. | |||||
223 | item.clipType = model.clipType | 228 | item.clipType = model.clipType | ||
224 | //item.binId= model.binId | 229 | //item.binId= model.binId | ||
225 | } else { | 230 | } else { | ||
226 | console.log('loaded composition: ', model.start, ', ID: ', model.item, ', index: ', trackRoot.DelegateModel.itemsIndex) | 231 | console.log('loaded composition: ', model.start, ', ID: ', model.itemId, ', index: ', trackRoot.DelegateModel.itemsIndex) | ||
227 | //item.aTrack = model.a_track | 232 | //item.aTrack = model.a_track | ||
228 | } | 233 | } | ||
229 | item.trackId= trackRoot.trackId | 234 | //item.trackId= trackRoot.trackId | ||
230 | //item.selected= trackRoot.selection.indexOf(item.clipId) !== -1 | 235 | //item.selected= trackRoot.selection.indexOf(item.clipId) !== -1 | ||
231 | //console.log(width, height); | 236 | //console.log(width, height); | ||
232 | } | 237 | } | ||
Context not available. | |||||
244 | id: clipDelegate | 249 | id: clipDelegate | ||
245 | Clip { | 250 | Clip { | ||
246 | height: trackRoot.height | 251 | height: trackRoot.height | ||
247 | | ||||
248 | onClicked: { | | |||
249 | console.log("Clip clicked",clip.clipId) | | |||
250 | trackRoot.clipClicked(clip, clip.parentTrack, shiftClick); | | |||
251 | clip.draggedX = clip.x | | |||
252 | } | | |||
253 | onMoved: { //called when the movement is finished | | |||
254 | var toTrack = clip.trackId | | |||
255 | var cIndex = clip.clipId | | |||
256 | var frame = clip.currentFrame | | |||
257 | var origFrame = clip.modelStart | | |||
258 | if (frame > -1) { | | |||
259 | controller.requestClipMove(cIndex, clip.originalTrackId, origFrame, false, false, false) | | |||
260 | controller.requestClipMove(cIndex, toTrack, frame, true, true, true) | | |||
261 | } | | |||
262 | clip.currentFrame = -1 | | |||
263 | } | | |||
264 | onDropped: { //called when the movement is finished | | |||
265 | var toTrack = clip.trackId | | |||
266 | var cIndex = clip.clipId | | |||
267 | var frame = clip.currentFrame | | |||
268 | var origFrame = clip.modelStart | | |||
269 | if (frame != origFrame && frame > -1) { | | |||
270 | controller.requestClipMove(cIndex, toTrack, origFrame, false, false, false) | | |||
271 | controller.requestClipMove(cIndex, toTrack, frame, true, true, true) | | |||
272 | } | | |||
273 | clip.currentFrame = -1 | | |||
274 | } | | |||
275 | onDragged: { //called when the move is in process | | |||
276 | var toTrack = clip.trackId | | |||
277 | var cIndex = clip.clipId | | |||
278 | clip.x = Math.max(0, clip.x) | | |||
279 | if (Math.round(clip.currentFrame * timeScale) == clip.x) { | | |||
280 | // No move to perform | | |||
281 | } else { | | |||
282 | var frame = Math.round(clip.x / timeScale) | | |||
283 | frame = controller.suggestClipMove(cIndex, toTrack, frame, root.snapping); | | |||
284 | if (clip.currentFrame == frame) { | | |||
285 | // Abort move | | |||
286 | clip.x = frame * timeScale | | |||
287 | } else { | | |||
288 | clip.x = frame * timeScale | | |||
289 | clip.currentFrame = frame | | |||
290 | var mapped = trackRoot.mapFromItem(clip, mouse.x, mouse.y) | | |||
291 | trackRoot.clipDragged(clip, mapped.x, mapped.y) | | |||
292 | clip.draggedX = clip.x | | |||
293 | } | | |||
294 | } | | |||
295 | } | | |||
296 | onTrimmingIn: { | 252 | onTrimmingIn: { | ||
297 | var new_duration = controller.requestItemResize(clip.clipId, newDuration, false, false, root.snapping, shiftTrim) | 253 | var new_duration = controller.requestItemResize(clip.clipId, newDuration, false, false, root.snapping, shiftTrim) | ||
298 | if (new_duration > 0) { | 254 | if (new_duration > 0) { | ||
Context not available. | |||||
313 | controller.requestItemResize(clip.clipId, clip.lastValidDuration, false, true, root.snapping, shiftTrim) | 269 | controller.requestItemResize(clip.clipId, clip.lastValidDuration, false, true, root.snapping, shiftTrim) | ||
314 | } | 270 | } | ||
315 | onTrimmingOut: { | 271 | onTrimmingOut: { | ||
272 | console.log(' + + +RQST RESIZE: ', newDuration, ' ON CLP: ', clip.clipId) | ||||
316 | var new_duration = controller.requestItemResize(clip.clipId, newDuration, true, false, root.snapping, shiftTrim) | 273 | var new_duration = controller.requestItemResize(clip.clipId, newDuration, true, false, root.snapping, shiftTrim) | ||
317 | if (new_duration > 0) { | 274 | if (new_duration > 0) { | ||
318 | clip.lastValidDuration = new_duration | 275 | clip.lastValidDuration = new_duration | ||
Context not available. | |||||
330 | controller.requestItemResize(clip.clipId, clip.originalDuration, true, false, root.snapping, shiftTrim) | 287 | controller.requestItemResize(clip.clipId, clip.originalDuration, true, false, root.snapping, shiftTrim) | ||
331 | controller.requestItemResize(clip.clipId, clip.lastValidDuration, true, true, root.snapping, shiftTrim) | 288 | controller.requestItemResize(clip.clipId, clip.lastValidDuration, true, true, root.snapping, shiftTrim) | ||
332 | } | 289 | } | ||
333 | | ||||
334 | Component.onCompleted: { | | |||
335 | moved.connect(trackRoot.clipDropped) | | |||
336 | dropped.connect(trackRoot.clipDropped) | | |||
337 | draggedToTrack.connect(trackRoot.clipDraggedToTrack) | | |||
338 | //console.log('BUILDING CLIP item ', model.clipId, 'name', model.name, ' service: ',mltService) | | |||
339 | } | | |||
340 | } | 290 | } | ||
341 | } | 291 | } | ||
342 | Component { | 292 | Component { | ||
Context not available. | |||||
345 | displayHeight: trackRoot.height / 2 | 295 | displayHeight: trackRoot.height / 2 | ||
346 | opacity: 0.8 | 296 | opacity: 0.8 | ||
347 | selected: root.timelineSelection.indexOf(clipId) !== -1 | 297 | selected: root.timelineSelection.indexOf(clipId) !== -1 | ||
348 | | ||||
349 | onClicked: { | | |||
350 | console.log("Composition clicked",clip.clipId) | | |||
351 | trackRoot.clipClicked(clip, trackRoot, shiftClick); | | |||
352 | clip.draggedX = clip.x | | |||
353 | } | | |||
354 | onMoved: { //called when the movement is finished | | |||
355 | console.log("Composition released",clip.clipId) | | |||
356 | var toTrack = clip.trackId | | |||
357 | var cIndex = clip.clipId | | |||
358 | var frame = Math.round(clip.x / timeScale) | | |||
359 | var origFrame = Math.round(clip.originalX / timeScale) | | |||
360 | | ||||
361 | console.log("Asking move ",toTrack, cIndex, frame) | | |||
362 | controller.requestCompositionMove(cIndex, clip.originalTrackId, origFrame, false, false) | | |||
363 | var val = controller.requestCompositionMove(cIndex, toTrack, frame, true, true) | | |||
364 | console.log("RESULT", val) | | |||
365 | } | | |||
366 | onDragged: { //called when the move is in process | | |||
367 | var toTrack = clip.trackId | | |||
368 | var cIndex = clip.clipId | | |||
369 | clip.x = Math.max(0, clip.x) | | |||
370 | var frame = Math.round(clip.x / timeScale) | | |||
371 | | ||||
372 | frame = controller.suggestCompositionMove(cIndex, toTrack, frame, root.snapping); | | |||
373 | | ||||
374 | if (!controller.requestCompositionMove(cIndex, toTrack, frame, false, false)) { | | |||
375 | // Abort move | | |||
376 | clip.x = clip.draggedX | | |||
377 | } else { | | |||
378 | clip.x = frame * timeScale | | |||
379 | var mapped = trackRoot.mapFromItem(clip, mouse.x, mouse.y) | | |||
380 | trackRoot.clipDragged(clip, mapped.x, mapped.y) | | |||
381 | clip.draggedX = clip.x | | |||
382 | } | | |||
383 | } | | |||
384 | onTrimmingIn: { | 298 | onTrimmingIn: { | ||
385 | if (controller.requestItemResize(clip.clipId, newDuration, false, false, root.snapping)) { | 299 | if (controller.requestItemResize(clip.clipId, newDuration, false, false, root.snapping)) { | ||
386 | clip.lastValidDuration = newDuration | 300 | clip.lastValidDuration = newDuration | ||
Context not available. | |||||
416 | controller.requestItemResize(clip.clipId, clip.originalDuration, true, false, root.snapping) | 330 | controller.requestItemResize(clip.clipId, clip.originalDuration, true, false, root.snapping) | ||
417 | controller.requestItemResize(clip.clipId, clip.lastValidDuration, true, true, root.snapping) | 331 | controller.requestItemResize(clip.clipId, clip.lastValidDuration, true, true, root.snapping) | ||
418 | } | 332 | } | ||
419 | | ||||
420 | Component.onCompleted: { | | |||
421 | moved.connect(trackRoot.compositionDropped) | | |||
422 | dropped.connect(trackRoot.compositionDropped) | | |||
423 | draggedToTrack.connect(trackRoot.compositionDraggedToTrack) | | |||
424 | // console.log('Showing item ', model.item, 'name', model.name, ' service: ',mltService) | | |||
425 | } | | |||
426 | } | 333 | } | ||
427 | } | 334 | } | ||
428 | } | 335 | } | ||
Context not available. |