Commit 0f144df5 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Ensure a mixed clip cannot be moved further than its counterpart mix clip

parent c69bc854
......@@ -659,7 +659,7 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
return true;
};
if (old_trackId == trackId) {
// We are moving a group on same track
// We are moving a clip on same track
if (finalMove && position >= mixData.first.firstClipInOut.second) {
int subPlaylist = m_allClips[clipId]->getSubPlaylistIndex();
update_playlist = [this, clipId, subPlaylist]() {
......@@ -1139,6 +1139,27 @@ QVariantList TimelineModel::suggestClipMove(int clipId, int trackId, int positio
position = snapped;
}
}
if (sourceTrackId == trackId) {
// Same track move, check if there is a mix and limit move
std::pair<MixInfo, MixInfo> mixData = getTrackById_const(trackId)->getMixInfo(clipId);
if (mixData.first.firstClipId > -1) {
// Clip has start mix
int clipDuration = m_allClips[clipId]->getPlaytime();
// ensure we don't move before first clip
position = qMax(position, mixData.first.firstClipInOut.first);
if (position + clipDuration <= mixData.first.firstClipInOut.second) {
position = mixData.first.firstClipInOut.second - clipDuration + 2;
}
}
if (mixData.second.firstClipId > -1) {
// Clip has end mix
int clipDuration = m_allClips[clipId]->getPlaytime();
position = qMin(position, mixData.second.secondClipInOut.first);
if (position + clipDuration >= mixData.second.secondClipInOut.second) {
position = mixData.second.secondClipInOut.second - clipDuration - 2;
}
}
}
// we check if move is possible
bool possible = (m_editMode == TimelineMode::NormalEdit) ? requestClipMove(clipId, trackId, position, moveMirrorTracks, true, false, false)
: requestFakeClipMove(clipId, trackId, position, true, false, false);
......
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