TSharedRef< SWidget > SDesignerToolBar::MakeToolBar(const TSharedPtr< FExtender > InExtenders) { FToolBarBuilder ToolbarBuilder( CommandList, FMultiBoxCustomization::None, InExtenders ); // Use a custom style FName ToolBarStyle = "ViewportMenu"; ToolbarBuilder.SetStyle(&FEditorStyle::Get(), ToolBarStyle); ToolbarBuilder.SetLabelVisibility(EVisibility::Collapsed); // Transform controls cannot be focusable as it fights with the press space to change transform mode feature ToolbarBuilder.SetIsFocusable( false ); ToolbarBuilder.BeginSection("View"); ToolbarBuilder.AddToolBarButton(FDesignerCommands::Get().ToggleOutlines, NAME_None, TAttribute<FText>(), TAttribute<FText>(), TAttribute<FSlateIcon>(), "ToggleOutlines"); ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("Transform"); ToolbarBuilder.BeginBlockGroup(); { ToolbarBuilder.AddToolBarButton( FDesignerCommands::Get().LayoutTransform, NAME_None, TAttribute<FText>(), TAttribute<FText>(), TAttribute<FSlateIcon>(), "LayoutTransform" ); ToolbarBuilder.AddToolBarButton( FDesignerCommands::Get().RenderTransform, NAME_None, TAttribute<FText>(), TAttribute<FText>(), TAttribute<FSlateIcon>(), "RenderTransform" ); } ToolbarBuilder.EndBlockGroup(); ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("LocationGridSnap"); { // Grab the existing UICommand FUICommandInfo* Command = FDesignerCommands::Get().LocationGridSnap.Get(); static FName PositionSnapName = FName(TEXT("PositionSnap")); // Setup a GridSnapSetting with the UICommand ToolbarBuilder.AddWidget(SNew(SViewportToolBarComboMenu) .Style(ToolBarStyle) .BlockLocation(EMultiBlockLocation::Start) .Cursor(EMouseCursor::Default) .IsChecked(this, &SDesignerToolBar::IsLocationGridSnapChecked) .OnCheckStateChanged(this, &SDesignerToolBar::HandleToggleLocationGridSnap) .Label(this, &SDesignerToolBar::GetLocationGridLabel) .OnGetMenuContent(this, &SDesignerToolBar::FillLocationGridSnapMenu) .ToggleButtonToolTip(Command->GetDescription()) .MenuButtonToolTip(LOCTEXT("LocationGridSnap_ToolTip", "Set the Position Grid Snap value")) .Icon(Command->GetIcon()) .ParentToolBar(SharedThis(this)) , PositionSnapName); } ToolbarBuilder.EndSection(); return ToolbarBuilder.MakeWidget(); }
void SMaterialEditorViewportPreviewShapeToolBar::Construct(const FArguments& InArgs, TSharedPtr<class SMaterialEditor3DPreviewViewport> InViewport) { // Force this toolbar to have small icons, as the preview panel is only small so we have limited space const bool bForceSmallIcons = true; FToolBarBuilder ToolbarBuilder(InViewport->GetCommandList(), FMultiBoxCustomization::None, nullptr, Orient_Horizontal, bForceSmallIcons); // Use a custom style ToolbarBuilder.SetStyle(&FEditorStyle::Get(), "ViewportMenu"); ToolbarBuilder.SetLabelVisibility(EVisibility::Collapsed); ToolbarBuilder.SetIsFocusable(false); ToolbarBuilder.BeginSection("Preview"); { ToolbarBuilder.AddToolBarButton(FMaterialEditorCommands::Get().SetCylinderPreview); ToolbarBuilder.AddToolBarButton(FMaterialEditorCommands::Get().SetSpherePreview); ToolbarBuilder.AddToolBarButton(FMaterialEditorCommands::Get().SetPlanePreview); ToolbarBuilder.AddToolBarButton(FMaterialEditorCommands::Get().SetCubePreview); ToolbarBuilder.AddToolBarButton(FMaterialEditorCommands::Get().SetPreviewMeshFromSelection); } ToolbarBuilder.EndSection(); static const FName DefaultForegroundName("DefaultForeground"); ChildSlot [ SNew(SBorder) .BorderImage(FEditorStyle::GetBrush("NoBorder")) // Color and opacity is changed based on whether or not the mouse cursor is hovering over the toolbar area .ColorAndOpacity(this, &SViewportToolBar::OnGetColorAndOpacity) .ForegroundColor(FEditorStyle::GetSlateColor(DefaultForegroundName)) .HAlign(HAlign_Right) [ ToolbarBuilder.MakeWidget() ] ]; SViewportToolBar::Construct(SViewportToolBar::FArguments()); }
TSharedRef<SWidget> SBehaviorTreeDiff::GenerateDiffListWidget() { BuildDiffSourceArray(); if(DiffListSource.Num() > 0) { struct FSortDiff { bool operator () (const FSharedDiffOnGraph& A, const FSharedDiffOnGraph& B) const { return A->Result.Diff < B->Result.Diff; } }; Sort(DiffListSource.GetData(),DiffListSource.Num(), FSortDiff()); // Map commands through UI const FDiffListCommands& Commands = FDiffListCommands::Get(); KeyCommands = MakeShareable(new FUICommandList ); KeyCommands->MapAction(Commands.Previous, FExecuteAction::CreateSP(this, &SBehaviorTreeDiff::PrevDiff)); KeyCommands->MapAction(Commands.Next, FExecuteAction::CreateSP(this, &SBehaviorTreeDiff::NextDiff)); FToolBarBuilder ToolbarBuilder(KeyCommands.ToSharedRef(), FMultiBoxCustomization::None); ToolbarBuilder.AddToolBarButton(Commands.Previous, NAME_None, TAttribute<FText>(), TAttribute<FText>(), FSlateIcon(FEditorStyle::GetStyleSetName(), "BlueprintDif.PrevDiff")); ToolbarBuilder.AddToolBarButton(Commands.Next, NAME_None, TAttribute<FText>(), TAttribute<FText>(), FSlateIcon(FEditorStyle::GetStyleSetName(), "BlueprintDif.NextDiff")); TSharedRef<SHorizontalBox> Result = SNew(SHorizontalBox) +SHorizontalBox::Slot() .FillWidth(1.f) .MaxWidth(350.f) [ SNew(SVerticalBox) +SVerticalBox::Slot() .Padding(0.f) .AutoHeight() [ ToolbarBuilder.MakeWidget() ] +SVerticalBox::Slot() .Padding(0.f) .AutoHeight() [ SNew(SBorder) .BorderImage(FEditorStyle::GetBrush("PropertyWindow.CategoryBackground")) .Padding(FMargin(2.0f)) .ForegroundColor(FEditorStyle::GetColor("PropertyWindow.CategoryForeground")) .ToolTipText(LOCTEXT("BehvaiorTreeDifDifferencesToolTip", "List of differences found between revisions, click to select")) .HAlign(HAlign_Center) [ SNew(STextBlock) .Text(LOCTEXT("RevisionDifferences", "Revision Differences")) ] ] +SVerticalBox::Slot() .Padding(1.f) .FillHeight(1.f) [ SAssignNew(DiffList, SListViewType) .ItemHeight(24) .ListItemsSource(&DiffListSource) .OnGenerateRow(this, &SBehaviorTreeDiff::OnGenerateRow) .SelectionMode(ESelectionMode::Single) .OnSelectionChanged(this, &SBehaviorTreeDiff::OnSelectionChanged) ] ]; return Result; } else { return SNew(SBorder).Visibility(EVisibility::Hidden); } }
void FAssetEditorToolkit::GenerateToolbar() { TSharedPtr<FExtender> Extender = FExtender::Combine(ToolbarExtenders); FToolBarBuilder ToolbarBuilder( GetToolkitCommands(), FMultiBoxCustomization::AllowCustomization( GetToolkitFName() ), Extender); ToolbarBuilder.SetIsFocusable(bIsToolbarFocusable); ToolbarBuilder.BeginSection("Asset"); { if( IsActuallyAnAsset() ) { ToolbarBuilder.AddToolBarButton(FAssetEditorCommonCommands::Get().SaveAsset); ToolbarBuilder.AddToolBarButton(FGlobalEditorCommonCommands::Get().FindInContentBrowser, NAME_None, LOCTEXT("FindInContentBrowserButton", "Find in CB")); } } ToolbarBuilder.EndSection(); TSharedRef<SHorizontalBox> MiscWidgets = SNew(SHorizontalBox); for (int32 WidgetIdx = 0; WidgetIdx < ToolbarWidgets.Num(); ++WidgetIdx) { MiscWidgets->AddSlot() .AutoWidth() .VAlign(VAlign_Center) .Padding(0.0f, 2.0f, 0.0f, 2.0f) [ ToolbarWidgets[WidgetIdx] ]; } Toolbar = SNew(SHorizontalBox) +SHorizontalBox::Slot() .HAlign(HAlign_Left) .VAlign(VAlign_Center) [ SNew(SVerticalBox) +SVerticalBox::Slot() .AutoHeight() .VAlign(VAlign_Bottom) [ ToolbarBuilder.MakeWidget() ] ] +SHorizontalBox::Slot() .HAlign(HAlign_Right) .VAlign(VAlign_Center) .AutoWidth() [ SNew(SVerticalBox) +SVerticalBox::Slot() .AutoHeight() .VAlign(VAlign_Bottom) [ SNew(SBorder) .BorderImage(FEditorStyle::GetBrush(TEXT("Toolbar.Background"))) .Visibility(ToolbarWidgets.Num() > 0 ? EVisibility::Visible : EVisibility::Collapsed) [ MiscWidgets ] ] ]; if (ToolbarWidgetContent.IsValid()) { ToolbarWidgetContent->SetContent(Toolbar.ToSharedRef()); } }
void STileLayerList::Construct(const FArguments& InArgs, UPaperTileMap* InTileMap, FNotifyHook* InNotifyHook) { TileMapPtr = InTileMap; NotifyHook = InNotifyHook; FTileMapEditorCommands::Register(); const FTileMapEditorCommands& Commands = FTileMapEditorCommands::Get(); CommandList = MakeShareable(new FUICommandList); CommandList->MapAction( Commands.AddNewLayerAbove, FExecuteAction::CreateSP(this, &STileLayerList::AddNewLayerAbove)); CommandList->MapAction( Commands.AddNewLayerBelow, FExecuteAction::CreateSP(this, &STileLayerList::AddNewLayerBelow)); CommandList->MapAction( Commands.DeleteLayer, FExecuteAction::CreateSP(this, &STileLayerList::DeleteLayer), FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingSelectedLayer)); CommandList->MapAction( Commands.DuplicateLayer, FExecuteAction::CreateSP(this, &STileLayerList::DuplicateLayer), FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingSelectedLayer)); CommandList->MapAction( Commands.MergeLayerDown, FExecuteAction::CreateSP(this, &STileLayerList::MergeLayerDown), FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingLayerBelow)); CommandList->MapAction( Commands.MoveLayerUp, FExecuteAction::CreateSP(this, &STileLayerList::MoveLayerUp), FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingLayerAbove)); CommandList->MapAction( Commands.MoveLayerDown, FExecuteAction::CreateSP(this, &STileLayerList::MoveLayerDown), FCanExecuteAction::CreateSP(this, &STileLayerList::CanExecuteActionNeedingLayerBelow)); FToolBarBuilder ToolbarBuilder(CommandList, FMultiBoxCustomization("TileLayerBrowserToolbar"), TSharedPtr<FExtender>(), Orient_Horizontal, /*InForceSmallIcons=*/ true); ToolbarBuilder.SetLabelVisibility(EVisibility::Collapsed); ToolbarBuilder.AddToolBarButton(Commands.AddNewLayerAbove); ToolbarBuilder.AddToolBarButton(Commands.MoveLayerUp); ToolbarBuilder.AddToolBarButton(Commands.MoveLayerDown); ToolbarBuilder.AddToolBarButton(Commands.DuplicateLayer); ToolbarBuilder.AddToolBarButton(Commands.DeleteLayer); TSharedRef<SWidget> Toolbar = ToolbarBuilder.MakeWidget(); RefreshMirrorList(); ListViewWidget = SNew(SPaperLayerListView) .SelectionMode(ESelectionMode::Single) .ClearSelectionOnClick(false) .ListItemsSource(&MirrorList) .OnSelectionChanged(this, &STileLayerList::OnSelectionChanged) .OnGenerateRow(this, &STileLayerList::OnGenerateLayerListRow) .OnContextMenuOpening(this, &STileLayerList::OnConstructContextMenu); // Restore the selection InTileMap->ValidateSelectedLayerIndex(); if (InTileMap->TileLayers.IsValidIndex(InTileMap->SelectedLayerIndex)) { UPaperTileLayer* SelectedLayer = InTileMap->TileLayers[InTileMap->SelectedLayerIndex]; SetSelectedLayer(SelectedLayer); } ChildSlot [ SNew(SVerticalBox) +SVerticalBox::Slot() [ SNew(SBox) .HeightOverride(115.0f) [ ListViewWidget.ToSharedRef() ] ] +SVerticalBox::Slot() .AutoHeight() [ Toolbar ] ]; }
TSharedRef<SHorizontalBox> SDistributionCurveEditor::BuildToolBar() { SelectedTab = TabNames[0]; FToolBarBuilder ToolbarBuilder( UICommandList, FMultiBoxCustomization::None ); ToolbarBuilder.BeginSection("CurveEditorFit"); { ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().FitHorizontally); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().FitVertically); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().FitToAll); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().FitToSelected); } ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("CurveEditorMode"); { ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().PanMode); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().ZoomMode); } ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("CurveEditorTangentTypes"); { ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().CurveAuto); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().CurveAutoClamped); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().CurveUser); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().CurveBreak); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().Linear); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().Constant); } ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("CurveEditorTangentOptions"); { ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().FlattenTangents); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().StraightenTangents); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().ShowAllTangents); } ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("CurveEditorTabs"); { ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().CreateTab); ToolbarBuilder.AddToolBarButton(FCurveEditorCommands::Get().DeleteTab); ToolbarBuilder.AddWidget( SNew(SBox) .WidthOverride(175) [ SNew(SVerticalBox) +SVerticalBox::Slot() .Padding(4) [ SNew(STextBlock) .Text(LOCTEXT("CurrentTab", "Current Tab: ")) .Visibility( this, &SDistributionCurveEditor::GetLargeIconVisibility ) ] +SVerticalBox::Slot() .AutoHeight() .Padding(4,0) [ SAssignNew(TabNamesComboBox, STextComboBox) .OptionsSource(&TabNames) .OnSelectionChanged(this, &SDistributionCurveEditor::TabSelectionChanged) .InitiallySelectedItem(SelectedTab) ] ] ); } ToolbarBuilder.EndSection(); return SNew(SHorizontalBox) +SHorizontalBox::Slot() .Padding(4,0) [ SNew(SBorder) .Padding(0) .BorderImage(FEditorStyle::GetBrush("NoBorder")) .IsEnabled(FSlateApplication::Get().GetNormalExecutionAttribute()) [ ToolbarBuilder.MakeWidget() ] ]; }
/** * Static: Creates a widget for the level editor tool bar * * @return New widget */ TSharedRef< SWidget > FLevelEditorToolBar::MakeLevelEditorToolBar( const TSharedRef<FUICommandList>& InCommandList, const TSharedRef<SLevelEditor> InLevelEditor ) { #define LOCTEXT_NAMESPACE "LevelEditorToolBar" FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor"); TSharedPtr<FExtender> Extenders = LevelEditorModule.GetToolBarExtensibilityManager()->GetAllExtenders(); static const FName LevelEditorToolBarName = "LevelEditorToolBar"; FToolBarBuilder ToolbarBuilder( InCommandList, FMultiBoxCustomization::AllowCustomization( LevelEditorToolBarName ), Extenders ); ToolbarBuilder.BeginSection("File"); { // Save All Levels ToolbarBuilder.AddToolBarButton( FLevelEditorCommands::Get().Save, NAME_None, TAttribute<FText>(), TAttribute<FText>(), FSlateIcon(FEditorStyle::GetStyleSetName(), "AssetEditor.SaveAsset") ); } ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("Content"); { ToolbarBuilder.AddToolBarButton( FLevelEditorCommands::Get().OpenContentBrowser, NAME_None, LOCTEXT( "ContentBrowser_Override", "Content" ), TAttribute<FText>(), TAttribute<FSlateIcon>(), "LevelToolbarContent" ); // Internal builds and external builds should see the marketplace by default, perforce builds should not. if (FEngineBuildSettings::IsInternalBuild() || !FEngineBuildSettings::IsPerforceBuild()) { ToolbarBuilder.AddToolBarButton(FLevelEditorCommands::Get().OpenMarketplace, NAME_None, LOCTEXT("Marketplace_Override", "Marketplace"), TAttribute<FText>(), TAttribute<FSlateIcon>(), "LevelToolbarMarketplace"); } } ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("Settings"); { ToolbarBuilder.AddComboButton( FUIAction(), FOnGetContent::CreateStatic(&FLevelEditorToolBar::GenerateQuickSettingsMenu, InCommandList), LOCTEXT("QuickSettingsCombo", "Quick Settings"), LOCTEXT("QuickSettingsCombo_ToolTip", "Quick level editor settings"), FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.ViewOptions") ); ToolbarBuilder.AddToolBarButton( FLevelEditorCommands::Get().WorldProperties, NAME_None, LOCTEXT( "WorldProperties_Override", "World Settings" ), LOCTEXT( "WorldProperties_ToolTipOverride", "Displays the world settings" ), TAttribute<FSlateIcon>(), "LevelToolbarWorldSettings" ); } ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection( NAME_None ); { ToolbarBuilder.AddComboButton( FUIAction(), FOnGetContent::CreateStatic( &FLevelEditorToolBar::GenerateOpenBlueprintMenuContent, InCommandList, TWeakPtr<SLevelEditor>( InLevelEditor ) ), LOCTEXT( "OpenBlueprint_Label", "Blueprints" ), LOCTEXT( "OpenBlueprint_ToolTip", "List of world Blueprints available to the user for editing or creation." ), FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.OpenLevelBlueprint") ); ToolbarBuilder.AddComboButton( FUIAction(), FOnGetContent::CreateStatic( &FLevelEditorToolBar::GenerateMatineeMenuContent, InCommandList, TWeakPtr<SLevelEditor>( InLevelEditor ) ), LOCTEXT( "EditMatinee_Label", "Matinee" ), LOCTEXT( "EditMatinee_Tooltip", "Displays a list of Matinee objects to open in the Matinee Editor"), FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.EditMatinee") ); } ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("Compile"); { // Build ToolbarBuilder.AddToolBarButton( FLevelEditorCommands::Get().Build, NAME_None, LOCTEXT("BuildAll", "Build") ); // Build menu drop down ToolbarBuilder.AddComboButton( FUIAction(), FOnGetContent::CreateStatic( &FLevelEditorToolBar::GenerateBuildMenuContent, InCommandList ), LOCTEXT( "BuildCombo_Label", "Build Options" ), LOCTEXT( "BuildComboToolTip", "Build options menu" ), FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Build"), true); // Only show the compile options on machines with the solution (assuming they can build it) if ( FSourceCodeNavigation::IsCompilerAvailable() && FLevelEditorActionCallbacks::CanShowSourceCodeActions() ) { ToolbarBuilder.AddToolBarButton( FLevelEditorCommands::Get().RecompileGameCode, NAME_None, LOCTEXT( "CompileMenuButton", "Compile" ), FLevelEditorCommands::Get().RecompileGameCode->GetDescription(), FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Recompile") ); ToolbarBuilder.AddComboButton( FUIAction(), FOnGetContent::CreateStatic( &FLevelEditorToolBar::GenerateCompileMenuContent, InCommandList ), LOCTEXT( "CompileCombo_Label", "Compile Options" ), LOCTEXT( "CompileMenuCombo_ToolTip", "Recompile options" ), FSlateIcon(FEditorStyle::GetStyleSetName(), "LevelEditor.Recompile"), true); } } ToolbarBuilder.EndSection(); ToolbarBuilder.BeginSection("Game"); { // Add the shared play-world commands that will be shown on the Kismet toolbar as well FPlayWorldCommands::BuildToolbar(ToolbarBuilder, true); } ToolbarBuilder.EndSection(); // Create the tool bar! return SNew( SBorder ) .Padding(0) .BorderImage( FEditorStyle::GetBrush("NoBorder") ) .IsEnabled( FSlateApplication::Get().GetNormalExecutionAttribute() ) [ ToolbarBuilder.MakeWidget() ]; #undef LOCTEXT_NAMESPACE }