void FAssetEditorToolkit::FillDefaultFileMenuCommands( FMenuBuilder& MenuBuilder ) { if( IsActuallyAnAsset() ) { MenuBuilder.AddMenuEntry( FAssetEditorCommonCommands::Get().SaveAsset, "SaveAsset", TAttribute<FText>(), TAttribute<FText>(), FSlateIcon(FEditorStyle::GetStyleSetName(), "AssetEditor.SaveAsset.Greyscale") ); MenuBuilder.AddMenuSeparator(); } if( IsWorldCentricAssetEditor() ) { // @todo toolkit minor: It would be awesome if the user could just "tear off" the SToolkitDisplay to do SwitchToStandaloneEditor // Would need to probably drop at mouseup location though instead of using saved layout pos. MenuBuilder.AddMenuEntry( FAssetEditorCommonCommands::Get().SwitchToStandaloneEditor ); } else { if( GetPreviousWorldCentricToolkitHost().IsValid() ) { // @todo toolkit checkin: Disabled temporarily until we have world-centric "ready to use"! if( 0 ) { MenuBuilder.AddMenuEntry( FAssetEditorCommonCommands::Get().SwitchToWorldCentricEditor ); } } } }
FString FBaseToolkit::GetTabPrefix() const { if( IsWorldCentricAssetEditor() ) { return GetWorldCentricTabPrefix(); } else { return TEXT( "" ); } }
void FSequencerAssetEditor::UnregisterTabSpawners(const TSharedRef<class FTabManager>& TabManager) { if( FSequencer::IsSequencerEnabled() && !IsWorldCentricAssetEditor() ) { TabManager->UnregisterTabSpawner( SequencerMainTabId ); } // @todo remove when world-centric mode is added FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor"); LevelEditorModule.AttachSequencer( SNullWidget::NullWidget, nullptr ); }
void FSequencerAssetEditor::RegisterTabSpawners(const TSharedRef<class FTabManager>& TabManager) { if( FSequencer::IsSequencerEnabled() && !IsWorldCentricAssetEditor() ) { WorkspaceMenuCategory = TabManager->AddLocalWorkspaceMenuCategory(LOCTEXT("WorkspaceMenu_SequencerAssetEditor", "Sequencer")); TabManager->RegisterTabSpawner( SequencerMainTabId, FOnSpawnTab::CreateSP(this, &FSequencerAssetEditor::SpawnTab_SequencerMain) ) .SetDisplayName( LOCTEXT("SequencerMainTab", "Sequencer") ) .SetGroup( WorkspaceMenuCategory.ToSharedRef() ); } }
FLinearColor FBaseToolkit::GetTabColorScale() const { return IsWorldCentricAssetEditor() ? GetWorldCentricTabColorScale() : FLinearColor( 0, 0, 0, 0 ); }
void FAssetEditorToolkit::InitAssetEditor( const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, const FName AppIdentifier, const TSharedRef<FTabManager::FLayout>& StandaloneDefaultLayout, const bool bCreateDefaultStandaloneMenu, const bool bCreateDefaultToolbar, const TArray<UObject*>& ObjectsToEdit, const bool bInIsToolbarFocusable ) { // Must not already be editing an object check( ObjectsToEdit.Num() > 0 ); check( EditingObjects.Num() == 0 ); bIsToolbarFocusable = bInIsToolbarFocusable; // cache reference to ToolkitManager; also ensure it was initialized. FToolkitManager& ToolkitManager = FToolkitManager::Get(); EditingObjects.Append( ObjectsToEdit ); // Store "previous" asset editing toolkit host, and clear it out PreviousWorldCentricToolkitHost = PreviousWorldCentricToolkitHostForNewAssetEditor; PreviousWorldCentricToolkitHostForNewAssetEditor.Reset(); ToolkitMode = Mode; TSharedPtr<SWindow> ParentWindow; TSharedPtr<SDockTab> NewMajorTab; TSharedPtr< SStandaloneAssetEditorToolkitHost > NewStandaloneHost; if( ToolkitMode == EToolkitMode::WorldCentric ) // @todo toolkit major: Do we need to remember this setting on a per-asset editor basis? Probably. { // Keep track of the level editor we're attached to (if any) ToolkitHost = InitToolkitHost; } else if( ensure( ToolkitMode == EToolkitMode::Standalone ) ) { // Open a standalone app to edit this asset. check( AppIdentifier != NAME_None ); // Create the label and the link for the toolkit documentation. TAttribute<FText> Label = TAttribute<FText>( this, &FAssetEditorToolkit::GetToolkitName ); TAttribute<FText> ToolTipText = TAttribute<FText>( this, &FAssetEditorToolkit::GetToolkitToolTipText ); FString DocLink = GetDocumentationLink(); if ( !DocLink.StartsWith( "Shared/" ) ) { DocLink = FString("Shared/") + DocLink; } // Create a new SlateToolkitHost NewMajorTab = SNew(SDockTab) .ContentPadding(0.0f) .TabRole(ETabRole::MajorTab) .ToolTip(IDocumentation::Get()->CreateToolTip(ToolTipText, nullptr, DocLink, GetToolkitFName().ToString())) .Icon( this, &FAssetEditorToolkit::GetDefaultTabIcon ) .Label( Label ); { static_assert(sizeof(EAssetEditorToolkitTabLocation) == sizeof(int32), "EAssetEditorToolkitTabLocation is the incorrect size"); const UEditorStyleSettings* StyleSettings = GetDefault<UEditorStyleSettings>(); // Work out where we should create this asset editor EAssetEditorToolkitTabLocation SavedAssetEditorToolkitTabLocation = StyleSettings->bOpenAssetEditorTabsInNewWindow ? EAssetEditorToolkitTabLocation::Standalone : EAssetEditorToolkitTabLocation::Docked; GConfig->GetInt( TEXT("AssetEditorToolkitTabLocation"), *ObjectsToEdit[0]->GetPathName(), reinterpret_cast<int32&>(SavedAssetEditorToolkitTabLocation), GEditorPerProjectIni ); const FName AssetEditorToolkitTab = (SavedAssetEditorToolkitTabLocation == EAssetEditorToolkitTabLocation::Docked) ? "DockedToolkit" : "StandaloneToolkit"; FGlobalTabmanager::Get()->InsertNewDocumentTab( AssetEditorToolkitTab, FTabManager::ESearchPreference::PreferLiveTab, NewMajorTab.ToSharedRef() ); } #if PLATFORM_MAC TSharedPtr< SEditableTextBox > ExposedEditableTextBox; TSharedRef<SWidget> SuperSearchWidget = FSuperSearchModule::Get().MakeSearchBox(ExposedEditableTextBox); #endif IUserFeedbackModule& UserFeedback = FModuleManager::LoadModuleChecked<IUserFeedbackModule>(TEXT("UserFeedback")); TSharedRef<SWidget> UserFeedbackWidget = UserFeedback.CreateFeedbackWidget(GetBaseToolkitName()); IIntroTutorials& IntroTutorials = FModuleManager::LoadModuleChecked<IIntroTutorials>(TEXT("IntroTutorials")); TSharedRef<SWidget> TutorialWidget = IntroTutorials.CreateTutorialsWidget(GetToolkitContextFName(), NewMajorTab->GetParentWindow()); NewMajorTab->SetRightContent( SNew(SHorizontalBox) + SHorizontalBox::Slot() .AutoWidth() .Padding(8.0f, 0.0f, 0.0f, 0.0f) .VAlign(VAlign_Center) [ UserFeedbackWidget ] #if PLATFORM_MAC +SHorizontalBox::Slot() .AutoWidth() .Padding(16.0f, 0.0f, 0.0f, 0.0f) .VAlign(VAlign_Center) [ SuperSearchWidget ] #endif +SHorizontalBox::Slot() .AutoWidth() .Padding(8.0f, 0.0f, 8.0f, 0.0f) .VAlign(VAlign_Center) [ TutorialWidget ] ); const TSharedRef<FTabManager> NewTabManager = FGlobalTabmanager::Get()->NewTabManager( NewMajorTab.ToSharedRef() ); NewTabManager->SetOnPersistLayout(FTabManager::FOnPersistLayout::CreateRaw(this, &FAssetEditorToolkit::HandleTabManagerPersistLayout)); this->TabManager = NewTabManager; NewMajorTab->SetContent ( SAssignNew( NewStandaloneHost, SStandaloneAssetEditorToolkitHost, NewTabManager, AppIdentifier ) .OnRequestClose(this, &FAssetEditorToolkit::OnRequestClose) ); // Assign our toolkit host before we setup initial content. (Important: We must cache this pointer here as SetupInitialContent // will callback into the toolkit host.) ToolkitHost = NewStandaloneHost; } check( ToolkitHost.IsValid() ); ToolkitManager.RegisterNewToolkit( SharedThis( this ) ); if (ToolkitMode == EToolkitMode::Standalone) { TSharedRef<FTabManager::FLayout> LayoutToUse = FLayoutSaveRestore::LoadFromConfig(GEditorLayoutIni, StandaloneDefaultLayout); // Actually create the widget content NewStandaloneHost->SetupInitialContent( LayoutToUse, NewMajorTab, bCreateDefaultStandaloneMenu ); } StandaloneHost = NewStandaloneHost; if (bCreateDefaultToolbar) { GenerateToolbar(); } else { Toolbar = SNullWidget::NullWidget; } ToolkitCommands->MapAction( FAssetEditorCommonCommands::Get().SaveAsset, FExecuteAction::CreateSP( this, &FAssetEditorToolkit::SaveAsset_Execute ), FCanExecuteAction::CreateSP( this, &FAssetEditorToolkit::CanSaveAsset )); ToolkitCommands->MapAction( FGlobalEditorCommonCommands::Get().FindInContentBrowser, FExecuteAction::CreateSP( this, &FAssetEditorToolkit::FindInContentBrowser_Execute ) ); ToolkitCommands->MapAction( FGlobalEditorCommonCommands::Get().ViewReferences, FExecuteAction::CreateSP( this, &FAssetEditorToolkit::ViewReferences_Execute ), FCanExecuteAction::CreateSP( this, &FAssetEditorToolkit::CanViewReferences )); ToolkitCommands->MapAction( FGlobalEditorCommonCommands::Get().ViewSizeMap, FExecuteAction::CreateSP( this, &FAssetEditorToolkit::ViewSizeMap_Execute ), FCanExecuteAction::CreateSP( this, &FAssetEditorToolkit::CanViewSizeMap )); ToolkitCommands->MapAction( FGlobalEditorCommonCommands::Get().OpenDocumentation, FExecuteAction::CreateSP( this, &FAssetEditorToolkit::BrowseDocumentation_Execute ) ); ToolkitCommands->MapAction( FAssetEditorCommonCommands::Get().ReimportAsset, FExecuteAction::CreateSP( this, &FAssetEditorToolkit::Reimport_Execute ) ); FGlobalEditorCommonCommands::MapActions(ToolkitCommands); if( IsWorldCentricAssetEditor() ) { ToolkitCommands->MapAction( FAssetEditorCommonCommands::Get().SwitchToStandaloneEditor, FExecuteAction::CreateStatic( &FAssetEditorToolkit::SwitchToStandaloneEditor_Execute, TWeakPtr< FAssetEditorToolkit >( AsShared() ) ) ); } else { if( GetPreviousWorldCentricToolkitHost().IsValid() ) { ToolkitCommands->MapAction( FAssetEditorCommonCommands::Get().SwitchToWorldCentricEditor, FExecuteAction::CreateStatic( &FAssetEditorToolkit::SwitchToWorldCentricEditor_Execute, TWeakPtr< FAssetEditorToolkit >( AsShared() ) ) ); } } // NOTE: Currently, the AssetEditorManager will keep a hard reference to our object as we're editing it FAssetEditorManager::Get().NotifyAssetsOpened( EditingObjects, this ); }