From 02d4ed57e0dbea18ee94b7c32b94e486dbdc5721 Mon Sep 17 00:00:00 2001 From: flurick Date: Dec 07 2022 17:28:22 +0000 Subject: Fix short-play only playing the last few frames etc. --- diff --git a/toonz/sources/include/toonzqt/flipconsole.h b/toonz/sources/include/toonzqt/flipconsole.h index 222a667..2f2d4a0 100644 --- a/toonz/sources/include/toonzqt/flipconsole.h +++ b/toonz/sources/include/toonzqt/flipconsole.h @@ -272,6 +272,7 @@ public: doButtonPressed(button); setChecked(button, !isChecked(button)); } + void setStopAt(int frame); // the main (currently the only) use for current flipconsole and setActive is // to @@ -349,6 +350,7 @@ private: std::vector m_gadgetsMask; int m_from, m_to, m_step; int m_currentFrame, m_framesCount; + int m_stopAt = -1; ImagePainter::VisualSettings m_settings; bool m_isPlay; diff --git a/toonz/sources/stopmotion/stopmotion.cpp b/toonz/sources/stopmotion/stopmotion.cpp index 5aa1cc5..71ba658 100644 --- a/toonz/sources/stopmotion/stopmotion.cpp +++ b/toonz/sources/stopmotion/stopmotion.cpp @@ -423,7 +423,7 @@ void StopMotion::onPlaybackChanged() { int frame = TApp::instance()->getCurrentFrame()->getFrame(); int lastFrame = TApp::instance()->getCurrentFrame()->getMaxFrameIndex(); - if (frame == 0 || frame == lastFrame) { + if (m_xSheetFrameNumber - 1 == frame + 1) { TApp::instance()->getCurrentFrame()->setFrame(m_xSheetFrameNumber - 1); } } @@ -3015,4 +3015,4 @@ public: sm->m_canon->zoomLiveView(); } } StopMotionToggleZoomCommand; -#endif \ No newline at end of file +#endif diff --git a/toonz/sources/toonz/vcrcommand.cpp b/toonz/sources/toonz/vcrcommand.cpp index 6451e74..32aeac9 100644 --- a/toonz/sources/toonz/vcrcommand.cpp +++ b/toonz/sources/toonz/vcrcommand.cpp @@ -137,12 +137,15 @@ public: ShortPlayCommand() : MenuItemHandler(MI_ShortPlay) {} void execute() override { - int row = TApp::instance()->getCurrentFrame()->getFrame(); + int currentFrame = TApp::instance()->getCurrentFrame()->getFrame(); int shortPlayFrameCount = Preferences::instance()->getShortPlayFrameCount(); - int count = + int frameCount = TApp::instance()->getCurrentXsheet()->getXsheet()->getFrameCount(); - int newFrame = std::max(0, count - shortPlayFrameCount); - TApp::instance()->getCurrentFrame()->setFrame(newFrame); + int stopFrame = std::min(currentFrame, frameCount); + int startFrame = std::max(0, stopFrame - shortPlayFrameCount); + FlipConsole::getCurrent()->setStopAt(stopFrame + 1); + + TApp::instance()->getCurrentFrame()->setFrame(startFrame); CommandManager::instance()->execute(MI_Play); } }; diff --git a/toonz/sources/toonzqt/flipconsole.cpp b/toonz/sources/toonzqt/flipconsole.cpp index 640b721..4359857 100644 --- a/toonz/sources/toonzqt/flipconsole.cpp +++ b/toonz/sources/toonzqt/flipconsole.cpp @@ -817,13 +817,18 @@ void FlipConsole::onNextFrame(int fps, QElapsedTimer *timer, else m_fpsField->setLineEditBackgroundColor(Qt::red); } + if (m_stopAt > 0 && m_currentFrame >= m_stopAt) { + doButtonPressed(ePause); + m_stopAt = -1; + } } //---------------------------------------------------------------------------- void FlipConsole::playNextFrame(QElapsedTimer *timer, qint64 targetInstant) { int from = m_from, to = m_to; - if (m_markerFrom <= m_markerTo) from = m_markerFrom, to = m_markerTo; + if (m_markerFrom <= m_markerTo && m_stopAt == -1) + from = m_markerFrom, to = m_markerTo; if (m_framesCount == 0 || (m_isPlay && m_currentFrame == (m_reverse ? from : to))) { @@ -1458,6 +1463,7 @@ void FlipConsole::onButtonPressed(int button) { playingConsole->setChecked(eLoop, false); playingConsole->setChecked(ePause, true); stoppedOther = true; + m_stopAt = -1; } } if (stoppedOther) { @@ -1532,7 +1538,8 @@ void FlipConsole::doButtonPressed(UINT button) { int from = m_from, to = m_to; // When the level editing mode, ignore the preview frame range marker if (m_markerFrom <= m_markerTo && m_frameHandle && - m_frameHandle->isEditingScene()) + m_frameHandle->isEditingScene() && + m_stopAt == -1) from = m_markerFrom, to = m_markerTo; bool linked = m_areLinked && m_isLinkable; @@ -1608,6 +1615,7 @@ void FlipConsole::doButtonPressed(UINT button) { playingConsole->setChecked(ePause, true); } } + m_stopAt = -1; return; } @@ -1615,6 +1623,7 @@ void FlipConsole::doButtonPressed(UINT button) { if (m_playbackExecutor.isRunning()) m_playbackExecutor.abort(); + m_stopAt = -1; m_isPlay = false; m_blanksToDraw = 0; @@ -1744,6 +1753,10 @@ void FlipConsole::doButtonPressed(UINT button) { //-------------------------------------------------------------------- +void FlipConsole::setStopAt(int frame) { m_stopAt = frame; } + +//-------------------------------------------------------------------- + QFrame *FlipConsole::createFrameSlider() { QFrame *frameSliderFrame = new QFrame(this);