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

Various fixes for spacer operation with subtitle track

parent 323ec2c2
Pipeline #269984 passed with stage
in 8 minutes and 26 seconds
......@@ -1385,6 +1385,13 @@ int SubtitleModel::getBlankEnd(int pos) const
return found ? min.frames(pCore->getCurrentFps()) : 0;
}
int SubtitleModel::getBlankSizeAtPos(int frame) const
{
int bkStart = getBlankStart(frame);
int bkEnd = getBlankEnd(frame);
return bkEnd - bkStart;
}
int SubtitleModel::getBlankStart(int pos) const
{
GenTime matchPos(pos, pCore->getCurrentFps());
......
......@@ -136,6 +136,8 @@ public:
int getBlankStart(int pos) const;
/** @brief Returns the position of the first subtitle after the blank at @position */
int getBlankEnd(int pos) const;
/** @brief Returns the duration of the blank at @position */
int getBlankSizeAtPos(int frame) const;
/** @brief If pos is blank, returns the position of the blank start. Otherwise returns the position of the next blank frame */
int getNextBlankStart(int pos) const;
/** @brief Returns true is track is empty at pos */
......
......@@ -454,12 +454,23 @@ std::pair<int, int> TimelineFunctions::requestSpacerStartOperation(const std::sh
firstCid = it.value();
}
}
if (timeline->getTrackById_const(it.key())->isBlankAt(clipPos - 1)) {
if (spaceDuration == -1) {
spaceDuration = timeline->getTrackById_const(it.key())->getBlankSizeAtPos(clipPos - 1);
} else {
int blank = timeline->getTrackById_const(it.key())->getBlankSizeAtPos(clipPos - 1);
spaceDuration = qMin(blank, spaceDuration);
if (timeline->isSubtitleTrack(it.key())) {
if (timeline->getSubtitleModel()->isBlankAt(clipPos - 1)) {
if (spaceDuration == -1) {
spaceDuration = timeline->getSubtitleModel()->getBlankSizeAtPos(clipPos - 1);
} else {
int blank = timeline->getSubtitleModel()->getBlankSizeAtPos(clipPos - 1);
spaceDuration = qMin(blank, spaceDuration);
}
}
} else {
if (timeline->getTrackById_const(it.key())->isBlankAt(clipPos - 1)) {
if (spaceDuration == -1) {
spaceDuration = timeline->getTrackById_const(it.key())->getBlankSizeAtPos(clipPos - 1);
} else {
int blank = timeline->getTrackById_const(it.key())->getBlankSizeAtPos(clipPos - 1);
spaceDuration = qMin(blank, spaceDuration);
}
}
}
if (relatedMaxSpace.contains(it.key())) {
......
......@@ -263,6 +263,10 @@ int TimelineModel::getItemTrackId(int itemId) const
if (isComposition(itemId)) {
return getCompositionTrackId(itemId);
}
if (isSubTitle(itemId)) {
// TODO: fix when introducing multiple subtitle tracks
return -2;
}
return -1;
}
......@@ -2114,7 +2118,7 @@ std::unordered_set<int> TimelineModel::getItemsInRange(int trackId, int start, i
Q_UNUSED(listCompositions)
std::unordered_set<int> allClips;
if (isSubtitleTrack(trackId)) {
if (isSubtitleTrack(trackId) || trackId == -1) {
// Subtitles
if (m_subtitleModel) {
std::unordered_set<int> subs = m_subtitleModel->getItemsInRange(start, end);
......
Supports Markdown
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