Commit 40085a04 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Fix creating mix between color clip and AV clip

parent c3155b94
......@@ -801,46 +801,37 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
bool TimelineModel::mixClip(int idToMove)
{
int selectedTrack = -1;
std::unordered_set<int> initialSelection;
if (idToMove == -1) {
initialSelection = getCurrentSelection();
if (initialSelection.empty()) {
std::unordered_set<int> initialSelection = getCurrentSelection();
if (idToMove == -1 && initialSelection.empty()) {
pCore->displayMessage(i18n("Select a clip to apply the mix"), InformationMessage, 500);
return false;
}
std::pair<int, int> clipsToMix;
int mixPosition = 0;
int previousClip = -1;
if (idToMove != -1) {
initialSelection = {idToMove};
idToMove = -1;
}
for (int s : initialSelection) {
if (!isClip(s)) {
continue;
}
if (selectedTrack == -1) {
idToMove = s;
break;
}
}
}
if (idToMove == -1 || !isClip(idToMove)) {
pCore->displayMessage(i18n("Select a clip to apply the mix"), InformationMessage, 500);
return false;
}
selectedTrack = getClipTrackId(idToMove);
selectedTrack = getClipTrackId(s);
if (selectedTrack == -1 || !isTrack(selectedTrack)) {
pCore->displayMessage(i18n("Select a clip to apply the mix"), InformationMessage, 500);
return false;
continue;
}
int mixPosition = getItemPosition(idToMove);
int clipDuration = getItemPlaytime(idToMove);
std::pair<int, int> clipsToMix;
mixPosition = getItemPosition(s);
int clipDuration = getItemPlaytime(s);
// Check if we have a clip before and/or after
int previousClip = -1;
int nextClip = -1;
// Check if clip already has a mix
if (getTrackById_const(selectedTrack)->hasStartMix(idToMove)) {
if (getTrackById_const(selectedTrack)->hasEndMix(idToMove)) {
pCore->displayMessage(i18n("Clip already mixed"), InformationMessage, 500);
return false;
if (getTrackById_const(selectedTrack)->hasStartMix(s)) {
if (getTrackById_const(selectedTrack)->hasEndMix(s)) {
continue;
}
nextClip = getTrackById_const(selectedTrack)->getClipByPosition(mixPosition + clipDuration + 1);
} else if (getTrackById_const(selectedTrack)->hasEndMix(idToMove)) {
} else if (getTrackById_const(selectedTrack)->hasEndMix(s)) {
previousClip = getTrackById_const(selectedTrack)->getClipByPosition(mixPosition - 1);
if (previousClip > -1 && getTrackById_const(selectedTrack)->hasEndMix(previousClip)) {
// Could happen if 2 clips before are mixed to full length
......@@ -862,18 +853,29 @@ bool TimelineModel::mixClip(int idToMove)
if (nextClip == -1) {
if (previousClip == -1) {
// No clip to mix, abort
pCore->displayMessage(i18n("No adjacent clip to perform mix"), InformationMessage, 500);
return false;
continue;
}
// Mix at start of selected clip
clipsToMix.first = previousClip;
clipsToMix.second = idToMove;
clipsToMix.second = s;
idToMove = s;
break;
} else {
// Mix at end of selected clip
mixPosition += clipDuration;
clipsToMix.first = idToMove;
clipsToMix.first = s;
clipsToMix.second = nextClip;
idToMove = s;
break;
}
}
if (idToMove == -1 || !isClip(idToMove)) {
pCore->displayMessage(i18n("Select a clip to apply the mix"), InformationMessage, 500);
return false;
}
std::function<bool(void)> undo = []() { return true; };
std::function<bool(void)> redo = []() { return true; };
bool result = requestClipMix(clipsToMix, selectedTrack, mixPosition, true, true, true, undo,
......
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