Add black frame at end of project, allowing to properly insert a zone at project's end

Ref: T1961
parent 2cfa9e64
......@@ -2963,7 +2963,6 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
chapters.setAttribute(QStringLiteral("fps"), project->fps());
doc.appendChild(chapters);
QMap <double, QString> guidesData = pCore->projectManager()->currentTimeline()->projectView()->guidesData();
QMapIterator<double, QString> g(guidesData);
QLocale locale;
......
......@@ -631,9 +631,9 @@ void Monitor::slotSetZoneStart()
checkOverlay();
}
void Monitor::slotSetZoneEnd()
void Monitor::slotSetZoneEnd(bool discardLastFrame)
{
m_ruler->setZoneEnd();
m_ruler->setZoneEnd(discardLastFrame);
emit zoneUpdated(m_ruler->zone());
setClipZone(m_ruler->zone());
checkOverlay();
......
......@@ -292,7 +292,7 @@ public slots:
void slotStart();
void slotEnd();
void slotSetZoneStart();
void slotSetZoneEnd();
void slotSetZoneEnd(bool discardLastFrame = false);
void slotZoneStart();
void slotZoneEnd();
void slotZoneMoved(int start, int end);
......
......@@ -526,6 +526,9 @@ void MonitorManager::slotSetOutPoint()
if (m_activeMonitor == m_clipMonitor) {
m_clipMonitor->slotSetZoneEnd();
} else if (m_activeMonitor == m_projectMonitor) {
m_projectMonitor->slotSetZoneEnd();
// Zone end behaves slightly differently in clip monitor and timeline monitor.
// in timeline, set zone end selects the frame before current cursor, but in clip monitor
// it selects frame at current cursor position.
m_projectMonitor->slotSetZoneEnd(true);
}
}
......@@ -81,16 +81,12 @@ void SmallRuler::adjustScale(int maximum, int offset)
void SmallRuler::setZoneStart()
{
int pos = m_render->requestedSeekPosition;
if (pos == SEEK_INACTIVE) pos = m_render->seekFramePosition();
setZone(pos, -1);
setZone(m_render->getCurrentSeekPosition(), -1);
}
void SmallRuler::setZoneEnd()
void SmallRuler::setZoneEnd(bool discardLastFrame)
{
int pos = m_render->requestedSeekPosition;
if (pos == SEEK_INACTIVE) pos = m_render->seekFramePosition();
setZone(-1, pos);
setZone(-1, m_render->getCurrentSeekPosition() - (discardLastFrame ? 1 : 0));
}
void SmallRuler::setZone(int start, int end)
......
......@@ -43,7 +43,7 @@ public:
void adjustScale(int maximum, int offset);
void setZone(int start, int end);
void setZoneStart();
void setZoneEnd();
void setZoneEnd(bool discardLastFrame = false);
QPoint zone() const;
void setMarkers(const QList < CommentedTime >& list);
QString markerAt(GenTime pos);
......
......@@ -888,13 +888,11 @@ double Render::playSpeed() const
GenTime Render::seekPosition() const
{
if (m_mltConsumer) return GenTime((int) m_mltConsumer->position(), m_fps);
//if (m_mltProducer) return GenTime((int) m_mltProducer->position(), m_fps);
else return GenTime();
}
int Render::seekFramePosition() const
{
//if (m_mltProducer) return (int) m_mltProducer->position();
if (m_mltConsumer) return (int) m_mltConsumer->position();
return 0;
}
......@@ -920,7 +918,7 @@ void Render::emitFrameUpdated(Mlt::Frame& frame)
int Render::getCurrentSeekPosition() const
{
if (requestedSeekPosition != SEEK_INACTIVE) return requestedSeekPosition;
return (int) m_mltProducer->position();
return (int) m_mltConsumer->position();
}
bool Render::checkFrameNumber(int pos)
......@@ -1005,14 +1003,14 @@ void Render::mltCheckLength(Mlt::Tractor *tractor)
if (m_isZoneMode) resetZoneMode();
if (trackNb == 1) {
QScopedPointer<Mlt::Producer> trackProducer(tractor->track(0));
duration = trackProducer->get_playtime() - 1;
duration = trackProducer->get_playtime();
m_mltProducer->set("out", duration);
emit durationChanged(duration);
return;
}
while (trackNb > 1) {
QScopedPointer<Mlt::Producer> trackProducer(tractor->track(trackNb - 1));
int trackDuration = trackProducer->get_playtime() - 1;
int trackDuration = trackProducer->get_playtime();
if (trackDuration > duration) duration = trackDuration;
trackNb--;
}
......
......@@ -397,7 +397,7 @@ void CustomRuler::paintEvent(QPaintEvent *e)
// Draw zone background
const int zoneStart = (int)(m_zoneStart * m_factor);
const int zoneEnd = (int)(m_zoneEnd * m_factor);
const int zoneEnd = (int)((m_zoneEnd + 1)* m_factor);
p.fillRect(zoneStart - m_offset, LABEL_SIZE + 2, zoneEnd - zoneStart, MAX_HEIGHT - LABEL_SIZE - 2, m_zoneBG);
double f, fend;
......
......@@ -567,8 +567,8 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
if (m_moveOpMode == Seek && event->buttons() != Qt::NoButton) {
QGraphicsView::mouseMoveEvent(event);
if (mappedXPos != m_document->renderer()->getCurrentSeekPosition() && mappedXPos != cursorPos()) {
seekCursorPos(mappedXPos);
slotCheckPositionScrolling();
seekCursorPos(mappedXPos);
slotCheckPositionScrolling();
}
return;
}
......@@ -7958,10 +7958,7 @@ void CustomTrackView::insertZone(TimelineMode::EditMode sceneMode, const QString
if (KdenliveSettings::useTimelineZoneToEdit())
timelineZone = m_document->zone();
else {
int cursorPos = seekPosition();
if (cursorPos == m_projectDuration)
cursorPos++;
timelineZone.setX(cursorPos);
timelineZone.setX(seekPosition());
timelineZone.setY(-1);
}
ItemInfo info;
......
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