Commit f72ab410 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Fix clips incorrectly resized on move with mix

parent 154f6aca
Pipeline #46927 passed with stage
in 12 minutes and 18 seconds
......@@ -688,9 +688,10 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
if (old_trackId == trackId) {
// We are moving a clip on same track
if (finalMove && position >= mixData.first.firstClipInOut.second) {
position += m_allClips[clipId]->getMixDuration() - m_allClips[clipId]->getMixCutPosition();
removeMixWithUndo(clipId, local_undo, local_redo);
}
} else if (finalMove) {
} else {
// Clip moved to another track, delete mix
int subPlaylist = m_allClips[clipId]->getSubPlaylistIndex();
update_playlist = [this, clipId, old_trackId, trackId, finalMove]() {
......@@ -718,6 +719,7 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
if (finalMove && (position + clipDuration <= mixData.second.secondClipInOut.first)) {
// Moved outside mix zone
removeMixWithUndo(mixData.second.secondClipId, local_undo, local_redo);
}
} else {
// Clip moved to another track, delete mix
......@@ -738,11 +740,8 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
int mixEnd = m_allClips[mixData.first.firstClipId]->getPosition() + m_allClips[mixData.first.firstClipId]->getPlaytime();
if (mixEnd < position) {
// Mix will be deleted, recreate on undo
bool isAudio = getTrackById_const(old_trackId)->isAudioTrack();
update_playlist_undo = [this, mixData, old_trackId, isAudio]() {
bool result = getTrackById_const(old_trackId)->createMix(mixData.first, isAudio);
return result;
};
position += m_allClips[mixData.first.secondClipId]->getMixDuration() - m_allClips[mixData.first.secondClipId]->getMixCutPosition();
removeMixWithUndo(mixData.first.secondClipId, local_undo, local_redo);
}
}
}
......@@ -752,11 +751,7 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
int mixEnd = m_allClips[mixData.second.secondClipId]->getPosition();
if (mixEnd > position + m_allClips[clipId]->getPlaytime()) {
// Mix will be deleted, recreate on undo
bool isAudio = getTrackById_const(old_trackId)->isAudioTrack();
update_playlist_undo = [this, mixData, old_trackId, isAudio]() {
bool result = getTrackById_const(old_trackId)->createMix(mixData.second, isAudio);
return result;
};
removeMixWithUndo(mixData.second.secondClipId, local_undo, local_redo);
}
}
}
......@@ -785,6 +780,7 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
Q_ASSERT(undone);
return false;
}
qDebug()<<":::MOVED CLIP: "<<clipId<<" TO "<<position;
sync_mix();
update_model();
simple_move_mix();
......@@ -2364,7 +2360,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
Q_ASSERT(undone);
return false;
}
int newStart = getTrackById_const(current_track_id)->getBlankStart(current_in - 1);
int newStart = getTrackById_const(current_track_id)->getBlankStart(current_in - 1, subPlaylist);
delta_pos = qMax(delta_pos, newStart - current_in);
}
} else {
......@@ -2374,7 +2370,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
subPlaylist = m_allClips[item.first]->getSubPlaylistIndex();
}
if (!getTrackById_const(current_track_id)->isAvailable(moveStart, moveEnd - moveStart, subPlaylist)) {
int newStart = getTrackById_const(current_track_id)->getBlankEnd(current_in + playtime);
int newStart = getTrackById_const(current_track_id)->getBlankEnd(current_in + playtime, subPlaylist);
if (newStart == current_in + playtime) {
// No move possible, abort
bool undone = local_undo();
......
......@@ -1548,10 +1548,10 @@ bool TrackModel::requestRemoveMix(std::pair<int, int> clipIds, Fun &undo, Fun &r
Fun local_undo = []() { return true; };
Fun local_redo = []() { return true; };
if (auto ptr = m_parent.lock()) {
// Resize main clip
result = ptr->getClipPtr(clipIds.second)->requestResize(endPos - secondInPos, false, local_undo, local_redo, true, true);
// Resize first part clip
result = result && ptr->getClipPtr(clipIds.first)->requestResize(secondInPos - firstInPos, true, local_undo, local_redo, true, true);
result = ptr->getClipPtr(clipIds.first)->requestResize(secondInPos - firstInPos, true, local_undo, local_redo, true, true);
// Resize main clip
result = result && ptr->getClipPtr(clipIds.second)->requestResize(endPos - secondInPos, false, local_undo, local_redo, true, true);
}
if (result) {
PUSH_LAMBDA(local_redo, redo);
......
......@@ -1467,7 +1467,7 @@ Rectangle {
controller.requestCompositionMove(dragProxy.draggedItem, tId, dragFrame , true, true, true)
} else {
if (controller.normalEdit()) {
controller.requestClipMove(dragProxy.draggedItem, dragProxy.sourceTrack, dragProxy.sourceFrame, moveMirrorTracks, true, false, false)
controller.requestClipMove(dragProxy.draggedItem, dragProxy.sourceTrack, dragProxy.sourceFrame, moveMirrorTracks, false, false, false)
controller.requestClipMove(dragProxy.draggedItem, tId, dragFrame , moveMirrorTracks, true, true, true)
} else {
// Fake move, only process final move
......
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