Moved toggle pivot to lower in the context menu, converted all context menu additions to use a singular mechanism (#1209)

main
Terry Michaels 5 years ago committed by GitHub
parent ac8ee00aff
commit adf6d93a06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -916,9 +916,6 @@ namespace AzToolsFramework
eECMF_USE_VIEWPORT_CENTER = 0x2,
};
/// Populate global edit-time context menu.
virtual void PopulateEditorGlobalContextMenu(QMenu * /*menu*/, const AZ::Vector2& /*point*/, int /*flags*/) {}
/// Populate slice portion of edit-time context menu
virtual void PopulateEditorGlobalContextMenu_SliceSection(QMenu * /*menu*/, const AZ::Vector2& /*point*/, int /*flags*/) {}

@ -79,7 +79,7 @@ namespace AzToolsFramework
* This is the menu that appears when right clicking the main editor window,
* including the Entity Outliner and the Viewport.
*/
virtual void PopulateEditorGlobalContextMenu(QMenu* menu) const = 0;
virtual void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) = 0;
};
using EditorContextMenuBus = AZ::EBus<EditorContextMenuEvents>;

@ -26,6 +26,7 @@
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/Commands/SelectionCommand.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
@ -544,8 +545,7 @@ namespace AzToolsFramework
QMenu* contextMenu = new QMenu(this);
// Populate global context menu.
EBUS_EVENT(EditorEvents::Bus,
PopulateEditorGlobalContextMenu,
AzToolsFramework::EditorContextMenuBus::Broadcast(&AzToolsFramework::EditorContextMenuEvents::PopulateEditorGlobalContextMenu,
contextMenu,
AZ::Vector2::CreateZero(),
EditorEvents::eECMF_HIDE_ENTITY_CREATION | EditorEvents::eECMF_USE_VIEWPORT_CENTER);

@ -119,7 +119,7 @@ namespace AzToolsFramework
return "Prefabs";
}
void PrefabIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu) const
void PrefabIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu, [[maybe_unused]] const AZ::Vector2& point, [[maybe_unused]] int flags)
{
AzToolsFramework::EntityIdList selectedEntities;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(

@ -65,7 +65,7 @@ namespace AzToolsFramework
// EditorContextMenuBus...
int GetMenuPosition() const override;
AZStd::string GetMenuIdentifier() const override;
void PopulateEditorGlobalContextMenu(QMenu* menu) const override;
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override;
// EntityOutlinerSourceDropHandlingBus...
void HandleSourceFileType(AZStd::string_view sourceFilePath, AZ::EntityId parentId, AZ::Vector3 position) const override;

@ -13,6 +13,7 @@
#include "EditorContextMenu.h"
#include "AzToolsFramework/Viewport/ViewportMessages.h"
#include "Editor/EditorContextMenuBus.h"
namespace AzToolsFramework
{
@ -55,8 +56,7 @@ namespace AzToolsFramework
// Populate global context menu.
const int contextMenuFlag = 0;
EditorEvents::Bus::BroadcastReverse(
&EditorEvents::PopulateEditorGlobalContextMenu, contextMenu.m_menu.data(),
AzToolsFramework::EditorContextMenuBus::Broadcast(&AzToolsFramework::EditorContextMenuEvents::PopulateEditorGlobalContextMenu, contextMenu.m_menu.data(),
AzFramework::Vector2FromScreenPoint(mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates),
contextMenuFlag);

@ -1018,6 +1018,7 @@ namespace AzToolsFramework
EditorEntityVisibilityNotificationBus::Router::BusRouterConnect();
EditorEntityLockComponentNotificationBus::Router::BusRouterConnect();
EditorManipulatorCommandUndoRedoRequestBus::Handler::BusConnect(entityContextId);
EditorContextMenuBus::Handler::BusConnect();
CreateTransformModeSelectionCluster();
CreateSpaceSelectionCluster();
@ -1038,6 +1039,7 @@ namespace AzToolsFramework
m_pivotOverrideFrame.Reset();
EditorContextMenuBus::Handler::BusConnect();
EditorManipulatorCommandUndoRedoRequestBus::Handler::BusDisconnect();
EditorEntityLockComponentNotificationBus::Router::BusRouterDisconnect();
EditorEntityVisibilityNotificationBus::Router::BusRouterDisconnect();
@ -3097,15 +3099,25 @@ namespace AzToolsFramework
}
}
void EditorTransformComponentSelection::PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& /*point*/, const int /*flags*/)
int EditorTransformComponentSelection::GetMenuPosition() const
{
QAction* action = menu->addAction(QObject::tr(s_togglePivotTitleRightClick));
QObject::connect(
action, &QAction::triggered, action,
[this]()
{
ToggleCenterPivotSelection();
});
return aznumeric_cast<int>(EditorContextMenuOrdering::BOTTOM);
}
AZStd::string EditorTransformComponentSelection::GetMenuIdentifier() const
{
return "Transform Component";
}
void EditorTransformComponentSelection::PopulateEditorGlobalContextMenu(QMenu* menu, [[maybe_unused]] const AZ::Vector2& point, [[maybe_unused]] int flags)
{
QAction* action = menu->addAction(QObject::tr(s_togglePivotTitleRightClick));
QObject::connect(
action, &QAction::triggered, action,
[this]()
{
ToggleCenterPivotSelection();
});
}
void EditorTransformComponentSelection::BeforeEntitySelectionChanged()

@ -22,6 +22,7 @@
#include <AzToolsFramework/API/EditorCameraBus.h>
#include <AzToolsFramework/Commands/EntityManipulatorCommand.h>
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <AzToolsFramework/Manipulators/BaseManipulator.h>
#include <AzToolsFramework/ToolsComponents/EditorLockComponentBus.h>
#include <AzToolsFramework/ToolsComponents/EditorVisibilityBus.h>
@ -126,6 +127,7 @@ namespace AzToolsFramework
//! Provide a suite of functionality for manipulating entities, primarily through their TransformComponent.
class EditorTransformComponentSelection
: public ViewportInteraction::ViewportSelectionRequests
, public EditorContextMenuBus::Handler
, private EditorEventsBus::Handler
, private EditorTransformComponentSelectionRequestBus::Handler
, private ToolsApplicationNotificationBus::Handler
@ -238,8 +240,12 @@ namespace AzToolsFramework
void UndoRedoEntityManipulatorCommand(
AZ::u8 pivotOverride, const AZ::Transform& transform, AZ::EntityId entityId) override;
// EditorContextMenuBus...
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2 & point, int flags) override;
int GetMenuPosition() const override;
AZStd::string GetMenuIdentifier() const override;
// EditorEventsBus ...
void PopulateEditorGlobalContextMenu(QMenu *menu, const AZ::Vector2& point, int flags) override;
void OnEscape() override;
// ToolsApplicationNotificationBus ...

@ -49,6 +49,7 @@
// AzToolsFramework
#include <AzToolsFramework/API/ComponentEntityObjectBus.h>
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <AzToolsFramework/Manipulators/ManipulatorManager.h>
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
#include <AzToolsFramework/ViewportSelection/EditorSelectionUtil.h>
@ -112,20 +113,20 @@ static const char TextCantCreateCameraNoLevel[] = "Cannot create camera when no
class EditorEntityNotifications
: public AzToolsFramework::EditorEntityContextNotificationBus::Handler
, public AzToolsFramework::EditorEvents::Bus::Handler
, public AzToolsFramework::EditorContextMenuBus::Handler
{
public:
EditorEntityNotifications(CRenderViewport& renderViewport)
: m_renderViewport(renderViewport)
{
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
AzToolsFramework::EditorContextMenuBus::Handler::BusConnect();
}
~EditorEntityNotifications() override
{
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
AzToolsFramework::EditorContextMenuBus::Handler::BusDisconnect();
}
// AzToolsFramework::EditorEntityContextNotificationBus
@ -138,7 +139,7 @@ public:
m_renderViewport.OnStopPlayInEditor();
}
// AzToolsFramework::EditorEvents::Bus
// AzToolsFramework::EditorContextMenu::Bus
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override
{
m_renderViewport.PopulateEditorGlobalContextMenu(menu, point, flags);

@ -179,7 +179,7 @@ public:
virtual void OnStartPlayInEditor();
virtual void OnStopPlayInEditor();
// AzToolsFramework::EditorEvents::Bus (handler moved to cpp to resolve link issues in unity builds)
// AzToolsFramework::EditorContextMenu::Bus (handler moved to cpp to resolve link issues in unity builds)
// We use this to determine when the viewport context menu is being displayed so we can exit move mode
void PopulateEditorGlobalContextMenu(QMenu* /*menu*/, const AZ::Vector2& /*point*/, int /*flags*/);

@ -167,7 +167,7 @@ void SandboxIntegrationManager::Setup()
AzToolsFramework::ToolsApplicationEvents::Bus::Handler::BusConnect();
AzToolsFramework::EditorRequests::Bus::Handler::BusConnect();
AzToolsFramework::EditorWindowRequests::Bus::Handler::BusConnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
AzToolsFramework::EditorContextMenuBus::Handler::BusConnect();
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusConnect();
@ -384,7 +384,7 @@ void SandboxIntegrationManager::Teardown()
AzFramework::DisplayContextRequestBus::Handler::BusDisconnect();
AzToolsFramework::SliceEditorEntityOwnershipServiceNotificationBus::Handler::BusDisconnect();
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
AzToolsFramework::EditorContextMenuBus::Handler::BusDisconnect();
AzToolsFramework::EditorWindowRequests::Bus::Handler::BusDisconnect();
AzToolsFramework::EditorRequests::Bus::Handler::BusDisconnect();
AzToolsFramework::ToolsApplicationEvents::Bus::Handler::BusDisconnect();
@ -589,6 +589,11 @@ void SandboxIntegrationManager::OnSaveLevel()
m_unsavedEntities.clear();
}
int SandboxIntegrationManager::GetMenuPosition() const
{
return aznumeric_cast<int>(AzToolsFramework::EditorContextMenuOrdering::TOP);
}
void SandboxIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags)
{
if (!IsLevelDocumentOpen())
@ -662,13 +667,6 @@ void SandboxIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu, con
SetupSliceContextMenu(menu);
}
else
{
menu->addSeparator();
// Allow handlers to append menu items to the context menu
AzToolsFramework::EditorContextMenuBus::Broadcast(&AzToolsFramework::EditorContextMenuEvents::PopulateEditorGlobalContextMenu, menu);
}
action = menu->addAction(QObject::tr("Duplicate"));
QObject::connect(action, &QAction::triggered, action, [this] { ContextMenu_Duplicate(); });

@ -23,6 +23,7 @@
#include <AzFramework/Viewport/DisplayContextRequestBus.h>
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <AzToolsFramework/ToolsComponents/EditorLayerComponentBus.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include <AzToolsFramework/UI/Layer/LayerUiHandler.h>
@ -97,7 +98,7 @@ class SandboxIntegrationManager
: private AzToolsFramework::ToolsApplicationEvents::Bus::Handler
, private AzToolsFramework::EditorRequests::Bus::Handler
, private AzToolsFramework::EditorPickModeNotificationBus::Handler
, private AzToolsFramework::EditorEvents::Bus::Handler
, private AzToolsFramework::EditorContextMenuBus::Handler
, private AzToolsFramework::EditorWindowRequests::Bus::Handler
, private AzFramework::AssetCatalogEventBus::Handler
, private AzFramework::DisplayContextRequestBus::Handler
@ -184,8 +185,9 @@ private:
void OnEntityPickModeStopped() override;
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::EditorEvents::Bus::Handler overrides
// AzToolsFramework::EditorContextMenu::Bus::Handler overrides
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override;
int GetMenuPosition() const;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

@ -35,6 +35,7 @@
#include <AzQtComponents/Utilities/QtViewPaneEffects.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/Commands/SelectionCommand.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
@ -530,8 +531,8 @@ void OutlinerWidget::contextMenuEvent(QContextMenuEvent* event)
QMenu* contextMenu = new QMenu(this);
// Populate global context menu.
EBUS_EVENT(AzToolsFramework::EditorEvents::Bus,
PopulateEditorGlobalContextMenu,
AzToolsFramework::EditorContextMenuBus::Broadcast(&AzToolsFramework::EditorContextMenuEvents::PopulateEditorGlobalContextMenu,
contextMenu,
AZ::Vector2::CreateZero(),
AzToolsFramework::EditorEvents::eECMF_HIDE_ENTITY_CREATION | AzToolsFramework::EditorEvents::eECMF_USE_VIEWPORT_CENTER);

@ -61,6 +61,7 @@ namespace Camera
void CameraEditorSystemComponent::Activate()
{
AzToolsFramework::EditorContextMenuBus::Handler::BusConnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
Camera::EditorCameraSystemRequestBus::Handler::BusConnect();
Camera::CameraViewRegistrationRequestsBus::Handler::BusConnect();
@ -71,6 +72,7 @@ namespace Camera
Camera::CameraViewRegistrationRequestsBus::Handler::BusDisconnect();
Camera::EditorCameraSystemRequestBus::Handler::BusDisconnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
AzToolsFramework::EditorContextMenuBus::Handler::BusDisconnect();
}
void CameraEditorSystemComponent::PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2&, int flags)

@ -15,6 +15,7 @@
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/API/EditorCameraBus.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include "CameraViewRegistrationBus.h"
@ -25,6 +26,7 @@ namespace Camera
, private AzToolsFramework::EditorEvents::Bus::Handler
, private EditorCameraSystemRequestBus::Handler
, private CameraViewRegistrationRequestsBus::Handler
, private AzToolsFramework::EditorContextMenuBus::Handler
{
public:
AZ_COMPONENT(CameraEditorSystemComponent, "{769802EB-722A-4F89-A475-DA396DA1FDCC}");
@ -40,9 +42,13 @@ namespace Camera
//////////////////////////////////////////////////////////////////////////
private:
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::EditorContextMenuBus
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// AzToolsFramework::EditorEvents
void PopulateEditorGlobalContextMenu(QMenu *menu, const AZ::Vector2& point, int flags) override;
void NotifyRegisterViews() override;
//////////////////////////////////////////////////////////////////////////

@ -134,6 +134,7 @@ namespace PhysX
void EditorSystemComponent::Activate()
{
Physics::EditorWorldBus::Handler::BusConnect();
AzToolsFramework::EditorContextMenuBus::Handler::BusConnect();
m_onMaterialLibraryLoadErrorEventHandler = AzPhysics::SystemEvents::OnMaterialLibraryLoadErrorEvent::Handler(
[this]([[maybe_unused]] AzPhysics::SystemEvents::MaterialLibraryLoadErrorType error)
@ -168,6 +169,7 @@ namespace PhysX
{
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
AzToolsFramework::EditorContextMenuBus::Handler::BusDisconnect();
Physics::EditorWorldBus::Handler::BusDisconnect();
if (auto* physicsSystem = AZ::Interface<AzPhysics::SystemInterface>::Get())

@ -15,6 +15,7 @@
#include <AzCore/Component/Component.h>
#include <AzFramework/Physics/SystemBus.h>
#include <AzFramework/Physics/Common/PhysicsEvents.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
namespace AzPhysics
@ -32,6 +33,7 @@ namespace PhysX
, public Physics::EditorWorldBus::Handler
, private AzToolsFramework::EditorEntityContextNotificationBus::Handler
, private AzToolsFramework::EditorEvents::Bus::Handler
, private AzToolsFramework::EditorContextMenuBus::Handler
{
public:
AZ_COMPONENT(EditorSystemComponent, "{560F08DC-94F5-4D29-9AD4-CDFB3B57C654}");
@ -62,8 +64,10 @@ namespace PhysX
void OnStartPlayInEditorBegin() override;
void OnStopPlayInEditor() override;
// AztoolsFramework::EditorEvents::Bus::Handler
// AztoolsFramework::EditorContextMenuBus::Handler
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override;
// AztoolsFramework::EditorEvents::Bus::Handler
void NotifyRegisterViews() override;
AZStd::optional<AZ::Data::Asset<AZ::Data::AssetData>> RetrieveDefaultMaterialLibrary();

@ -66,6 +66,7 @@ namespace ScriptCanvasEditor
SystemComponent::~SystemComponent()
{
AzToolsFramework::UnregisterViewPane(LyViewPane::ScriptCanvas);
AzToolsFramework::EditorContextMenuBus::Handler::BusDisconnect();
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
AzToolsFramework::AssetSeedManagerRequests::Bus::Handler::BusDisconnect();
@ -119,6 +120,7 @@ namespace ScriptCanvasEditor
void SystemComponent::Init()
{
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
AzToolsFramework::EditorContextMenuBus::Handler::BusConnect();
}
void SystemComponent::Activate()

@ -22,6 +22,7 @@
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
#include <AzToolsFramework/Editor/EditorContextMenuBus.h>
#include <Editor/Assets/ScriptCanvasAssetTracker.h>
#include <AzToolsFramework/Asset/AssetSeedManager.h>
@ -42,6 +43,7 @@ namespace ScriptCanvasEditor
, private AZ::Data::AssetBus::MultiHandler
, private AZ::Interface<IUpgradeRequests>::Registrar
, private AzToolsFramework::AssetSeedManagerRequests::Bus::Handler
, private AzToolsFramework::EditorContextMenuBus::Handler
{
public:
AZ_COMPONENT(SystemComponent, "{1DE7A120-4371-4009-82B5-8140CB1D7B31}");
@ -71,8 +73,12 @@ namespace ScriptCanvasEditor
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AztoolsFramework::EditorEvents::Bus::Handler...
// AztoolsFramework::EditorContextMenuBus::Handler...
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AztoolsFramework::EditorEvents::Bus::Handler...
void NotifyRegisterViews() override;
////////////////////////////////////////////////////////////////////////

Loading…
Cancel
Save