Changeset View
Changeset View
Standalone View
Standalone View
src/timeline2/view/qml/Clip.qml
Context not available. | |||||
51 | property int fadeIn: 0 | 51 | property int fadeIn: 0 | ||
---|---|---|---|---|---|
52 | property int fadeOut: 0 | 52 | property int fadeOut: 0 | ||
53 | property int binId: 0 | 53 | property int binId: 0 | ||
54 | property var parentTrack: trackRoot | 54 | property var parentTrack | ||
55 | property int trackIndex //Index in track repeater | 55 | property int trackIndex //Index in track repeater | ||
56 | property int trackId: -42 //Id in the model | 56 | property int trackId //Id in the model | ||
57 | property int clipId //Id of the clip in the model | 57 | property int clipId //Id of the clip in the model | ||
58 | property int originalTrackId: trackId | 58 | property int originalTrackId: -1 | ||
59 | property int originalX: x | 59 | property int originalX: x | ||
60 | property int originalDuration: clipDuration | 60 | property int originalDuration: clipDuration | ||
61 | property int lastValidDuration: clipDuration | 61 | property int lastValidDuration: clipDuration | ||
Context not available. | |||||
70 | property bool forceReloadThumb: false | 70 | property bool forceReloadThumb: false | ||
71 | width : clipDuration * timeScale; | 71 | width : clipDuration * timeScale; | ||
72 | 72 | | |||
73 | signal clicked(var clip, int shiftClick) | | |||
74 | signal moved(var clip) | | |||
75 | signal dragged(var clip, var mouse) | | |||
76 | signal dropped(var clip) | | |||
77 | signal draggedToTrack(var clip, int pos, int xpos) | | |||
78 | signal trimmingIn(var clip, real newDuration, var mouse, bool shiftTrim) | 73 | signal trimmingIn(var clip, real newDuration, var mouse, bool shiftTrim) | ||
79 | signal trimmedIn(var clip, bool shiftTrim) | 74 | signal trimmedIn(var clip, bool shiftTrim) | ||
80 | signal trimmingOut(var clip, real newDuration, var mouse, bool shiftTrim) | 75 | signal trimmingOut(var clip, real newDuration, var mouse, bool shiftTrim) | ||
Context not available. | |||||
95 | } | 90 | } | ||
96 | } | 91 | } | ||
97 | 92 | | |||
93 | onClipIdChanged: { | ||||
94 | console.log('()()(()()()()((\nWARNING CLIP ID CHANGED TO: ', clipRoot.clipId,'\n())()()()') | ||||
95 | } | ||||
96 | | ||||
98 | onInPointChanged: { | 97 | onInPointChanged: { | ||
99 | if (parentTrack.isAudio) { | 98 | if (parentTrack.isAudio) { | ||
100 | thumbsLoader.item.reload() | 99 | thumbsLoader.item.reload() | ||
Context not available. | |||||
108 | } | 107 | } | ||
109 | 108 | | |||
110 | ToolTip { | 109 | ToolTip { | ||
111 | visible: mouseArea.containsMouse && !mouseArea.pressed | 110 | visible: mouseArea.containsMouse && !dragProxyArea.pressed | ||
112 | font.pixelSize: root.baseUnit | 111 | font.pixelSize: root.baseUnit | ||
113 | delay: 1000 | 112 | delay: 1000 | ||
114 | timeout: 5000 | 113 | timeout: 5000 | ||
Context not available. | |||||
137 | x = modelStart * timeScale; | 136 | x = modelStart * timeScale; | ||
138 | } | 137 | } | ||
139 | 138 | | |||
139 | onTrackIdChanged: { | ||||
140 | clipRoot.parentTrack = Logic.getTrackById(trackId) | ||||
141 | clipRoot.y = clipRoot.originalTrackId == -1 || trackId == originalTrackId ? 0 : parentTrack.y - Logic.getTrackById(clipRoot.originalTrackId).y; | ||||
142 | } | ||||
143 | | ||||
140 | onForceReloadThumbChanged: { | 144 | onForceReloadThumbChanged: { | ||
141 | // TODO: find a way to force reload of clip thumbs | 145 | // TODO: find a way to force reload of clip thumbs | ||
142 | thumbsLoader.item.reload() | 146 | thumbsLoader.item.reload() | ||
Context not available. | |||||
146 | x = modelStart * timeScale; | 150 | x = modelStart * timeScale; | ||
147 | width = clipDuration * timeScale; | 151 | width = clipDuration * timeScale; | ||
148 | labelRect.x = scrollX > modelStart * timeScale ? scrollX - modelStart * timeScale : 0 | 152 | labelRect.x = scrollX > modelStart * timeScale ? scrollX - modelStart * timeScale : 0 | ||
149 | if (parentTrack.isAudio) { | 153 | if (parentTrack && parentTrack.isAudio) { | ||
150 | thumbsLoader.item.reload(); | 154 | thumbsLoader.item.reload(); | ||
151 | } | 155 | } | ||
152 | } | 156 | } | ||
Context not available. | |||||
177 | return isAudio? '#445f5a' : '#416e8c' | 181 | return isAudio? '#445f5a' : '#416e8c' | ||
178 | } | 182 | } | ||
179 | 183 | | |||
180 | function reparent(track) { | 184 | /*function reparent(track) { | ||
181 | console.log('TrackId: ',trackId) | 185 | console.log('TrackId: ',trackId) | ||
182 | parent = track | 186 | parent = track | ||
183 | height = track.height | 187 | height = track.height | ||
Context not available. | |||||
185 | trackId = parentTrack.trackId | 189 | trackId = parentTrack.trackId | ||
186 | console.log('Reparenting clip to Track: ', trackId) | 190 | console.log('Reparenting clip to Track: ', trackId) | ||
187 | //generateWaveform() | 191 | //generateWaveform() | ||
188 | } | 192 | }*/ | ||
189 | 193 | | |||
190 | property bool variableThumbs: (isAudio || clipType == ProducerType.Color || mltService === '') | 194 | property bool variableThumbs: (isAudio || clipType == ProducerType.Color || mltService === '') | ||
191 | property bool isImage: clipType == ProducerType.Image | 195 | property bool isImage: clipType == ProducerType.Image | ||
Context not available. | |||||
218 | } | 222 | } | ||
219 | 223 | | |||
220 | onAudioLevelsChanged: { | 224 | onAudioLevelsChanged: { | ||
221 | if (parentTrack.isAudio) { | 225 | if (parentTrack && parentTrack.isAudio) { | ||
222 | thumbsLoader.item.reload() | 226 | thumbsLoader.item.reload() | ||
223 | } | 227 | } | ||
224 | } | 228 | } | ||
Context not available. | |||||
226 | id: mouseArea | 230 | id: mouseArea | ||
227 | visible: root.activeTool === 0 | 231 | visible: root.activeTool === 0 | ||
228 | anchors.fill: clipRoot | 232 | anchors.fill: clipRoot | ||
229 | acceptedButtons: Qt.LeftButton | Qt.RightButton | 233 | acceptedButtons: Qt.RightButton //Qt.LeftButton | | ||
230 | drag.target: parent | | |||
231 | drag.axis: Drag.XAxis | | |||
232 | property int startX | | |||
233 | drag.smoothed: false | | |||
234 | hoverEnabled: true | 234 | hoverEnabled: true | ||
235 | cursorShape: containsMouse ? pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor : tracksArea.cursorShape | 235 | cursorShape: dragProxyArea.drag.active ? Qt.ClosedHandCursor : Qt.OpenHandCursor | ||
236 | onPressed: { | 236 | onPressed: { | ||
237 | root.stopScrolling = true | 237 | root.stopScrolling = true | ||
238 | originalX = clipRoot.x | 238 | if (mouse.button == Qt.RightButton) { | ||
239 | originalTrackId = clipRoot.trackId | | |||
240 | startX = clipRoot.x | | |||
241 | root.stopScrolling = true | | |||
242 | clipRoot.forceActiveFocus(); | | |||
243 | if (!clipRoot.selected) { | | |||
244 | clipRoot.clicked(clipRoot, mouse.modifiers == Qt.ShiftModifier) | | |||
245 | } | | |||
246 | if (mouse.button == Qt.LeftButton) { | | |||
247 | drag.target = clipRoot | | |||
248 | focus = true | | |||
249 | } else if (mouse.button == Qt.RightButton) { | | |||
250 | drag.target = undefined | 239 | drag.target = undefined | ||
251 | clipMenu.item.clipId = clipRoot.clipId | 240 | clipMenu.item.clipId = clipRoot.clipId | ||
252 | clipMenu.item.clipStatus = clipRoot.clipStatus | 241 | clipMenu.item.clipStatus = clipRoot.clipStatus | ||
Context not available. | |||||
271 | controller.requestClipMove(clipRoot.clipId, controller.getPreviousTrackId(clipRoot.trackId), clipRoot.modelStart, true, true, true); | 260 | controller.requestClipMove(clipRoot.clipId, controller.getPreviousTrackId(clipRoot.trackId), clipRoot.modelStart, true, true, true); | ||
272 | } | 261 | } | ||
273 | onPositionChanged: { | 262 | onPositionChanged: { | ||
274 | if (pressed && mouse.buttons === Qt.LeftButton && drag.target != undefined) { | 263 | var mapped = parentTrack.mapFromItem(clipRoot, mouse.x, mouse.y).x | ||
275 | var trackIndex = Logic.getTrackIndexFromId(clipRoot.trackId) | 264 | root.mousePosChanged(Math.round(mapped / timeline.scaleFactor)) | ||
276 | if ((mouse.y < 0 && trackIndex > 0) || (mouse.y > height && trackIndex < tracksRepeater.count - 1)) { | | |||
277 | var mapped = parentTrack.mapFromItem(clipRoot, mouse.x, mouse.y).x | | |||
278 | clipRoot.draggedToTrack(clipRoot, mapToItem(null, 0, mouse.y).y, mapped) | | |||
279 | } else { | | |||
280 | clipRoot.dragged(clipRoot, mouse) | | |||
281 | } | | |||
282 | } | | |||
283 | } | 265 | } | ||
284 | onReleased: { | 266 | onEntered: { | ||
285 | root.stopScrolling = false | 267 | var itemPos = mapToItem(tracksContainerArea, 0, 0, width, height) | ||
286 | if (mouse.button == Qt.LeftButton && drag.target != undefined) { | 268 | initDrag(clipRoot, itemPos, clipRoot.clipId, clipRoot.modelStart, clipRoot.trackId, false) | ||
287 | var delta = clipRoot.x - startX | 269 | } | ||
288 | drag.target = undefined | 270 | onExited: { | ||
289 | cursorShape = Qt.OpenHandCursor | 271 | endDrag() | ||
290 | if (trackId !== originalTrackId) { | | |||
291 | var track = Logic.getTrackById(trackId) | | |||
292 | parent.moved(clipRoot) | | |||
293 | reparent(track) | | |||
294 | originalX = clipRoot.x | | |||
295 | clipRoot.y = 0 | | |||
296 | originalTrackId = trackId | | |||
297 | } else if (delta != 0) { | | |||
298 | parent.dropped(clipRoot) | | |||
299 | originalX = clipRoot.x | | |||
300 | } | | |||
301 | } | | |||
302 | } | 272 | } | ||
303 | onDoubleClicked: { | 273 | onDoubleClicked: { | ||
304 | drag.target = undefined | | |||
305 | if (mouse.modifiers & Qt.ShiftModifier) { | 274 | if (mouse.modifiers & Qt.ShiftModifier) { | ||
306 | if (keyframeModel && showKeyframes) { | 275 | if (keyframeModel && showKeyframes) { | ||
307 | // Add new keyframe | 276 | // Add new keyframe | ||
Context not available. | |||||
429 | 398 | | |||
430 | KeyframeView { | 399 | KeyframeView { | ||
431 | id: effectRow | 400 | id: effectRow | ||
432 | visible: clipRoot.showKeyframes && keyframeModel | 401 | visible: clipRoot.showKeyframes && clipRoot.keyframeModel | ||
433 | selected: clipRoot.selected | 402 | selected: clipRoot.selected | ||
434 | inPoint: clipRoot.inPoint | 403 | inPoint: clipRoot.inPoint | ||
435 | outPoint: clipRoot.outPoint | 404 | outPoint: clipRoot.outPoint | ||
Context not available. |