Styles
Styles can be created and applied to the various parts of a widget. This makes it easy to iterate on the look of the components in the UI, as well as share and reuse styles.
// Tool bar
{
Set( "ToolBar.Background", FSlateBoxBrush( TEXT("Common/GroupBorder"), FMargin(4.0f/16.0f) ) );
Set( "ToolBarButton.Normal", FSlateNoResource() ); // Note: Intentionally transparent background
Set( "ToolBarButton.Pressed", FSlateBoxBrush( TEXT("Old/MenuItemButton_Pressed"), 4.0f/32.0f ) );
Set( "ToolBarButton.Hovered", FSlateBoxBrush( TEXT("Old/MenuItemButton_Hovered"), 4.0f/32.0f ) );
// Tool bar buttons are sometimes toggle buttons, so they need styles for "checked" state
Set( "ToolBarButton.Checked", FSlateBoxBrush( TEXT("Old/MenuItemButton_Pressed"), 4.0f/32.0f, FLinearColor( 0.3f, 0.3f, 0.3f ) ) );
Set( "ToolBarButton.Checked_Hovered", FSlateBoxBrush( TEXT("Old/MenuItemButton_Hovered"), 4.0f/32.0f ) );
Set( "ToolBarButton.Checked_Pressed", FSlateBoxBrush( TEXT("Old/MenuItemButton_Pressed"), 4.0f/32.0f, FLinearColor( 0.5f, 0.5f, 0.5f ) ) );
// Tool bar button label font
Set( "ToolBarButton.LabelFont", FSlateFontInfo( TEXT("Roboto-Regular"), 8 ) );
}
Styles used in composition:
SNew( SBorder )
.BorderImage( FEditorStyle::GetBrush( "ToolBar.Background" ) )
.Content()
[
SNew(SHorizontalBox)
// Compile button (faked to look like a multibox button)
+SHorizontalBox::Slot()
[
SNew(SButton)
.Style(TEXT("ToolBarButton"))
.OnClicked( InKismet2.ToSharedRef(), &FKismet::Compile_OnClicked )
.IsEnabled( InKismet2.ToSharedRef(), &FKismet::InEditingMode )
.Content()
[
SNew(SVerticalBox)
+SVerticalBox::Slot()
.Padding( 1.0f )
.HAlign(HAlign_Center)
[
SNew(SImage)
.Image(this, &SBlueprintEditorToolbar::GetStatusImage)
.ToolTipText(this, &SBlueprintEditorToolbar::GetStatusTooltip)
]
+SVerticalBox::Slot()
.Padding( 1.0f )
.HAlign(HAlign_Center)
[
SNew(STextBlock)
.Text(LOCTEXT("CompileButton", "Compile"))
.Font( FEditorStyle::GetFontStyle( FName( "ToolBarButton.LabelFont" ) ) )
.ToolTipText(LOCTEXT("CompileButton_Tooltip", "Recompile the blueprint"))
]
]
]
]