Files
UnrealEngineUWP/Engine/Source/Developer/Toolbox/Private/Toolbox.cpp
Dan Hertzka f3092790eb Window menu refactor & polish
- Window menu is now sectioned and labeled based on the current editor. There's now a local workspace root member in FTabManager and a workspace category in FAssetEditorToolkit (both are FWorkspaceItem objects). Individual editors attach their local category to the tab manager's local root. Workflow app modes have their own category members that are swapped out when the mode changes.

- Finally, the AssetEditorCategory of FWorkspaceMenuStructure has been removed entirely.

- Replaced the AddMenuSeparator() call in FTabManager::PopulateSpawnerMenu_Helper() with a section of the same title as the workspace category.

- Tab spawner menu entries for the local editor now properly show the icon of the associated tab. To accomplish this it was necessary to change FWorkflowTabFactory::TabIcon to be an FSlateIcon instead of an FSlateBrush*. All factory instances have been updated accordingly.

- Added & updated lots of icons! (those missing will be TTP'd)

- The nomad tab spawner section (named "General" in the menu) has been largely compressed into the Developer Tools submenu, which has also been organized into sections for readability.

- Unreal frontend options were also moved into a context menu within the General section

- Moved all experimental tools to their own section of the Window menu. When they're no longer experimental they should register as nomads in the appropriate category

- Undo history now under Edit menu

[CL 2324285 by Dan Hertzka in Main branch]
2014-10-09 12:34:55 -04:00

180 lines
4.7 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "Toolbox.h"
#include "ModuleManager.h"
#include "GammaUI.h"
#include "ModuleUIInterface.h"
#include "Editor/WorkspaceMenuStructure/Public/WorkspaceMenuStructureModule.h"
#include "MainFrame.h"
#include "DesktopPlatformModule.h"
IMPLEMENT_MODULE( FToolboxModule, Toolbox );
static bool CanShowModulesTab()
{
FString SolutionPath;
return FDesktopPlatformModule::Get()->GetSolutionPath(SolutionPath);
}
class SDebugPanel : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SDebugPanel){}
SLATE_END_ARGS()
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void Construct( const FArguments& )
{
ChildSlot
[
SNew( SVerticalBox )
+ SVerticalBox::Slot()
.AutoHeight()
.Padding( 4.0f )
.HAlign(HAlign_Left)
[
SNew( SButton )
.Text( NSLOCTEXT("DeveloperToolbox", "ReloadTextures", "Reload Textures") )
.OnClicked( this, &SDebugPanel::OnReloadTexturesClicked )
]
+ SVerticalBox::Slot()
.AutoHeight()
.Padding( 4.0f )
.HAlign(HAlign_Left)
[
SNew( SButton )
.Text( NSLOCTEXT("DeveloperToolbox", "FlushFontCache", "Flush Font Cache") )
.OnClicked( this, &SDebugPanel::OnFlushFontCacheClicked )
]
+ SVerticalBox::Slot()
.AutoHeight()
.Padding( 4.0f )
.HAlign(HAlign_Left)
[
SNew( SButton )
.Text( NSLOCTEXT("DeveloperToolbox", "TestNotifications", "Test Notifications") )
.OnClicked( this, &SDebugPanel::OnTestNotificationsClicked )
]
+ SVerticalBox::Slot()
.AutoHeight()
.Padding( 4.0f )
.HAlign(HAlign_Left)
[
SNew( SButton )
.Text( NSLOCTEXT("DeveloperToolbox", "DisplayTextureAtlases", "Display Texture Atlases") )
.OnClicked( this, &SDebugPanel::OnDisplayTextureAtlases )
]
];
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
FReply OnReloadTexturesClicked()
{
FSlateApplication::Get().GetRenderer()->ReloadTextureResources();
return FReply::Handled();
}
FReply OnDisplayTextureAtlases()
{
FSlateApplication::Get().GetRenderer()->DisplayTextureAtlases();
return FReply::Handled();
}
FReply OnFlushFontCacheClicked()
{
FSlateApplication::Get().GetRenderer()->FlushFontCache();
return FReply::Handled();
}
FReply OnTestNotificationsClicked()
{
static int32 Counter = 0;
FFormatNamedArguments Args;
Args.Add( TEXT("CounterNumber"), Counter++ );
FNotificationInfo Info( FText::Format( NSLOCTEXT("DeveloperToolbox", "TestNotificationCounter", "Test Notification {CounterNumber}"), Args ) );
Info.bFireAndForget = true;
Info.ExpireDuration = 3.0f;
Info.FadeOutDuration = 3.0f;
FSlateNotificationManager::Get().AddNotification(Info);
return FReply::Handled();
}
};
TSharedRef<SDockTab> CreateDebugToolsTab( const FSpawnTabArgs& Args )
{
FGammaUI& GammaUI = FModuleManager::Get().LoadModuleChecked<FGammaUI>( FName("GammaUI") );
return
SNew(SDockTab)
.TabRole( ETabRole::NomadTab )
[
SNew(SVerticalBox)
+SVerticalBox::Slot()
.AutoHeight()
[
SNew( SDebugPanel )
]
+SVerticalBox::Slot()
.AutoHeight()
[
GammaUI.GetGammaUIPanel().ToSharedRef()
]
];
}
TSharedRef<SDockTab> CreateModulesTab( const FSpawnTabArgs& Args )
{
IModuleUIInterface& ModuleUI = FModuleManager::Get().LoadModuleChecked<IModuleUIInterface>( FName("ModuleUI") );
return
SNew(SDockTab)
.TabRole( ETabRole::NomadTab )
[
SNew(SBorder)
.Padding(2)
.BorderImage( FEditorStyle::GetBrush("ToolPanel.GroupBorder") )
[
ModuleUI.GetModuleUIWidget()
]
];
}
void FToolboxModule::StartupModule()
{
const IWorkspaceMenuStructure& MenuStructure = WorkspaceMenu::GetMenuStructure();
FGlobalTabmanager::Get()->RegisterNomadTabSpawner( "DebugTools", FOnSpawnTab::CreateStatic( &CreateDebugToolsTab ) )
.SetDisplayName( NSLOCTEXT("Toolbox", "DebugTools", "Debug Tools") )
.SetTooltipText( NSLOCTEXT("Toolbox", "DebugToolsTooltipText", "Open the Debug Tools tab.") )
.SetGroup( MenuStructure.GetDeveloperToolsDebugCategory() )
.SetIcon( FSlateIcon(FEditorStyle::GetStyleSetName(), "DebugTools.TabIcon") );
if ( CanShowModulesTab() )
{
FGlobalTabmanager::Get()->RegisterNomadTabSpawner( "ModulesTab", FOnSpawnTab::CreateStatic( &CreateModulesTab ) )
.SetDisplayName( NSLOCTEXT("Toolbox", "Modules", "Modules") )
.SetTooltipText( NSLOCTEXT("Toolbox", "ModulesTooltipText", "Open the Modules tab.") )
.SetGroup( MenuStructure.GetDeveloperToolsMiscCategory() )
.SetIcon( FSlateIcon(FEditorStyle::GetStyleSetName(), "Modules.TabIcon") );
}
}
void FToolboxModule::ShutdownModule()
{
if (FSlateApplication::IsInitialized())
{
FGlobalTabmanager::Get()->UnregisterNomadTabSpawner("DebugTools");
if (CanShowModulesTab())
{
FGlobalTabmanager::Get()->UnregisterNomadTabSpawner("ModulesTab");
}
}
}