Create a layout in your application mode class and it will be applied while Calling SetCurrentMode(ModeName) in editor class
FTestEditorApplicationMode::FTestEditorApplicationMode(TSharedPtr<class FTestEditor> InTestEditor)
: FApplicationMode(FTestEditor::CustomTestMode, FTestEditor::GetLocalizedMode)
{
TestEditor = InTestEditor;
TestEditorTabFactories.RegisterFactory(MakeShareable(new FTestDetailsSummoner(InTestEditor)));
TestEditorTabFactories.RegisterFactory(MakeShareable(new FTestSearchSummoner(InTestEditor)));
TabLayout = FTabManager::NewLayout( "Standalone_TestEditor_Layout_v1" )
->AddArea
(
FTabManager::NewPrimaryArea() ->SetOrientation(Orient_Vertical)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.1f)
->AddTab(InTestEditor->GetToolbarTabId(), ETabState::OpenedTab)
->SetHideTabWell(true)
)
->Split
(
FTabManager::NewSplitter() ->SetOrientation(Orient_Horizontal)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.7f)
->AddTab(FTestEditorTabs::GraphEditorID, ETabState::ClosedTab)
)
->Split
(
FTabManager::NewSplitter() ->SetOrientation(Orient_Vertical)
->SetSizeCoefficient(0.3f)
->Split
(
FTabManager::NewStack()
->AddTab(FTestEditorTabs::GraphDetailsID, ETabState::OpenedTab)
->AddTab(FTestEditorTabs::SearchID, ETabState::ClosedTab)
)
)
)
);
}
Each tab is identified by an unique name, such as FTestEditorTabs::GraphEditorID above.
Actually, RestoreFromLayout is called in the SetCurrentMode, also you can call it directly by yourself.
void FWorkflowCentricApplication::SetCurrentMode(FName NewMode)
{
...
// Activate the new layout
const TSharedRef<FTabManager::FLayout> NewLayout = CurrentAppModePtr->ActivateMode(TabManager);
RestoreFromLayout(NewLayout);
...
}
If there exists a layout in config file, it will load the existing one. If you want to clean it, you should remove config file in the Engine Saved folder.
TSharedRef<FTabManager::FLayout> FApplicationMode::ActivateMode(TSharedPtr<FTabManager> InTabManager)
{
check(InTabManager.IsValid());
RegisterTabFactories(InTabManager);
// Try loading the layout from INI
check(TabLayout.IsValid());
return FLayoutSaveRestore::LoadFromConfig(GEditorLayoutIni, TabLayout.ToSharedRef());
}