Commit 60c3a4dc authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix timeline drag in overwrite/edit mode

parent 8f21a725
Pipeline #6570 passed with stage
in 18 minutes and 2 seconds
......@@ -606,8 +606,9 @@ bool TimelineModel::requestFakeClipMove(int clipId, int trackId, int position, b
QWriteLocker locker(&m_lock);
TRACE(clipId, trackId, position, updateView, logUndo, invalidateTimeline)
Q_ASSERT(m_allClips.count(clipId) > 0);
if (m_allClips[clipId]->getPosition() == position && getClipTrackId(clipId) == trackId) {
if (m_allClips[clipId]->getPosition() == position && m_allClips[clipId]->getFakeTrackId() == trackId) {
TRACE_RES(true);
qDebug()<<"........\nABORTING MOVE; SAME POS/TRACK\n..........";
return true;
}
if (m_groups->isInGroup(clipId)) {
......@@ -709,7 +710,7 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
// Trying move on incompatible track type, stay on same track
trackId = sourceTrackId;
}
if (currentPos == position && sourceTrackId == trackId) {
if (currentPos == position && m_editMode == TimelineMode::NormalEdit && sourceTrackId == trackId) {
TRACE_RES(position);
return position;
}
......@@ -739,7 +740,7 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
}
}
// we check if move is possible
bool possible = m_editMode == TimelineMode::NormalEdit ? requestClipMove(clipId, trackId, position, moveMirrorTracks, true, false, false)
bool possible = (m_editMode == TimelineMode::NormalEdit) ? requestClipMove(clipId, trackId, position, moveMirrorTracks, true, false, false)
: requestFakeClipMove(clipId, trackId, position, true, false, false);
/*} else {
possible = requestClipMoveAttempt(clipId, trackId, position);
......
......@@ -1201,7 +1201,7 @@ Rectangle {
var posy = Math.min(Math.max(0, mouse.y + parent.y - dragProxy.verticalOffset), tracksContainerArea.height)
var tId = Logic.getTrackIdFromPos(posy)
if (dragProxy.masterObject && tId == dragProxy.masterObject.trackId) {
if (posx == dragFrame) {
if (posx == dragFrame && controller.normalEdit()) {
return
}
}
......
......@@ -2239,7 +2239,10 @@ void TimelineController::grabCurrent()
int TimelineController::getItemMovingTrack(int itemId) const
{
if (m_model->isClip(itemId)) {
int trackId = m_model->m_allClips[itemId]->getFakeTrackId();
int trackId = -1;
if (m_model->m_editMode != TimelineMode::NormalEdit) {
trackId = m_model->m_allClips[itemId]->getFakeTrackId();
}
return trackId < 0 ? m_model->m_allClips[itemId]->getCurrentTrackId() : trackId;
}
return m_model->m_allCompositions[itemId]->getCurrentTrackId();
......@@ -2284,6 +2287,10 @@ bool TimelineController::endFakeMove(int clipId, int position, bool updateView,
}
res = res && m_model->getTrackById(trackId)->requestClipInsertion(clipId, position, updateView, invalidateTimeline, undo, redo);
if (res) {
// Terminate fake move
if (m_model->isClip(clipId)) {
m_model->m_allClips[clipId]->setFakeTrackId(-1);
}
if (logUndo) {
pCore->pushUndo(undo, redo, i18n("Move item"));
}
......@@ -2300,6 +2307,10 @@ bool TimelineController::endFakeGroupMove(int clipId, int groupId, int delta_tra
std::function<bool(void)> redo = []() { return true; };
bool res = endFakeGroupMove(clipId, groupId, delta_track, delta_pos, updateView, logUndo, undo, redo);
if (res && logUndo) {
// Terminate fake move
if (m_model->isClip(clipId)) {
m_model->m_allClips[clipId]->setFakeTrackId(-1);
}
pCore->pushUndo(undo, redo, i18n("Move group"));
}
return res;
......
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