diff --git a/toonz/sources/include/toonzqt/flipconsole.h b/toonz/sources/include/toonzqt/flipconsole.h index cf9e412..def79e2 100644 --- a/toonz/sources/include/toonzqt/flipconsole.h +++ b/toonz/sources/include/toonzqt/flipconsole.h @@ -245,7 +245,7 @@ public: void getFrameRange(int &from, int &to, int &step) const { from = m_from, to = m_to, step = m_step; } - void setFrameRate(int rate); + void setFrameRate(int rate, bool forceUpdate = true); // if doShowHide==true, applies set visible, otherwise applies setEnabled void enableButton(UINT button, bool enable, bool doShowHide = true); void showCurrentFrame(); @@ -331,7 +331,7 @@ private: ImagePainter::VisualSettings m_settings; bool m_isPlay; - int m_fps; + int m_fps, m_sceneFps; bool m_reverse; int m_markerFrom, m_markerTo; bool m_drawBlanksEnabled; diff --git a/toonz/sources/include/toonzqt/flipconsoleowner.h b/toonz/sources/include/toonzqt/flipconsoleowner.h index 97e3546..b3eec23 100644 --- a/toonz/sources/include/toonzqt/flipconsoleowner.h +++ b/toonz/sources/include/toonzqt/flipconsoleowner.h @@ -18,8 +18,6 @@ public: virtual void onDrawFrame(int frame, const ImagePainter::VisualSettings &settings) = 0; - // return true if the frmae is in cache. reimplemented only in Flipbook - virtual bool isFrameAlreadyCached(int frame) { return true; }; virtual void swapBuffers(){}; virtual void changeSwapBehavior(bool enable){}; }; diff --git a/toonz/sources/toonz/comboviewerpane.cpp b/toonz/sources/toonz/comboviewerpane.cpp index 5caadc5..05bd8b7 100644 --- a/toonz/sources/toonz/comboviewerpane.cpp +++ b/toonz/sources/toonz/comboviewerpane.cpp @@ -321,16 +321,13 @@ void ComboViewerPanel::onDrawFrame( assert(frame >= 0); if (frame != frameHandle->getFrameIndex() + 1) { - if (frameHandle->isEditingScene()) { - TXshColumn *column = app->getCurrentXsheet()->getXsheet()->getColumn( - app->getCurrentColumn()->getColumnIndex()); - if (column) { - TXshSoundColumn *soundColumn = column->getSoundColumn(); - if (soundColumn && !soundColumn->isPlaying()) - app->getCurrentFrame()->scrubColumn(frame, frame, soundColumn); - } - } + int oldFrame = frameHandle->getFrame(); frameHandle->setCurrentFrame(frame); + if (!frameHandle->isPlaying() && !frameHandle->isEditingLevel() && + oldFrame != frameHandle->getFrame()) + frameHandle->scrubXsheet( + frame - 1, frame - 1, + TApp::instance()->getCurrentXsheet()->getXsheet()); } else if (settings.m_blankColor != TPixel::Transparent) @@ -384,7 +381,8 @@ void ComboViewerPanel::showEvent(QShowEvent *event) { // onXshLevelSwitched(TXshLevel*): changeWindowTitle() + updateFrameRange() ret = ret && connect(levelHandle, SIGNAL(xshLevelSwitched(TXshLevel *)), this, SLOT(onXshLevelSwitched(TXshLevel *))); - + ret = ret && connect(levelHandle, SIGNAL(xshLevelTitleChanged()), this, + SLOT(changeWindowTitle())); // updateFrameRange(): update the frame slider's range ret = ret && connect(levelHandle, SIGNAL(xshLevelChanged()), this, SLOT(updateFrameRange())); @@ -414,12 +412,14 @@ void ComboViewerPanel::showEvent(QShowEvent *event) { void ComboViewerPanel::hideEvent(QHideEvent *event) { StyleShortcutSwitchablePanel::hideEvent(event); TApp *app = TApp::instance(); - disconnect(app->getCurrentScene()); - disconnect(app->getCurrentLevel()); - disconnect(app->getCurrentFrame()); - disconnect(app->getCurrentObject()); - disconnect(app->getCurrentXsheet()); - disconnect(app->getCurrentTool()); + disconnect(app->getCurrentFrame(), 0, this, 0); + disconnect(app->getCurrentScene(), 0, this, 0); + disconnect(app->getCurrentLevel(), 0, this, 0); + disconnect(app->getCurrentObject(), 0, this, 0); + disconnect(app->getCurrentXsheet(), 0, this, 0); + + disconnect(app->getCurrentTool(), SIGNAL(toolSwitched()), m_sceneViewer, + SLOT(onToolSwitched())); m_flipConsole->setActive(false); } @@ -714,14 +714,14 @@ void ComboViewerPanel::onSceneChanged() { int frameIndex = fh->getFrameIndex(); int maxFrameIndex = fh->getMaxFrameIndex(); if (frameIndex > maxFrameIndex) maxFrameIndex = frameIndex; - - // set the FPS for new scene + // update fps only when the scene settings is changed m_flipConsole->setFrameRate(TApp::instance() ->getCurrentScene() ->getScene() ->getProperties() ->getOutputProperties() - ->getFrameRate()); + ->getFrameRate(), + false); // update the frame slider's range with new frameHandle m_flipConsole->setFrameRange(1, maxFrameIndex + 1, 1, frameIndex + 1); @@ -744,6 +744,12 @@ void ComboViewerPanel::onSceneSwitched() { enableFlipConsoleForCamerastand(false); m_sceneViewer->enablePreview(SceneViewer::NO_PREVIEW); m_flipConsole->setChecked(FlipConsole::eDefineSubCamera, false); + m_flipConsole->setFrameRate(TApp::instance() + ->getCurrentScene() + ->getScene() + ->getProperties() + ->getOutputProperties() + ->getFrameRate()); m_sceneViewer->setEditPreviewSubcamera(false); onSceneChanged(); } @@ -796,21 +802,13 @@ void ComboViewerPanel::onFrameTypeChanged() { //----------------------------------------------------------------------------- -bool ComboViewerPanel::isFrameAlreadyCached(int frame) { - if (m_sceneViewer->isPreviewEnabled()) { - class Previewer *pr = Previewer::instance(); - return pr->isFrameReady(frame - 1); - } else - return true; -} - -//----------------------------------------------------------------------------- - void ComboViewerPanel::onPreferenceChanged(const QString &prefName) { m_flipConsole->onPreferenceChanged(prefName); StyleShortcutSwitchablePanel::onPreferenceChanged(prefName); } +//----------------------------------------------------------------------------- + void ComboViewerPanel::playAudioFrame(int frame) { if (m_first) { m_first = false; @@ -833,6 +831,8 @@ void ComboViewerPanel::playAudioFrame(int frame) { false); } +//----------------------------------------------------------------------------- + bool ComboViewerPanel::hasSoundtrack() { if (m_sound != NULL) { m_sound = NULL; diff --git a/toonz/sources/toonz/comboviewerpane.h b/toonz/sources/toonz/comboviewerpane.h index 14f26e8..b12bef6 100644 --- a/toonz/sources/toonz/comboviewerpane.h +++ b/toonz/sources/toonz/comboviewerpane.h @@ -89,9 +89,6 @@ public: void onDrawFrame(int frame, const ImagePainter::VisualSettings &settings) override; - // reimplementation of FlipConsoleOwner::isFrameAlreadyCached - bool isFrameAlreadyCached(int frame) override; - protected: void showEvent(QShowEvent *) override; void hideEvent(QHideEvent *) override; diff --git a/toonz/sources/toonz/viewerpane.cpp b/toonz/sources/toonz/viewerpane.cpp index 5c79951..43afba2 100644 --- a/toonz/sources/toonz/viewerpane.cpp +++ b/toonz/sources/toonz/viewerpane.cpp @@ -241,9 +241,11 @@ void SceneViewerPanel::showEvent(QShowEvent *event) { ret = ret && connect(xshHandle, SIGNAL(xsheetChanged()), this, SLOT(onSceneChanged())); - + ret = ret && connect(sceneHandle, SIGNAL(sceneSwitched()), this, + SLOT(onSceneChanged())); ret = ret && connect(sceneHandle, SIGNAL(sceneChanged()), this, SLOT(onSceneChanged())); + ret = ret && connect(sceneHandle, SIGNAL(nameSceneChanged()), this, SLOT(changeWindowTitle())); @@ -289,7 +291,8 @@ void SceneViewerPanel::hideEvent(QHideEvent *event) { disconnect(sceneHandle, SIGNAL(sceneChanged()), this, SLOT(onSceneChanged())); disconnect(sceneHandle, SIGNAL(nameSceneChanged()), this, SLOT(changeWindowTitle())); - + disconnect(sceneHandle, SIGNAL(sceneSwitched()), this, + SLOT(onSceneChanged())); disconnect(levelHandle, SIGNAL(xshLevelSwitched(TXshLevel *)), this, SLOT(onXshLevelSwitched(TXshLevel *))); disconnect(levelHandle, SIGNAL(xshLevelChanged()), this, @@ -470,7 +473,16 @@ void SceneViewerPanel::enableFlipConsoleForCamerastand(bool on) { //----------------------------------------------------------------------------- -void SceneViewerPanel::onXshLevelSwitched(TXshLevel *) { changeWindowTitle(); } +void SceneViewerPanel::onXshLevelSwitched(TXshLevel *) { + changeWindowTitle(); + m_sceneViewer->update(); + // If the level switched by using the level choose combo box in the film + // strip, + // the current level switches without change in the frame type (level or + // scene). + // For such case, update the frame range of the console here. + if (TApp::instance()->getCurrentFrame()->isEditingLevel()) updateFrameRange(); +} //----------------------------------------------------------------------------- @@ -588,6 +600,14 @@ void SceneViewerPanel::onSceneChanged() { TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); assert(scene); + // update fps only when the scene settings is changed + m_flipConsole->setFrameRate(TApp::instance() + ->getCurrentScene() + ->getScene() + ->getProperties() + ->getOutputProperties() + ->getFrameRate(), + false); // vinz: perche veniva fatto? // m_flipConsole->updateCurrentFPS(scene->getProperties()->getOutputProperties()->getFrameRate()); @@ -686,6 +706,8 @@ void SceneViewerPanel::playAudioFrame(int frame) { false); } +//----------------------------------------------------------------------------- + bool SceneViewerPanel::hasSoundtrack() { if (m_sound != NULL) { m_sound = NULL; diff --git a/toonz/sources/toonz/viewerpane.h b/toonz/sources/toonz/viewerpane.h index 48e5c11..327c130 100644 --- a/toonz/sources/toonz/viewerpane.h +++ b/toonz/sources/toonz/viewerpane.h @@ -57,6 +57,9 @@ public: void onDrawFrame(int frame, const ImagePainter::VisualSettings &settings) override; + bool widgetInThisPanelIsFocused() override { + return m_sceneViewer->hasFocus(); + } protected: void showEvent(QShowEvent *) override; @@ -66,6 +69,13 @@ protected: void createFrameToolBar(); void createPlayToolBar(); void addColorMaskButton(QWidget *parent, const char *iconSVGName, int id); + // reimplementation of TPanel::widgetFocusOnEnter + void widgetFocusOnEnter() override { + m_sceneViewer->setFocus(Qt::OtherFocusReason); + // activate shortcut key for this flipconsole + m_flipConsole->makeCurrent(); + }; + void widgetClearFocusOnLeave() override { m_sceneViewer->clearFocus(); }; void enableFlipConsoleForCamerastand(bool on); void playAudioFrame(int frame); bool hasSoundtrack(); diff --git a/toonz/sources/toonzqt/flipconsole.cpp b/toonz/sources/toonzqt/flipconsole.cpp index 7fc8c0d..6afecf0 100644 --- a/toonz/sources/toonzqt/flipconsole.cpp +++ b/toonz/sources/toonzqt/flipconsole.cpp @@ -443,6 +443,7 @@ FlipConsole::FlipConsole(QVBoxLayout *mainLayout, UINT gadgetsMask, , m_framesCount(1) , m_settings() , m_fps(24) + , m_sceneFps(24) , m_isPlay(false) , m_reverse(false) , m_doubleRed(0) @@ -841,10 +842,13 @@ void FlipConsole::updateCurrentFPS(int val) { //----------------------------------------------------------------------------- -void FlipConsole::setFrameRate(int val) { - if (!m_fpsSlider) return; - m_fpsSlider->setValue(val); - setCurrentFPS(val); +void FlipConsole::setFrameRate(int val, bool forceUpdate) { + if (m_sceneFps != val || forceUpdate) { + if (!m_fpsSlider) return; + m_fpsSlider->setValue(val); + setCurrentFPS(val); + } + m_sceneFps = val; } //-----------------------------------------------------------------------------