diff --git a/toonz/sources/toonz/comboviewerpane.cpp b/toonz/sources/toonz/comboviewerpane.cpp index 5caadc5..f85084e 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())); @@ -413,13 +411,38 @@ 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()); + TApp *app = TApp::instance(); + TFrameHandle *frameHandle = app->getCurrentFrame(); + TSceneHandle *sceneHandle = app->getCurrentScene(); + TXshLevelHandle *levelHandle = app->getCurrentLevel(); + TObjectHandle *objectHandle = app->getCurrentObject(); + TXsheetHandle *xshHandle = app->getCurrentXsheet(); + + disconnect(xshHandle, SIGNAL(xsheetChanged()), this, SLOT(onSceneChanged())); + + 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, + SLOT(changeWindowTitle())); + disconnect(levelHandle, SIGNAL(xshLevelTitleChanged()), this, + SLOT(changeWindowTitle())); + disconnect(levelHandle, SIGNAL(xshLevelChanged()), this, + SLOT(updateFrameRange())); + + disconnect(frameHandle, SIGNAL(frameSwitched()), this, + SLOT(changeWindowTitle())); + disconnect(frameHandle, SIGNAL(frameSwitched()), this, + SLOT(onFrameChanged())); + disconnect(frameHandle, SIGNAL(frameTypeChanged()), this, + SLOT(onFrameTypeChanged())); + + disconnect(app->getCurrentTool(), SIGNAL(toolSwitched()), m_sceneViewer, + SLOT(onToolSwitched())); m_flipConsole->setActive(false); } @@ -811,6 +834,8 @@ void ComboViewerPanel::onPreferenceChanged(const QString &prefName) { StyleShortcutSwitchablePanel::onPreferenceChanged(prefName); } +//----------------------------------------------------------------------------- + void ComboViewerPanel::playAudioFrame(int frame) { if (m_first) { m_first = false; @@ -833,6 +858,8 @@ void ComboViewerPanel::playAudioFrame(int frame) { false); } +//----------------------------------------------------------------------------- + bool ComboViewerPanel::hasSoundtrack() { if (m_sound != NULL) { m_sound = NULL; diff --git a/toonz/sources/toonz/viewerpane.cpp b/toonz/sources/toonz/viewerpane.cpp index 5c79951..55d882a 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,12 @@ void SceneViewerPanel::onSceneChanged() { TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); assert(scene); + m_flipConsole->setFrameRate(TApp::instance() + ->getCurrentScene() + ->getScene() + ->getProperties() + ->getOutputProperties() + ->getFrameRate()); // vinz: perche veniva fatto? // m_flipConsole->updateCurrentFPS(scene->getProperties()->getOutputProperties()->getFrameRate()); @@ -605,12 +623,6 @@ void SceneViewerPanel::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(); } @@ -656,6 +668,16 @@ void SceneViewerPanel::onFrameTypeChanged() { //----------------------------------------------------------------------------- +bool SceneViewerPanel::isFrameAlreadyCached(int frame) { + if (m_sceneViewer->isPreviewEnabled()) { + class Previewer *pr = Previewer::instance(); + return pr->isFrameReady(frame - 1); + } else + return true; +} + +//----------------------------------------------------------------------------- + void SceneViewerPanel::onPreferenceChanged(const QString &prefName) { m_flipConsole->onPreferenceChanged(prefName); StyleShortcutSwitchablePanel::onPreferenceChanged(prefName); @@ -686,6 +708,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..62c8af2 100644 --- a/toonz/sources/toonz/viewerpane.h +++ b/toonz/sources/toonz/viewerpane.h @@ -57,6 +57,11 @@ public: void onDrawFrame(int frame, const ImagePainter::VisualSettings &settings) override; + bool widgetInThisPanelIsFocused() override { + return m_sceneViewer->hasFocus(); + } + // reimplementation of FlipConsoleOwner::isFrameAlreadyCached + bool isFrameAlreadyCached(int frame) override; protected: void showEvent(QShowEvent *) override; @@ -66,6 +71,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();