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
# include "SourcesViewWidgets.h"
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 "Widgets/Images/SImage.h"
# include "EditorStyleSet.h"
# include "EditorFontGlyphs.h"
# include "PathViewTypes.h"
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 "DragAndDrop/DecoratedDragDropOp.h"
2014-03-14 14:13:41 -04:00
# include "DragAndDrop/AssetDragDropOp.h"
# include "DragAndDrop/AssetPathDragDropOp.h"
2015-06-19 07:33:02 -04:00
# include "DragAndDrop/CollectionDragDropOp.h"
2015-02-09 11:42:01 -05:00
# include "DragDropHandler.h"
2014-03-14 14:13:41 -04:00
# include "ContentBrowserUtils.h"
2014-04-23 18:13:40 -04:00
# include "CollectionViewUtils.h"
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 "Widgets/Text/SInlineEditableTextBlock.h"
2014-03-14 14:13:41 -04:00
# define LOCTEXT_NAMESPACE "ContentBrowser"
//////////////////////////
// SAssetTreeItem
//////////////////////////
void SAssetTreeItem : : Construct ( const FArguments & InArgs )
{
TreeItem = InArgs . _TreeItem ;
OnNameChanged = InArgs . _OnNameChanged ;
OnVerifyNameChanged = InArgs . _OnVerifyNameChanged ;
OnAssetsDragDropped = InArgs . _OnAssetsDragDropped ;
OnPathsDragDropped = InArgs . _OnPathsDragDropped ;
OnFilesDragDropped = InArgs . _OnFilesDragDropped ;
IsItemExpanded = InArgs . _IsItemExpanded ;
bDraggedOver = false ;
FolderOpenBrush = FEditorStyle : : GetBrush ( " ContentBrowser.AssetTreeFolderOpen " ) ;
FolderClosedBrush = FEditorStyle : : GetBrush ( " ContentBrowser.AssetTreeFolderClosed " ) ;
2015-01-26 20:22:53 -05:00
FolderOpenCodeBrush = FEditorStyle : : GetBrush ( " ContentBrowser.AssetTreeFolderOpenCode " ) ;
FolderClosedCodeBrush = FEditorStyle : : GetBrush ( " ContentBrowser.AssetTreeFolderClosedCode " ) ;
2014-03-14 14:13:41 -04:00
FolderDeveloperBrush = FEditorStyle : : GetBrush ( " ContentBrowser.AssetTreeFolderDeveloper " ) ;
2015-01-26 20:22:53 -05:00
FolderType = EFolderType : : Normal ;
if ( ContentBrowserUtils : : IsDevelopersFolder ( InArgs . _TreeItem - > FolderPath ) )
{
FolderType = EFolderType : : Developer ;
}
else if ( ContentBrowserUtils : : IsClassPath /*IsClassRootDir*/ ( InArgs . _TreeItem - > FolderPath ) )
{
FolderType = EFolderType : : Code ;
}
2014-03-14 14:13:41 -04:00
bool bIsRoot = ! InArgs . _TreeItem - > Parent . IsValid ( ) ;
ChildSlot
[
SNew ( SBorder )
. BorderImage ( this , & SAssetTreeItem : : GetBorderImage )
. Padding ( FMargin ( 0 , bIsRoot ? 3 : 0 , 0 , 0 ) ) // For root items in the tree, give them a little breathing room on the top
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. Padding ( 0 , 0 , 2 , 0 )
. VAlign ( VAlign_Center )
[
// Folder Icon
SNew ( SImage )
. Image ( this , & SAssetTreeItem : : GetFolderIcon )
. ColorAndOpacity ( this , & SAssetTreeItem : : GetFolderColor )
]
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
[
SAssignNew ( InlineRenameWidget , SInlineEditableTextBlock )
. Text ( this , & SAssetTreeItem : : GetNameText )
2015-01-16 15:39:47 -05:00
. ToolTipText ( this , & SAssetTreeItem : : GetToolTipText )
2014-03-14 14:13:41 -04:00
. Font ( FEditorStyle : : GetFontStyle ( bIsRoot ? " ContentBrowser.SourceTreeRootItemFont " : " ContentBrowser.SourceTreeItemFont " ) )
. HighlightText ( InArgs . _HighlightText )
. OnTextCommitted ( this , & SAssetTreeItem : : HandleNameCommitted )
. OnVerifyTextChanged ( this , & SAssetTreeItem : : VerifyNameChanged )
. IsSelected ( InArgs . _IsSelected )
. IsReadOnly ( this , & SAssetTreeItem : : IsReadOnly )
]
]
] ;
if ( InlineRenameWidget . IsValid ( ) )
{
2015-01-08 09:29:27 -05:00
EnterEditingModeDelegateHandle = TreeItem . Pin ( ) - > OnRenamedRequestEvent . AddSP ( InlineRenameWidget . Get ( ) , & SInlineEditableTextBlock : : EnterEditingMode ) ;
2014-03-14 14:13:41 -04:00
}
}
SAssetTreeItem : : ~ SAssetTreeItem ( )
{
if ( InlineRenameWidget . IsValid ( ) )
{
2015-01-08 09:29:27 -05:00
TreeItem . Pin ( ) - > OnRenamedRequestEvent . Remove ( EnterEditingModeDelegateHandle ) ;
2014-03-14 14:13:41 -04:00
}
}
2015-06-19 07:33:02 -04:00
bool SAssetTreeItem : : ValidateDragDrop ( const FGeometry & MyGeometry , const FDragDropEvent & DragDropEvent , bool & OutIsKnownDragOperation ) const
2015-02-09 11:42:01 -05:00
{
2015-06-19 07:33:02 -04:00
OutIsKnownDragOperation = false ;
2015-02-09 11:42:01 -05:00
TSharedPtr < FTreeItem > TreeItemPinned = TreeItem . Pin ( ) ;
2015-06-19 07:33:02 -04:00
return TreeItemPinned . IsValid ( ) & & DragDropHandler : : ValidateDragDropOnAssetFolder ( MyGeometry , DragDropEvent , TreeItemPinned - > FolderPath , OutIsKnownDragOperation ) ;
2015-02-09 11:42:01 -05:00
}
2014-03-14 14:13:41 -04:00
void SAssetTreeItem : : OnDragEnter ( const FGeometry & MyGeometry , const FDragDropEvent & DragDropEvent )
{
2015-06-19 07:33:02 -04:00
ValidateDragDrop ( MyGeometry , DragDropEvent , bDraggedOver ) ; // updates bDraggedOver
2014-03-14 14:13:41 -04:00
}
void SAssetTreeItem : : OnDragLeave ( const FDragDropEvent & DragDropEvent )
{
2015-02-09 11:42:01 -05:00
TSharedPtr < FDragDropOperation > Operation = DragDropEvent . GetOperation ( ) ;
if ( Operation . IsValid ( ) )
2014-03-14 14:13:41 -04:00
{
2015-02-09 11:42:01 -05:00
Operation - > SetCursorOverride ( TOptional < EMouseCursor : : Type > ( ) ) ;
if ( Operation - > IsOfType < FAssetDragDropOp > ( ) )
{
TSharedPtr < FAssetDragDropOp > DragDropOp = StaticCastSharedPtr < FAssetDragDropOp > ( Operation ) ;
DragDropOp - > ResetToDefaultToolTip ( ) ;
}
2014-03-14 14:13:41 -04:00
}
2015-02-09 11:42:01 -05:00
2014-03-14 14:13:41 -04:00
bDraggedOver = false ;
}
FReply SAssetTreeItem : : OnDragOver ( const FGeometry & MyGeometry , const FDragDropEvent & DragDropEvent )
{
2015-06-19 07:33:02 -04:00
ValidateDragDrop ( MyGeometry , DragDropEvent , bDraggedOver ) ; // updates bDraggedOver
return ( bDraggedOver ) ? FReply : : Handled ( ) : FReply : : Unhandled ( ) ;
2014-03-14 14:13:41 -04:00
}
FReply SAssetTreeItem : : OnDrop ( const FGeometry & MyGeometry , const FDragDropEvent & DragDropEvent )
{
2015-06-19 07:33:02 -04:00
if ( ValidateDragDrop ( MyGeometry , DragDropEvent , bDraggedOver ) ) // updates bDraggedOver
2014-03-14 14:13:41 -04:00
{
2015-06-19 07:33:02 -04:00
bDraggedOver = false ;
2014-04-23 18:00:50 -04:00
TSharedPtr < FDragDropOperation > Operation = DragDropEvent . GetOperation ( ) ;
if ( ! Operation . IsValid ( ) )
{
return FReply : : Unhandled ( ) ;
}
if ( Operation - > IsOfType < FAssetDragDropOp > ( ) )
2014-03-14 14:13:41 -04:00
{
TSharedPtr < FAssetDragDropOp > DragDropOp = StaticCastSharedPtr < FAssetDragDropOp > ( DragDropEvent . GetOperation ( ) ) ;
OnAssetsDragDropped . ExecuteIfBound ( DragDropOp - > AssetData , TreeItem . Pin ( ) ) ;
return FReply : : Handled ( ) ;
}
2014-04-23 18:00:50 -04:00
else if ( Operation - > IsOfType < FAssetPathDragDropOp > ( ) )
2014-03-14 14:13:41 -04:00
{
TSharedPtr < FAssetPathDragDropOp > DragDropOp = StaticCastSharedPtr < FAssetPathDragDropOp > ( DragDropEvent . GetOperation ( ) ) ;
2015-02-09 11:42:01 -05:00
OnPathsDragDropped . ExecuteIfBound ( DragDropOp - > PathNames , TreeItem . Pin ( ) ) ;
2014-03-14 14:13:41 -04:00
return FReply : : Handled ( ) ;
}
2014-04-23 18:00:50 -04:00
else if ( Operation - > IsOfType < FExternalDragOperation > ( ) )
2014-03-14 14:13:41 -04:00
{
TSharedPtr < FExternalDragOperation > DragDropOp = StaticCastSharedPtr < FExternalDragOperation > ( DragDropEvent . GetOperation ( ) ) ;
2015-02-09 11:42:01 -05:00
OnFilesDragDropped . ExecuteIfBound ( DragDropOp - > GetFiles ( ) , TreeItem . Pin ( ) ) ;
2014-03-14 14:13:41 -04:00
return FReply : : Handled ( ) ;
}
}
2015-06-19 07:33:02 -04:00
if ( bDraggedOver )
{
// We were able to handle this operation, but could not due to another error - still report this drop as handled so it doesn't fall through to other widgets
bDraggedOver = false ;
return FReply : : Handled ( ) ;
}
2014-03-14 14:13:41 -04:00
return FReply : : Unhandled ( ) ;
}
void SAssetTreeItem : : Tick ( const FGeometry & AllottedGeometry , const double InCurrentTime , const float InDeltaTime )
{
LastGeometry = AllottedGeometry ;
}
bool SAssetTreeItem : : VerifyNameChanged ( const FText & InName , FText & OutError ) const
{
if ( TreeItem . IsValid ( ) )
{
TSharedPtr < FTreeItem > TreeItemPtr = TreeItem . Pin ( ) ;
if ( OnVerifyNameChanged . IsBound ( ) )
{
2015-07-28 18:21:55 -04:00
return OnVerifyNameChanged . Execute ( InName . ToString ( ) , OutError , TreeItemPtr - > FolderPath ) ;
2014-03-14 14:13:41 -04:00
}
}
return true ;
}
void SAssetTreeItem : : HandleNameCommitted ( const FText & NewText , ETextCommit : : Type /*CommitInfo*/ )
{
if ( TreeItem . IsValid ( ) )
{
TSharedPtr < FTreeItem > TreeItemPtr = TreeItem . Pin ( ) ;
2014-08-01 05:51:26 -04:00
if ( TreeItemPtr - > bNamingFolder )
2014-03-14 14:13:41 -04:00
{
2014-08-01 05:51:26 -04:00
TreeItemPtr - > bNamingFolder = false ;
2014-03-14 14:13:41 -04:00
2014-08-01 05:51:26 -04:00
const FString OldPath = TreeItemPtr - > FolderPath ;
2014-03-14 14:13:41 -04:00
FString Path ;
TreeItemPtr - > FolderPath . Split ( TEXT ( " / " ) , & Path , NULL , ESearchCase : : CaseSensitive , ESearchDir : : FromEnd ) ;
2015-01-16 15:39:47 -05:00
TreeItemPtr - > DisplayName = NewText ;
2014-03-14 14:13:41 -04:00
TreeItemPtr - > FolderName = NewText . ToString ( ) ;
TreeItemPtr - > FolderPath = Path + TEXT ( " / " ) + NewText . ToString ( ) ;
FVector2D MessageLoc ;
MessageLoc . X = LastGeometry . AbsolutePosition . X ;
MessageLoc . Y = LastGeometry . AbsolutePosition . Y + LastGeometry . Size . Y * LastGeometry . Scale ;
2014-08-01 05:51:26 -04:00
OnNameChanged . ExecuteIfBound ( TreeItemPtr , OldPath , MessageLoc ) ;
2014-03-14 14:13:41 -04:00
}
}
}
bool SAssetTreeItem : : IsReadOnly ( ) const
{
if ( TreeItem . IsValid ( ) )
{
2014-08-01 05:51:26 -04:00
return ! TreeItem . Pin ( ) - > bNamingFolder ;
2014-03-14 14:13:41 -04:00
}
else
{
return true ;
}
}
bool SAssetTreeItem : : IsValidAssetPath ( ) const
{
if ( TreeItem . IsValid ( ) )
{
// The classes folder is not a real path
2015-01-16 15:39:47 -05:00
return ! ContentBrowserUtils : : IsClassPath ( TreeItem . Pin ( ) - > FolderPath ) ;
2014-03-14 14:13:41 -04:00
}
else
{
return false ;
}
}
const FSlateBrush * SAssetTreeItem : : GetFolderIcon ( ) const
{
2015-01-26 20:22:53 -05:00
switch ( FolderType )
2014-03-14 14:13:41 -04:00
{
2015-01-26 20:22:53 -05:00
case EFolderType : : Code :
return ( IsItemExpanded . Get ( ) ) ? FolderOpenCodeBrush : FolderClosedCodeBrush ;
case EFolderType : : Developer :
2014-03-14 14:13:41 -04:00
return FolderDeveloperBrush ;
2015-01-26 20:22:53 -05:00
default :
return ( IsItemExpanded . Get ( ) ) ? FolderOpenBrush : FolderClosedBrush ;
2014-03-14 14:13:41 -04:00
}
}
FSlateColor SAssetTreeItem : : GetFolderColor ( ) const
{
if ( TreeItem . IsValid ( ) )
{
const TSharedPtr < FLinearColor > Color = ContentBrowserUtils : : LoadColor ( TreeItem . Pin ( ) - > FolderPath ) ;
if ( Color . IsValid ( ) )
{
return * Color . Get ( ) ;
}
}
return ContentBrowserUtils : : GetDefaultColor ( ) ;
}
FText SAssetTreeItem : : GetNameText ( ) const
{
2015-01-16 15:39:47 -05:00
TSharedPtr < FTreeItem > TreeItemPin = TreeItem . Pin ( ) ;
if ( TreeItemPin . IsValid ( ) )
2014-03-14 14:13:41 -04:00
{
2015-01-16 15:39:47 -05:00
return TreeItemPin - > DisplayName ;
}
else
{
return FText ( ) ;
}
}
FText SAssetTreeItem : : GetToolTipText ( ) const
{
TSharedPtr < FTreeItem > TreeItemPin = TreeItem . Pin ( ) ;
if ( TreeItemPin . IsValid ( ) )
{
return FText : : FromString ( TreeItemPin - > FolderPath ) ;
2014-03-14 14:13:41 -04:00
}
else
{
return FText ( ) ;
}
}
const FSlateBrush * SAssetTreeItem : : GetBorderImage ( ) const
{
return bDraggedOver ? FEditorStyle : : GetBrush ( " Menu.Background " ) : FEditorStyle : : GetBrush ( " NoBorder " ) ;
}
//////////////////////////
2015-06-19 07:33:02 -04:00
// SCollectionTreeItem
2014-03-14 14:13:41 -04:00
//////////////////////////
2015-06-19 07:33:02 -04:00
void SCollectionTreeItem : : Construct ( const FArguments & InArgs )
2014-03-14 14:13:41 -04:00
{
ParentWidget = InArgs . _ParentWidget ;
CollectionItem = InArgs . _CollectionItem ;
OnBeginNameChange = InArgs . _OnBeginNameChange ;
OnNameChangeCommit = InArgs . _OnNameChangeCommit ;
OnVerifyRenameCommit = InArgs . _OnVerifyRenameCommit ;
2015-06-19 07:33:02 -04:00
OnValidateDragDrop = InArgs . _OnValidateDragDrop ;
OnHandleDragDrop = InArgs . _OnHandleDragDrop ;
2014-03-14 14:13:41 -04:00
bDraggedOver = false ;
ChildSlot
[
SNew ( SBorder )
2015-06-19 07:33:02 -04:00
. BorderImage ( this , & SCollectionTreeItem : : GetBorderImage )
2014-03-14 14:13:41 -04:00
. Padding ( 0 )
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
2015-05-29 13:15:40 -04:00
. Padding ( 0 , 0 , 2 , 0 )
[
SNew ( SCheckBox )
. Visibility ( InArgs . _IsCollectionChecked . IsSet ( ) ? EVisibility : : Visible : EVisibility : : Collapsed )
. IsEnabled ( InArgs . _IsCheckBoxEnabled )
. IsChecked ( InArgs . _IsCollectionChecked )
. OnCheckStateChanged ( InArgs . _OnCollectionCheckStateChanged )
]
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
. Padding ( 0 , 0 , 2 , 0 )
2014-03-14 14:13:41 -04:00
[
2015-07-09 09:59:51 -04:00
// Share Type Icon
2014-03-14 14:13:41 -04:00
SNew ( SImage )
2015-05-29 13:15:40 -04:00
. Image ( FEditorStyle : : GetBrush ( ECollectionShareType : : GetIconStyleName ( InArgs . _CollectionItem - > CollectionType ) ) )
2015-06-19 07:33:02 -04:00
. ColorAndOpacity ( this , & SCollectionTreeItem : : GetCollectionColor )
2015-07-09 09:59:51 -04:00
. ToolTipText ( ECollectionShareType : : GetDescription ( InArgs . _CollectionItem - > CollectionType ) )
2014-03-14 14:13:41 -04:00
]
+ SHorizontalBox : : Slot ( )
[
SAssignNew ( InlineRenameWidget , SInlineEditableTextBlock )
2015-06-19 07:33:02 -04:00
. Text ( this , & SCollectionTreeItem : : GetNameText )
2015-05-29 13:15:40 -04:00
. HighlightText ( InArgs . _HighlightText )
. Font ( FEditorStyle : : GetFontStyle ( " ContentBrowser.SourceListItemFont " ) )
2015-06-19 07:33:02 -04:00
. OnBeginTextEdit ( this , & SCollectionTreeItem : : HandleBeginNameChange )
. OnTextCommitted ( this , & SCollectionTreeItem : : HandleNameCommitted )
. OnVerifyTextChanged ( this , & SCollectionTreeItem : : HandleVerifyNameChanged )
2015-05-29 13:15:40 -04:00
. IsSelected ( InArgs . _IsSelected )
. IsReadOnly ( InArgs . _IsReadOnly )
2014-03-14 14:13:41 -04:00
]
2015-07-03 13:54:34 -04:00
2015-07-09 09:59:51 -04:00
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. Padding ( 2 , 0 , 3 , 0 )
[
// Storage Mode Icon
SNew ( SBox )
. WidthOverride ( 16 )
. HeightOverride ( 16 )
. VAlign ( VAlign_Center )
. HAlign ( HAlign_Center )
[
SNew ( STextBlock )
. Font ( FEditorStyle : : Get ( ) . GetFontStyle ( " FontAwesome.10 " ) )
. Text ( this , & SCollectionTreeItem : : GetCollectionStorageModeIconText )
. ColorAndOpacity ( FLinearColor : : Gray )
. ToolTipText ( this , & SCollectionTreeItem : : GetCollectionStorageModeToolTipText )
]
]
2015-07-03 13:54:34 -04:00
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
. Padding ( 2 , 0 , 2 , 0 )
[
SNew ( SImage )
. Image ( FEditorStyle : : GetBrush ( " ContentBrowser.CollectionStatus " ) )
. ColorAndOpacity ( this , & SCollectionTreeItem : : GetCollectionStatusColor )
. ToolTipText ( this , & SCollectionTreeItem : : GetCollectionStatusToolTipText )
]
2014-03-14 14:13:41 -04:00
]
] ;
if ( InlineRenameWidget . IsValid ( ) )
{
// This is broadcast when the context menu / input binding requests a rename
2015-01-08 09:29:27 -05:00
EnterEditingModeDelegateHandle = CollectionItem . Pin ( ) - > OnRenamedRequestEvent . AddSP ( InlineRenameWidget . Get ( ) , & SInlineEditableTextBlock : : EnterEditingMode ) ;
2014-03-14 14:13:41 -04:00
}
}
2015-06-19 07:33:02 -04:00
SCollectionTreeItem : : ~ SCollectionTreeItem ( )
2014-03-14 14:13:41 -04:00
{
if ( InlineRenameWidget . IsValid ( ) )
{
2015-01-08 09:29:27 -05:00
CollectionItem . Pin ( ) - > OnRenamedRequestEvent . Remove ( EnterEditingModeDelegateHandle ) ;
2014-03-14 14:13:41 -04:00
}
}
2015-06-19 07:33:02 -04:00
void SCollectionTreeItem : : Tick ( const FGeometry & AllottedGeometry , const double InCurrentTime , const float InDeltaTime )
2014-03-14 14:13:41 -04:00
{
// Cache this widget's geometry so it can pop up warnings over itself
CachedGeometry = AllottedGeometry ;
}
2015-06-19 07:33:02 -04:00
bool SCollectionTreeItem : : ValidateDragDrop ( const FGeometry & MyGeometry , const FDragDropEvent & DragDropEvent , bool & OutIsKnownDragOperation ) const
2014-03-14 14:13:41 -04:00
{
2015-06-19 07:33:02 -04:00
OutIsKnownDragOperation = false ;
2014-03-14 14:13:41 -04:00
2015-06-19 07:33:02 -04:00
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( OnValidateDragDrop . IsBound ( ) & & CollectionItemPtr . IsValid ( ) )
{
return OnValidateDragDrop . Execute ( CollectionItemPtr . ToSharedRef ( ) , MyGeometry , DragDropEvent , OutIsKnownDragOperation ) ;
2014-03-14 14:13:41 -04:00
}
2015-06-19 07:33:02 -04:00
return false ;
2014-03-14 14:13:41 -04:00
}
2015-06-19 07:33:02 -04:00
void SCollectionTreeItem : : OnDragEnter ( const FGeometry & MyGeometry , const FDragDropEvent & DragDropEvent )
2014-03-14 14:13:41 -04:00
{
2015-06-19 07:33:02 -04:00
ValidateDragDrop ( MyGeometry , DragDropEvent , bDraggedOver ) ; // updates bDraggedOver
2014-03-14 14:13:41 -04:00
}
2015-06-19 07:33:02 -04:00
void SCollectionTreeItem : : OnDragLeave ( const FDragDropEvent & DragDropEvent )
2014-03-14 14:13:41 -04:00
{
2015-06-19 07:33:02 -04:00
TSharedPtr < FDragDropOperation > Operation = DragDropEvent . GetOperation ( ) ;
if ( Operation . IsValid ( ) )
2014-03-14 14:13:41 -04:00
{
2015-06-19 07:33:02 -04:00
Operation - > SetCursorOverride ( TOptional < EMouseCursor : : Type > ( ) ) ;
2014-03-14 14:13:41 -04:00
2015-06-19 07:33:02 -04:00
if ( Operation - > IsOfType < FCollectionDragDropOp > ( ) | | Operation - > IsOfType < FAssetDragDropOp > ( ) )
2014-03-14 14:13:41 -04:00
{
2015-06-19 07:33:02 -04:00
TSharedPtr < FDecoratedDragDropOp > DragDropOp = StaticCastSharedPtr < FDecoratedDragDropOp > ( Operation ) ;
DragDropOp - > ResetToDefaultToolTip ( ) ;
2014-03-14 14:13:41 -04:00
}
}
2015-06-19 07:33:02 -04:00
bDraggedOver = false ;
2014-03-14 14:13:41 -04:00
}
2015-06-19 07:33:02 -04:00
FReply SCollectionTreeItem : : OnDragOver ( const FGeometry & MyGeometry , const FDragDropEvent & DragDropEvent )
2014-03-14 14:13:41 -04:00
{
2015-06-19 07:33:02 -04:00
ValidateDragDrop ( MyGeometry , DragDropEvent , bDraggedOver ) ; // updates bDraggedOver
return ( bDraggedOver ) ? FReply : : Handled ( ) : FReply : : Unhandled ( ) ;
}
2014-03-14 14:13:41 -04:00
2015-06-19 07:33:02 -04:00
FReply SCollectionTreeItem : : OnDrop ( const FGeometry & MyGeometry , const FDragDropEvent & DragDropEvent )
{
if ( ValidateDragDrop ( MyGeometry , DragDropEvent , bDraggedOver ) & & OnHandleDragDrop . IsBound ( ) ) // updates bDraggedOver
2014-03-14 14:13:41 -04:00
{
2015-06-19 07:33:02 -04:00
bDraggedOver = false ;
return OnHandleDragDrop . Execute ( CollectionItem . Pin ( ) . ToSharedRef ( ) , MyGeometry , DragDropEvent ) ;
}
2014-03-14 14:13:41 -04:00
2015-06-19 07:33:02 -04:00
if ( bDraggedOver )
{
// We were able to handle this operation, but could not due to another error - still report this drop as handled so it doesn't fall through to other widgets
bDraggedOver = false ;
2014-03-14 14:13:41 -04:00
return FReply : : Handled ( ) ;
}
return FReply : : Unhandled ( ) ;
}
2015-06-19 07:33:02 -04:00
void SCollectionTreeItem : : HandleBeginNameChange ( const FText & OldText )
2014-03-14 14:13:41 -04:00
{
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( CollectionItemPtr . IsValid ( ) )
{
// If we get here via a context menu or input binding, bRenaming will already be set on the item.
// If we got here by double clicking the editable text field, we need to set it now.
CollectionItemPtr - > bRenaming = true ;
OnBeginNameChange . ExecuteIfBound ( CollectionItemPtr ) ;
}
}
2015-06-19 07:33:02 -04:00
void SCollectionTreeItem : : HandleNameCommitted ( const FText & NewText , ETextCommit : : Type CommitInfo )
2014-03-14 14:13:41 -04:00
{
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( CollectionItemPtr . IsValid ( ) )
{
if ( CollectionItemPtr - > bRenaming )
{
CollectionItemPtr - > bRenaming = false ;
if ( OnNameChangeCommit . IsBound ( ) )
{
FText WarningMessage ;
bool bIsCommitted = ( CommitInfo ! = ETextCommit : : OnCleared ) ;
if ( ! OnNameChangeCommit . Execute ( CollectionItemPtr , NewText . ToString ( ) , bIsCommitted , WarningMessage ) & & ParentWidget . IsValid ( ) & & bIsCommitted )
{
// Failed to rename/create a collection, display a warning.
ContentBrowserUtils : : DisplayMessage ( WarningMessage , CachedGeometry . GetClippingRect ( ) , ParentWidget . ToSharedRef ( ) ) ;
}
}
}
}
}
2015-06-19 07:33:02 -04:00
bool SCollectionTreeItem : : HandleVerifyNameChanged ( const FText & NewText , FText & OutErrorMessage )
2014-03-14 14:13:41 -04:00
{
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( CollectionItemPtr . IsValid ( ) )
{
return ! OnVerifyRenameCommit . IsBound ( ) | | OnVerifyRenameCommit . Execute ( CollectionItemPtr , NewText . ToString ( ) , CachedGeometry . GetClippingRect ( ) , OutErrorMessage ) ;
}
return true ;
}
2015-06-19 07:33:02 -04:00
FText SCollectionTreeItem : : GetNameText ( ) const
2014-03-14 14:13:41 -04:00
{
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( CollectionItemPtr . IsValid ( ) )
{
2015-06-01 09:29:31 -04:00
return FText : : FromName ( CollectionItemPtr - > CollectionName ) ;
2014-03-14 14:13:41 -04:00
}
else
{
return FText ( ) ;
}
}
2015-06-19 07:33:02 -04:00
FSlateColor SCollectionTreeItem : : GetCollectionColor ( ) const
2014-04-23 18:13:40 -04:00
{
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( CollectionItemPtr . IsValid ( ) )
{
2015-06-01 09:29:31 -04:00
const TSharedPtr < FLinearColor > Color = CollectionViewUtils : : LoadColor ( CollectionItemPtr - > CollectionName . ToString ( ) , CollectionItemPtr - > CollectionType ) ;
2014-04-23 18:13:40 -04:00
if ( Color . IsValid ( ) )
{
return * Color . Get ( ) ;
}
}
return CollectionViewUtils : : GetDefaultColor ( ) ;
}
2015-06-19 07:33:02 -04:00
const FSlateBrush * SCollectionTreeItem : : GetBorderImage ( ) const
2014-03-14 14:13:41 -04:00
{
return bDraggedOver ? FEditorStyle : : GetBrush ( " Menu.Background " ) : FEditorStyle : : GetBrush ( " NoBorder " ) ;
}
2015-07-09 09:59:51 -04:00
FText SCollectionTreeItem : : GetCollectionStorageModeIconText ( ) const
{
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( CollectionItemPtr . IsValid ( ) )
{
switch ( CollectionItemPtr - > StorageMode )
{
case ECollectionStorageMode : : Static :
return FEditorFontGlyphs : : List_Alt ;
case ECollectionStorageMode : : Dynamic :
return FEditorFontGlyphs : : Bolt ;
default :
break ;
}
}
return FText : : GetEmpty ( ) ;
}
FText SCollectionTreeItem : : GetCollectionStorageModeToolTipText ( ) const
{
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( CollectionItemPtr . IsValid ( ) )
{
return ECollectionStorageMode : : GetDescription ( CollectionItemPtr - > StorageMode ) ;
}
return FText : : GetEmpty ( ) ;
}
2015-07-03 13:54:34 -04:00
FSlateColor SCollectionTreeItem : : GetCollectionStatusColor ( ) const
{
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( CollectionItemPtr . IsValid ( ) )
{
switch ( CollectionItemPtr - > CurrentStatus )
{
case ECollectionItemStatus : : IsUpToDateAndPopulated :
return FLinearColor ( 0.10616 , 0.48777 , 0.10616 ) ; // Green
case ECollectionItemStatus : : IsUpToDateAndEmpty :
return FLinearColor : : Gray ;
case ECollectionItemStatus : : IsOutOfDate :
return FLinearColor ( 0.87514 , 0.42591 , 0.07383 ) ; // Orange
case ECollectionItemStatus : : IsCheckedOutByAnotherUser :
case ECollectionItemStatus : : IsConflicted :
case ECollectionItemStatus : : IsMissingSCCProvider :
return FLinearColor ( 0.70117 , 0.08464 , 0.07593 ) ; // Red
case ECollectionItemStatus : : HasLocalChanges :
return FLinearColor ( 0.10363 , 0.53564 , 0.7372 ) ; // Blue
default :
break ;
}
}
return FLinearColor : : White ;
}
FText SCollectionTreeItem : : GetCollectionStatusToolTipText ( ) const
{
TSharedPtr < FCollectionItem > CollectionItemPtr = CollectionItem . Pin ( ) ;
if ( CollectionItemPtr . IsValid ( ) )
{
switch ( CollectionItemPtr - > CurrentStatus )
{
case ECollectionItemStatus : : IsUpToDateAndPopulated :
return LOCTEXT ( " CollectionStatus_IsUpToDateAndPopulated " , " Collection is up-to-date " ) ;
case ECollectionItemStatus : : IsUpToDateAndEmpty :
return LOCTEXT ( " CollectionStatus_IsUpToDateAndEmpty " , " Collection is empty " ) ;
case ECollectionItemStatus : : IsOutOfDate :
return LOCTEXT ( " CollectionStatus_IsOutOfDate " , " Collection is not at the latest revision " ) ;
case ECollectionItemStatus : : IsCheckedOutByAnotherUser :
return LOCTEXT ( " CollectionStatus_IsCheckedOutByAnotherUser " , " Collection is checked out by another user " ) ;
case ECollectionItemStatus : : IsConflicted :
return LOCTEXT ( " CollectionStatus_IsConflicted " , " Collection is conflicted - please use your external source control provider to resolve this conflict " ) ;
case ECollectionItemStatus : : IsMissingSCCProvider :
return LOCTEXT ( " CollectionStatus_IsMissingSCCProvider " , " Collection is missing its source control provider - please check your source control settings " ) ;
case ECollectionItemStatus : : HasLocalChanges :
return LOCTEXT ( " CollectionStatus_HasLocalChanges " , " Collection has local unsaved or uncomitted changes " ) ;
default :
break ;
}
}
return FText : : GetEmpty ( ) ;
}
2014-03-14 14:13:41 -04:00
# undef LOCTEXT_NAMESPACE