2
0
Эх сурвалжийг харах

Generalized the view pane options for enable/disable during Component Mode. (#12055)

By moving this to the ViewPaneOptions, we can now add this functionality to new view panes without needing to hardcode the view pane name in QtViewPaneManager.
This will be used by the Paint Brush Settings view pane in an upcoming PR.

Signed-off-by: Mike Balfour <[email protected]>

Signed-off-by: Mike Balfour <[email protected]>
Mike Balfour 2 жил өмнө
parent
commit
3e0da91f96

+ 4 - 0
Code/Editor/Controls/ConsoleSCB.cpp

@@ -389,6 +389,10 @@ void CConsoleSCB::RegisterViewClass()
     opts.showInMenu = true;
     opts.builtInActionId = ID_VIEW_CONSOLEWINDOW;
     opts.shortcut = QKeySequence(Qt::Key_QuoteLeft);
+    // Override the default behavior for component mode enter/exit and imgui enter/exit
+    // so that we don't disable and enable the Console window.
+    opts.isDisabledInComponentMode = false;
+    opts.isDisabledInImGuiMode = false;
 
     AzToolsFramework::RegisterViewPane<CConsoleSCB>(LyViewPane::Console, LyViewPane::CategoryTools, opts);
 }

+ 18 - 0
Code/Editor/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin.cpp

@@ -120,6 +120,11 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito
     ViewPaneOptions inspectorOptions;
     inspectorOptions.canHaveMultipleInstances = true;
     inspectorOptions.preferedDockingArea = Qt::RightDockWidgetArea;
+    // Override the default behavior for component mode enter/exit and imgui enter/exit
+    // so that we don't automatically disable and enable the entire Entity Inspector. This will be handled separately per-component.
+    inspectorOptions.isDisabledInComponentMode = false;
+    inspectorOptions.isDisabledInImGuiMode = false;
+
     RegisterViewPane<QComponentEntityEditorInspectorWindow>(
         LyViewPane::EntityInspector,
         LyViewPane::CategoryTools,
@@ -130,6 +135,11 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito
     pinnedInspectorOptions.preferedDockingArea = Qt::NoDockWidgetArea;
     pinnedInspectorOptions.paneRect = QRect(50, 50, 400, 700);
     pinnedInspectorOptions.showInMenu = false;
+    // Override the default behavior for component mode enter/exit and imgui enter/exit
+    // so that we don't automatically disable and enable the entire Pinned Entity Inspector. This will be handled separately per-component.
+    pinnedInspectorOptions.isDisabledInComponentMode = false;
+    pinnedInspectorOptions.isDisabledInImGuiMode = false;
+
     RegisterViewPane<QComponentEntityEditorInspectorWindow>(
         LyViewPane::EntityInspectorPinned,
         LyViewPane::CategoryTools,
@@ -145,6 +155,10 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito
         ViewPaneOptions outlinerOptions;
         outlinerOptions.canHaveMultipleInstances = true;
         outlinerOptions.preferedDockingArea = Qt::LeftDockWidgetArea;
+        // Override the default behavior for component mode enter/exit and imgui enter/exit
+        // so that we don't automatically disable and enable the Entity Outliner. This will be handled separately.
+        outlinerOptions.isDisabledInComponentMode = false;
+        outlinerOptions.isDisabledInImGuiMode = false;
 
         RegisterViewPane<QEntityOutlinerWindow>(
             LyViewPane::EntityOutliner,
@@ -164,6 +178,10 @@ ComponentEntityEditorPlugin::ComponentEntityEditorPlugin([[maybe_unused]] IEdito
         ViewPaneOptions outlinerOptions;
         outlinerOptions.canHaveMultipleInstances = true;
         outlinerOptions.preferedDockingArea = Qt::LeftDockWidgetArea;
+        // Override the default behavior for component mode enter/exit and imgui enter/exit
+        // so that we don't automatically disable and enable the Entity Outliner. This will be handled separately.
+        outlinerOptions.isDisabledInComponentMode = false;
+        outlinerOptions.isDisabledInImGuiMode = false;
 
         // this pane was originally introduced with this name, so layout settings are all saved with that name, despite the preview label being removed.
         outlinerOptions.saveKeyName = "Entity Outliner (PREVIEW)";

+ 28 - 40
Code/Editor/QtViewPaneManager.cpp

@@ -542,30 +542,11 @@ QString DockWidget::settingsKey(const QString& paneName)
     return QStringLiteral("ViewPane-") + paneName;
 }
 
-// run generic function on all widgets considered for greying out/disabling
-template<typename Fn>
-void SetDefaultActionsEnabled(
-    const bool enabled, QtViewPanes& registeredPanes, const Fn& fn)
+void EnableAllWidgetInstances(QList<DockWidget*>& widgetInstances, bool enable)
 {
-    for (QtViewPane& p : registeredPanes)
+    for (auto& dockWidget : widgetInstances)
     {
-        if (!p.m_dockWidgetInstances.empty())
-        {
-            for (auto& dockWidget : p.m_dockWidgetInstances)
-            {
-                const auto& paneName = dockWidget->PaneName();
-                // disable/fade all widgets other than those in the EntityInspector, EntityOutliner and Console
-                // note: The Console is not greyed out and the EntityInspector and EntityOutliner handle their
-                // own fading when entering/leaving ComponentMode
-                if (paneName != LyViewPane::EntityInspector &&
-                    paneName != LyViewPane::EntityInspectorPinned &&
-                    paneName != LyViewPane::Console &&
-                    paneName != LyViewPane::EntityOutliner)
-                {
-                    fn(dockWidget->widget(), enabled);
-                }
-            }
-        }
+        AzQtComponents::SetWidgetInteractEnabled(dockWidget->widget(), enable);
     }
 }
 
@@ -585,35 +566,42 @@ QtViewPaneManager::QtViewPaneManager(QObject* parent)
     m_windowRequest.BusConnect();
 
     m_componentModeNotifications->SetEnteredComponentModeFunc(
-        [this](const AzToolsFramework::ViewportEditorModesInterface&)
-    {
-        // gray out panels when entering ComponentMode
-        SetDefaultActionsEnabled(false, m_registeredPanes, [](QWidget* widget, bool on)
+        [this]([[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModes)
         {
-            AzQtComponents::SetWidgetInteractEnabled(widget, on);
+            for (QtViewPane& p : m_registeredPanes)
+            {
+                if (p.m_options.isDisabledInComponentMode)
+                {
+                    // By default, disable all widgets when entering Component Mode
+                    EnableAllWidgetInstances(p.m_dockWidgetInstances, false);
+                }
+            }
         });
-    });
 
     m_componentModeNotifications->SetLeftComponentModeFunc(
-        [this](const AzToolsFramework::ViewportEditorModesInterface&)
+        [this]([[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModes)
     {
-        // enable panels again when leaving ComponentMode
-        SetDefaultActionsEnabled(true, m_registeredPanes, [](QWidget* widget, bool on)
-        {
-            AzQtComponents::SetWidgetInteractEnabled(widget, on);
+            for (QtViewPane& p : m_registeredPanes)
+            {
+                if (p.m_options.isDisabledInComponentMode)
+                {
+                    // By default, enable all widgets again when leaving Component Mode
+                    EnableAllWidgetInstances(p.m_dockWidgetInstances, true);
+                }
+            }
         });
-    });
 
     m_windowRequest.SetEnableEditorUiFunc(
         [this](bool enable)
         {
-            // gray out panels when entering ImGui mode
-            SetDefaultActionsEnabled(
-                enable, m_registeredPanes,
-                [](QWidget* widget, bool on)
+            for (QtViewPane& p : m_registeredPanes)
+            {
+                if (p.m_options.isDisabledInImGuiMode)
                 {
-                    AzQtComponents::SetWidgetInteractEnabled(widget, on);
-                });
+                    // By default, disable/enable all widgets when entering/exiting IMGUI
+                    EnableAllWidgetInstances(p.m_dockWidgetInstances, enable);
+                }
+            }
         });
 }
 

+ 3 - 0
Code/Framework/AzToolsFramework/AzToolsFramework/API/ViewPaneOptions.h

@@ -41,6 +41,9 @@ namespace AzToolsFramework
 
         bool showOnToolsToolbar = false;                                ///< set to true if the view pane should create a button on the tools toolbar to open/close the pane
         AZStd::string toolbarIcon;                                      ///< path to the icon to use for the toolbar button - only used if showOnToolsToolbar is set to true
+
+        bool isDisabledInComponentMode = true;                          ///< set to false if the view pane should remain enabled during component mode
+        bool isDisabledInImGuiMode = true;                              ///< set to false if the view pane should remain enabled during imgui mode
     };
 
 } // namespace AzToolsFramework