From b5303207409149897e5249fca41ba4a93012b310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Tue, 11 Jan 2022 15:35:32 -0800 Subject: [PATCH] Hide viewer buttons when roto/tracker properties panel is minimized (#748) - addresses issue commented in [#745 (review)](https://github.com/NatronGitHub/Natron/pull/745#pullrequestreview-847945375) - when panel is maximized, buttons are displayed even if viewer is not in render path (see #744 for an explanation of that feature). This is not 100% satisfactory, but better than before IMHO - do not show the viewer buttons if a node is selected in the nodegraph but has its properties panel minimized - maximize properties panel when double-clicking a node in the nodegraph - minimized() and maximized() were originally two separate signals (in NodeSettingsPanel), so I kept it that way, but we could have simpler definitions of NodeGui::onSettingsPanelMinimized() and NodeGui::onSettingsPanelMaximized() that simply call NodeGui::onSettingsPanelClosed(true) or NodeGui::onSettingsPanelClosed(false). --- Gui/NodeGui.cpp | 40 +++++++++++++++++++++++++++++++++------ Gui/NodeGui.h | 8 ++++++++ Gui/NodeViewerContext.cpp | 14 ++++++++++++++ Gui/NodeViewerContext.h | 4 ++++ 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Gui/NodeGui.cpp b/Gui/NodeGui.cpp index e269da309f..311f075d52 100644 --- a/Gui/NodeGui.cpp +++ b/Gui/NodeGui.cpp @@ -434,6 +434,8 @@ NodeGui::ensurePanelCreated(bool minimized, bool hideUnmodified) if (_settingsPanel) { QObject::connect( _settingsPanel, SIGNAL(nameChanged(QString)), this, SLOT(setName(QString)) ); QObject::connect( _settingsPanel, SIGNAL(closeChanged(bool)), this, SLOT(onSettingsPanelClosed(bool)) ); + QObject::connect( _settingsPanel, SIGNAL(minimized()), this, SLOT(onSettingsPanelMinimized()) ); + QObject::connect( _settingsPanel, SIGNAL(maximized()), this, SLOT(onSettingsPanelMaximized()) ); QObject::connect( _settingsPanel, SIGNAL(colorChanged(QColor)), this, SLOT(onSettingsPanelColorChanged(QColor)) ); _graph->getGui()->setNodeViewerInterface(thisShared); @@ -497,6 +499,32 @@ NodeGui::onSettingsPanelClosed(bool closed) Q_EMIT settingsPanelClosed(closed); } +void +NodeGui::onSettingsPanelMinimized() +{ + NodePtr internalNode = getNode(); + if (internalNode && internalNode->hasAnyPersistentMessage()) { + const std::list& viewers = getDagGui()->getGui()->getViewersList(); + for (std::list::const_iterator it = viewers.begin(); it != viewers.end(); ++it) { + (*it)->getViewer()->updatePersistentMessage(); + } + } + Q_EMIT settingsPanelMinimized(); +} + +void +NodeGui::onSettingsPanelMaximized() +{ + NodePtr internalNode = getNode(); + if (internalNode && internalNode->hasAnyPersistentMessage()) { + const std::list& viewers = getDagGui()->getGui()->getViewersList(); + for (std::list::const_iterator it = viewers.begin(); it != viewers.end(); ++it) { + (*it)->getViewer()->updatePersistentMessage(); + } + } + Q_EMIT settingsPanelMaximized(); +} + NodeSettingsPanel* NodeGui::createPanel(QVBoxLayout* container, const NodeGuiPtr& thisAsShared) @@ -2102,23 +2130,23 @@ NodeGui::setVisibleSettingsPanel(bool b, bool m, bool h) } if (_settingsPanel) { _settingsPanel->setClosed(!b); + if (b) { + // also maximize (but don't minimize when closing) + _settingsPanel->minimizeOrMaximize(false); + } } } bool NodeGui::isSettingsPanelVisible() const { - if (_settingsPanel) { - return !_settingsPanel->isClosed(); - } else { - return false; - } + return _settingsPanel && !_settingsPanel->isClosed() && !_settingsPanel->isMinimized(); } bool NodeGui::isSettingsPanelMinimized() const { - return _settingsPanel ? _settingsPanel->isMinimized() : false; + return _settingsPanel && _settingsPanel->isMinimized(); } void diff --git a/Gui/NodeGui.h b/Gui/NodeGui.h index d89e63f0d0..8c43d0fb82 100644 --- a/Gui/NodeGui.h +++ b/Gui/NodeGui.h @@ -453,6 +453,10 @@ public Q_SLOTS: void onSettingsPanelClosed(bool closed); + void onSettingsPanelMinimized(); + + void onSettingsPanelMaximized(); + void onSettingsPanelColorChanged(const QColor & color); void togglePreview(); @@ -543,6 +547,10 @@ public Q_SLOTS: void settingsPanelClosed(bool b); + void settingsPanelMinimized(); + + void settingsPanelMaximized(); + void previewImageComputed(); protected: diff --git a/Gui/NodeViewerContext.cpp b/Gui/NodeViewerContext.cpp index 7936a25d1c..3ff605b497 100644 --- a/Gui/NodeViewerContext.cpp +++ b/Gui/NodeViewerContext.cpp @@ -159,6 +159,8 @@ NodeViewerContext::createGui() QObject::connect( _imp->viewer, SIGNAL(selectionCleared()), this, SLOT(onViewerSelectionCleared()), Qt::UniqueConnection ); NodeGuiPtr node = _imp->getNode(); QObject::connect( node.get(), SIGNAL(settingsPanelClosed(bool)), this, SLOT(onNodeSettingsPanelClosed(bool)), Qt::UniqueConnection ); + QObject::connect( node.get(), SIGNAL(settingsPanelMinimized()), this, SLOT(onNodeSettingsPanelMinimized()), Qt::UniqueConnection ); + QObject::connect( node.get(), SIGNAL(settingsPanelMaximized()), this, SLOT(onNodeSettingsPanelMaximized()), Qt::UniqueConnection ); KnobsVec knobsOrdered = node->getNode()->getEffectInstance()->getViewerUIKnobs(); @@ -268,6 +270,18 @@ NodeViewerContext::onNodeSettingsPanelClosed(bool closed) } } +void +NodeViewerContext::onNodeSettingsPanelMinimized() +{ + return onNodeSettingsPanelClosed(true); +} + +void +NodeViewerContext::onNodeSettingsPanelMaximized() +{ + return onNodeSettingsPanelClosed(false); +} + int NodeViewerContext::getItemsSpacingOnSameLine() const { diff --git a/Gui/NodeViewerContext.h b/Gui/NodeViewerContext.h index 940624a791..1f7065d2c7 100644 --- a/Gui/NodeViewerContext.h +++ b/Gui/NodeViewerContext.h @@ -138,6 +138,10 @@ public Q_SLOTS: void onNodeSettingsPanelClosed(bool closed); + void onNodeSettingsPanelMinimized(); + + void onNodeSettingsPanelMaximized(); + private: boost::scoped_ptr _imp;