void FTranslationEditorMenu::SetupTranslationEditorMenu( TSharedPtr< FExtender > Extender, FTranslationEditor& TranslationEditor) { // Add additional editor menu { struct Local { static void AddSaveMenuOption( FMenuBuilder& MenuBuilder ) { MenuBuilder.AddMenuEntry( FTranslationEditorCommands::Get().SaveTranslations, "SaveTranslations", TAttribute<FText>(), TAttribute<FText>(), FSlateIcon(FEditorStyle::GetStyleSetName(), "AssetEditor.SaveAsset.Greyscale") ); } static void AddTranslationEditorMenu( FMenuBarBuilder& MenuBarBuilder ) { // View MenuBarBuilder.AddPullDownMenu( LOCTEXT("TranslationMenu", "Translation"), LOCTEXT("TranslationMenu_ToolTip", "Open the Translation menu"), FNewMenuDelegate::CreateStatic( &FTranslationEditorMenu::FillTranslationMenu ), "View"); } }; Extender->AddMenuExtension( "FileLoadAndSave", EExtensionHook::First, TranslationEditor.GetToolkitCommands(), FMenuExtensionDelegate::CreateStatic( &Local::AddSaveMenuOption ) ); Extender->AddMenuBarExtension( "Edit", EExtensionHook::After, TranslationEditor.GetToolkitCommands(), FMenuBarExtensionDelegate::CreateStatic( &Local::AddTranslationEditorMenu ) ); } }
void SStandaloneAssetEditorToolkitHost::SetupInitialContent( const TSharedRef<FTabManager::FLayout>& DefaultLayout, const TSharedPtr<SDockTab>& InHostTab, const bool bCreateDefaultStandaloneMenu ) { // @todo toolkit major: Expose common asset editing features here! (or require the asset editor's content to do this itself!) // - Add a "toolkit menu" // - Toolkits can access this and add menu items as needed // - In world-centric, main frame menu becomes extendable // - e.g., "Blueprint", "Debug" menus added // - In standalone, toolkits get their own menu // - Also, the core menu is just added as the first pull-down in the standalone menu // - Multiple toolkits can be active and add their own menu items! // - In world-centric, the core toolkit menu is available from the drop down // - No longer need drop down next to toolkit display? Not sure... Probably still want this // - Add a "toolkit toolbar" // - In world-centric, draws next to the level editor tool bar (or on top of) // - Could either extend existing tool bar or add additional tool bars // - May need to change arrangement to allow for wider tool bars (maybe displace grid settings too) // - In standalone, just draws under the toolkit's menu if (bCreateDefaultStandaloneMenu) { struct Local { static void FillFileMenu( FMenuBuilder& MenuBuilder, TWeakPtr< FAssetEditorToolkit > AssetEditorToolkitWeak ) { auto AssetEditorToolkit( AssetEditorToolkitWeak.Pin().ToSharedRef() ); AssetEditorToolkit->FillDefaultFileMenuCommands( MenuBuilder ); } static void AddAssetMenu( FMenuBarBuilder& MenuBarBuilder, TWeakPtr< FAssetEditorToolkit > AssetEditorToolkitWeak ) { MenuBarBuilder.AddPullDownMenu( LOCTEXT("AssetMenuLabel", "Asset"), // @todo toolkit major: Either use "Asset", "File", or the asset type name e.g. "Blueprint" (Also update custom pull-down menus) LOCTEXT("AssetMenuLabel_ToolTip", "Opens a menu with commands for managing this asset"), FNewMenuDelegate::CreateStatic( &Local::FillAssetMenu, AssetEditorToolkitWeak ), "Asset"); auto AssetEditorToolkit( AssetEditorToolkitWeak.Pin().ToSharedRef() ); } static void FillAssetMenu( FMenuBuilder& MenuBuilder, TWeakPtr< FAssetEditorToolkit > AssetEditorToolkitWeak ) { auto AssetEditorToolkit( AssetEditorToolkitWeak.Pin().ToSharedRef() ); MenuBuilder.BeginSection("AssetEditorActions", LOCTEXT("ActionsHeading", "Actions") ); { AssetEditorToolkit->FillDefaultAssetMenuCommands( MenuBuilder ); } MenuBuilder.EndSection(); } static void ExtendHelpMenu( FMenuBuilder& MenuBuilder, TWeakPtr< FAssetEditorToolkit > AssetEditorToolkitWeak ) { auto AssetEditorToolkit( AssetEditorToolkitWeak.Pin().ToSharedRef() ); MenuBuilder.BeginSection("HelpBrowse", NSLOCTEXT("MainHelpMenu", "Browse", "Browse")); { AssetEditorToolkit->FillDefaultHelpMenuCommands( MenuBuilder ); } MenuBuilder.EndSection(); } }; TSharedPtr<FExtender> MenuExtender = MakeShareable(new FExtender()); auto AssetEditorToolkit = HostedAssetEditorToolkit.ToSharedRef(); // Add asset-specific menu items to the top of the "File" menu MenuExtender->AddMenuExtension( "FileLoadAndSave", EExtensionHook::First, AssetEditorToolkit->GetToolkitCommands(), FMenuExtensionDelegate::CreateStatic( &Local::FillFileMenu, TWeakPtr< FAssetEditorToolkit >( AssetEditorToolkit ) ) ); // Add the "Asset" menu, if we're editing an asset if (AssetEditorToolkit->IsActuallyAnAsset()) { MenuExtender->AddMenuBarExtension( "Edit", EExtensionHook::After, AssetEditorToolkit->GetToolkitCommands(), FMenuBarExtensionDelegate::CreateStatic( &Local::AddAssetMenu, TWeakPtr< FAssetEditorToolkit >( AssetEditorToolkit ) ) ); } MenuExtender->AddMenuExtension( "HelpOnline", EExtensionHook::Before, AssetEditorToolkit->GetToolkitCommands(), FMenuExtensionDelegate::CreateStatic( &Local::ExtendHelpMenu, TWeakPtr< FAssetEditorToolkit >( AssetEditorToolkit ) ) ); MenuExtenders.Add(MenuExtender); } DefaultMenuWidget = SNullWidget::NullWidget; HostTabPtr = InHostTab; RestoreFromLayout(DefaultLayout); GenerateMenus(bCreateDefaultStandaloneMenu); }