Editor | Refactor right-click context menu to improve grouping and surface most used items to the top. (#7742)
* Move "Open pinned Inspector" to separate handler to move it after the Prefab menu items. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Rearrange context menu items, add shortcuts Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Fix pragma once in header Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Revert casing changes that would cause issues in automated testing. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>development
parent
1f4b62dc72
commit
b69ae11ec6
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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 <ContextMenuHandlers.h>
|
||||||
|
|
||||||
|
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
|
||||||
|
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
void ContextMenuBottomHandler::Setup()
|
||||||
|
{
|
||||||
|
AzToolsFramework::EditorContextMenuBus::Handler::BusConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContextMenuBottomHandler::Teardown()
|
||||||
|
{
|
||||||
|
AzToolsFramework::EditorContextMenuBus::Handler::BusDisconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ContextMenuBottomHandler::GetMenuPosition() const
|
||||||
|
{
|
||||||
|
return aznumeric_cast<int>(AzToolsFramework::EditorContextMenuOrdering::BOTTOM);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContextMenuBottomHandler::PopulateEditorGlobalContextMenu(
|
||||||
|
QMenu* menu, [[maybe_unused]] const AZ::Vector2& point, [[maybe_unused]] int flags)
|
||||||
|
{
|
||||||
|
AzToolsFramework::EntityIdList selected;
|
||||||
|
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
|
||||||
|
selected, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||||
|
|
||||||
|
QAction* action = nullptr;
|
||||||
|
|
||||||
|
if (selected.size() > 0)
|
||||||
|
{
|
||||||
|
action = menu->addAction(QObject::tr("Open pinned Inspector"));
|
||||||
|
QObject::connect(
|
||||||
|
action, &QAction::triggered, action,
|
||||||
|
[selected]
|
||||||
|
{
|
||||||
|
AzToolsFramework::EntityIdSet pinnedEntities(selected.begin(), selected.end());
|
||||||
|
AzToolsFramework::EditorRequestBus::Broadcast(&AzToolsFramework::EditorRequests::OpenPinnedInspector, pinnedEntities);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* 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 <AzToolsFramework/Editor/EditorContextMenuBus.h>
|
||||||
|
|
||||||
|
class ContextMenuBottomHandler : private AzToolsFramework::EditorContextMenuBus::Handler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Setup();
|
||||||
|
void Teardown();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// EditorContextMenu overrides ...
|
||||||
|
void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override;
|
||||||
|
int GetMenuPosition() const override;
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue