Fix corruption when clicking in timeline after undo or clip offset correction

parent 0803d6ed
...@@ -70,6 +70,7 @@ Rectangle { ...@@ -70,6 +70,7 @@ Rectangle {
property double speed: 1.0 property double speed: 1.0
property color borderColor: 'black' property color borderColor: 'black'
property bool forceReloadThumb property bool forceReloadThumb
property bool isComposition: false
width : clipDuration * timeScale; width : clipDuration * timeScale;
opacity: dragProxyArea.drag.active && dragProxy.draggedItem == clipId ? 0.8 : 1.0 opacity: dragProxyArea.drag.active && dragProxy.draggedItem == clipId ? 0.8 : 1.0
...@@ -87,7 +88,8 @@ Rectangle { ...@@ -87,7 +88,8 @@ Rectangle {
function clearAndMove(offset) { function clearAndMove(offset) {
controller.requestClearSelection() controller.requestClearSelection()
controller.requestClipMove(clipRoot.clipId, clipRoot.trackId, clipRoot.modelStart - offset, true, true, true); controller.requestClipMove(clipRoot.clipId, clipRoot.trackId, clipRoot.modelStart - offset, true, true, true)
controller.requestAddToSelection(clipRoot.clipId)
} }
onInPointChanged: { onInPointChanged: {
......
...@@ -52,6 +52,7 @@ Item { ...@@ -52,6 +52,7 @@ Item {
property int aTrack: -1 property int aTrack: -1
property int clipId //Id of the clip in the model property int clipId //Id of the clip in the model
property int originalTrackId: trackId property int originalTrackId: trackId
property bool isComposition: true
property int originalX: x property int originalX: x
property int originalDuration: clipDuration property int originalDuration: clipDuration
property int lastValidDuration: clipDuration property int lastValidDuration: clipDuration
......
...@@ -71,8 +71,8 @@ function getTrackIndexFromId(id) { ...@@ -71,8 +71,8 @@ function getTrackIndexFromId(id) {
function getTrackById(id) { function getTrackById(id) {
var i = 0; var i = 0;
for (; i < trackHeaderRepeater.count; i++) { for (; i < tracksRepeater.count; i++) {
if (trackHeaderRepeater.itemAt(i).trackId == id) { if (tracksRepeater.itemAt(i).trackInternalId == id) {
return tracksRepeater.itemAt(i); return tracksRepeater.itemAt(i);
} }
} }
......
...@@ -1021,8 +1021,8 @@ Rectangle { ...@@ -1021,8 +1021,8 @@ Rectangle {
property bool isComposition property bool isComposition
property int verticalOffset property int verticalOffset
property var masterObject property var masterObject
color: 'green' color: 'transparent'
opacity: 0.8 //opacity: 0.8
MouseArea { MouseArea {
id: dragProxyArea id: dragProxyArea
anchors.fill: parent anchors.fill: parent
...@@ -1068,11 +1068,23 @@ Rectangle { ...@@ -1068,11 +1068,23 @@ Rectangle {
var posx = Math.round((parent.x)/ root.timeScale) var posx = Math.round((parent.x)/ root.timeScale)
var clickAccepted = true var clickAccepted = true
if (controller.normalEdit() && (tk != Logic.getTrackIdFromPos(parent.y) || x != posx)) { if (controller.normalEdit() && (tk != Logic.getTrackIdFromPos(parent.y) || x != posx)) {
console.log('INCORRECT DRAG, Trying to recover item: ', parent.y,' XPOS: ',x,'=',posx,'\n!!!!!!!!!!') console.log('INCORRECT DRAG, Trying to recover item: ', parent.y,' XPOS: ',x,'=',posx,'on track: ',tk ,'\n!!!!!!!!!!')
// Try to find correct item // Try to find correct item
var track = Logic.getTrackById(tk) var track = Logic.getTrackById(tk)
var container = track.children[0].children[0].children[0] var container = track.children[0]
var tentativeClip = container.childAt(mouseX + parent.x, 5) var tentativeClip = undefined
var realX = mouseX + parent.x
for (var i = 0 ; i < container.children.length; i++) {
if (container.children[i].children.length == 0 || container.children[i].children[0].children.length == 0) {
continue
}
var testX = container.children[i].children[0].children[0].x - realX
if (dragProxy.isComposition == container.children[i].children[0].children[0].isComposition && testX < 0 && testX + container.children[i].children[0].children[0].width > 0) {
// Found clip in place
tentativeClip = container.children[i].children[0].children[0]
break
}
}
if (tentativeClip && tentativeClip.clipId) { if (tentativeClip && tentativeClip.clipId) {
clickAccepted = true clickAccepted = true
dragProxy.draggedItem = tentativeClip.clipId dragProxy.draggedItem = tentativeClip.clipId
...@@ -1089,6 +1101,7 @@ Rectangle { ...@@ -1089,6 +1101,7 @@ Rectangle {
mouse.accepted = false mouse.accepted = false
dragProxy.draggedItem = -1 dragProxy.draggedItem = -1
dragProxy.masterObject = undefined dragProxy.masterObject = undefined
dragProxy.sourceFrame = -1
parent.x = 0 parent.x = 0
parent.y = 0 parent.y = 0
parent.width = 0 parent.width = 0
......
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