2019-12-26 14:45:42 -05:00
|
|
|
// Copyright 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/SEditableTextBlock.h"
|
|
|
|
|
#include "Widgets/SBoxPanel.h"
|
|
|
|
|
#include "Widgets/Layout/SSpacer.h"
|
|
|
|
|
#include "Widgets/Images/SImage.h"
|
|
|
|
|
#include "Widgets/Layout/SBox.h"
|
|
|
|
|
#include "Widgets/Input/SEditableTextBox.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
|
2022-03-31 11:55:06 -04:00
|
|
|
FEditableTextBlock::FEditableTextBlock( const FText& InLabel, const FText& InToolTip, const FSlateIcon& InIcon, const TAttribute< FText >& InTextAttribute, bool bInReadOnly, const FOnTextCommitted& InOnTextCommitted, const FOnTextChanged& InOnTextChanged, const FOnVerifyTextChanged& InOnVerifyTextChanged )
|
2014-07-23 09:04:48 -04:00
|
|
|
: FMultiBlock( FUIAction(), NAME_None, EMultiBlockType::EditableText ),
|
2014-03-14 14:13:41 -04:00
|
|
|
LabelOverride( InLabel ),
|
|
|
|
|
ToolTipOverride( InToolTip ),
|
|
|
|
|
IconOverride( InIcon ),
|
|
|
|
|
TextAttribute( InTextAttribute ),
|
|
|
|
|
OnTextCommitted( InOnTextCommitted ),
|
|
|
|
|
OnTextChanged( InOnTextChanged ),
|
2022-03-31 11:55:06 -04:00
|
|
|
OnVerifyTextChanged( InOnVerifyTextChanged ),
|
2014-03-14 14:13:41 -04:00
|
|
|
bReadOnly( bInReadOnly )
|
2014-04-26 23:13:43 -04:00
|
|
|
{ }
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-11-20 19:21:21 -05:00
|
|
|
bool FEditableTextBlock::HasIcon() const
|
|
|
|
|
{
|
|
|
|
|
const TSharedPtr< const FUICommandInfo >& UICommand = GetAction();
|
|
|
|
|
const FSlateIcon ActionIcon = UICommand.IsValid() ? UICommand->GetIcon() : FSlateIcon();
|
|
|
|
|
|
|
|
|
|
const FSlateIcon& ActualIcon = !IconOverride.IsSet() ? ActionIcon : IconOverride;
|
|
|
|
|
|
|
|
|
|
if (ActualIcon.IsSet())
|
|
|
|
|
{
|
|
|
|
|
const FSlateBrush* IconBrush = ActualIcon.GetIcon();
|
|
|
|
|
return (IconBrush->GetResourceName() != NAME_None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-04-26 23:13:43 -04:00
|
|
|
TSharedRef<class IMultiBlockBaseWidget> FEditableTextBlock::ConstructWidget() const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
return SNew( SEditableTextBlock )
|
2014-04-26 23:13:43 -04:00
|
|
|
.Cursor(EMouseCursor::Default);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-04-26 23:13:43 -04:00
|
|
|
void SEditableTextBlock::BuildMultiBlockWidget( const ISlateStyle* StyleSet, const FName& StyleName )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
TSharedPtr< const FMultiBox > MultiBox = OwnerMultiBoxWidget.Pin()->GetMultiBox();
|
|
|
|
|
TSharedPtr< const FEditableTextBlock > EditableTextBlock = StaticCastSharedRef< const FEditableTextBlock >( MultiBlock.ToSharedRef() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tool tips are optional so if the tool tip override is empty and there is no UI command just use the empty tool tip.
|
|
|
|
|
const TSharedPtr< const FUICommandInfo >& UICommand = EditableTextBlock->GetAction();
|
|
|
|
|
|
|
|
|
|
const TAttribute<FText>& Label = !EditableTextBlock->LabelOverride.IsBound() && EditableTextBlock->LabelOverride.Get().IsEmpty() && UICommand.IsValid() ? UICommand->GetLabel() : EditableTextBlock->LabelOverride;
|
2015-07-08 04:48:54 -04:00
|
|
|
const TAttribute<FText>& TextBlockToolTip = !EditableTextBlock->ToolTipOverride.IsBound() && EditableTextBlock->ToolTipOverride.Get().IsEmpty() && UICommand.IsValid() ? UICommand->GetDescription() : EditableTextBlock->ToolTipOverride;
|
2014-03-14 14:13:41 -04:00
|
|
|
const bool bHasLabel = !Label.Get().IsEmpty();
|
|
|
|
|
|
2015-08-26 10:33:13 -04:00
|
|
|
// Add this widget to the search list of the multibox
|
2020-08-11 01:36:57 -04:00
|
|
|
OwnerMultiBoxWidget.Pin()->AddElement(this->AsWidget(), Label.Get(), MultiBlock->GetSearchable());
|
2015-08-26 10:33:13 -04:00
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
// See if the action is valid and if so we will use the actions icon if we dont override it later
|
|
|
|
|
const FSlateIcon ActionIcon = UICommand.IsValid() ? UICommand->GetIcon() : FSlateIcon();
|
|
|
|
|
|
|
|
|
|
// Allow the block to override the tool bar icon, too
|
|
|
|
|
const FSlateIcon& ActualIcon = !EditableTextBlock->IconOverride.IsSet() ? ActionIcon : EditableTextBlock->IconOverride;
|
|
|
|
|
|
|
|
|
|
// If we were supplied an image than go ahead and use that, otherwise we use a null widget
|
|
|
|
|
TSharedRef< SWidget > IconWidget = SNullWidget::NullWidget;
|
|
|
|
|
if( ActualIcon.IsSet() )
|
|
|
|
|
{
|
|
|
|
|
const FSlateBrush* IconBrush = ActualIcon.GetIcon();
|
|
|
|
|
if( IconBrush->GetResourceName() != NAME_None )
|
|
|
|
|
{
|
2014-04-26 23:13:43 -04:00
|
|
|
IconWidget = SNew( SImage )
|
2014-03-14 14:13:41 -04:00
|
|
|
.Image( IconBrush );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-11 01:36:57 -04:00
|
|
|
const float MenuIconSize = StyleSet->GetFloat(StyleName, ".MenuIconSize", 16.f);
|
|
|
|
|
|
2014-07-28 06:53:40 -04:00
|
|
|
ChildSlot
|
|
|
|
|
[
|
2014-03-14 14:13:41 -04:00
|
|
|
SNew( SHorizontalBox )
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
SNew(SSpacer)
|
2020-08-11 01:36:57 -04:00
|
|
|
.Size( FVector2D(MenuIconSize + 3, MenuIconSize) )
|
2014-03-14 14:13:41 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
SNew( SBox )
|
|
|
|
|
.Visibility(IconWidget != SNullWidget::NullWidget ? EVisibility::Visible : EVisibility::Collapsed)
|
2020-08-11 01:36:57 -04:00
|
|
|
.WidthOverride(MenuIconSize + 2 )
|
|
|
|
|
.HeightOverride(MenuIconSize)
|
2014-03-14 14:13:41 -04:00
|
|
|
.HAlign(HAlign_Center)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SNew( SBox )
|
2020-08-11 01:36:57 -04:00
|
|
|
.WidthOverride(MenuIconSize)
|
|
|
|
|
.HeightOverride(MenuIconSize)
|
2014-03-14 14:13:41 -04:00
|
|
|
[
|
|
|
|
|
IconWidget
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
SNew( SBox )
|
|
|
|
|
.Visibility(bHasLabel ? EVisibility::Visible : EVisibility::Collapsed)
|
|
|
|
|
.Padding(FMargin(1, 0, 10, 0))
|
|
|
|
|
.VAlign( VAlign_Center )
|
|
|
|
|
[
|
|
|
|
|
SNew( STextBlock )
|
|
|
|
|
.TextStyle( StyleSet, ISlateStyle::Join(StyleName, ".Label") )
|
|
|
|
|
.Text( Label )
|
2015-07-08 04:48:54 -04:00
|
|
|
.ToolTipText( TextBlockToolTip )
|
2014-03-14 14:13:41 -04:00
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
+SHorizontalBox::Slot()
|
|
|
|
|
.HAlign( HAlign_Fill )
|
|
|
|
|
.FillWidth( 1.0f )
|
|
|
|
|
.Padding( FMargin( 2.0f, 1.0f ) )
|
|
|
|
|
[
|
|
|
|
|
SNew( SEditableTextBox )
|
|
|
|
|
.Style( StyleSet, ISlateStyle::Join(StyleName, ".EditableText") )
|
|
|
|
|
.Text( EditableTextBlock->TextAttribute )
|
|
|
|
|
.IsReadOnly( EditableTextBlock->bReadOnly )
|
|
|
|
|
.SelectAllTextWhenFocused( true )
|
|
|
|
|
.RevertTextOnEscape( true )
|
|
|
|
|
.MinDesiredWidth( MultiBoxConstants::EditableTextMinWidth )
|
|
|
|
|
.OnTextChanged( EditableTextBlock->OnTextChanged )
|
2022-03-31 11:55:06 -04:00
|
|
|
.OnVerifyTextChanged( EditableTextBlock->OnVerifyTextChanged )
|
2014-03-14 14:13:41 -04:00
|
|
|
.OnTextCommitted( EditableTextBlock->OnTextCommitted )
|
2015-07-08 04:48:54 -04:00
|
|
|
.ToolTipText( TextBlockToolTip )
|
2014-07-28 06:53:40 -04:00
|
|
|
]
|
|
|
|
|
];
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
// Bind our widget's enabled state to whether or not our action can execute
|
|
|
|
|
SetEnabled( TAttribute<bool>( this, &SEditableTextBlock::IsEnabled ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool SEditableTextBlock::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;
|
|
|
|
|
}
|