Clarify ImGui activation in Editor viewport (#1765)

* Clarify ImGui activation in Editor viewport

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* All working following changes from comments in PR

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* One more change

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* fixes from comments in PR.

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* Fixed git merge error

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* Added header to ImGuiBus.h

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* Fix for Jenkins error

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>

* Minor typo fix

Signed-off-by: John Jones-Steele <jjjoness@amazon.com>
This commit is contained in:
jjjoness
2021-07-09 18:03:20 +01:00
committed by GitHub
parent 76cef6e91f
commit 1b530195fc
17 changed files with 201 additions and 18 deletions
@@ -36,8 +36,47 @@ namespace AzToolsFramework
/// Retrieve the main application window.
virtual QWidget* GetAppMainWindow() { return nullptr; }
};
using EditorWindowRequestBus = AZ::EBus<EditorWindowRequests>;
class EditorWindowUIRequests : public AZ::EBusTraits
{
public:
using Bus = AZ::EBus<EditorWindowUIRequests>;
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
//////////////////////////////////////////////////////////////////////////
/// Enable/Disable the Editor UI.
virtual void SetEditorUiEnabled([[maybe_unused]] bool enable) {}
};
using EditorWindowUIRequestBus = AZ::EBus<EditorWindowUIRequests>;
using EnableUiFunction = AZStd::function<void(bool)>;
/// Helper for EditorWindowRequests to be used as a
/// member instead of inheriting from EBus directly.
class EditorWindowRequestBusImpl
: public EditorWindowUIRequestBus::Handler
{
public:
/// Set the function to be called when entering ImGui Mode.
void SetEnableEditorUiFunc(const EnableUiFunction enableEditorUiFunc)
{
m_enableEditorUiFunc = AZStd::move(enableEditorUiFunc);
}
private:
// EditorWindowRequestBus
void SetEditorUiEnabled( [[maybe_unused]] bool enable) override
{
m_enableEditorUiFunc(enable);
}
EnableUiFunction m_enableEditorUiFunc; ///< Function to call when entering ImGui Mode.
};
} // namespace AzToolsFramework
#endif // AZTOOLSFRAMEWORK_EDITORWINDOWREQUESTBUS_H
@@ -291,10 +291,12 @@ namespace AzToolsFramework
GetEntityContextId());
EditorEntityInfoNotificationBus::Handler::BusConnect();
Prefab::PrefabPublicNotificationBus::Handler::BusConnect();
EditorWindowUIRequestBus::Handler::BusConnect();
}
EntityOutlinerWidget::~EntityOutlinerWidget()
{
EditorWindowUIRequestBus::Handler::BusDisconnect();
Prefab::PrefabPublicNotificationBus::Handler::BusDisconnect();
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusDisconnect();
EditorEntityInfoNotificationBus::Handler::BusDisconnect();
@@ -1106,16 +1108,25 @@ namespace AzToolsFramework
AzQtComponents::SetWidgetInteractEnabled(entityOutlinerUi->m_searchWidget, on);
}
void EntityOutlinerWidget::EnableUi(bool enable)
{
SetEntityOutlinerState(m_gui, enable);
setEnabled(enable);
}
void EntityOutlinerWidget::SetEditorUiEnabled(bool enable)
{
EnableUi(enable);
}
void EntityOutlinerWidget::EnteredComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
{
SetEntityOutlinerState(m_gui, false);
setEnabled(false);
EnableUi(false);
}
void EntityOutlinerWidget::LeftComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
{
setEnabled(true);
SetEntityOutlinerState(m_gui, true);
EnableUi(true);
}
void EntityOutlinerWidget::OnPrefabInstancePropagationBegin()
@@ -11,6 +11,7 @@
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/base.h>
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
@@ -58,6 +59,7 @@ namespace AzToolsFramework
, private EditorEntityInfoNotificationBus::Handler
, private ComponentModeFramework::EditorComponentModeNotificationBus::Handler
, private Prefab::PrefabPublicNotificationBus::Handler
, private EditorWindowUIRequestBus::Handler
{
Q_OBJECT;
public:
@@ -105,6 +107,9 @@ namespace AzToolsFramework
void OnPrefabInstancePropagationBegin() override;
void OnPrefabInstancePropagationEnd() override;
// EditorWindowUIRequestBus overrides
void SetEditorUiEnabled(bool enable) override;
// Build a selection object from the given entities. Entities already in the Widget's selection buffers are ignored.
template <class EntityIdCollection>
QItemSelection BuildSelectionFromEntities(const EntityIdCollection& entityIds);
@@ -155,6 +160,7 @@ namespace AzToolsFramework
AZ::EntityId GetEntityIdFromIndex(const QModelIndex& index) const;
QModelIndex GetIndexFromEntityId(const AZ::EntityId& entityId) const;
void ExtractEntityIdsFromSelection(const QItemSelection& selection, EntityIdList& entityIdList) const;
void EnableUi(bool enable);
// OutlinerModelNotificationBus::Handler
// Receive notification from the outliner model that we should scroll
@@ -376,6 +376,7 @@ namespace AzToolsFramework
ToolsApplicationEvents::Bus::Handler::BusConnect();
AZ::EntitySystemBus::Handler::BusConnect();
EntityPropertyEditorRequestBus::Handler::BusConnect();
EditorWindowUIRequestBus::Handler::BusConnect();
m_spacer = nullptr;
m_emptyIcon = QIcon();
@@ -421,6 +422,7 @@ namespace AzToolsFramework
{
qApp->removeEventFilter(this);
EditorWindowUIRequestBus::Handler::BusDisconnect();
EntityPropertyEditorRequestBus::Handler::BusDisconnect();
ToolsApplicationEvents::Bus::Handler::BusDisconnect();
AZ::EntitySystemBus::Handler::BusDisconnect();
@@ -4961,6 +4963,27 @@ namespace AzToolsFramework
EnableDisableComponentActions(widget, actions, false);
}
void EntityPropertyEditor::SetEditorUiEnabled(bool enable)
{
if (enable)
{
EnableComponentActions(this, m_entityComponentActions);
}
else
{
DisableComponentActions(this, m_entityComponentActions);
}
m_disabled = !enable;
SetPropertyEditorState(m_gui, enable);
for (auto componentEditor : m_componentEditors)
{
AzQtComponents::SetWidgetInteractEnabled(componentEditor, enable);
}
// record the selected state after entering/leaving component mode
SaveComponentEditorState();
}
void EntityPropertyEditor::EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes)
{
DisableComponentActions(this, m_entityComponentActions);
@@ -21,6 +21,7 @@
#include <AzCore/Asset/AssetCommon.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include <AzToolsFramework/Undo/UndoSystem.h>
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/API/EntityPropertyEditorRequestsBus.h>
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
@@ -108,6 +109,7 @@ namespace AzToolsFramework
, public EditorInspectorComponentNotificationBus::MultiHandler
, private AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler
, public AZ::EntitySystemBus::Handler
, private EditorWindowUIRequestBus::Handler
{
Q_OBJECT;
public:
@@ -208,6 +210,9 @@ namespace AzToolsFramework
void GetSelectedEntities(EntityIdList& selectedEntityIds) override;
void SetNewComponentId(AZ::ComponentId componentId) override;
// EditorWindowRequestBus overrides
void SetEditorUiEnabled(bool enable) override;
bool IsEntitySelected(const AZ::EntityId& id) const;
bool IsSingleEntitySelected(const AZ::EntityId& id) const;