Fix zone problems (setting in/out sometimes has a 1 frame offset) and seek to...

Fix zone problems (setting in/out sometimes has a 1 frame offset) and seek to clip end after zone insert
parent 68b14887
......@@ -2496,7 +2496,13 @@ void MainWindow::slotInsertClipOverwrite()
// No clip in monitor
return;
}
getMainTimeline()->controller()->insertZone(binId, m_clipMonitor->getZoneInfo(), true);
int pos = getMainTimeline()->controller()->insertZone(binId, m_clipMonitor->getZoneInfo(), true);
if (pos > 0) {
pCore->monitorManager()->activateMonitor(Kdenlive::ProjectMonitor);
m_projectMonitor->refreshMonitorIfActive(true);
getCurrentTimeline()->controller()->setPosition(pos);
pCore->monitorManager()->activateMonitor(Kdenlive::ClipMonitor);
}
}
void MainWindow::slotInsertClipInsert()
......@@ -2506,7 +2512,13 @@ void MainWindow::slotInsertClipInsert()
// No clip in monitor
return;
}
getMainTimeline()->controller()->insertZone(binId, m_clipMonitor->getZoneInfo(), false);
int pos = getMainTimeline()->controller()->insertZone(binId, m_clipMonitor->getZoneInfo(), false);
if (pos > 0) {
pCore->monitorManager()->activateMonitor(Kdenlive::ProjectMonitor);
m_projectMonitor->refreshMonitorIfActive(true);
getCurrentTimeline()->controller()->setPosition(pos);
pCore->monitorManager()->activateMonitor(Kdenlive::ClipMonitor);
}
}
void MainWindow::slotExtractZone()
......
......@@ -87,7 +87,7 @@ public slots:
virtual void stop() = 0;
virtual void start() = 0;
virtual void slotPlay() = 0;
virtual void refreshMonitorIfActive() = 0;
virtual void refreshMonitorIfActive(bool directUpdate = false) = 0;
virtual void slotMouseSeek(int eventDelta, uint modifiers) = 0;
bool slotActivateMonitor();
virtual void slotSwitchFullScreen(bool minimizeOnly = false) = 0;
......
......@@ -658,7 +658,8 @@ void Monitor::slotSetZoneStart()
void Monitor::slotSetZoneEnd(bool discardLastFrame)
{
int pos = m_glMonitor->getCurrentPos() - (discardLastFrame ? 1 : 0);
Q_UNUSED(discardLastFrame);
int pos = m_glMonitor->getCurrentPos() + 1;
m_glMonitor->getControllerProxy()->setZoneOut(pos);
if (m_controller) {
m_controller->setZone(m_glMonitor->getControllerProxy()->zone());
......@@ -1256,10 +1257,14 @@ void Monitor::slotRefreshMonitor(bool visible)
}
}
void Monitor::refreshMonitorIfActive()
void Monitor::refreshMonitorIfActive(bool directUpdate)
{
if (isActive()) {
m_glMonitor->requestRefresh();
if (directUpdate) {
m_glMonitor->refresh();
} else {
m_glMonitor->requestRefresh();
}
}
}
......
......@@ -328,7 +328,7 @@ public slots:
void requestSeek(int pos);
/** @brief Check current position to show relevant infos in qml view (markers, zone in/out, etc). */
void checkOverlay(int pos = -1);
void refreshMonitorIfActive() override;
void refreshMonitorIfActive(bool directUpdate = false) override;
signals:
void seekPosition(int);
......
......@@ -592,10 +592,10 @@ void MonitorManager::slotSetOutPoint()
if (m_activeMonitor == m_clipMonitor) {
m_clipMonitor->slotSetZoneEnd();
} else if (m_activeMonitor == m_projectMonitor) {
// Zone end behaves slightly differently in clip monitor and timeline monitor.
// NOT anymore: 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);
m_projectMonitor->slotSetZoneEnd();
}
}
......
......@@ -320,7 +320,7 @@ bool TimelineFunctions::insertSpace(std::shared_ptr<TimelineItemModel> timeline,
Q_UNUSED(trackId)
std::unordered_set<int> clips = timeline->getItemsAfterPosition(-1, zone.x(), -1, true);
bool result = false;
bool result = true;
if (clips.size() > 0) {
int clipId = *clips.begin();
if (clips.size() > 1) {
......
......@@ -1422,7 +1422,7 @@ void TimelineController::liftZone(QPoint zone)
TimelineFunctions::extractZone(m_model, tracks, m_zone == QPoint() ? zone : m_zone, true);
}
bool TimelineController::insertZone(const QString &binId, QPoint zone, bool overwrite)
int TimelineController::insertZone(const QString &binId, QPoint zone, bool overwrite)
{
std::shared_ptr<ProjectClip> clip = pCore->bin()->getBinClip(binId);
int targetTrack = -1;
......@@ -1445,7 +1445,7 @@ bool TimelineController::insertZone(const QString &binId, QPoint zone, bool over
insertPoint = timelinePosition();
sourceZone = zone;
}
return TimelineFunctions::insertZone(m_model, targetTrack, binId, insertPoint, sourceZone, overwrite);
return TimelineFunctions::insertZone(m_model, targetTrack, binId, insertPoint, sourceZone, overwrite) ? insertPoint + (zone.y() -zone.x()) : -1;
}
void TimelineController::updateClip(int clipId, QVector<int> roles)
......
......@@ -347,7 +347,10 @@ public:
void extractZone(QPoint zone);
/** @brief Delete selected zone */
void liftZone(QPoint zone);
bool insertZone(const QString &binId, QPoint zone, bool overwrite);
/** @brief Insert clip monitor into timeline
* @returns the zone end position or -1 on fail
*/
int insertZone(const QString &binId, QPoint zone, bool overwrite);
void updateClip(int clipId, QVector<int> roles);
void showClipKeyframes(int clipId, bool value);
void showCompositionKeyframes(int clipId, bool value);
......
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