From: Jean-Baptiste M. <nu...@kd...> - 2017-06-21 09:11:27
|
Git commit b1d58c304504e5aa26fd8cd089a2aff96c26af8e by Jean-Baptiste Mardelle. Committed on 21/06/2017 at 09:10. Pushed by mardelle into branch 'refactoring_timeline'. Fix crash in composition move, fix qml anchor error and snap items on first drag in timeline M +0 -2 src/timeline2/model/compositionmodel.cpp M +2 -2 src/timeline2/model/trackmodel.cpp M +6 -7 src/timeline2/view/qml/Composition.qml M +2 -0 src/timeline2/view/qml/timeline.qml https://commits.kde.org/kdenlive/b1d58c304504e5aa26fd8cd089a2aff96c26af8e diff --git a/src/timeline2/model/compositionmodel.cpp b/src/timeline2/model/compositionmodel.cpp index 6f5204dde..c751dfee8 100644 --- a/src/timeline2/model/compositionmodel.cpp +++ b/src/timeline2/model/compositionmodel.cpp @@ -86,7 +86,6 @@ bool CompositionModel::requestResize(int size, bool right, Fun &undo, Fun &redo) } Fun operation = [in, out, track_operation, this]() { if (track_operation()) { - setInOut(in, out); return true; } return false; @@ -99,7 +98,6 @@ bool CompositionModel::requestResize(int size, bool right, Fun &undo, Fun &redo) } Fun reverse = [old_in, old_out, track_reverse, this]() { if (track_reverse()) { - setInOut(old_in, old_out); return true; } return false; diff --git a/src/timeline2/model/trackmodel.cpp b/src/timeline2/model/trackmodel.cpp index 03ac4a148..51631b8a6 100644 --- a/src/timeline2/model/trackmodel.cpp +++ b/src/timeline2/model/trackmodel.cpp @@ -638,12 +638,12 @@ int TrackModel::getBlankEnd(int position) Fun TrackModel::requestCompositionResize_lambda(int compoId, int in, int out) { QWriteLocker locker(&m_lock); - qDebug() << "compo resize " << compoId << in << out; int compo_position = m_allCompositions[compoId]->getPosition(); Q_ASSERT(m_compoPos.count(compo_position) > 0); Q_ASSERT(m_compoPos[compo_position] == compoId); int old_in = compo_position; int old_out = old_in + m_allCompositions[compoId]->getPlaytime(); + qDebug() << "compo resize " << compoId << in <<"-"<< out<<" / "<<old_in <<"-"<< old_out; if (out == -1) { out = in + old_out - old_in; } @@ -679,7 +679,7 @@ Fun TrackModel::requestCompositionResize_lambda(int compoId, int in, int out) return [in, out, compoId, update_snaps, this]() { m_compoPos.erase(m_allCompositions[compoId]->getPosition()); m_allCompositions[compoId]->setInOut(in, out); - update_snaps(m_allCompositions[compoId]->getPosition(), m_allCompositions[compoId]->getPosition() + out - in + 1); + update_snaps(in, out + 1); m_compoPos[m_allCompositions[compoId]->getPosition()] = compoId; return true; }; diff --git a/src/timeline2/view/qml/Composition.qml b/src/timeline2/view/qml/Composition.qml index 40bc49444..77ea1b847 100644 --- a/src/timeline2/view/qml/Composition.qml +++ b/src/timeline2/view/qml/Composition.qml @@ -239,20 +239,19 @@ Item { onPressed: { root.stopScrolling = true - compositionRoot.originalX = mapToItem(null, x, y).x + compositionRoot.originalX = compositionRoot.x compositionRoot.originalDuration = clipDuration parent.anchors.left = undefined } onReleased: { root.stopScrolling = false - parent.anchors.left = compositionRoot.left + parent.anchors.left = displayRect.left compositionRoot.trimmedIn(compositionRoot) parent.opacity = 0 } onPositionChanged: { if (mouse.buttons === Qt.LeftButton) { - compositionRoot.draggedX = mapToItem(null, x, y).x - var delta = Math.round((draggedX - originalX) / timeScale) + var delta = Math.round((trimIn.x) / timeScale) if (delta !== 0) { var newDuration = compositionRoot.clipDuration - delta compositionRoot.trimmingIn(compositionRoot, newDuration, mouse) @@ -265,9 +264,9 @@ Item { } Rectangle { id: trimOut - anchors.right: parent.right + anchors.right: displayRect.right anchors.rightMargin: 0 - height: parent.height + height: displayRect.height width: 5 color: 'red' opacity: 0 @@ -291,7 +290,7 @@ Item { } onReleased: { root.stopScrolling = false - parent.anchors.right = compositionRoot.right + parent.anchors.right = displayRect.right compositionRoot.trimmedOut(compositionRoot) } onPositionChanged: { diff --git a/src/timeline2/view/qml/timeline.qml b/src/timeline2/view/qml/timeline.qml index 9a5d5ecb2..73c9bbd5a 100644 --- a/src/timeline2/view/qml/timeline.qml +++ b/src/timeline2/view/qml/timeline.qml @@ -150,6 +150,7 @@ Rectangle { var track = Logic.getTrackIdFromPos(drag.y) if (track !=-1) { var frame = Math.round((drag.x + scrollView.flickableItem.contentX) / timeline.scaleFactor) + frame = controller.suggestSnapPoint(frame, root.snapping) if (clipBeingDroppedId >= 0){ controller.requestCompositionMove(clipBeingDroppedId, track, frame, true, false) continuousScrolling(drag.x + scrollView.flickableItem.contentX) @@ -219,6 +220,7 @@ Rectangle { if (clipBeingMovedId == -1) { var track = Logic.getTrackIdFromPos(drag.y) var frame = Math.round((drag.x + scrollView.flickableItem.contentX) / timeline.scaleFactor) + frame = controller.suggestSnapPoint(frame, root.snapping) if (clipBeingDroppedId >= 0){ controller.requestClipMove(clipBeingDroppedId, track, frame, true, false) continuousScrolling(drag.x + scrollView.flickableItem.contentX) |