Files
UnrealEngineUWP/Engine/Source/Developer/SessionFrontend/Private/Widgets/SSessionFrontend.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

213 lines
7.8 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "SessionFrontendPrivatePCH.h"
#define LOCTEXT_NAMESPACE "SSessionFrontend"
/* Local constants
*****************************************************************************/
static const FName AutomationTabId("AutomationPanel");
static const FName SessionBrowserTabId("SessionBrowser");
static const FName SessionConsoleTabId("SessionConsole");
static const FName SessionScreenTabId("ScreenComparison");
static const FName ProfilerTabId("Profiler");
/* SSessionFrontend interface
*****************************************************************************/
void SSessionFrontend::Construct( const FArguments& InArgs, const TSharedRef<SDockTab>& ConstructUnderMajorTab, const TSharedPtr<SWindow>& ConstructUnderWindow )
{
InitializeControllers();
// create & initialize tab manager
TabManager = FGlobalTabmanager::Get()->NewTabManager(ConstructUnderMajorTab);
TSharedRef<FWorkspaceItem> AppMenuGroup = TabManager->GetLocalWorkspaceMenuRoot()->AddGroup(LOCTEXT("SessionFrontendMenuGroupName", "Session Frontend"));
TabManager->RegisterTabSpawner(AutomationTabId, FOnSpawnTab::CreateRaw(this, &SSessionFrontend::HandleTabManagerSpawnTab, AutomationTabId))
.SetDisplayName(LOCTEXT("AutomationTabTitle", "Automation"))
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "SessionFrontEnd.Tabs.Tools"))
.SetGroup(AppMenuGroup);
TabManager->RegisterTabSpawner(SessionBrowserTabId, FOnSpawnTab::CreateRaw(this, &SSessionFrontend::HandleTabManagerSpawnTab, SessionBrowserTabId))
.SetDisplayName(LOCTEXT("SessionBrowserTitle", "Session Browser"))
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "SessionFrontEnd.Tabs.Tools"))
.SetGroup(AppMenuGroup);
TabManager->RegisterTabSpawner(SessionConsoleTabId, FOnSpawnTab::CreateRaw(this, &SSessionFrontend::HandleTabManagerSpawnTab, SessionConsoleTabId))
.SetDisplayName(LOCTEXT("ConsoleTabTitle", "Console"))
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "SessionFrontEnd.Tabs.Tools"))
.SetGroup(AppMenuGroup);
TabManager->RegisterTabSpawner(SessionScreenTabId, FOnSpawnTab::CreateRaw(this, &SSessionFrontend::HandleTabManagerSpawnTab, SessionScreenTabId))
.SetDisplayName(LOCTEXT("ScreenTabTitle", "Screen Comparison"))
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "SessionFrontEnd.Tabs.Tools"))
.SetGroup(AppMenuGroup);
TabManager->RegisterTabSpawner(ProfilerTabId, FOnSpawnTab::CreateRaw(this, &SSessionFrontend::HandleTabManagerSpawnTab, ProfilerTabId))
.SetDisplayName(LOCTEXT("ProfilerTabTitle", "Profiler"))
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "Profiler.Tab"))
.SetGroup(AppMenuGroup);
// create tab layout
const TSharedRef<FTabManager::FLayout> Layout = FTabManager::NewLayout("SessionFrontendLayout_v1.1")
->AddArea
(
FTabManager::NewPrimaryArea()
->SetOrientation(Orient_Vertical)
->Split
(
// session browser
FTabManager::NewStack()
->AddTab(SessionBrowserTabId, ETabState::OpenedTab)
->SetHideTabWell(true)
->SetSizeCoefficient(0.15f)
)
->Split
(
// applications
FTabManager::NewStack()
->AddTab(SessionConsoleTabId, ETabState::OpenedTab)
->AddTab(AutomationTabId, ETabState::OpenedTab)
->AddTab(SessionScreenTabId, ETabState::ClosedTab)
->AddTab(ProfilerTabId, ETabState::OpenedTab)
->SetSizeCoefficient(0.85f)
->SetForegroundTab(SessionConsoleTabId)
)
);
// create & initialize main menu
FMenuBarBuilder MenuBarBuilder = FMenuBarBuilder(TSharedPtr<FUICommandList>());
MenuBarBuilder.AddPullDownMenu(
LOCTEXT("WindowMenuLabel", "Window"),
FText::GetEmpty(),
FNewMenuDelegate::CreateStatic(&SSessionFrontend::FillWindowMenu, TabManager),
"Window"
);
ChildSlot
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.AutoHeight()
[
MenuBarBuilder.MakeWidget()
]
+ SVerticalBox::Slot()
.FillHeight(1.0f)
[
TabManager->RestoreFrom(Layout, ConstructUnderWindow).ToSharedRef()
]
];
}
/* SSessionFrontend implementation
*****************************************************************************/
void SSessionFrontend::FillWindowMenu( FMenuBuilder& MenuBuilder, const TSharedPtr<FTabManager> TabManager )
{
if (!TabManager.IsValid())
{
return;
}
#if !WITH_EDITOR
FGlobalTabmanager::Get()->PopulateTabSpawnerMenu(MenuBuilder, WorkspaceMenu::GetMenuStructure().GetStructureRoot());
#endif //!WITH_EDITOR
TabManager->PopulateLocalTabSpawnerMenu(MenuBuilder);
}
void SSessionFrontend::InitializeControllers( )
{
// load required modules and objects
ISessionServicesModule& SessionServicesModule = FModuleManager::LoadModuleChecked<ISessionServicesModule>("SessionServices");
ITargetDeviceServicesModule& TargetDeviceServicesModule = FModuleManager::LoadModuleChecked<ITargetDeviceServicesModule>("TargetDeviceServices");
IScreenShotToolsModule& ScreenShotModule = FModuleManager::LoadModuleChecked<IScreenShotToolsModule>("ScreenShotComparisonTools");
// create controllers
DeviceProxyManager = TargetDeviceServicesModule.GetDeviceProxyManager();
SessionManager = SessionServicesModule.GetSessionManager();
ScreenShotManager = ScreenShotModule.GetScreenShotManager();
}
/* SSessionFrontend callbacks
*****************************************************************************/
void SSessionFrontend::HandleAutomationModuleShutdown()
{
IAutomationWindowModule& AutomationWindowModule = FModuleManager::LoadModuleChecked<IAutomationWindowModule>("AutomationWindow");
TSharedPtr<SDockTab> AutomationWindowModuleTab = AutomationWindowModule.GetAutomationWindowTab().Pin();
if (AutomationWindowModuleTab.IsValid())
{
AutomationWindowModuleTab->RequestCloseTab();
}
}
TSharedRef<SDockTab> SSessionFrontend::HandleTabManagerSpawnTab( const FSpawnTabArgs& Args, FName TabIdentifier ) const
{
TSharedPtr<SWidget> TabWidget = SNullWidget::NullWidget;
TSharedRef<SDockTab> DockTab = SNew(SDockTab)
.TabRole(ETabRole::PanelTab);
if (TabIdentifier == AutomationTabId)
{
// create a controller every time a tab is created
IAutomationControllerModule& AutomationControllerModule = FModuleManager::LoadModuleChecked<IAutomationControllerModule>(TEXT("AutomationController"));
IAutomationControllerManagerPtr AutomationController = AutomationControllerModule.GetAutomationController();
IAutomationWindowModule& AutomationWindowModule = FModuleManager::LoadModuleChecked<IAutomationWindowModule>("AutomationWindow");
AutomationController->OnShutdown().BindRaw(this, &SSessionFrontend::HandleAutomationModuleShutdown);
TabWidget = AutomationWindowModule.CreateAutomationWindow(
AutomationController.ToSharedRef(),
SessionManager.ToSharedRef()
);
AutomationWindowModule.OnShutdown().BindRaw(this, &SSessionFrontend::HandleAutomationModuleShutdown);
}
else if (TabIdentifier == ProfilerTabId)
{
IProfilerModule& ProfilerModule = FModuleManager::LoadModuleChecked<IProfilerModule>(TEXT("Profiler"));
TabWidget = ProfilerModule.CreateProfilerWindow(SessionManager.ToSharedRef(), DockTab);
}
else if (TabIdentifier == SessionBrowserTabId)
{
TabWidget = SNew(SSessionBrowser, SessionManager.ToSharedRef());
}
else if (TabIdentifier == SessionConsoleTabId)
{
TabWidget = SNew(SSessionConsole, SessionManager.ToSharedRef());
}
else if (TabIdentifier == SessionScreenTabId)
{
TabWidget = FModuleManager::LoadModuleChecked<IScreenShotComparisonModule>("ScreenShotComparison").CreateScreenShotComparison(
ScreenShotManager.ToSharedRef()
);
}
DockTab->SetContent(TabWidget.ToSharedRef());
// save the Automation Window Dock Tab so that we can close it on required module being shutdown or recompiled.
if (TabIdentifier == AutomationTabId)
{
FModuleManager::LoadModuleChecked<IAutomationWindowModule>("AutomationWindow").SetAutomationWindowTab(DockTab);
}
return DockTab;
}
#undef LOCTEXT_NAMESPACE