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

Fix tests and resize issue

parent 44a05018
......@@ -2957,6 +2957,7 @@ int TimelineModel::requestItemResizeInfo(int itemId, int in, int out, int size,
Fun temp_undo = []() { return true; };
Fun temp_redo = []() { return true; };
bool skipSnaps = snapDistance <= 0;
bool sizeUpdated = false;
if (checkMix && right && size > out - in && isClip(itemId)) {
int playlist = -1;
if (getTrackById_const(trackId)->hasEndMix(itemId)) {
......@@ -2964,11 +2965,12 @@ int TimelineModel::requestItemResizeInfo(int itemId, int in, int out, int size,
}
int targetPos = in + size - 1;
if (!getTrackById_const(trackId)->isBlankAt(targetPos, playlist)) {
int updatedSize = getTrackById_const(trackId)->getBlankEnd(out + 1, playlist) - in;
if (size - updatedSize > snapDistance) {
int updatedSize = getTrackById_const(trackId)->getBlankEnd(out, playlist) - in + 1;
if (!skipSnaps && size - updatedSize > snapDistance) {
skipSnaps = true;
}
size = updatedSize;
sizeUpdated = true;
}
} else if (checkMix && !right && size > (out - in) && isClip(itemId)) {
int targetPos = out - size;
......@@ -2978,20 +2980,21 @@ int TimelineModel::requestItemResizeInfo(int itemId, int in, int out, int size,
}
if (!getTrackById_const(trackId)->isBlankAt(targetPos, playlist)) {
int updatedSize = out - getTrackById_const(trackId)->getBlankStart(in - 1, playlist);
if (size - updatedSize > snapDistance) {
if (!skipSnaps && size - updatedSize > snapDistance) {
skipSnaps = true;
}
size = updatedSize;
sizeUpdated = true;
}
}
int timelinePos = pCore->getTimelinePosition();
int proposed_size = size;
if (!skipSnaps) {
int timelinePos = pCore->getTimelinePosition();
m_snaps->addPoint(timelinePos);
proposed_size = m_snaps->proposeSize(in, out, getBoundaries(itemId), size, right, snapDistance);
m_snaps->removePoint(timelinePos);
}
if (proposed_size > 0) {
if (proposed_size > 0 && (!skipSnaps || sizeUpdated)) {
// only test move if proposed_size is valid
bool success = false;
if (isClip(itemId)) {
......
......@@ -569,9 +569,13 @@ TEST_CASE("Clip manipulation", "[ClipModel]")
state2();
// the gap between the two clips is 1 frame, we try to resize them by 2 frames
REQUIRE(timeline->requestItemResize(cid1, length - 2, true) == -1);
// It will only be resized by one frame
REQUIRE(timeline->requestItemResize(cid1, length - 2, true) == length - 3);
undoStack->undo();
state2();
REQUIRE(timeline->requestItemResize(cid2, length, false) == -1);
// Resize a clip over another clip will resize it to fill the gap
REQUIRE(timeline->requestItemResize(cid2, length, false) == length - 1);
undoStack->undo();
state2();
REQUIRE(timeline->requestClipMove(cid2, tid1, length - 4));
......
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