Merge pull request #4522 from aws-lumberyard-dev/LYN-5265_state_tracker_impl
LYN-7122: Remove redundant editor mode notifications.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <AzFramework/API/ApplicationAPI.h>
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h>
|
||||
|
||||
// AzQtComponents
|
||||
@@ -166,15 +167,14 @@ LevelEditorMenuHandler::LevelEditorMenuHandler(MainWindow* mainWindow, QtViewPan
|
||||
m_mainWindow->menuBar()->setNativeMenuBar(true);
|
||||
#endif
|
||||
|
||||
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusConnect(
|
||||
AzToolsFramework::GetEntityContextId());
|
||||
ViewportEditorModeNotificationsBus::Handler::BusConnect(GetEntityContextId());
|
||||
EditorMenuRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
LevelEditorMenuHandler::~LevelEditorMenuHandler()
|
||||
{
|
||||
EditorMenuRequestBus::Handler::BusDisconnect();
|
||||
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusDisconnect();
|
||||
ViewportEditorModeNotificationsBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void LevelEditorMenuHandler::Initialize()
|
||||
@@ -1184,36 +1184,44 @@ void LevelEditorMenuHandler::AddDisableActionInSimModeListener(QAction* action)
|
||||
}));
|
||||
}
|
||||
|
||||
void LevelEditorMenuHandler::EnteredComponentMode(const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
|
||||
void LevelEditorMenuHandler::OnEditorModeActivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
|
||||
if (!menuWrapper.isNull())
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
{
|
||||
// copy of menu actions
|
||||
auto actions = menuWrapper.Get()->actions();
|
||||
// remove all non-reserved edit menu options
|
||||
actions.erase(
|
||||
std::remove_if(actions.begin(), actions.end(), [](QAction* action)
|
||||
{
|
||||
return !action->property("Reserved").toBool();
|
||||
}),
|
||||
actions.end());
|
||||
if (auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
|
||||
!menuWrapper.isNull())
|
||||
{
|
||||
// copy of menu actions
|
||||
auto actions = menuWrapper.Get()->actions();
|
||||
// remove all non-reserved edit menu options
|
||||
actions.erase(
|
||||
std::remove_if(actions.begin(), actions.end(), [](QAction* action)
|
||||
{
|
||||
return !action->property("Reserved").toBool();
|
||||
}),
|
||||
actions.end());
|
||||
|
||||
// clear and update the menu with new actions
|
||||
menuWrapper.Get()->clear();
|
||||
menuWrapper.Get()->addActions(actions);
|
||||
// clear and update the menu with new actions
|
||||
menuWrapper.Get()->clear();
|
||||
menuWrapper.Get()->addActions(actions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LevelEditorMenuHandler::LeftComponentMode(const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
|
||||
void LevelEditorMenuHandler::OnEditorModeDeactivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
RestoreEditMenuToDefault();
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
{
|
||||
RestoreEditMenuToDefault();
|
||||
}
|
||||
}
|
||||
|
||||
void LevelEditorMenuHandler::AddEditMenuAction(QAction* action)
|
||||
{
|
||||
auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
|
||||
if (!menuWrapper.isNull())
|
||||
if (auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
|
||||
!menuWrapper.isNull())
|
||||
{
|
||||
menuWrapper.Get()->addAction(action);
|
||||
}
|
||||
@@ -1237,8 +1245,8 @@ void LevelEditorMenuHandler::AddMenuAction(AZStd::string_view categoryId, QActio
|
||||
|
||||
void LevelEditorMenuHandler::RestoreEditMenuToDefault()
|
||||
{
|
||||
auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
|
||||
if (!menuWrapper.isNull())
|
||||
if (auto menuWrapper = m_actionManager->FindMenu(s_editMenuId);
|
||||
!menuWrapper.isNull())
|
||||
{
|
||||
menuWrapper.Get()->clear();
|
||||
PopulateEditMenu(menuWrapper);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <QPointer>
|
||||
#include "ActionManager.h"
|
||||
#include "QtViewPaneManager.h"
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
#endif
|
||||
|
||||
class MainWindow;
|
||||
@@ -28,7 +28,7 @@ struct QtViewPane;
|
||||
|
||||
class LevelEditorMenuHandler
|
||||
: public QObject
|
||||
, private AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler
|
||||
, private AzToolsFramework::ViewportEditorModeNotificationsBus::Handler
|
||||
, private AzToolsFramework::EditorMenuRequestBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -88,9 +88,11 @@ private:
|
||||
|
||||
void AddDisableActionInSimModeListener(QAction* action);
|
||||
|
||||
// EditorComponentModeNotificationBus
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
// ViewportEditorModeNotificationsBus overrides ...
|
||||
void OnEditorModeActivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
void OnEditorModeDeactivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
|
||||
// EditorMenuRequestBus
|
||||
void AddEditMenuAction(QAction* action) override;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "Objects/EntityObject.h"
|
||||
|
||||
#include <AzFramework/Terrain/TerrainDataRequestBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#define MUSIC_LEVEL_LIBRARY_FILE "Music.xml"
|
||||
|
||||
@@ -98,6 +98,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include "ActionManager.h"
|
||||
|
||||
#include <ImGuiBus.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
#include <LmbrCentral/Audio/AudioSystemComponentBus.h>
|
||||
|
||||
using namespace AZ;
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.h"
|
||||
|
||||
#include <AzCore/Console/Console.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
|
||||
AZ_CVAR_EXTERNED(bool, ed_visibility_logTiming);
|
||||
|
||||
@@ -107,14 +109,13 @@ CObjectManager::CObjectManager()
|
||||
m_objectsByName.reserve(1024);
|
||||
LoadRegistry();
|
||||
|
||||
AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusConnect(
|
||||
AzToolsFramework::GetEntityContextId());
|
||||
AzToolsFramework::ViewportEditorModeNotificationsBus::Handler::BusConnect(AzToolsFramework::GetEntityContextId());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CObjectManager::~CObjectManager()
|
||||
{
|
||||
AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::ViewportEditorModeNotificationsBus::Handler::BusDisconnect();
|
||||
|
||||
m_bExiting = true;
|
||||
SaveRegistry();
|
||||
@@ -2306,25 +2307,33 @@ void CObjectManager::SelectObjectInRect(CBaseObject* pObj, CViewport* view, HitC
|
||||
}
|
||||
}
|
||||
|
||||
void CObjectManager::EnteredComponentMode(const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
|
||||
void CObjectManager::OnEditorModeActivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
// hide current gizmo for entity (translate/rotate/scale)
|
||||
IGizmoManager* gizmoManager = GetGizmoManager();
|
||||
const size_t gizmoCount = static_cast<size_t>(gizmoManager->GetGizmoCount());
|
||||
for (size_t i = 0; i < gizmoCount; ++i)
|
||||
if (mode == AzToolsFramework::ViewportEditorMode::Component)
|
||||
{
|
||||
gizmoManager->RemoveGizmo(gizmoManager->GetGizmoByIndex(static_cast<int>(i)));
|
||||
// hide current gizmo for entity (translate/rotate/scale)
|
||||
IGizmoManager* gizmoManager = GetGizmoManager();
|
||||
const size_t gizmoCount = static_cast<size_t>(gizmoManager->GetGizmoCount());
|
||||
for (size_t i = 0; i < gizmoCount; ++i)
|
||||
{
|
||||
gizmoManager->RemoveGizmo(gizmoManager->GetGizmoByIndex(static_cast<int>(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CObjectManager::LeftComponentMode(const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
|
||||
void CObjectManager::OnEditorModeDeactivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
// show translate/rotate/scale gizmo again
|
||||
if (IGizmoManager* gizmoManager = GetGizmoManager())
|
||||
if (mode == AzToolsFramework::ViewportEditorMode::Component)
|
||||
{
|
||||
if (CBaseObject* selectedObject = GetIEditor()->GetSelectedObject())
|
||||
// show translate/rotate/scale gizmo again
|
||||
if (IGizmoManager* gizmoManager = GetGizmoManager())
|
||||
{
|
||||
gizmoManager->AddGizmo(new CAxisGizmo(selectedObject));
|
||||
if (CBaseObject* selectedObject = GetIEditor()->GetSelectedObject())
|
||||
{
|
||||
gizmoManager->AddGizmo(new CAxisGizmo(selectedObject));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
#include "ObjectManagerEventBus.h"
|
||||
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <Include/SandboxAPI.h>
|
||||
|
||||
// forward declarations.
|
||||
@@ -58,7 +59,7 @@ public:
|
||||
*/
|
||||
class CObjectManager
|
||||
: public IObjectManager
|
||||
, private AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler
|
||||
, private AzToolsFramework::ViewportEditorModeNotificationsBus::Handler
|
||||
{
|
||||
public:
|
||||
//! Selection functor callback.
|
||||
@@ -329,9 +330,11 @@ private:
|
||||
|
||||
void FindDisplayableObjects(DisplayContext& dc, bool bDisplay);
|
||||
|
||||
// EditorComponentModeNotificationBus
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
// ViewportEditorModeNotificationsBus overrides ...
|
||||
void OnEditorModeActivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
void OnEditorModeDeactivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
|
||||
private:
|
||||
typedef std::map<GUID, CBaseObjectPtr, guid_less_predicate> Objects;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
||||
#include <AzToolsFramework/UI/ComponentPalette/ComponentPaletteUtil.hxx>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QLabel>
|
||||
@@ -267,8 +268,7 @@ OutlinerWidget::OutlinerWidget(QWidget* pParent, Qt::WindowFlags flags)
|
||||
ToolsApplicationEvents::Bus::Handler::BusConnect();
|
||||
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
|
||||
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusConnect();
|
||||
AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusConnect(
|
||||
AzToolsFramework::GetEntityContextId());
|
||||
AzToolsFramework::ViewportEditorModeNotificationsBus::Handler::BusConnect(AzToolsFramework::GetEntityContextId());
|
||||
AzToolsFramework::EditorEntityInfoNotificationBus::Handler::BusConnect();
|
||||
AzToolsFramework::EditorWindowUIRequestBus::Handler::BusConnect();
|
||||
}
|
||||
@@ -276,7 +276,7 @@ OutlinerWidget::OutlinerWidget(QWidget* pParent, Qt::WindowFlags flags)
|
||||
OutlinerWidget::~OutlinerWidget()
|
||||
{
|
||||
AzToolsFramework::EditorWindowUIRequestBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::ViewportEditorModeNotificationsBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorEntityInfoNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorPickModeNotificationBus::Handler::BusDisconnect();
|
||||
EntityHighlightMessages::Bus::Handler::BusDisconnect();
|
||||
@@ -1335,14 +1335,22 @@ void OutlinerWidget::SetEditorUiEnabled(bool enable)
|
||||
EnableUi(enable);
|
||||
}
|
||||
|
||||
void OutlinerWidget::EnteredComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
|
||||
void OutlinerWidget::OnEditorModeActivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
EnableUi(false);
|
||||
if (mode == AzToolsFramework::ViewportEditorMode::Component)
|
||||
{
|
||||
EnableUi(false);
|
||||
}
|
||||
}
|
||||
|
||||
void OutlinerWidget::LeftComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
|
||||
void OutlinerWidget::OnEditorModeDeactivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
EnableUi(true);
|
||||
if (mode == AzToolsFramework::ViewportEditorMode::Component)
|
||||
{
|
||||
EnableUi(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OutlinerWidget::OnSliceInstantiated(const AZ::Data::AssetId& /*sliceAssetId*/, AZ::SliceComponent::SliceInstanceAddress& sliceAddress, const AzFramework::SliceInstantiationTicket& /*ticket*/)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <AzCore/base.h>
|
||||
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Entity/SliceEditorEntityOwnershipServiceBus.h>
|
||||
@@ -58,7 +58,7 @@ class OutlinerWidget
|
||||
, private AzToolsFramework::EditorEntityContextNotificationBus::Handler
|
||||
, private AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler
|
||||
, private AzToolsFramework::EditorEntityInfoNotificationBus::Handler
|
||||
, private AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler
|
||||
, private AzToolsFramework::ViewportEditorModeNotificationsBus::Handler
|
||||
, private AzToolsFramework::EditorWindowUIRequestBus::Handler
|
||||
{
|
||||
Q_OBJECT;
|
||||
@@ -105,9 +105,11 @@ private:
|
||||
void OnEntityInfoUpdatedAddChildEnd(AZ::EntityId /*parentId*/, AZ::EntityId /*childId*/) override;
|
||||
void OnEntityInfoUpdatedName(AZ::EntityId entityId, const AZStd::string& /*name*/) override;
|
||||
|
||||
// EditorComponentModeNotificationBus
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
// ViewportEditorModeNotificationsBus overrides ...
|
||||
void OnEditorModeActivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
void OnEditorModeDeactivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
|
||||
// EditorWindowUIRequestBus overrides
|
||||
void SetEditorUiEnabled(bool enable) override;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <AzAssetBrowser/AzAssetBrowserWindow.h>
|
||||
#include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
|
||||
#include <AzQtComponents/Utilities/AutoSettingsGroup.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
#include <AzToolsFramework/UI/Docking/DockWidgetUtils.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/ComponentEditor.hxx>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.hxx>
|
||||
@@ -44,11 +45,54 @@
|
||||
#include <AzQtComponents/Buses/ShortcutDispatch.h>
|
||||
#include <AzQtComponents/Utilities/QtViewPaneEffects.h>
|
||||
#include <AzQtComponents/Components/StyleManager.h>
|
||||
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include "ShortcutDispatcher.h"
|
||||
|
||||
// Helper for EditorComponentModeNotifications to be used
|
||||
// as a member instead of inheriting from EBus directly.
|
||||
class ViewportEditorModeNotificationsBusImpl
|
||||
: public AzToolsFramework::ViewportEditorModeNotificationsBus::Handler
|
||||
{
|
||||
public:
|
||||
// Set the function to be called when entering ComponentMode.
|
||||
void SetEnteredComponentModeFunc(
|
||||
const AZStd::function<void(const AzToolsFramework::ViewportEditorModesInterface&)>& enteredComponentModeFunc)
|
||||
{
|
||||
m_enteredComponentModeFunc = enteredComponentModeFunc;
|
||||
}
|
||||
|
||||
// Set the function to be called when leaving ComponentMode.
|
||||
void SetLeftComponentModeFunc(
|
||||
const AZStd::function<void(const AzToolsFramework::ViewportEditorModesInterface&)>& leftComponentModeFunc)
|
||||
{
|
||||
m_leftComponentModeFunc = leftComponentModeFunc;
|
||||
}
|
||||
|
||||
private:
|
||||
// ViewportEditorModeNotificationsBus overrides ...
|
||||
void OnEditorModeActivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override
|
||||
{
|
||||
if (mode == AzToolsFramework::ViewportEditorMode::Component)
|
||||
{
|
||||
m_enteredComponentModeFunc(editorModeState);
|
||||
}
|
||||
}
|
||||
|
||||
void OnEditorModeDeactivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override
|
||||
{
|
||||
if (mode == AzToolsFramework::ViewportEditorMode::Component)
|
||||
{
|
||||
m_leftComponentModeFunc(editorModeState);
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::function<void(const AzToolsFramework::ViewportEditorModesInterface&)> m_enteredComponentModeFunc; ///< Function to call when entering ComponentMode.
|
||||
AZStd::function<void(const AzToolsFramework::ViewportEditorModesInterface&)> m_leftComponentModeFunc; ///< Function to call when leaving ComponentMode.
|
||||
};
|
||||
|
||||
struct ViewLayoutState
|
||||
{
|
||||
QVector<QString> viewPanes;
|
||||
@@ -519,16 +563,17 @@ QtViewPaneManager::QtViewPaneManager(QObject* parent)
|
||||
, m_settings(nullptr)
|
||||
, m_restoreInProgress(false)
|
||||
, m_advancedDockManager(nullptr)
|
||||
, m_componentModeNotifications(AZStd::make_unique<ViewportEditorModeNotificationsBusImpl>())
|
||||
{
|
||||
qRegisterMetaTypeStreamOperators<ViewLayoutState>("ViewLayoutState");
|
||||
qRegisterMetaTypeStreamOperators<QVector<QString> >("QVector<QString>");
|
||||
|
||||
// view pane manager is interested when we enter/exit ComponentMode
|
||||
m_componentModeNotifications.BusConnect(AzToolsFramework::GetEntityContextId());
|
||||
m_componentModeNotifications->BusConnect(AzToolsFramework::GetEntityContextId());
|
||||
m_windowRequest.BusConnect();
|
||||
|
||||
m_componentModeNotifications.SetEnteredComponentModeFunc(
|
||||
[this](const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
|
||||
m_componentModeNotifications->SetEnteredComponentModeFunc(
|
||||
[this](const AzToolsFramework::ViewportEditorModesInterface&)
|
||||
{
|
||||
// gray out panels when entering ComponentMode
|
||||
SetDefaultActionsEnabled(false, m_registeredPanes, [](QWidget* widget, bool on)
|
||||
@@ -537,8 +582,8 @@ QtViewPaneManager::QtViewPaneManager(QObject* parent)
|
||||
});
|
||||
});
|
||||
|
||||
m_componentModeNotifications.SetLeftComponentModeFunc(
|
||||
[this](const AZStd::vector<AZ::Uuid>& /*componentModeTypes*/)
|
||||
m_componentModeNotifications->SetLeftComponentModeFunc(
|
||||
[this](const AzToolsFramework::ViewportEditorModesInterface&)
|
||||
{
|
||||
// enable panels again when leaving ComponentMode
|
||||
SetDefaultActionsEnabled(true, m_registeredPanes, [](QWidget* widget, bool on)
|
||||
@@ -563,7 +608,7 @@ QtViewPaneManager::QtViewPaneManager(QObject* parent)
|
||||
QtViewPaneManager::~QtViewPaneManager()
|
||||
{
|
||||
m_windowRequest.BusDisconnect();
|
||||
m_componentModeNotifications.BusDisconnect();
|
||||
m_componentModeNotifications->BusDisconnect();
|
||||
}
|
||||
|
||||
static bool lessThan(const QtViewPane& v1, const QtViewPane& v2)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <AzQtComponents/Components/DockTabWidget.h>
|
||||
#include <AzQtComponents/Components/StyledDockWidget.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
|
||||
|
||||
#include <QObject>
|
||||
@@ -34,6 +33,7 @@
|
||||
#endif
|
||||
|
||||
class QMainWindow;
|
||||
class ViewportEditorModeNotificationsBusImpl;
|
||||
struct ViewLayoutState;
|
||||
|
||||
namespace AzQtComponents
|
||||
@@ -245,9 +245,9 @@ private:
|
||||
|
||||
QPointer<AzQtComponents::FancyDocking> m_advancedDockManager;
|
||||
|
||||
using EditorComponentModeNotificationBusImpl = AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBusImpl;
|
||||
EditorComponentModeNotificationBusImpl m_componentModeNotifications; //!< Helper for EditorComponentModeNotificationBus so
|
||||
//!< QtViewPaneManager does not need to inherit directly from it. */
|
||||
AZStd::unique_ptr<ViewportEditorModeNotificationsBusImpl>
|
||||
m_componentModeNotifications; //!< Helper for EditorComponentModeNotificationBus so
|
||||
//!< QtViewPaneManager does not need to inherit directly from it. */
|
||||
|
||||
using EditorWindowRequestBusImpl = AzToolsFramework::EditorWindowRequestBusImpl;
|
||||
EditorWindowRequestBusImpl m_windowRequest; //!< Helper for EditorWindowRequestBus so
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
|
||||
// Editor
|
||||
#include "ViewManager.h"
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/Outcome/Outcome.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
//! The AZ::Interface for component mode collection queries.
|
||||
class ComponentModeCollectionInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ComponentModeCollectionInterface, "{DFAA4450-BBCD-47C0-9B91-FEA2DBD9B152}");
|
||||
|
||||
virtual ~ComponentModeCollectionInterface() = default;
|
||||
|
||||
//! Retrieves the list of all Component types (usually one).
|
||||
//! @note If called outside of component mode, an empty vector will be returned.
|
||||
virtual AZStd::vector<AZ::Uuid> GetComponentTypes() const = 0;
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
void ViewportEditorModeNotifications::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
behaviorContext->EBus<ViewportEditorModeNotificationsBus>("ViewportEditorModeNotificationsBus")
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Editor")
|
||||
->Attribute(AZ::Script::Attributes::Module, "editor")
|
||||
->Event("OnEditorModeActivated", &ViewportEditorModeNotifications::OnEditorModeActivated)
|
||||
->Event("OnEditorModeDeactivated", &ViewportEditorModeNotifications::OnEditorModeDeactivated)
|
||||
;
|
||||
}
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
+5
@@ -34,6 +34,8 @@ namespace AzToolsFramework
|
||||
class ViewportEditorModesInterface
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ViewportEditorModesInterface, "{2421496C-4A46-41C9-8AEF-AE2B6E43E6CF}");
|
||||
|
||||
virtual ~ViewportEditorModesInterface() = default;
|
||||
|
||||
//! Returns true if the specified editor mode is active, otherwise false.
|
||||
@@ -52,6 +54,9 @@ namespace AzToolsFramework
|
||||
using BusIdType = ViewportEditorModeTrackerInfo::IdType;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AZ_RTTI(ViewportEditorModeNotifications, "{9469DE39-6C21-423C-94FA-EF3A9616B14F}", AZ::EBusTraits);
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
//! Notifies subscribers of the a given viewport to the activation of the specified editor mode.
|
||||
virtual void OnEditorModeActivated([[maybe_unused]] const ViewportEditorModesInterface& editorModeState, [[maybe_unused]] ViewportEditorMode mode)
|
||||
{
|
||||
|
||||
+6
-15
@@ -203,6 +203,12 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::vector<AZ::Uuid> ComponentModeCollection::GetComponentTypes() const
|
||||
{
|
||||
// If in component mode, return the active component types, otherwise return an empty vector
|
||||
return InComponentMode() ? m_activeComponentTypes : AZStd::vector<AZ::Uuid>{};
|
||||
}
|
||||
|
||||
void ComponentModeCollection::BeginComponentMode()
|
||||
{
|
||||
m_selectedComponentModeIndex = 0;
|
||||
@@ -211,13 +217,6 @@ namespace AzToolsFramework
|
||||
|
||||
// notify listeners the editor has entered ComponentMode - listeners may
|
||||
// wish to modify state to indicate this (e.g. appearance, functionality etc.)
|
||||
EditorComponentModeNotificationBus::Event(
|
||||
GetEntityContextId(), &EditorComponentModeNotifications::EnteredComponentMode,
|
||||
m_activeComponentTypes);
|
||||
|
||||
// this call to activate the component mode editor state should eventually replace the bus call in
|
||||
// ComponentModeCollection::BeginComponentMode() to EditorComponentModeNotifications::EnteredComponentMode
|
||||
// such that all of the notifications for activating/deactivating the different editor modes are in a central location
|
||||
m_viewportEditorModeTracker->ActivateMode({ GetEntityContextId() }, ViewportEditorMode::Component);
|
||||
|
||||
// enable actions for the first/primary ComponentMode
|
||||
@@ -288,14 +287,6 @@ namespace AzToolsFramework
|
||||
|
||||
// notify listeners the editor has left ComponentMode - listeners may
|
||||
// wish to modify state to indicate this (e.g. appearance, functionality etc.)
|
||||
EditorComponentModeNotificationBus::Event(
|
||||
GetEntityContextId(),
|
||||
&EditorComponentModeNotifications::LeftComponentMode,
|
||||
m_activeComponentTypes);
|
||||
|
||||
// this call to deactivate the component mode editor state should eventually replace the bus call in
|
||||
// ComponentModeCollection::EndComponentMode() to EditorComponentModeNotifications::LeftComponentMode
|
||||
// such that all of the notifications for activating/deactivating the different editor modes are in a central location
|
||||
m_viewportEditorModeTracker->DeactivateMode({ GetEntityContextId() }, ViewportEditorMode::Component);
|
||||
|
||||
// clear stored modes and builders for this ComponentMode
|
||||
|
||||
+5
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzToolsFramework/API/ComponentModeCollectionInterface.h>
|
||||
#include <AzToolsFramework/ComponentMode/ComponentModeViewportUi.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
|
||||
@@ -21,6 +22,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
/// Manages all individual ComponentModes for a single instance of Editor wide ComponentMode.
|
||||
class ComponentModeCollection
|
||||
: public ComponentModeCollectionInterface
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR_DECL
|
||||
@@ -89,6 +91,9 @@ namespace AzToolsFramework
|
||||
/// Called once each time a ComponentMode is added.
|
||||
void PopulateViewportUi();
|
||||
|
||||
// ComponentModeCollectionInterface overrides ...
|
||||
AZStd::vector<AZ::Uuid> GetComponentTypes() const override;
|
||||
|
||||
private:
|
||||
// Internal helper used by Select[|Prev|Next]ActiveComponentMode
|
||||
bool ActiveComponentModeChanged(const AZ::Uuid& previousComponentType);
|
||||
|
||||
+2
-14
@@ -24,18 +24,8 @@ namespace AzToolsFramework
|
||||
: public EditorComponentModeNotificationBus::Handler
|
||||
, public AZ::BehaviorEBusHandler
|
||||
{
|
||||
AZ_EBUS_BEHAVIOR_BINDER(EditorComponentModeNotificationBusHandler, "{AD2F4204-0913-4FC9-9A10-492538F60C70}", AZ::SystemAllocator,
|
||||
EnteredComponentMode, LeftComponentMode, ActiveComponentModeChanged);
|
||||
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentTypes) override
|
||||
{
|
||||
Call(FN_EnteredComponentMode, componentTypes);
|
||||
}
|
||||
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentTypes) override
|
||||
{
|
||||
Call(FN_LeftComponentMode, componentTypes);
|
||||
}
|
||||
AZ_EBUS_BEHAVIOR_BINDER(
|
||||
EditorComponentModeNotificationBusHandler, "{AD2F4204-0913-4FC9-9A10-492538F60C70}", AZ::SystemAllocator, ActiveComponentModeChanged);
|
||||
|
||||
void ActiveComponentModeChanged(const AZ::Uuid& componentType) override
|
||||
{
|
||||
@@ -171,8 +161,6 @@ namespace AzToolsFramework
|
||||
->Attribute(AZ::Script::Attributes::Category, "Editor")
|
||||
->Attribute(AZ::Script::Attributes::Module, "editor")
|
||||
->Handler<Internal::EditorComponentModeNotificationBusHandler>()
|
||||
->Event("EnteredComponentMode", &EditorComponentModeNotifications::EnteredComponentMode)
|
||||
->Event("LeftComponentMode", &EditorComponentModeNotifications::LeftComponentMode)
|
||||
->Event("ActiveComponentModeChanged", &EditorComponentModeNotifications::ActiveComponentModeChanged)
|
||||
;
|
||||
}
|
||||
|
||||
-42
@@ -238,12 +238,6 @@ namespace AzToolsFramework
|
||||
using BusIdType = AzFramework::EntityContextId;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
|
||||
/// Called when Editor enters ComponentMode - pass the list of all Component types (usually one).
|
||||
virtual void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentTypes) = 0;
|
||||
|
||||
/// Called when Editor leaves ComponentMode - pass the list of all Component types (usually one).
|
||||
virtual void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentTypes) = 0;
|
||||
|
||||
/// Called when Tab is pressed to cycle the 'selected' ComponentMode (which shortcuts/actions are active).
|
||||
/// Also called when directly selecting a Component in the EntityOutliner.
|
||||
virtual void ActiveComponentModeChanged(const AZ::Uuid& /*componentType*/) {}
|
||||
@@ -255,42 +249,6 @@ namespace AzToolsFramework
|
||||
/// Type to inherit to implement EditorComponentModeNotifications.
|
||||
using EditorComponentModeNotificationBus = AZ::EBus<EditorComponentModeNotifications>;
|
||||
|
||||
/// Helper for EditorComponentModeNotifications to be used
|
||||
/// as a member instead of inheriting from EBus directly.
|
||||
class EditorComponentModeNotificationBusImpl
|
||||
: public EditorComponentModeNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
/// Set the function to be called when entering ComponentMode.
|
||||
void SetEnteredComponentModeFunc(
|
||||
const AZStd::function<void(const AZStd::vector<AZ::Uuid>&)>& enteredComponentModeFunc)
|
||||
{
|
||||
m_enteredComponentModeFunc = enteredComponentModeFunc;
|
||||
}
|
||||
|
||||
/// Set the function to be called when leaving ComponentMode.
|
||||
void SetLeftComponentModeFunc(
|
||||
const AZStd::function<void(const AZStd::vector<AZ::Uuid>&)>& leftComponentModeFunc)
|
||||
{
|
||||
m_leftComponentModeFunc = leftComponentModeFunc;
|
||||
}
|
||||
|
||||
private:
|
||||
// EditorComponentModeNotificationBus
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override
|
||||
{
|
||||
m_enteredComponentModeFunc(componentModeTypes);
|
||||
}
|
||||
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override
|
||||
{
|
||||
m_leftComponentModeFunc(componentModeTypes);
|
||||
}
|
||||
|
||||
AZStd::function<void(const AZStd::vector<AZ::Uuid>&)> m_enteredComponentModeFunc; ///< Function to call when entering ComponentMode.
|
||||
AZStd::function<void(const AZStd::vector<AZ::Uuid>&)> m_leftComponentModeFunc; ///< Function to call when leaving ComponentMode.
|
||||
};
|
||||
|
||||
/// Helper to answer if the Editor is in ComponentMode or not.
|
||||
inline bool InComponentMode()
|
||||
{
|
||||
|
||||
+15
-7
@@ -26,6 +26,7 @@
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
#include <AzToolsFramework/UI/ComponentPalette/ComponentPaletteUtil.hxx>
|
||||
#include <AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h>
|
||||
#include <AzToolsFramework/UI/Outliner/EntityOutlinerDisplayOptionsMenu.h>
|
||||
@@ -292,8 +293,7 @@ namespace AzToolsFramework
|
||||
EntityOutlinerModelNotificationBus::Handler::BusConnect();
|
||||
ToolsApplicationEvents::Bus::Handler::BusConnect();
|
||||
EditorEntityContextNotificationBus::Handler::BusConnect();
|
||||
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusConnect(
|
||||
GetEntityContextId());
|
||||
ViewportEditorModeNotificationsBus::Handler::BusConnect(GetEntityContextId());
|
||||
EditorEntityInfoNotificationBus::Handler::BusConnect();
|
||||
Prefab::PrefabPublicNotificationBus::Handler::BusConnect();
|
||||
EditorWindowUIRequestBus::Handler::BusConnect();
|
||||
@@ -303,7 +303,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
EditorWindowUIRequestBus::Handler::BusDisconnect();
|
||||
Prefab::PrefabPublicNotificationBus::Handler::BusDisconnect();
|
||||
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusDisconnect();
|
||||
ViewportEditorModeNotificationsBus::Handler::BusDisconnect();
|
||||
EditorEntityInfoNotificationBus::Handler::BusDisconnect();
|
||||
EditorPickModeNotificationBus::Handler::BusDisconnect();
|
||||
EntityHighlightMessages::Bus::Handler::BusDisconnect();
|
||||
@@ -1128,14 +1128,22 @@ namespace AzToolsFramework
|
||||
EnableUi(enable);
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::EnteredComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
|
||||
void EntityOutlinerWidget::OnEditorModeActivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
EnableUi(false);
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
{
|
||||
EnableUi(false);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::LeftComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
|
||||
void EntityOutlinerWidget::OnEditorModeDeactivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
EnableUi(true);
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
{
|
||||
EnableUi(true);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::OnPrefabInstancePropagationBegin()
|
||||
|
||||
+7
-5
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicNotificationBus.h>
|
||||
@@ -59,7 +59,7 @@ namespace AzToolsFramework
|
||||
, private ToolsApplicationEvents::Bus::Handler
|
||||
, private EditorEntityContextNotificationBus::Handler
|
||||
, private EditorEntityInfoNotificationBus::Handler
|
||||
, private ComponentModeFramework::EditorComponentModeNotificationBus::Handler
|
||||
, private ViewportEditorModeNotificationsBus::Handler
|
||||
, private Prefab::PrefabPublicNotificationBus::Handler
|
||||
, private EditorWindowUIRequestBus::Handler
|
||||
{
|
||||
@@ -101,9 +101,11 @@ namespace AzToolsFramework
|
||||
void OnEntityInfoUpdatedAddChildEnd(AZ::EntityId /*parentId*/, AZ::EntityId /*childId*/) override;
|
||||
void OnEntityInfoUpdatedName(AZ::EntityId entityId, const AZStd::string& /*name*/) override;
|
||||
|
||||
// EditorComponentModeNotificationBus
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
// ViewportEditorModeNotificationsBus overrides ...
|
||||
void OnEditorModeActivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
void OnEditorModeDeactivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
|
||||
// PrefabPublicNotificationBus
|
||||
void OnPrefabInstancePropagationBegin() override;
|
||||
|
||||
@@ -90,7 +90,6 @@ namespace AzToolsFramework
|
||||
|
||||
void SetComponentOverridden(const bool overridden);
|
||||
|
||||
// Calls match EditorComponentModeNotificationBus - called from EntityPropertyEditor
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes);
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes);
|
||||
void ActiveComponentModeChanged(const AZ::Uuid& componentType);
|
||||
|
||||
+39
-24
@@ -33,6 +33,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <AzQtComponents/Components/Style.h>
|
||||
#include <AzQtComponents/Components/Widgets/DragAndDrop.h>
|
||||
#include <AzQtComponents/Components/Widgets/LineEdit.h>
|
||||
#include <AzToolsFramework/API/ComponentModeCollectionInterface.h>
|
||||
#include <AzToolsFramework/API/EntityCompositionRequestBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
|
||||
@@ -486,8 +487,12 @@ namespace AzToolsFramework
|
||||
, m_isSystemEntityEditor(false)
|
||||
, m_isLevelEntityEditor(isLevelEntityEditor)
|
||||
{
|
||||
|
||||
initEntityPropertyEditorResources();
|
||||
|
||||
m_componentModeCollection = AZ::Interface<ComponentModeCollectionInterface>::Get();
|
||||
AZ_Assert(m_componentModeCollection, "Could not retrieve component mode collection.");
|
||||
|
||||
m_prefabPublicInterface = AZ::Interface<Prefab::PrefabPublicInterface>::Get();
|
||||
AZ_Assert(m_prefabPublicInterface != nullptr, "EntityPropertyEditor requires a PrefabPublicInterface instance on Initialize.");
|
||||
|
||||
@@ -5698,39 +5703,49 @@ namespace AzToolsFramework
|
||||
SaveComponentEditorState();
|
||||
}
|
||||
|
||||
void EntityPropertyEditor::EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes)
|
||||
void EntityPropertyEditor::OnEditorModeActivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
DisableComponentActions(this, m_entityComponentActions);
|
||||
SetPropertyEditorState(m_gui, false);
|
||||
m_disabled = true;
|
||||
|
||||
if (!componentModeTypes.empty())
|
||||
if (mode == AzToolsFramework::ViewportEditorMode::Component)
|
||||
{
|
||||
m_componentEditorLastSelectedIndex = GetComponentEditorIndexFromType(componentModeTypes.front());
|
||||
}
|
||||
DisableComponentActions(this, m_entityComponentActions);
|
||||
SetPropertyEditorState(m_gui, false);
|
||||
const auto componentModeTypes = m_componentModeCollection->GetComponentTypes();
|
||||
m_disabled = true;
|
||||
|
||||
if (!componentModeTypes.empty())
|
||||
{
|
||||
m_componentEditorLastSelectedIndex = GetComponentEditorIndexFromType(componentModeTypes.front());
|
||||
}
|
||||
|
||||
for (auto componentEditor : m_componentEditors)
|
||||
{
|
||||
componentEditor->EnteredComponentMode(componentModeTypes);
|
||||
}
|
||||
for (auto componentEditor : m_componentEditors)
|
||||
{
|
||||
componentEditor->EnteredComponentMode(componentModeTypes);
|
||||
}
|
||||
|
||||
// record the selected state after entering component mode
|
||||
SaveComponentEditorState();
|
||||
// record the selected state after entering component mode
|
||||
SaveComponentEditorState();
|
||||
}
|
||||
}
|
||||
|
||||
void EntityPropertyEditor::LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes)
|
||||
void EntityPropertyEditor::OnEditorModeDeactivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
EnableComponentActions(this, m_entityComponentActions);
|
||||
SetPropertyEditorState(m_gui, true);
|
||||
m_disabled = false;
|
||||
|
||||
for (auto componentEditor : m_componentEditors)
|
||||
if (mode == AzToolsFramework::ViewportEditorMode::Component)
|
||||
{
|
||||
componentEditor->LeftComponentMode(componentModeTypes);
|
||||
}
|
||||
EnableComponentActions(this, m_entityComponentActions);
|
||||
SetPropertyEditorState(m_gui, true);
|
||||
const auto componentModeTypes = m_componentModeCollection->GetComponentTypes();
|
||||
m_disabled = false;
|
||||
|
||||
// record the selected state after leaving component mode
|
||||
SaveComponentEditorState();
|
||||
for (auto componentEditor : m_componentEditors)
|
||||
{
|
||||
componentEditor->LeftComponentMode(componentModeTypes);
|
||||
}
|
||||
|
||||
// record the selected state after leaving component mode
|
||||
SaveComponentEditorState();
|
||||
}
|
||||
}
|
||||
|
||||
void EntityPropertyEditor::ActiveComponentModeChanged(const AZ::Uuid& componentType)
|
||||
|
||||
+11
-2
@@ -26,6 +26,7 @@
|
||||
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/API/EntityPropertyEditorRequestsBus.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/ComponentMimeData.h>
|
||||
@@ -59,6 +60,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
class ComponentEditor;
|
||||
class ComponentPaletteWidget;
|
||||
class ComponentModeCollectionInterface;
|
||||
struct SourceControlFileInfo;
|
||||
|
||||
namespace AssetBrowser
|
||||
@@ -108,6 +110,7 @@ namespace AzToolsFramework
|
||||
, public AzToolsFramework::EditorEntityContextNotificationBus::Handler
|
||||
, public AzToolsFramework::EntityPropertyEditorRequestBus::Handler
|
||||
, public AzToolsFramework::PropertyEditorEntityChangeNotificationBus::MultiHandler
|
||||
, private AzToolsFramework::ViewportEditorModeNotificationsBus::Handler
|
||||
, public EditorInspectorComponentNotificationBus::MultiHandler
|
||||
, private AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler
|
||||
, public AZ::EntitySystemBus::Handler
|
||||
@@ -231,10 +234,14 @@ namespace AzToolsFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// EditorComponentModeNotificationBus
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
void ActiveComponentModeChanged(const AZ::Uuid& componentType) override;
|
||||
|
||||
// ViewportEditorModeNotificationsBus overrides ...
|
||||
void OnEditorModeActivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
void OnEditorModeDeactivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
|
||||
// EntityPropertEditorRequestBus
|
||||
void GetSelectedAndPinnedEntities(EntityIdList& selectedEntityIds) override;
|
||||
void GetSelectedEntities(EntityIdList& selectedEntityIds) override;
|
||||
@@ -627,6 +634,8 @@ namespace AzToolsFramework
|
||||
float m_moveFadeSecondsRemaining;
|
||||
AZStd::vector<int> m_indexMapOfMovedRow;
|
||||
|
||||
AzToolsFramework::ComponentModeCollectionInterface* m_componentModeCollection = nullptr;
|
||||
|
||||
// When m_initiatingPropertyChangeNotification is set to true, it means this EntityPropertyEditor is
|
||||
// broadcasting a change to all listeners about a property change for a given entity. This is needed
|
||||
// so that we don't update the values twice for this inspector
|
||||
|
||||
+14
-6
@@ -129,7 +129,7 @@ namespace UnitTest
|
||||
using AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus;
|
||||
|
||||
AzToolsFramework::EditorActionRequestBus::Handler::BusConnect();
|
||||
EditorComponentModeNotificationBus::Handler::BusConnect(GetEntityContextId());
|
||||
ViewportEditorModeNotificationsBus::Handler::BusConnect(GetEntityContextId());
|
||||
m_defaultWidget.setFocus();
|
||||
}
|
||||
|
||||
@@ -137,18 +137,26 @@ namespace UnitTest
|
||||
{
|
||||
using AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus;
|
||||
|
||||
EditorComponentModeNotificationBus::Handler::BusDisconnect();
|
||||
ViewportEditorModeNotificationsBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::EditorActionRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void TestEditorActions::EnteredComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentTypes)
|
||||
void TestEditorActions::OnEditorModeActivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
m_componentModeWidget.setFocus();
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
{
|
||||
m_componentModeWidget.setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void TestEditorActions::LeftComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentTypes)
|
||||
void TestEditorActions::OnEditorModeDeactivated(
|
||||
[[maybe_unused]] const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode)
|
||||
{
|
||||
m_defaultWidget.setFocus();
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
{
|
||||
m_defaultWidget.setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void TestEditorActions::AddActionViaBus(int id, QAction* action)
|
||||
|
||||
+7
-5
@@ -23,9 +23,9 @@
|
||||
#include <AZTestShared/Utils/Utils.h>
|
||||
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerInterface.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityTransformBus.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
#include <AzToolsFramework/Viewport/ActionBus.h>
|
||||
#include <AzToolsFramework/Viewport/ViewportMessages.h>
|
||||
@@ -103,7 +103,7 @@ namespace UnitTest
|
||||
/// component mode editing.
|
||||
class TestEditorActions
|
||||
: private AzToolsFramework::EditorActionRequestBus::Handler
|
||||
, private AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler
|
||||
, private AzToolsFramework::ViewportEditorModeNotificationsBus::Handler
|
||||
{
|
||||
// EditorActionRequestBus ...
|
||||
void AddActionViaBus(int id, QAction* action) override;
|
||||
@@ -114,9 +114,11 @@ namespace UnitTest
|
||||
void AttachOverride(QWidget* /*object*/) override {}
|
||||
void DetachOverride() override {}
|
||||
|
||||
// EditorComponentModeNotificationBus ...
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentTypes) override;
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentTypes) override;
|
||||
// ViewportEditorModeNotificationsBus overrides ...
|
||||
void OnEditorModeActivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
void OnEditorModeDeactivated(
|
||||
const AzToolsFramework::ViewportEditorModesInterface& editorModeState, AzToolsFramework::ViewportEditorMode mode) override;
|
||||
|
||||
public:
|
||||
void Connect();
|
||||
|
||||
+9
@@ -27,6 +27,10 @@ namespace AzToolsFramework
|
||||
, m_viewportEditorModeTracker(viewportEditorModeTracker)
|
||||
, m_componentModeCollection(viewportEditorModeTracker)
|
||||
{
|
||||
AZ_Assert(
|
||||
AZ::Interface<ComponentModeCollectionInterface>::Get() == nullptr, "Unexpected registration of component mode collection.")
|
||||
AZ::Interface<ComponentModeCollectionInterface>::Register(&m_componentModeCollection);
|
||||
|
||||
ActionOverrideRequestBus::Handler::BusConnect(GetEntityContextId());
|
||||
ComponentModeFramework::ComponentModeSystemRequestBus::Handler::BusConnect();
|
||||
|
||||
@@ -40,6 +44,11 @@ namespace AzToolsFramework
|
||||
ComponentModeFramework::ComponentModeSystemRequestBus::Handler::BusDisconnect();
|
||||
ActionOverrideRequestBus::Handler::BusDisconnect();
|
||||
m_viewportEditorModeTracker->DeactivateMode({ GetEntityContextId() }, ViewportEditorMode::Default);
|
||||
|
||||
AZ_Assert(
|
||||
AZ::Interface<ComponentModeCollectionInterface>::Get() != nullptr,
|
||||
"Unexpected unregistration of component mode collection.")
|
||||
AZ::Interface<ComponentModeCollectionInterface>::Unregister(&m_componentModeCollection);
|
||||
}
|
||||
|
||||
void EditorDefaultSelection::SetOverridePhantomWidget(QWidget* phantomOverrideWidget)
|
||||
|
||||
+20
-12
@@ -1023,7 +1023,7 @@ namespace AzToolsFramework
|
||||
EditorTransformComponentSelectionRequestBus::Handler::BusConnect(entityContextId);
|
||||
ToolsApplicationNotificationBus::Handler::BusConnect();
|
||||
Camera::EditorCameraNotificationBus::Handler::BusConnect();
|
||||
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusConnect(entityContextId);
|
||||
ViewportEditorModeNotificationsBus::Handler::BusConnect(entityContextId);
|
||||
EditorEntityContextNotificationBus::Handler::BusConnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterConnect();
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterConnect();
|
||||
@@ -1071,7 +1071,7 @@ namespace AzToolsFramework
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterDisconnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterDisconnect();
|
||||
EditorEntityContextNotificationBus::Handler::BusDisconnect();
|
||||
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusDisconnect();
|
||||
ViewportEditorModeNotificationsBus::Handler::BusDisconnect();
|
||||
Camera::EditorCameraNotificationBus::Handler::BusDisconnect();
|
||||
ToolsApplicationNotificationBus::Handler::BusDisconnect();
|
||||
EditorTransformComponentSelectionRequestBus::Handler::BusDisconnect();
|
||||
@@ -3667,22 +3667,30 @@ namespace AzToolsFramework
|
||||
m_selectedEntityIdsAndManipulatorsDirty = true;
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::EnteredComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
|
||||
void EditorTransformComponentSelection::OnEditorModeActivated(
|
||||
[[maybe_unused]] const ViewportEditorModesInterface& editorModeState, ViewportEditorMode mode)
|
||||
{
|
||||
SetAllViewportUiVisible(false);
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
{
|
||||
SetAllViewportUiVisible(false);
|
||||
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterDisconnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterDisconnect();
|
||||
ToolsApplicationNotificationBus::Handler::BusDisconnect();
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterDisconnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterDisconnect();
|
||||
ToolsApplicationNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::LeftComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
|
||||
void EditorTransformComponentSelection::OnEditorModeDeactivated(
|
||||
[[maybe_unused]] const ViewportEditorModesInterface& editorModeState, ViewportEditorMode mode)
|
||||
{
|
||||
SetAllViewportUiVisible(true);
|
||||
if (mode == ViewportEditorMode::Component)
|
||||
{
|
||||
SetAllViewportUiVisible(true);
|
||||
|
||||
ToolsApplicationNotificationBus::Handler::BusConnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterConnect();
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterConnect();
|
||||
ToolsApplicationNotificationBus::Handler::BusConnect();
|
||||
EditorEntityVisibilityNotificationBus::Router::BusRouterConnect();
|
||||
EditorEntityLockComponentNotificationBus::Router::BusRouterConnect();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorTransformComponentSelection::CreateEntityManipulatorDeselectCommand(ScopedUndoBatch& undoBatch)
|
||||
|
||||
+5
-5
@@ -18,7 +18,7 @@
|
||||
#include <AzFramework/Viewport/CursorState.h>
|
||||
#include <AzToolsFramework/API/EditorCameraBus.h>
|
||||
#include <AzToolsFramework/Commands/EntityManipulatorCommand.h>
|
||||
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
|
||||
#include <AzToolsFramework/API/ViewportEditorModeTrackerNotificationBus.h>
|
||||
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
|
||||
#include <AzToolsFramework/Manipulators/BaseManipulator.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorLockComponentBus.h>
|
||||
@@ -153,7 +153,7 @@ namespace AzToolsFramework
|
||||
, private EditorTransformComponentSelectionRequestBus::Handler
|
||||
, private ToolsApplicationNotificationBus::Handler
|
||||
, private Camera::EditorCameraNotificationBus::Handler
|
||||
, private ComponentModeFramework::EditorComponentModeNotificationBus::Handler
|
||||
, private ViewportEditorModeNotificationsBus::Handler
|
||||
, private EditorEntityContextNotificationBus::Handler
|
||||
, private EditorEntityVisibilityNotificationBus::Router
|
||||
, private EditorEntityLockComponentNotificationBus::Router
|
||||
@@ -286,9 +286,9 @@ namespace AzToolsFramework
|
||||
// EditorContextLockComponentNotificationBus overrides ...
|
||||
void OnEntityLockChanged(bool locked) override;
|
||||
|
||||
// EditorComponentModeNotificationBus overrides ...
|
||||
void EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
void LeftComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes) override;
|
||||
// ViewportEditorModeNotificationsBus overrides ...
|
||||
void OnEditorModeActivated(const ViewportEditorModesInterface& editorModeState, ViewportEditorMode mode) override;
|
||||
void OnEditorModeDeactivated(const ViewportEditorModesInterface& editorModeState, ViewportEditorMode mode) override;
|
||||
|
||||
// EditorEntityContextNotificationBus overrides ...
|
||||
void OnStartPlayInEditor() override;
|
||||
|
||||
@@ -30,12 +30,14 @@ set(FILES
|
||||
API/AssetDatabaseBus.h
|
||||
API/ComponentEntityObjectBus.h
|
||||
API/ComponentEntitySelectionBus.h
|
||||
API/ComponentModeCollectionInterface.h
|
||||
API/EditorCameraBus.h
|
||||
API/EditorCameraBus.cpp
|
||||
API/EditorAnimationSystemRequestBus.h
|
||||
API/EditorEntityAPI.h
|
||||
API/EditorLevelNotificationBus.h
|
||||
API/ViewportEditorModeTrackerNotificationBus.h
|
||||
API/ViewportEditorModeTrackerNotificationBus.cpp
|
||||
API/EditorVegetationRequestsBus.h
|
||||
API/EditorPythonConsoleBus.h
|
||||
API/EditorPythonRunnerRequestsBus.h
|
||||
|
||||
Reference in New Issue
Block a user