Files
UnrealEngineUWP/Engine/Source/Runtime/Slate/Public/Framework/MultiBox/SToolBarButtonBlock.h

182 lines
5.9 KiB
C
Raw Normal View History

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
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 "CoreMinimal.h"
#include "Misc/Attribute.h"
#include "Layout/Visibility.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Input/Reply.h"
#include "Textures/SlateIcon.h"
#include "Framework/Commands/UICommandInfo.h"
#include "Framework/Commands/UICommandList.h"
#include "Framework/MultiBox/MultiBox.h"
/**
* Tool bar button MultiBlock
*/
class SLATE_API FToolBarButtonBlock
: public FMultiBlock
{
public:
/**
* Constructor
*
* @param InCommand The command associated with this tool bar button
* @param InCommandList The list of commands that are mapped to delegates so that we know what to execute for this button
* @param InLabelOverride Optional label override. If omitted, then the action's label will be used instead.
* @param InToolTipOverride Optional tool tip override. If omitted, then the action's label will be used instead.
* @param InIconOverride Optional icon to use for the tool bar image. If omitted, then the action's icon will be used instead.
*/
FToolBarButtonBlock( const TSharedPtr< const FUICommandInfo > InCommand, TSharedPtr< const FUICommandList > InCommandList, const TAttribute<FText>& InLabelOverride = TAttribute<FText>(), const TAttribute<FText>& InToolTipOverride = TAttribute<FText>(), const TAttribute<FSlateIcon>& InIconOverride = TAttribute<FSlateIcon>() );
/**
* Constructor
*
* @param InLabel The label to display in the menu
* @param InToolTip The tool tip to display when the menu entry is hovered over
* @param InIcon The icon to display to the left of the label
* @param InUIAction UI action to take when this menu item is clicked as well as to determine if the menu entry can be executed or appears "checked"
* @param InUserInterfaceActionType Type of interface action
*/
FToolBarButtonBlock( const TAttribute<FText>& InLabel, const TAttribute<FText>& InToolTip, const TAttribute<FSlateIcon>& InIcon, const FUIAction& InUIAction, const EUserInterfaceActionType::Type InUserInterfaceActionType );
void SetLabelVisibility( EVisibility InLabelVisibility ) { LabelVisibility = InLabelVisibility ; }
void SetIsFocusable( bool bInIsFocusable ) { bIsFocusable = bInIsFocusable; }
/** Set whether this toolbar should always use small icons, regardless of the current settings */
void SetForceSmallIcons( const bool InForceSmallIcons ) { bForceSmallIcons = InForceSmallIcons; }
/** FMultiBlock interface */
virtual void CreateMenuEntry(class FMenuBuilder& MenuBuilder) const override;
virtual bool HasIcon() const override;
private:
/** FMultiBlock private interface */
virtual TSharedRef< class IMultiBlockBaseWidget > ConstructWidget() const override;
private:
// Friend our corresponding widget class
friend class SToolBarButtonBlock;
/** Optional overridden text label for this tool bar button. If not set, then the action's label will be used instead. */
TAttribute<FText> LabelOverride;
/** Optional overridden tool tip for this tool bar button. If not set, then the action's tool tip will be used instead. */
TAttribute<FText> ToolTipOverride;
/** Optional overridden icon for this tool bar button. IF not set, then the action's icon will be used instead. */
TAttribute<FSlateIcon> IconOverride;
TOptional< EVisibility > LabelVisibility;
/** In the case where a command is not bound, the user interface action type to use. If a command is bound, we
simply use the action type associated with that command. */
EUserInterfaceActionType::Type UserInterfaceActionType;
/** Whether ToolBar will have Focusable buttons */
bool bIsFocusable;
/** Whether this toolbar should always use small icons, regardless of the current settings */
bool bForceSmallIcons;
};
/**
* Tool bar button MultiBlock widget
*/
class SLATE_API SToolBarButtonBlock
: public SMultiBlockBaseWidget
{
public:
SLATE_BEGIN_ARGS( SToolBarButtonBlock )
: _IsFocusable(false)
, _ForceSmallIcons(false)
, _TutorialHighlightName(NAME_None)
{}
SLATE_ARGUMENT( TOptional< EVisibility >, LabelVisibility )
SLATE_ARGUMENT( bool, IsFocusable )
SLATE_ARGUMENT( bool, ForceSmallIcons )
SLATE_ARGUMENT( FName, TutorialHighlightName )
SLATE_END_ARGS()
/**
* Builds this MultiBlock widget up from the MultiBlock associated with it
*/
virtual void BuildMultiBlockWidget(const ISlateStyle* StyleSet, const FName& StyleName) override;
/**
* Construct this widget
*
* @param InArgs The declaration data for this widget
*/
void Construct( const FArguments& InArgs );
protected:
/**
* Called by Slate when this tool bar button's button is clicked
*/
FReply OnClicked();
/**
* Called by Slate when this tool bar check box button is toggled
*/
void OnCheckStateChanged( const ECheckBoxState NewCheckedState );
/**
* Called by slate to determine if this button should appear checked
*
* @return ECheckBoxState::Checked if it should be checked, ECheckBoxState::Unchecked if not.
*/
ECheckBoxState OnIsChecked() const;
/**
* Called by Slate to determine if this button is enabled
*
* @return True if the menu entry is enabled, false otherwise
*/
bool IsEnabled() const;
/**
* 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 GetBlockVisibility() const;
private:
/** Called by Slate to determine whether icons/labels are visible */
EVisibility GetIconVisibility(bool bIsASmallIcon) const;
/** Gets the icon brush for the toolbar block widget */
const FSlateBrush* GetIconBrush() const;
const FSlateBrush* GetSmallIconBrush() const;
private:
TAttribute< EVisibility > LabelVisibility;
/** Whether ToolBar will have Focusable buttons. */
bool bIsFocusable;
/** Whether this toolbar should always use small icons, regardless of the current settings */
bool bForceSmallIcons;
/** Name to identify a widget for tutorials */
FName TutorialHighlightName;
};