OpenToonz - An open-source full-featured 2D animation creation software
C
Fx setting popup enhancements (#2479)
manongjohnb13816d1b0aa
diff --git a/toonz/sources/include/toonzqt/fxschematicnode.h b/toonz/sources/include/toonzqt/fxschematicnode.hindex f0d7a7af6..15385236d 100644--- a/toonz/sources/include/toonzqt/fxschematicnode.h+++ b/toonz/sources/include/toonzqt/fxschematicnode.h@@ -365,6 +365,7 @@ public:protected:void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;+ void mousePressEvent(QGraphicsSceneMouseEvent *me) override;};//*****************************************************@@ -384,6 +385,7 @@ public:protected:void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;+ void mousePressEvent(QGraphicsSceneMouseEvent *me) override;};//*****************************************************@@ -408,6 +410,7 @@ public:protected:void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;+ void mousePressEvent(QGraphicsSceneMouseEvent *me) override;protected slots:@@ -441,6 +444,7 @@ public:protected:void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;+ void mousePressEvent(QGraphicsSceneMouseEvent *me) override;protected slots:@@ -479,6 +483,7 @@ public:protected:void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;+ void mousePressEvent(QGraphicsSceneMouseEvent *me) override;private:void renameObject(const TStageObjectId &id, std::string name);@@ -517,6 +522,7 @@ public:protected:void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;+ void mousePressEvent(QGraphicsSceneMouseEvent *me) override;protected slots:@@ -575,6 +581,7 @@ public:protected:void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) override;+ void mousePressEvent(QGraphicsSceneMouseEvent *me) override;QPointF computePos() const;protected slots:diff --git a/toonz/sources/include/toonzqt/fxsettings.h b/toonz/sources/include/toonzqt/fxsettings.hindex 64386c0a8..5fa061966 100644--- a/toonz/sources/include/toonzqt/fxsettings.h+++ b/toonz/sources/include/toonzqt/fxsettings.h@@ -190,6 +190,7 @@ class DVAPI ParamViewer final : public QFrame {Q_OBJECTTFxP m_fx;+ TFxP m_actualFx;QStackedWidget *m_tablePageSet;QMap<std::string, int> m_tableFxIndex;@@ -253,6 +254,7 @@ class DVAPI FxSettings final : public QSplitter {bool m_isCameraModeView;int m_container_height;+ int m_container_width;public:FxSettings(QWidget *parent, const TPixel32 &checkCol1,diff --git a/toonz/sources/toonz/fxparameditorpopup.cpp b/toonz/sources/toonz/fxparameditorpopup.cppindex ef0385e13..0ff3a2b8b 100644--- a/toonz/sources/toonz/fxparameditorpopup.cpp+++ b/toonz/sources/toonz/fxparameditorpopup.cpp@@ -59,6 +59,7 @@ FxParamEditorPopup::FxParamEditorPopup()}//=============================================================================-+/*OpenPopupCommandHandler<FxParamEditorPopup> openFxParamEditorPopup(MI_FxParamEditor);+*/\ No newline at end of filediff --git a/toonz/sources/toonz/tpanels.cpp b/toonz/sources/toonz/tpanels.cppindex 0f770110c..4e5a6c1f5 100644--- a/toonz/sources/toonz/tpanels.cpp+++ b/toonz/sources/toonz/tpanels.cpp@@ -53,6 +53,7 @@#include "toonzqt/tselectionhandle.h"#include "toonzqt/tmessageviewer.h"#include "toonzqt/scriptconsole.h"+#include "toonzqt/fxsettings.h"// TnzLib includes#include "toonz/palettecontroller.h"@@ -1358,3 +1359,52 @@ public:OpenFloatingPanel openHistoryPanelCommand(MI_OpenHistoryPanel, "HistoryPanel",QObject::tr("History"));//=============================================================================++//=============================================================================+// FxSettings+//-----------------------------------------------------------------------------++FxSettingsPanel::FxSettingsPanel(QWidget *parent) : TPanel(parent) {+ TApp *app = TApp::instance();+ TSceneHandle *hScene = app->getCurrentScene();+ TPixel32 col1, col2;+ Preferences::instance()->getChessboardColors(col1, col2);++ m_fxSettings = new FxSettings(this, col1, col2);+ m_fxSettings->setSceneHandle(hScene);+ m_fxSettings->setFxHandle(app->getCurrentFx());+ m_fxSettings->setFrameHandle(app->getCurrentFrame());+ m_fxSettings->setXsheetHandle(app->getCurrentXsheet());+ m_fxSettings->setLevelHandle(app->getCurrentLevel());+ m_fxSettings->setObjectHandle(app->getCurrentObject());++ m_fxSettings->setCurrentFx();++ setWidget(m_fxSettings);+}++//=============================================================================+// FxSettingsFactory+//-----------------------------------------------------------------------------++class FxSettingsFactory final : public TPanelFactory {+public:+ FxSettingsFactory() : TPanelFactory("FxSettings") {}++ TPanel *createPanel(QWidget *parent) override {+ FxSettingsPanel *panel = new FxSettingsPanel(parent);+ panel->move(qApp->desktop()->screenGeometry(panel).center());+ panel->setObjectName(getPanelType());+ panel->setWindowTitle(QObject::tr("Fx Settings"));+ panel->setMinimumSize(390, 85);+ panel->allowMultipleInstances(false);+ return panel;+ }++ void initialize(TPanel *panel) override { assert(0); }++} FxSettingsFactory;++//=============================================================================+OpenFloatingPanel openFxSettingsCommand(MI_FxParamEditor, "FxSettings",+ QObject::tr("Fx Settings"));diff --git a/toonz/sources/toonz/tpanels.h b/toonz/sources/toonz/tpanels.hindex 2a0498a30..904902b20 100644--- a/toonz/sources/toonz/tpanels.h+++ b/toonz/sources/toonz/tpanels.h@@ -25,6 +25,8 @@ class FunctionViewer;class FlipBook;class ToolOptions;class ComboViewerPanel;+class FxSettings;+//=========================================================// PaletteViewerPanel//---------------------------------------------------------@@ -267,4 +269,17 @@ protected:void widgetClearFocusOnLeave() override;};+//=========================================================+// FxSettingsPanel+//---------------------------------------------------------++class FxSettingsPanel final : public TPanel {+ Q_OBJECT++ FxSettings *m_fxSettings;++public:+ FxSettingsPanel(QWidget *parent);+};+#endifdiff --git a/toonz/sources/toonzqt/fxschematicnode.cpp b/toonz/sources/toonzqt/fxschematicnode.cppindex 86513756b..5affb297e 100644--- a/toonz/sources/toonzqt/fxschematicnode.cpp+++ b/toonz/sources/toonzqt/fxschematicnode.cpp@@ -46,6 +46,8 @@// TnzCore includes#include "tconst.h"+#include "../toonz/menubarcommandids.h"+// Qt includes#include <QAction>#include <QApplication>@@ -690,7 +692,7 @@ void FxPainter::contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) {QMenu *addMenu = fxScene->getAddFxMenu();QAction *fxEditorPopup =- CommandManager::instance()->getAction("MI_FxParamEditor");+ CommandManager::instance()->getAction(MI_FxParamEditor);QAction *copy = CommandManager::instance()->getAction("MI_Copy");QAction *cut = CommandManager::instance()->getAction("MI_Cut");QAction *group = CommandManager::instance()->getAction("MI_Group");@@ -1579,7 +1581,7 @@ void FxSchematicPort::contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) {SLOT(onConnectToXSheet()));QAction *fxEditorPopup =- CommandManager::instance()->getAction("MI_FxParamEditor");+ CommandManager::instance()->getAction(MI_FxParamEditor);menu.addMenu(fxScene->getAddFxMenu());menu.addAction(fxEditorPopup);@@ -2238,6 +2240,15 @@ void FxSchematicOutputNode::mouseDoubleClickEvent(outputSettingsPopup->trigger();}+void FxSchematicOutputNode::mousePressEvent(QGraphicsSceneMouseEvent *me) {+ FxSchematicNode::mousePressEvent(me);++ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ // this signal cause the update the contents of the FxSettings+ if (fxEditorPopup->isVisible()) emit fxNodeDoubleClicked();+}+//*****************************************************//// FxSchematicXSheetNode@@ -2306,6 +2317,15 @@ void FxSchematicXSheetNode::mouseDoubleClickEvent(sceneSettingsPopup->trigger();}+void FxSchematicXSheetNode::mousePressEvent(QGraphicsSceneMouseEvent *me) {+ FxSchematicNode::mousePressEvent(me);++ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ // this signal cause the update the contents of the FxSettings+ if (fxEditorPopup->isVisible()) emit fxNodeDoubleClicked();+}+//*****************************************************//// FxSchematicNormalFxNode@@ -2620,9 +2640,9 @@ void FxSchematicNormalFxNode::mouseDoubleClickEvent(m_nameItem->setFocus();setFlag(QGraphicsItem::ItemIsSelectable, false);} else {- QAction *fxEitorPopup =- CommandManager::instance()->getAction("MI_FxParamEditor");- fxEitorPopup->trigger();+ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ fxEditorPopup->trigger();// this signal cause the update the contents of the FxSettingsemit fxNodeDoubleClicked();}@@ -2630,6 +2650,17 @@ void FxSchematicNormalFxNode::mouseDoubleClickEvent(//-----------------------------------------------------+void FxSchematicNormalFxNode::mousePressEvent(QGraphicsSceneMouseEvent *me) {+ FxSchematicNode::mousePressEvent(me);++ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ // this signal cause the update the contents of the FxSettings+ if (fxEditorPopup->isVisible()) emit fxNodeDoubleClicked();+}++//-----------------------------------------------------+void FxSchematicNormalFxNode::resize(bool maximized) {}//*****************************************************@@ -2856,7 +2887,7 @@ void FxSchematicZeraryNode::mouseDoubleClickEvent(setFlag(QGraphicsItem::ItemIsSelectable, false);} else {QAction *fxEditorPopup =- CommandManager::instance()->getAction("MI_FxParamEditor");+ CommandManager::instance()->getAction(MI_FxParamEditor);fxEditorPopup->trigger();// this signal cause the update the contents of the FxSettings@@ -2866,6 +2897,17 @@ void FxSchematicZeraryNode::mouseDoubleClickEvent(//-----------------------------------------------------+void FxSchematicZeraryNode::mousePressEvent(QGraphicsSceneMouseEvent *me) {+ FxSchematicNode::mousePressEvent(me);++ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ // this signal cause the update the contents of the FxSettings+ if (fxEditorPopup->isVisible()) emit fxNodeDoubleClicked();+}++//-----------------------------------------------------+void FxSchematicZeraryNode::onNameChanged() {m_nameItem->hide();m_name = m_nameItem->toPlainText();@@ -3164,11 +3206,28 @@ void FxSchematicColumnNode::mouseDoubleClickEvent(m_nameItem->show();m_nameItem->setFocus();setFlag(QGraphicsItem::ItemIsSelectable, false);+ } else {+ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ fxEditorPopup->trigger();+ // this signal cause the update the contents of the FxSettings+ emit fxNodeDoubleClicked();}}//-----------------------------------------------------+void FxSchematicColumnNode::mousePressEvent(QGraphicsSceneMouseEvent *me) {+ FxSchematicNode::mousePressEvent(me);++ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ // this signal cause the update the contents of the FxSettings+ if (fxEditorPopup->isVisible()) emit fxNodeDoubleClicked();+}++//-----------------------------------------------------+void FxSchematicColumnNode::renameObject(const TStageObjectId &id,std::string name) {FxSchematicScene *fxScene = dynamic_cast<FxSchematicScene *>(scene());@@ -3335,14 +3394,25 @@ void FxSchematicPaletteNode::mouseDoubleClickEvent(m_nameItem->setFocus();setFlag(QGraphicsItem::ItemIsSelectable, false);} else {- QAction *fxEitorPopup =- CommandManager::instance()->getAction("MI_FxParamEditor");- fxEitorPopup->trigger();+ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ fxEditorPopup->trigger();}}//-----------------------------------------------------+void FxSchematicPaletteNode::mousePressEvent(QGraphicsSceneMouseEvent *me) {+ FxSchematicNode::mousePressEvent(me);++ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ // this signal cause the update the contents of the FxSettings+ if (fxEditorPopup->isVisible()) emit fxNodeDoubleClicked();+}++//-----------------------------------------------------+void FxSchematicPaletteNode::renameObject(const TStageObjectId &id,std::string name) {FxSchematicScene *fxScene = dynamic_cast<FxSchematicScene *>(scene());@@ -3494,6 +3564,15 @@ void FxGroupNode::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) {}}+void FxGroupNode::mousePressEvent(QGraphicsSceneMouseEvent *me) {+ FxSchematicNode::mousePressEvent(me);++ QAction *fxEditorPopup =+ CommandManager::instance()->getAction(MI_FxParamEditor);+ // this signal cause the update the contents of the FxSettings+ if (fxEditorPopup->isVisible()) emit fxNodeDoubleClicked();+}+//-----------------------------------------------------QPointF FxGroupNode::computePos() const {diff --git a/toonz/sources/toonzqt/fxschematicscene.cpp b/toonz/sources/toonzqt/fxschematicscene.cppindex e16c8abe3..dfb2b0166 100644--- a/toonz/sources/toonzqt/fxschematicscene.cpp+++ b/toonz/sources/toonzqt/fxschematicscene.cpp@@ -578,6 +578,8 @@ FxSchematicNode *FxSchematicScene::addGroupedFxSchematicNode(SLOT(onSwitchCurrentFx(TFx *)));connect(node, SIGNAL(currentColumnChanged(int)), this,SLOT(onCurrentColumnChanged(int)));+ connect(node, SIGNAL(fxNodeDoubleClicked()), this,+ SLOT(onFxNodeDoubleClicked()));m_groupedTable[groupId] = node;return node;}diff --git a/toonz/sources/toonzqt/fxsettings.cpp b/toonz/sources/toonzqt/fxsettings.cppindex 20f35ab4e..2c2da56ad 100644--- a/toonz/sources/toonzqt/fxsettings.cpp+++ b/toonz/sources/toonzqt/fxsettings.cpp@@ -16,6 +16,7 @@#include "pluginhost.h"#include "tenv.h"#include "tsystem.h"+#include "docklayout.h"#include "toonz/tcamera.h"#include "toonz/toonzfolders.h"@@ -38,7 +39,6 @@#include <QMap>#include <QPainter>#include <QCheckBox>-#include <QDialog>#include <QPushButton>#include <QDesktopServices>@@ -1016,9 +1016,12 @@ void ParamViewer::setFx(const TFxP ¤tFx, const TFxP &actualFx, int frame,if (m_fx != currentFx) {getCurrentPageSet()->setFx(currentFx, actualFx, frame);- QSize pageViewerPreferedSize =- getCurrentPageSet()->getPreferedSize() + QSize(2, 20);- emit preferedSizeChanged(pageViewerPreferedSize);+ if (m_actualFx != actualFx) {+ m_actualFx = actualFx;+ QSize pageViewerPreferedSize =+ getCurrentPageSet()->getPreferedSize() + QSize(2, 50);+ emit preferedSizeChanged(pageViewerPreferedSize);+ }}}@@ -1086,7 +1089,8 @@ FxSettings::FxSettings(QWidget *parent, const TPixel32 &checkCol1,, m_checkCol1(checkCol1), m_checkCol2(checkCol2), m_isCameraModeView(false)- , m_container_height(177) {+ , m_container_height(184)+ , m_container_width(390) {// param viewerm_paramViewer = new ParamViewer(this);// swatch@@ -1306,7 +1310,7 @@ void FxSettings::setCurrentFrame() {//-----------------------------------------------------------------------------void FxSettings::changeTitleBar(TFx *fx) {- QDialog *popup = dynamic_cast<QDialog *>(parentWidget());+ DockWidget *popup = dynamic_cast<DockWidget *>(parentWidget());if (!popup) return;QString titleText(tr("Fx Settings"));@@ -1512,12 +1516,19 @@ void FxSettings::onViewModeChanged(QAction *triggeredAct) {void FxSettings::onPreferedSizeChanged(QSize pvBestSize) {QSize popupBestSize = pvBestSize;++ // Set minimum size, just in case+ popupBestSize.setHeight(std::max(popupBestSize.height(), 85));+ popupBestSize.setWidth(std::max(popupBestSize.width(), 390));+if (m_toolBar->isVisible()) {- popupBestSize += QSize(0, m_viewer->height() + m_toolBar->height());+ popupBestSize += QSize(0, m_viewer->height() + m_toolBar->height() + 4);+ popupBestSize.setWidth(+ std::max(popupBestSize.width(), m_viewer->width() + 13));}- QDialog *popup = dynamic_cast<QDialog *>(parentWidget());- if (popup) {+ DockWidget *popup = dynamic_cast<DockWidget *>(parentWidget());+ if (popup && popup->isFloating()) {QRect geom = popup->geometry();geom.setSize(popupBestSize);popup->setGeometry(geom);@@ -1530,19 +1541,24 @@ void FxSettings::onPreferedSizeChanged(QSize pvBestSize) {void FxSettings::onShowSwatchButtonToggled(bool on) {QWidget *bottomContainer = widget(1);- if (!on)+ if (!on) {m_container_height =bottomContainer->height() + handleWidth() /* ハンドル幅 */;-+ m_container_width = m_viewer->width() + 13;+ }bottomContainer->setVisible(on);- QDialog *popup = dynamic_cast<QDialog *>(parentWidget());- if (popup) {+ DockWidget *popup = dynamic_cast<DockWidget *>(parentWidget());+ if (popup && popup->isFloating()) {QRect geom = popup->geometry();int height_change = (on) ? m_container_height : -m_container_height;+ int width_change = 0;++ if (on && m_container_width > geom.width())+ width_change = m_container_width - geom.width();- geom.setSize(geom.size() + QSize(0, height_change));+ geom.setSize(geom.size() + QSize(width_change, height_change));popup->setGeometry(geom);popup->update();}