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

When dragging a clip in insert mode, don't allow leaving empty space in timeline.

Related to #673
parent e6d2c205
Pipeline #26911 passed with stage
in 21 minutes and 27 seconds
...@@ -727,6 +727,14 @@ QVariantList TimelineModel::suggestItemMove(int itemId, int trackId, int positio ...@@ -727,6 +727,14 @@ QVariantList TimelineModel::suggestItemMove(int itemId, int trackId, int positio
return suggestCompositionMove(itemId, trackId, position, cursorPosition, snapDistance); return suggestCompositionMove(itemId, trackId, position, cursorPosition, snapDistance);
} }
int TimelineModel::adjustFrame(int frame, int trackId)
{
if (m_editMode == TimelineMode::InsertEdit && isTrack(trackId)) {
frame = qMin(frame, getTrackById_const(trackId)->trackDuration());
}
return frame;
}
QVariantList TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cursorPosition, int snapDistance, bool moveMirrorTracks) QVariantList TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cursorPosition, int snapDistance, bool moveMirrorTracks)
{ {
QWriteLocker locker(&m_lock); QWriteLocker locker(&m_lock);
...@@ -744,6 +752,14 @@ QVariantList TimelineModel::suggestClipMove(int clipId, int trackId, int positio ...@@ -744,6 +752,14 @@ QVariantList TimelineModel::suggestClipMove(int clipId, int trackId, int positio
TRACE_RES(position); TRACE_RES(position);
return {position, trackId}; return {position, trackId};
} }
if (m_editMode == TimelineMode::InsertEdit) {
int maxPos = getTrackById_const(trackId)->trackDuration();
if (m_allClips[clipId]->getCurrentTrackId() == trackId) {
maxPos -= m_allClips[clipId]->getPlaytime();
}
qDebug()<<"=== TRYING CLIP MOVE AT: "<<position<<", MAX TK: "<<getTrackById_const(trackId)->trackDuration();
position = qMin(position, maxPos);
}
bool after = position > currentPos; bool after = position > currentPos;
if (snapDistance > 0) { if (snapDistance > 0) {
std::vector<int> ignored_pts; std::vector<int> ignored_pts;
......
...@@ -389,6 +389,9 @@ public: ...@@ -389,6 +389,9 @@ public:
Q_INVOKABLE QVariantList suggestItemMove(int itemId, int trackId, int position, int cursorPosition, int snapDistance = -1); Q_INVOKABLE QVariantList suggestItemMove(int itemId, int trackId, int position, int cursorPosition, int snapDistance = -1);
Q_INVOKABLE QVariantList suggestClipMove(int clipId, int trackId, int position, int cursorPosition, int snapDistance = -1, bool moveMirrorTracks = true); Q_INVOKABLE QVariantList suggestClipMove(int clipId, int trackId, int position, int cursorPosition, int snapDistance = -1, bool moveMirrorTracks = true);
Q_INVOKABLE QVariantList suggestCompositionMove(int compoId, int trackId, int position, int cursorPosition, int snapDistance = -1); Q_INVOKABLE QVariantList suggestCompositionMove(int compoId, int trackId, int position, int cursorPosition, int snapDistance = -1);
/** @brief returns the frame pos adjusted to edit mode
*/
Q_INVOKABLE int adjustFrame(int frame, int trackId);
/* @brief Request clip insertion at given position. This action is undoable /* @brief Request clip insertion at given position. This action is undoable
Returns true on success. If it fails, nothing is modified. Returns true on success. If it fails, nothing is modified.
......
...@@ -514,7 +514,8 @@ Rectangle { ...@@ -514,7 +514,8 @@ Rectangle {
clipBeingDroppedId = insertAndMaybeGroup(timeline.activeTrack, frame, clipBeingDroppedData) clipBeingDroppedId = insertAndMaybeGroup(timeline.activeTrack, frame, clipBeingDroppedData)
} else { } else {
// we want insert/overwrite mode, make a fake insert at end of timeline, then move to position // we want insert/overwrite mode, make a fake insert at end of timeline, then move to position
clipBeingDroppedId = insertAndMaybeGroup(timeline.activeTrack, timeline.fullDuration, clipBeingDroppedData) frame = controller.adjustFrame(frame, timeline.activeTrack)
clipBeingDroppedId = insertAndMaybeGroup(timeline.activeTrack, frame, clipBeingDroppedData)
if (clipBeingDroppedId > -1) { if (clipBeingDroppedId > -1) {
var moveData = controller.suggestClipMove(clipBeingDroppedId, timeline.activeTrack, frame, root.consumerPosition, root.snapping) var moveData = controller.suggestClipMove(clipBeingDroppedId, timeline.activeTrack, frame, root.consumerPosition, root.snapping)
fakeFrame = moveData[0] fakeFrame = moveData[0]
......
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