Files
UnrealEngineUWP/Engine/Source/Editor/LevelEditor/Private/LevelEditorContextMenu.h
steven dao b70a3f2efd Add new Actions (Actor/Component/Element) menu to the level editor's main menu bar that brings up the context menu corresponding to the selection
- The menu's title changes depending on the selection ("Actor", "Component", or "Element" currently since those are the three currently-defined context menus for the level editor)
- The context menus will get reorganized in subsequent changes so that the pulldown Actions menu displays the full set of entries while the right-click context menu is trimmed down to a shorter subset of entries. This change does not reorganize any items yet.
- Add support to UToolMenus for using a TAttribute<FText> for the pulldown menu title/tooltip and for supplying FOnGetContent for generating the pulldown menu.

#rb rex.hill
#preflight 61534e89260f7d0001c7e4ac

#ROBOMERGE-OWNER: steven.dao
#ROBOMERGE-AUTHOR: steven.dao
#ROBOMERGE-SOURCE: CL 17652268 via CL 17652271 via CL 17652276 via CL 17652280 via CL 17652287
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v875-17642767)
#ROBOMERGE[STARSHIP]: UE5-Main

[CL 17652461 by steven dao in ue5-release-engine-test branch]
2021-09-28 17:41:11 -04:00

92 lines
3.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Editor/UnrealEdTypes.h"
#include "LevelEditorMenuContext.h"
class FExtender;
class UToolMenu;
class UTypedElementSelectionSet;
struct FToolMenuContext;
class SLevelEditor;
class SWidget;
struct FToolMenuSection;
/**
* Context menu construction class
*/
class FLevelEditorContextMenu
{
public:
/**
* Summons the level viewport context menu
* @param LevelEditor The level editor using this menu.
* @param ContextType The context we should use to specialize this menu
* @param HitProxyActor The hitproxy actor in the case the ContextType is Viewport
*/
static void SummonMenu( const TSharedRef< class SLevelEditor >& LevelEditor, ELevelEditorMenuContext ContextType, const FTypedElementHandle& HitProxyElement = FTypedElementHandle());
/**
* Summons the viewport view option menu
* @param LevelEditor The level editor using this menu.
*/
static void SummonViewOptionMenu( const TSharedRef< class SLevelEditor >& LevelEditor, const ELevelViewportType ViewOption );
/**
* Creates a widget for the context menu that can be inserted into a pop-up window
*
* @param LevelEditor The level editor using this menu.
* @param ContextType The context we should use to specialize this menu
* @param Extender Allows extension of this menu based on context.
* @param HitProxyActor The hitproxy actor in the case the ContextType is Viewport
* @return Widget for this context menu
*/
static TSharedRef< SWidget > BuildMenuWidget(TWeakPtr< ILevelEditor > LevelEditor, ELevelEditorMenuContext ContextType, TSharedPtr<FExtender> Extender = TSharedPtr<FExtender>(), const FTypedElementHandle& HitProxyElement = FTypedElementHandle());
/**
* Populates the specified menu builder for the context menu that can be inserted into a pop-up window
*
* @param Menu The menu to fill
* @param LevelEditor The level editor using this menu.
* @param ContextType The context we should use to specialize this menu
* @param Extender Allows extension of this menu based on context.
* @param HitProxyActor The hitproxy actor in the case the ContextType is Viewport
*/
static UToolMenu* GenerateMenu(TWeakPtr< ILevelEditor > LevelEditor, ELevelEditorMenuContext ContextType, TSharedPtr<FExtender> Extender = TSharedPtr<FExtender>(), const FTypedElementHandle& HitProxyElement = FTypedElementHandle());
/* Adds required information to Context for build menu based on current selection */
static FName InitMenuContext(FToolMenuContext& Context, TWeakPtr<ILevelEditor> LevelEditor, ELevelEditorMenuContext ContextType, const FTypedElementHandle& HitProxyElement = FTypedElementHandle());
/* Returns name of menu to display based on current selection */
static FName GetContextMenuName(ELevelEditorMenuContext ContextType, const UTypedElementSelectionSet* InSelectionSet);
/* Returns a user-readable title for the menu to display; the title can be displayed in UI like the menu bar */
static FText GetContextMenuTitle(ELevelEditorMenuContext ContextType, const UTypedElementSelectionSet* InSelectionSet);
/* Returns a user-readable tooltip describing the menu to display */
static FText GetContextMenuToolTip(ELevelEditorMenuContext ContextType, const UTypedElementSelectionSet* InSelectionSet);
private:
static void RegisterComponentContextMenu();
static void RegisterActorContextMenu();
static void RegisterElementContextMenu();
static void RegisterSceneOutlinerContextMenu();
static void RegisterMenuBarEmptyContextMenu();
static void RegisterEmptySelectionContextMenu();
static void AddPlayFromHereSubMenu(FToolMenuSection& Section);
/**
* Builds the actor group menu
*
* @param Menu The menu to add items to.
* @param SelectedActorInfo Information about the selected actors.
*/
static void BuildGroupMenu(UToolMenu* Menu, const struct FSelectedActorInfo& SelectedActorInfo);
};