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

Undo/redo on clip monitor set in/out point

parent e69a368e
Pipeline #45047 passed with stage
in 10 minutes and 16 seconds
......@@ -774,14 +774,60 @@ void Monitor::slotLoadClipZone(const QPoint &zone)
void Monitor::slotSetZoneStart()
{
m_glMonitor->getControllerProxy()->setZoneIn(m_glMonitor->getCurrentPos());
checkOverlay();
QPoint oldZone = m_glMonitor->getControllerProxy()->zone();
int currentIn = m_glMonitor->getCurrentPos();
int updatedZoneOut = -1;
if (currentIn > oldZone.y()) {
updatedZoneOut = qMin(m_glMonitor->duration(), currentIn + (oldZone.y() - oldZone.x()));
}
Fun undo_zone = [this, oldZone, updatedZoneOut]() {
m_glMonitor->getControllerProxy()->setZoneIn(oldZone.x());
if (updatedZoneOut > -1) {
m_glMonitor->getControllerProxy()->setZoneOut(oldZone.y());
}
checkOverlay();
return true;
};
Fun redo_zone = [this, currentIn, updatedZoneOut]() {
if (updatedZoneOut > -1) {
m_glMonitor->getControllerProxy()->setZoneOut(updatedZoneOut);
}
m_glMonitor->getControllerProxy()->setZoneIn(currentIn);
checkOverlay();
return true;
};
redo_zone();
pCore->pushUndo(undo_zone, redo_zone, i18n("Set Zone"));
}
void Monitor::slotSetZoneEnd()
{
m_glMonitor->getControllerProxy()->setZoneOut(m_glMonitor->getCurrentPos() + 1);
checkOverlay();
QPoint oldZone = m_glMonitor->getControllerProxy()->zone();
int currentOut = m_glMonitor->getCurrentPos() + 1;
int updatedZoneIn = -1;
if (currentOut < oldZone.x()) {
updatedZoneIn = qMax(0, currentOut - (oldZone.y() - oldZone.x()));
}
Fun undo_zone = [this, oldZone, updatedZoneIn]() {
m_glMonitor->getControllerProxy()->setZoneOut(oldZone.y());
if (updatedZoneIn > -1) {
m_glMonitor->getControllerProxy()->setZoneIn(oldZone.x());
}
checkOverlay();
return true;
};
Fun redo_zone = [this, currentOut, updatedZoneIn]() {
if (updatedZoneIn > -1) {
m_glMonitor->getControllerProxy()->setZoneIn(updatedZoneIn);
}
m_glMonitor->getControllerProxy()->setZoneOut(currentOut);
checkOverlay();
return true;
};
redo_zone();
pCore->pushUndo(undo_zone, redo_zone, i18n("Set Zone"));
}
// virtual
......
......@@ -140,13 +140,6 @@ void MonitorProxy::setZoneIn(int pos)
if (m_zoneIn > 0) {
emit removeSnap(m_zoneIn);
}
if (pos > m_zoneOut) {
if (m_zoneOut > 0) {
emit removeSnap(m_zoneOut - 1);
}
m_zoneOut = qMin(q->duration(), pos + (m_zoneOut - m_zoneIn));
emit addSnap(m_zoneOut - 1);
}
m_zoneIn = pos;
if (pos > 0) {
emit addSnap(pos);
......@@ -160,13 +153,6 @@ void MonitorProxy::setZoneOut(int pos)
if (m_zoneOut > 0) {
emit removeSnap(m_zoneOut - 1);
}
if (pos < m_zoneIn) {
if (m_zoneIn > 0) {
emit removeSnap(m_zoneIn);
}
m_zoneIn = qMax(0, pos - (m_zoneOut - m_zoneIn));
emit addSnap(m_zoneIn);
}
m_zoneOut = pos;
if (pos > 0) {
emit addSnap(m_zoneOut - 1);
......
......@@ -1338,8 +1338,6 @@ void TimelineController::updateZone(const QPoint oldZone, const QPoint newZone,
emit zoneMoved(m_zone);
return;
}
std::function<bool(void)> undo = []() { return true; };
std::function<bool(void)> redo = []() { return true; };
Fun undo_zone = [this, oldZone]() {
setZone(oldZone, false);
return true;
......@@ -1349,8 +1347,7 @@ void TimelineController::updateZone(const QPoint oldZone, const QPoint newZone,
return true;
};
redo_zone();
UPDATE_UNDO_REDO_NOLOCK(redo_zone, undo_zone, undo, redo);
pCore->pushUndo(undo, redo, i18n("Set Zone"));
pCore->pushUndo(undo_zone, redo_zone, i18n("Set Zone"));
}
void TimelineController::setZoneIn(int inPoint)
......
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