Files
UnrealEngineUWP/Engine/Source/Editor/AnimationEditor/Private/AnimationEditorMode.cpp
Chris Gagnon 8fc25ea18e Merging //UE4/Dev-Main to Dev-Editor (//UE4/Dev-Editor)
#rb none

[CL 4676797 by Chris Gagnon in Dev-Editor branch]
2019-01-02 14:54:39 -05:00

143 lines
5.8 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "AnimationEditorMode.h"
#include "Modules/ModuleManager.h"
#include "PersonaModule.h"
#include "AnimationEditor.h"
#include "ISkeletonTree.h"
#include "ISkeletonEditorModule.h"
#include "IPersonaToolkit.h"
FAnimationEditorMode::FAnimationEditorMode(TSharedRef<FWorkflowCentricApplication> InHostingApp, TSharedRef<ISkeletonTree> InSkeletonTree)
: FApplicationMode(AnimationEditorModes::AnimationEditorMode)
{
HostingAppPtr = InHostingApp;
TSharedRef<FAnimationEditor> AnimationEditor = StaticCastSharedRef<FAnimationEditor>(InHostingApp);
ISkeletonEditorModule& SkeletonEditorModule = FModuleManager::LoadModuleChecked<ISkeletonEditorModule>("SkeletonEditor");
TabFactories.RegisterFactory(SkeletonEditorModule.CreateSkeletonTreeTabFactory(InHostingApp, InSkeletonTree));
FOnObjectsSelected OnObjectsSelected = FOnObjectsSelected::CreateSP(&AnimationEditor.Get(), &FAnimationEditor::HandleObjectsSelected);
FPersonaModule& PersonaModule = FModuleManager::LoadModuleChecked<FPersonaModule>("Persona");
TabFactories.RegisterFactory(PersonaModule.CreateDetailsTabFactory(InHostingApp, FOnDetailsCreated::CreateSP(&AnimationEditor.Get(), &FAnimationEditor::HandleDetailsCreated)));
FPersonaViewportArgs ViewportArgs(AnimationEditor->GetPersonaToolkit()->GetPreviewScene());
ViewportArgs.bShowTimeline = false;
ViewportArgs.ContextName = TEXT("AnimationEditor.Viewport");
PersonaModule.RegisterPersonaViewportTabFactories(TabFactories, InHostingApp, ViewportArgs);
TabFactories.RegisterFactory(PersonaModule.CreateAdvancedPreviewSceneTabFactory(InHostingApp, AnimationEditor->GetPersonaToolkit()->GetPreviewScene()));
TabFactories.RegisterFactory(PersonaModule.CreateAnimationAssetBrowserTabFactory(InHostingApp, AnimationEditor->GetPersonaToolkit(), FOnOpenNewAsset::CreateSP(&AnimationEditor.Get(), &FAnimationEditor::HandleOpenNewAsset), FOnAnimationSequenceBrowserCreated::CreateSP(&AnimationEditor.Get(), &FAnimationEditor::HandleAnimationSequenceBrowserCreated), true));
TabFactories.RegisterFactory(PersonaModule.CreateAssetDetailsTabFactory(InHostingApp, FOnGetAsset::CreateSP(&AnimationEditor.Get(), &FAnimationEditor::HandleGetAsset), FOnDetailsCreated()));
TabFactories.RegisterFactory(PersonaModule.CreateCurveViewerTabFactory(InHostingApp, InSkeletonTree->GetEditableSkeleton(), AnimationEditor->GetPersonaToolkit()->GetPreviewScene(), AnimationEditor->OnPostUndo, OnObjectsSelected));
TabFactories.RegisterFactory(PersonaModule.CreateSkeletonSlotNamesTabFactory(InHostingApp, InSkeletonTree->GetEditableSkeleton(), AnimationEditor->OnPostUndo, FOnObjectSelected::CreateSP(&AnimationEditor.Get(), &FAnimationEditor::HandleObjectSelected)));
TabFactories.RegisterFactory(PersonaModule.CreateAnimNotifiesTabFactory(InHostingApp, InSkeletonTree->GetEditableSkeleton(), OnObjectsSelected));
TabLayout = FTabManager::NewLayout("Standalone_AnimationEditor_Layout_v1.2")
->AddArea
(
FTabManager::NewPrimaryArea()
->SetOrientation(Orient_Vertical)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.1f)
->SetHideTabWell(true)
->AddTab(InHostingApp->GetToolbarTabId(), ETabState::OpenedTab)
)
->Split
(
FTabManager::NewSplitter()
->SetSizeCoefficient(0.9f)
->SetOrientation(Orient_Horizontal)
->Split
(
FTabManager::NewSplitter()
->SetSizeCoefficient(0.2f)
->SetOrientation(Orient_Vertical)
->Split
(
FTabManager::NewStack()
->SetHideTabWell(false)
->AddTab(AnimationEditorTabs::SkeletonTreeTab, ETabState::OpenedTab)
->AddTab(AnimationEditorTabs::AssetDetailsTab, ETabState::OpenedTab)
)
)
->Split
(
FTabManager::NewSplitter()
->SetSizeCoefficient(0.6f)
->SetOrientation(Orient_Vertical)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.6f)
->SetHideTabWell(true)
->AddTab(AnimationEditorTabs::ViewportTab, ETabState::OpenedTab)
)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.4f)
->SetHideTabWell(true)
->AddTab(AnimationEditorTabs::DocumentTab, ETabState::ClosedTab)
)
)
->Split
(
FTabManager::NewSplitter()
->SetSizeCoefficient(0.2f)
->SetOrientation(Orient_Vertical)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.6f)
->SetHideTabWell(false)
->AddTab(AnimationEditorTabs::DetailsTab, ETabState::OpenedTab)
->AddTab(AnimationEditorTabs::AdvancedPreviewTab, ETabState::OpenedTab)
->SetForegroundTab(AnimationEditorTabs::DetailsTab)
)
->Split
(
FTabManager::NewStack()
->SetSizeCoefficient(0.4f)
->SetHideTabWell(false)
->AddTab(AnimationEditorTabs::AssetBrowserTab, ETabState::OpenedTab)
->AddTab(AnimationEditorTabs::CurveNamesTab, ETabState::ClosedTab)
->AddTab(AnimationEditorTabs::SlotNamesTab, ETabState::ClosedTab)
)
)
)
);
PersonaModule.OnRegisterTabs().Broadcast(TabFactories, InHostingApp);
LayoutExtender = MakeShared<FLayoutExtender>();
PersonaModule.OnRegisterLayoutExtensions().Broadcast(*LayoutExtender.Get());
TabLayout->ProcessExtensions(*LayoutExtender.Get());
}
void FAnimationEditorMode::RegisterTabFactories(TSharedPtr<FTabManager> InTabManager)
{
TSharedPtr<FWorkflowCentricApplication> HostingApp = HostingAppPtr.Pin();
HostingApp->RegisterTabSpawners(InTabManager.ToSharedRef());
HostingApp->PushTabFactories(TabFactories);
FApplicationMode::RegisterTabFactories(InTabManager);
}
void FAnimationEditorMode::AddTabFactory(FCreateWorkflowTabFactory FactoryCreator)
{
if (FactoryCreator.IsBound())
{
TabFactories.RegisterFactory(FactoryCreator.Execute(HostingAppPtr.Pin()));
}
}
void FAnimationEditorMode::RemoveTabFactory(FName TabFactoryID)
{
TabFactories.UnregisterFactory(TabFactoryID);
}