2016-12-08 08:52:44 -05:00
|
|
|
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "Framework/MultiBox/SToolBarButtonBlock.h"
|
|
|
|
|
#include "Widgets/SBoxPanel.h"
|
|
|
|
|
#include "Framework/Application/SlateApplication.h"
|
|
|
|
|
#include "Widgets/Images/SImage.h"
|
|
|
|
|
#include "Framework/MultiBox/MultiBoxBuilder.h"
|
|
|
|
|
#include "Widgets/Input/SButton.h"
|
|
|
|
|
#include "Widgets/SToolTip.h"
|
|
|
|
|
#include "Widgets/Input/SCheckBox.h"
|
2014-04-26 20:23:08 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
FToolBarButtonBlock::FToolBarButtonBlock( const TSharedPtr< const FUICommandInfo > InCommand, TSharedPtr< const FUICommandList > InCommandList, const TAttribute<FText>& InLabelOverride, const TAttribute<FText>& InToolTipOverride, const TAttribute<FSlateIcon>& InIconOverride )
|
2014-07-23 09:04:48 -04:00
|
|
|
: FMultiBlock( InCommand, InCommandList, NAME_None, EMultiBlockType::ToolBarButton )
|
2014-03-14 14:13:41 -04:00
|
|
|
, LabelOverride( InLabelOverride )
|
|
|
|
|
, ToolTipOverride( InToolTipOverride )
|
|
|
|
|
, IconOverride( InIconOverride )
|
|
|
|
|
, LabelVisibility()
|
|
|
|
|
, UserInterfaceActionType(EUserInterfaceActionType::Button)
|
|
|
|
|
, bIsFocusable(false)
|
|
|
|
|
, bForceSmallIcons(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FToolBarButtonBlock::FToolBarButtonBlock( const TAttribute<FText>& InLabel, const TAttribute<FText>& InToolTip, const TAttribute<FSlateIcon>& InIcon, const FUIAction& InUIAction, const EUserInterfaceActionType::Type InUserInterfaceActionType )
|
|
|
|
|
: FMultiBlock( InUIAction )
|
|
|
|
|
, LabelOverride( InLabel )
|
|
|
|
|
, ToolTipOverride( InToolTip )
|
|
|
|
|
, IconOverride( InIcon )
|
|
|
|
|
, LabelVisibility()
|
|
|
|
|
, UserInterfaceActionType(InUserInterfaceActionType)
|
|
|
|
|
, bIsFocusable(false)
|
|
|
|
|
, bForceSmallIcons(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FToolBarButtonBlock::CreateMenuEntry(FMenuBuilder& MenuBuilder) const
|
|
|
|
|
{
|
2015-07-08 04:48:54 -04:00
|
|
|
TSharedPtr<const FUICommandInfo> MenuEntryAction = GetAction();
|
|
|
|
|
TSharedPtr<const FUICommandList> MenuEntryActionList = GetActionList();
|
|
|
|
|
if (MenuEntryAction.IsValid() && MenuEntryActionList.IsValid())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-07-08 04:48:54 -04:00
|
|
|
MenuBuilder.PushCommandList(MenuEntryActionList.ToSharedRef());
|
|
|
|
|
MenuBuilder.AddMenuEntry(MenuEntryAction);
|
2014-03-14 14:13:41 -04:00
|
|
|
MenuBuilder.PopCommandList();
|
|
|
|
|
}
|
|
|
|
|
else if ( LabelOverride.IsSet() )
|
|
|
|
|
{
|
|
|
|
|
const FUIAction& DirectAction = GetDirectActions();
|
|
|
|
|
MenuBuilder.AddMenuEntry( LabelOverride.Get(), ToolTipOverride.Get(), IconOverride.Get(), DirectAction );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-20 19:21:21 -05:00
|
|
|
bool FToolBarButtonBlock::HasIcon() const
|
|
|
|
|
{
|
|
|
|
|
const FSlateIcon ActionIcon = GetAction().IsValid() ? GetAction()->GetIcon() : FSlateIcon();
|
|
|
|
|
const FSlateIcon& ActualIcon = IconOverride.IsSet() ? IconOverride.Get() : ActionIcon;
|
|
|
|
|
|
|
|
|
|
if (ActualIcon.IsSet())
|
|
|
|
|
{
|
|
|
|
|
return ActualIcon.GetIcon()->GetResourceName() != NAME_None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
/**
|
|
|
|
|
* Allocates a widget for this type of MultiBlock. Override this in derived classes.
|
|
|
|
|
*
|
|
|
|
|
* @return MultiBlock widget object
|
|
|
|
|
*/
|
|
|
|
|
TSharedRef< class IMultiBlockBaseWidget > FToolBarButtonBlock::ConstructWidget() const
|
|
|
|
|
{
|
|
|
|
|
return SNew( SToolBarButtonBlock )
|
|
|
|
|
.LabelVisibility( LabelVisibility.IsSet() ? LabelVisibility.GetValue() : TOptional< EVisibility >() )
|
|
|
|
|
.IsFocusable( bIsFocusable )
|
|
|
|
|
.ForceSmallIcons( bForceSmallIcons )
|
|
|
|
|
.TutorialHighlightName(GetTutorialHighlightName())
|
|
|
|
|
.Cursor( EMouseCursor::Default );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Construct this widget
|
|
|
|
|
*
|
|
|
|
|
* @param InArgs The declaration data for this widget
|
|
|
|
|
*/
|
|
|
|
|
void SToolBarButtonBlock::Construct( const FArguments& InArgs )
|
|
|
|
|
{
|
|
|
|
|
if ( InArgs._LabelVisibility.IsSet() )
|
|
|
|
|
{
|
|
|
|
|
LabelVisibility = InArgs._LabelVisibility.GetValue();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LabelVisibility = TAttribute< EVisibility >::Create( TAttribute< EVisibility >::FGetter::CreateSP( SharedThis( this ), &SToolBarButtonBlock::GetIconVisibility, false ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bIsFocusable = InArgs._IsFocusable;
|
|
|
|
|
bForceSmallIcons = InArgs._ForceSmallIcons;
|
|
|
|
|
TutorialHighlightName = InArgs._TutorialHighlightName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Builds this MultiBlock widget up from the MultiBlock associated with it
|
|
|
|
|
*/
|
|
|
|
|
void SToolBarButtonBlock::BuildMultiBlockWidget(const ISlateStyle* StyleSet, const FName& StyleName)
|
|
|
|
|
{
|
|
|
|
|
struct Local
|
|
|
|
|
{
|
|
|
|
|
/** Appends the key binding to the end of the provided ToolTip */
|
|
|
|
|
static FText AppendKeyBindingToToolTip( const TAttribute<FText> ToolTip, TWeakPtr< const FUICommandInfo> Command )
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<const FUICommandInfo> CommandPtr = Command.Pin();
|
|
|
|
|
|
2015-03-17 11:36:28 -04:00
|
|
|
if( CommandPtr.IsValid() && CommandPtr->GetActiveChord()->IsValidChord() )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
FFormatNamedArguments Args;
|
|
|
|
|
Args.Add( TEXT("ToolTipDescription"), ToolTip.Get() );
|
|
|
|
|
Args.Add( TEXT("Keybinding"), CommandPtr->GetInputText() );
|
|
|
|
|
return FText::Format( NSLOCTEXT("ToolBar", "ToolTip + Keybinding", "{ToolTipDescription} ({Keybinding})"), Args );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return ToolTip.Get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TSharedRef< const FMultiBox > MultiBox( OwnerMultiBoxWidget.Pin()->GetMultiBox() );
|
|
|
|
|
|
|
|
|
|
TSharedRef< const FToolBarButtonBlock > ToolBarButtonBlock = StaticCastSharedRef< const FToolBarButtonBlock >( MultiBlock.ToSharedRef() );
|
|
|
|
|
|
|
|
|
|
// Allow the block to override the action's label and tool tip string, if desired
|
|
|
|
|
TAttribute<FText> ActualLabel;
|
|
|
|
|
if (ToolBarButtonBlock->LabelOverride.IsSet())
|
|
|
|
|
{
|
|
|
|
|
ActualLabel = ToolBarButtonBlock->LabelOverride;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ActualLabel = ToolBarButtonBlock->GetAction()->GetLabel();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-26 10:33:13 -04:00
|
|
|
// Add this widget to the search list of the multibox
|
|
|
|
|
if (MultiBlock->GetSearchable())
|
|
|
|
|
OwnerMultiBoxWidget.Pin()->AddSearchElement(this->AsWidget(), ActualLabel.Get());
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
TAttribute<FText> ActualToolTip;
|
|
|
|
|
if (ToolBarButtonBlock->ToolTipOverride.IsSet())
|
|
|
|
|
{
|
|
|
|
|
ActualToolTip = ToolBarButtonBlock->ToolTipOverride;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ActualToolTip = ToolBarButtonBlock->GetAction()->GetDescription();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If a key is bound to the command, append it to the tooltip text.
|
|
|
|
|
TWeakPtr<const FUICommandInfo> Action = ToolBarButtonBlock->GetAction();
|
|
|
|
|
ActualToolTip = TAttribute< FText >::Create( TAttribute< FText >::FGetter::CreateStatic( &Local::AppendKeyBindingToToolTip, ActualToolTip, Action ) );
|
|
|
|
|
|
|
|
|
|
// If we were supplied an image than go ahead and use that, otherwise we use a null widget
|
|
|
|
|
TSharedRef< SWidget > IconWidget =
|
|
|
|
|
SNew( SImage )
|
|
|
|
|
.Visibility( this, &SToolBarButtonBlock::GetIconVisibility, false )
|
|
|
|
|
.Image( this, &SToolBarButtonBlock::GetIconBrush );
|
|
|
|
|
TSharedRef< SWidget > SmallIconWidget =
|
|
|
|
|
SNew( SImage )
|
|
|
|
|
.Visibility( this, &SToolBarButtonBlock::GetIconVisibility, true )
|
|
|
|
|
.Image( this, &SToolBarButtonBlock::GetSmallIconBrush );
|
|
|
|
|
|
|
|
|
|
// Create the content for our button
|
|
|
|
|
TSharedRef< SWidget > ButtonContent =
|
|
|
|
|
|
|
|
|
|
SNew(SHorizontalBox)
|
2014-09-05 07:39:52 -04:00
|
|
|
.AddMetaData<FTagMetaData>(FTagMetaData(TutorialHighlightName))
|
2014-08-05 09:04:35 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.FillWidth(1)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SNew( SVerticalBox )
|
|
|
|
|
|
|
|
|
|
// Icon image
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
.HAlign( HAlign_Center ) // Center the icon horizontally, so that large labels don't stretch out the artwork
|
|
|
|
|
[
|
|
|
|
|
IconWidget
|
|
|
|
|
]
|
|
|
|
|
+ SVerticalBox::Slot().AutoHeight()
|
|
|
|
|
.HAlign( HAlign_Center )
|
|
|
|
|
[
|
|
|
|
|
SmallIconWidget
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
// Label text
|
|
|
|
|
+ SVerticalBox::Slot().AutoHeight()
|
|
|
|
|
.HAlign( HAlign_Center ) // Center the label text horizontally
|
|
|
|
|
[
|
|
|
|
|
SNew( STextBlock )
|
|
|
|
|
.Visibility( LabelVisibility )
|
|
|
|
|
.Text( ActualLabel )
|
|
|
|
|
.TextStyle( StyleSet, ISlateStyle::Join( StyleName, ".Label" ) ) // Smaller font for tool tip labels
|
|
|
|
|
.ShadowOffset( FVector2D::UnitVector )
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
EMultiBlockLocation::Type BlockLocation = GetMultiBlockLocation();
|
|
|
|
|
|
|
|
|
|
// What type of UI should we create for this block?
|
|
|
|
|
EUserInterfaceActionType::Type UserInterfaceType = ToolBarButtonBlock->UserInterfaceActionType;
|
|
|
|
|
if ( Action.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
// If we have a UICommand, then this is specified in the command.
|
|
|
|
|
UserInterfaceType = Action.Pin()->GetUserInterfaceType();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( UserInterfaceType == EUserInterfaceActionType::Button )
|
|
|
|
|
{
|
|
|
|
|
FName BlockStyle = EMultiBlockLocation::ToName(ISlateStyle::Join( StyleName, ".Button" ), BlockLocation);
|
2014-07-28 06:53:40 -04:00
|
|
|
ChildSlot
|
|
|
|
|
[
|
2014-03-14 14:13:41 -04:00
|
|
|
// Create a button
|
|
|
|
|
SNew( SButton )
|
|
|
|
|
.ContentPadding(0)
|
|
|
|
|
|
|
|
|
|
// Use the tool bar item style for this button
|
|
|
|
|
.ButtonStyle( StyleSet, BlockStyle )
|
|
|
|
|
|
|
|
|
|
.ForegroundColor( FSlateColor::UseForeground() )
|
|
|
|
|
|
|
|
|
|
.IsFocusable(bIsFocusable)
|
|
|
|
|
[
|
|
|
|
|
ButtonContent
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
// Bind the button's "on clicked" event to our object's method for this
|
|
|
|
|
.OnClicked( this, &SToolBarButtonBlock::OnClicked )
|
|
|
|
|
|
|
|
|
|
// Pass along the block's tool-tip string
|
2014-08-01 02:25:53 -04:00
|
|
|
.ToolTip( FMultiBoxSettings::ToolTipConstructor.Execute( ActualToolTip, nullptr, Action.Pin() ) )
|
2014-07-28 06:53:40 -04:00
|
|
|
];
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
else if( ensure( UserInterfaceType == EUserInterfaceActionType::ToggleButton || UserInterfaceType == EUserInterfaceActionType::RadioButton ) )
|
|
|
|
|
{
|
|
|
|
|
FName BlockStyle = EMultiBlockLocation::ToName(ISlateStyle::Join( StyleName, ".ToggleButton" ), BlockLocation);
|
|
|
|
|
FName CheckboxStyle = ISlateStyle::Join( StyleName, ".SToolBarButtonBlock.CheckBox.Padding" );
|
|
|
|
|
|
2014-07-28 06:53:40 -04:00
|
|
|
ChildSlot
|
|
|
|
|
[
|
2014-03-14 14:13:41 -04:00
|
|
|
// Create a check box
|
|
|
|
|
SNew( SCheckBox )
|
|
|
|
|
|
|
|
|
|
// Use the tool bar style for this check box
|
|
|
|
|
.Style( StyleSet, BlockStyle )
|
|
|
|
|
|
|
|
|
|
// User will have set the focusable attribute for the block, honor it
|
|
|
|
|
.IsFocusable( bIsFocusable )
|
|
|
|
|
|
|
|
|
|
// Pass along the block's tool-tip string
|
2014-08-01 02:25:53 -04:00
|
|
|
.ToolTip( FMultiBoxSettings::ToolTipConstructor.Execute( ActualToolTip, nullptr, Action.Pin() ) )
|
2014-03-14 14:13:41 -04:00
|
|
|
[
|
|
|
|
|
ButtonContent
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
// Bind the button's "on checked" event to our object's method for this
|
|
|
|
|
.OnCheckStateChanged( this, &SToolBarButtonBlock::OnCheckStateChanged )
|
|
|
|
|
|
|
|
|
|
// Bind the check box's "checked" state to our user interface action
|
|
|
|
|
.IsChecked( this, &SToolBarButtonBlock::OnIsChecked )
|
|
|
|
|
|
2014-07-28 06:53:40 -04:00
|
|
|
.Padding( StyleSet->GetMargin(CheckboxStyle) )
|
|
|
|
|
];
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChildSlot.Padding(StyleSet->GetMargin(ISlateStyle::Join( StyleName, ".SToolBarButtonBlock.Padding" )));
|
|
|
|
|
|
|
|
|
|
// Bind our widget's enabled state to whether or not our action can execute
|
|
|
|
|
SetEnabled( TAttribute< bool >( this, &SToolBarButtonBlock::IsEnabled ) );
|
|
|
|
|
|
|
|
|
|
// Bind our widget's visible state to whether or not the button should be visible
|
|
|
|
|
SetVisibility( TAttribute<EVisibility>(this, &SToolBarButtonBlock::GetBlockVisibility) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called by Slate when this tool bar button's button is clicked
|
|
|
|
|
*/
|
|
|
|
|
FReply SToolBarButtonBlock::OnClicked()
|
|
|
|
|
{
|
|
|
|
|
// Button was clicked, so trigger the action!
|
|
|
|
|
TSharedPtr< const FUICommandList > ActionList = MultiBlock->GetActionList();
|
|
|
|
|
TSharedPtr< const FUICommandInfo > Action = MultiBlock->GetAction();
|
|
|
|
|
const FUIAction& DirectActions = MultiBlock->GetDirectActions();
|
|
|
|
|
|
|
|
|
|
if( ActionList.IsValid() && Action.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
ActionList->ExecuteAction( Action.ToSharedRef() );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// There is no action list or action associated with this block via a UI command. Execute any direct action we have
|
|
|
|
|
MultiBlock->GetDirectActions().Execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef< const FMultiBox > MultiBox( OwnerMultiBoxWidget.Pin()->GetMultiBox() );
|
|
|
|
|
|
|
|
|
|
// If this is a context menu, then we'll also dismiss the window after the user clicked on the item
|
|
|
|
|
const bool ClosingMenu = MultiBox->ShouldCloseWindowAfterMenuSelection();
|
|
|
|
|
if( ClosingMenu )
|
|
|
|
|
{
|
2016-07-28 10:41:43 -04:00
|
|
|
FSlateApplication::Get().DismissMenuByWidget(AsShared());
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called by Slate when this tool bar check box button is toggled
|
|
|
|
|
*/
|
2014-12-10 14:24:09 -05:00
|
|
|
void SToolBarButtonBlock::OnCheckStateChanged( const ECheckBoxState NewCheckedState )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
OnClicked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called by slate to determine if this button should appear checked
|
|
|
|
|
*
|
2014-12-10 14:24:09 -05:00
|
|
|
* @return ECheckBoxState::Checked if it should be checked, ECheckBoxState::Unchecked if not.
|
2014-03-14 14:13:41 -04:00
|
|
|
*/
|
2014-12-10 14:24:09 -05:00
|
|
|
ECheckBoxState SToolBarButtonBlock::OnIsChecked() const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
TSharedPtr< const FUICommandList > ActionList = MultiBlock->GetActionList();
|
|
|
|
|
TSharedPtr< const FUICommandInfo > Action = MultiBlock->GetAction();
|
|
|
|
|
const FUIAction& DirectActions = MultiBlock->GetDirectActions();
|
|
|
|
|
|
2015-05-29 12:57:25 -04:00
|
|
|
ECheckBoxState CheckState = ECheckBoxState::Unchecked;
|
2014-03-14 14:13:41 -04:00
|
|
|
if( ActionList.IsValid() && Action.IsValid() )
|
|
|
|
|
{
|
2015-05-29 12:57:25 -04:00
|
|
|
CheckState = ActionList->GetCheckState( Action.ToSharedRef() );
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// There is no action list or action associated with this block via a UI command. Execute any direct action we have
|
2015-05-29 12:57:25 -04:00
|
|
|
CheckState = DirectActions.GetCheckState();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-05-29 12:57:25 -04:00
|
|
|
return CheckState;
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called by Slate to determine if this button is enabled
|
|
|
|
|
*
|
|
|
|
|
* @return True if the menu entry is enabled, false otherwise
|
|
|
|
|
*/
|
|
|
|
|
bool SToolBarButtonBlock::IsEnabled() const
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr< const FUICommandList > ActionList = MultiBlock->GetActionList();
|
|
|
|
|
TSharedPtr< const FUICommandInfo > Action = MultiBlock->GetAction();
|
|
|
|
|
const FUIAction& DirectActions = MultiBlock->GetDirectActions();
|
|
|
|
|
|
|
|
|
|
bool bEnabled = true;
|
|
|
|
|
if( ActionList.IsValid() && Action.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
bEnabled = ActionList->CanExecuteAction( Action.ToSharedRef() );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// There is no action list or action associated with this block via a UI command. Execute any direct action we have
|
|
|
|
|
bEnabled = DirectActions.CanExecute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called by Slate to determine if this button is visible
|
|
|
|
|
*
|
|
|
|
|
* @return EVisibility::Visible or EVisibility::Collapsed, depending on if the button should be displayed
|
|
|
|
|
*/
|
|
|
|
|
EVisibility SToolBarButtonBlock::GetBlockVisibility() const
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr< const FUICommandList > ActionList = MultiBlock->GetActionList();
|
2014-06-23 06:27:16 -04:00
|
|
|
const FUIAction& DirectActions = MultiBlock->GetDirectActions();
|
2014-03-14 14:13:41 -04:00
|
|
|
if( ActionList.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
return ActionList->GetVisibility( MultiBlock->GetAction().ToSharedRef() );
|
|
|
|
|
}
|
2014-06-23 06:27:16 -04:00
|
|
|
else if(DirectActions.IsActionVisibleDelegate.IsBound())
|
|
|
|
|
{
|
|
|
|
|
return DirectActions.IsActionVisibleDelegate.Execute() ? EVisibility::Visible : EVisibility::Collapsed;
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
return EVisibility::Visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EVisibility SToolBarButtonBlock::GetIconVisibility(bool bIsASmallIcon) const
|
|
|
|
|
{
|
|
|
|
|
return ((bForceSmallIcons || FMultiBoxSettings::UseSmallToolBarIcons.Get()) ^ bIsASmallIcon) ? EVisibility::Collapsed : EVisibility::Visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FSlateBrush* SToolBarButtonBlock::GetIconBrush() const
|
|
|
|
|
{
|
|
|
|
|
TSharedRef< const FToolBarButtonBlock > ToolBarButtonBlock = StaticCastSharedRef< const FToolBarButtonBlock >( MultiBlock.ToSharedRef() );
|
|
|
|
|
|
|
|
|
|
const FSlateIcon ActionIcon = ToolBarButtonBlock->GetAction().IsValid() ? ToolBarButtonBlock->GetAction()->GetIcon() : FSlateIcon();
|
|
|
|
|
const FSlateIcon& ActualIcon = ToolBarButtonBlock->IconOverride.IsSet() ? ToolBarButtonBlock->IconOverride.Get() : ActionIcon;
|
|
|
|
|
|
|
|
|
|
if( ActualIcon.IsSet() )
|
|
|
|
|
{
|
|
|
|
|
return ActualIcon.GetIcon();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
check( OwnerMultiBoxWidget.IsValid() );
|
|
|
|
|
|
|
|
|
|
TSharedPtr<SMultiBoxWidget> MultiBoxWidget = OwnerMultiBoxWidget.Pin();
|
|
|
|
|
const ISlateStyle* const StyleSet = MultiBoxWidget->GetStyleSet();
|
|
|
|
|
return StyleSet->GetBrush( "MultiBox.GenericToolBarIcon" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FSlateBrush* SToolBarButtonBlock::GetSmallIconBrush() const
|
|
|
|
|
{
|
|
|
|
|
TSharedRef< const FToolBarButtonBlock > ToolBarButtonBlock = StaticCastSharedRef< const FToolBarButtonBlock >( MultiBlock.ToSharedRef() );
|
|
|
|
|
|
|
|
|
|
const FSlateIcon ActionIcon = ToolBarButtonBlock->GetAction().IsValid() ? ToolBarButtonBlock->GetAction()->GetIcon() : FSlateIcon();
|
|
|
|
|
const FSlateIcon& ActualIcon = ToolBarButtonBlock->IconOverride.IsSet() ? ToolBarButtonBlock->IconOverride.Get() : ActionIcon;
|
|
|
|
|
|
|
|
|
|
if( ActualIcon.IsSet() )
|
|
|
|
|
{
|
|
|
|
|
return ActualIcon.GetSmallIcon();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
check( OwnerMultiBoxWidget.IsValid() );
|
|
|
|
|
|
|
|
|
|
TSharedPtr<SMultiBoxWidget> MultiBoxWidget = OwnerMultiBoxWidget.Pin();
|
|
|
|
|
const ISlateStyle* const StyleSet = MultiBoxWidget->GetStyleSet();
|
|
|
|
|
return StyleSet->GetBrush( "MultiBox.GenericToolBarIcon.Small" );
|
|
|
|
|
}
|
|
|
|
|
}
|