2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "ContentBrowserPCH.h"
|
|
|
|
|
#include "PathViewTypes.h"
|
|
|
|
|
#include "CollectionViewTypes.h"
|
|
|
|
|
#include "SourcesViewWidgets.h"
|
|
|
|
|
|
|
|
|
|
#include "DragAndDrop/AssetDragDropOp.h"
|
|
|
|
|
#include "DragAndDrop/AssetPathDragDropOp.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"
|
2014-10-14 22:50:06 -04:00
|
|
|
#include "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-02-09 11:42:01 -05:00
|
|
|
bool SAssetTreeItem::ValidateDragDrop( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent ) const
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<FTreeItem> TreeItemPinned = TreeItem.Pin();
|
|
|
|
|
return TreeItemPinned.IsValid() && DragDropHandler::ValidateDragDropOnAssetFolder(MyGeometry, DragDropEvent, TreeItemPinned->FolderPath);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
void SAssetTreeItem::OnDragEnter( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
|
|
|
{
|
2015-02-09 11:42:01 -05:00
|
|
|
bDraggedOver = false;
|
|
|
|
|
|
|
|
|
|
if (ValidateDragDrop(MyGeometry, DragDropEvent))
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-02-09 11:42:01 -05:00
|
|
|
bDraggedOver = true;
|
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-02-09 11:42:01 -05:00
|
|
|
bDraggedOver = false;
|
|
|
|
|
|
|
|
|
|
if (ValidateDragDrop(MyGeometry, DragDropEvent))
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-02-09 11:42:01 -05:00
|
|
|
bDraggedOver = true;
|
|
|
|
|
return FReply::Handled();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SAssetTreeItem::OnDrop( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
|
|
|
{
|
|
|
|
|
bDraggedOver = false;
|
|
|
|
|
|
2015-02-09 11:42:01 -05:00
|
|
|
if (ValidateDragDrop(MyGeometry, DragDropEvent))
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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())
|
|
|
|
|
{
|
|
|
|
|
return OnVerifyNameChanged.Execute(InName, OutError, TreeItemPtr->FolderPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////
|
|
|
|
|
// SCollectionListItem
|
|
|
|
|
//////////////////////////
|
|
|
|
|
|
|
|
|
|
void SCollectionListItem::Construct( const FArguments& InArgs )
|
|
|
|
|
{
|
|
|
|
|
ParentWidget = InArgs._ParentWidget;
|
|
|
|
|
CollectionItem = InArgs._CollectionItem;
|
|
|
|
|
OnBeginNameChange = InArgs._OnBeginNameChange;
|
|
|
|
|
OnNameChangeCommit = InArgs._OnNameChangeCommit;
|
|
|
|
|
OnVerifyRenameCommit = InArgs._OnVerifyRenameCommit;
|
|
|
|
|
OnAssetsDragDropped = InArgs._OnAssetsDragDropped;
|
|
|
|
|
bDraggedOver = false;
|
|
|
|
|
|
|
|
|
|
FString CollectionTypeImage;
|
2014-12-02 10:22:37 -05:00
|
|
|
FText CollectionTypeTooltip;
|
2014-03-14 14:13:41 -04:00
|
|
|
switch (InArgs._CollectionItem->CollectionType)
|
|
|
|
|
{
|
|
|
|
|
case ECollectionShareType::CST_Shared:
|
|
|
|
|
CollectionTypeImage = TEXT("ContentBrowser.Shared");
|
2014-12-02 10:22:37 -05:00
|
|
|
CollectionTypeTooltip = LOCTEXT("SharedCollectionTooltip", "Shared. This collection is visible to everyone.");
|
2014-03-14 14:13:41 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ECollectionShareType::CST_Private:
|
|
|
|
|
CollectionTypeImage = TEXT("ContentBrowser.Private");
|
2014-12-02 10:22:37 -05:00
|
|
|
CollectionTypeTooltip = LOCTEXT("PrivateCollectionTooltip", "Private. This collection is only visible to you.");
|
2014-03-14 14:13:41 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ECollectionShareType::CST_Local:
|
|
|
|
|
CollectionTypeImage = TEXT("ContentBrowser.Local");
|
2014-12-02 10:22:37 -05:00
|
|
|
CollectionTypeTooltip = LOCTEXT("LocalCollectionTooltip", "Local. This collection is only visible to you and is not in source control.");
|
2014-03-14 14:13:41 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
CollectionTypeImage = TEXT("");
|
2014-12-02 10:22:37 -05:00
|
|
|
CollectionTypeTooltip = FText::GetEmpty();
|
2014-03-14 14:13:41 -04:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChildSlot
|
|
|
|
|
[
|
|
|
|
|
SNew(SBorder)
|
|
|
|
|
.BorderImage(this, &SCollectionListItem::GetBorderImage)
|
|
|
|
|
.Padding(0)
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
.ToolTip( SNew(SToolTip).Text(CollectionTypeTooltip) )
|
|
|
|
|
|
|
|
|
|
+SHorizontalBox::Slot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.Padding(0, 0, 4, 0)
|
|
|
|
|
[
|
|
|
|
|
// Type Icon
|
|
|
|
|
SNew(SImage)
|
|
|
|
|
.Image( FEditorStyle::GetBrush(*CollectionTypeImage) )
|
2014-04-23 18:13:40 -04:00
|
|
|
.ColorAndOpacity( this, &SCollectionListItem::GetCollectionColor )
|
2014-03-14 14:13:41 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
+SHorizontalBox::Slot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SAssignNew(InlineRenameWidget, SInlineEditableTextBlock)
|
|
|
|
|
.Text( this, &SCollectionListItem::GetNameText )
|
|
|
|
|
.Font( FEditorStyle::GetFontStyle("ContentBrowser.SourceListItemFont") )
|
|
|
|
|
.OnBeginTextEdit(this, &SCollectionListItem::HandleBeginNameChange)
|
|
|
|
|
.OnTextCommitted(this, &SCollectionListItem::HandleNameCommitted)
|
|
|
|
|
.OnVerifyTextChanged(this, &SCollectionListItem::HandleVerifyNameChanged)
|
|
|
|
|
.IsSelected( InArgs._IsSelected )
|
|
|
|
|
.IsReadOnly( InArgs._IsReadOnly )
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SCollectionListItem::~SCollectionListItem()
|
|
|
|
|
{
|
|
|
|
|
if(InlineRenameWidget.IsValid())
|
|
|
|
|
{
|
2015-01-08 09:29:27 -05:00
|
|
|
CollectionItem.Pin()->OnRenamedRequestEvent.Remove( EnterEditingModeDelegateHandle );
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCollectionListItem::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
// Cache this widget's geometry so it can pop up warnings over itself
|
|
|
|
|
CachedGeometry = AllottedGeometry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCollectionListItem::OnDragEnter( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
|
|
|
{
|
2014-04-23 18:00:50 -04:00
|
|
|
TSharedPtr<FAssetDragDropOp> DragDropOp = DragDropEvent.GetOperationAs<FAssetDragDropOp>();
|
|
|
|
|
if ( DragDropOp.IsValid() )
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
bool bCanDrop = DragDropOp->AssetData.Num() > 0;
|
|
|
|
|
|
|
|
|
|
if (bCanDrop)
|
|
|
|
|
{
|
|
|
|
|
bDraggedOver = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCollectionListItem::OnDragLeave( const FDragDropEvent& DragDropEvent )
|
|
|
|
|
{
|
|
|
|
|
bDraggedOver = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SCollectionListItem::OnDragOver( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
|
|
|
{
|
2014-04-23 18:00:50 -04:00
|
|
|
TSharedPtr<FAssetDragDropOp> DragDropOp = DragDropEvent.GetOperationAs<FAssetDragDropOp>();
|
|
|
|
|
if (DragDropOp.IsValid())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
bool bCanDrop = DragDropOp->AssetData.Num() > 0;
|
|
|
|
|
|
|
|
|
|
if (bCanDrop)
|
|
|
|
|
{
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SCollectionListItem::OnDrop( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
|
|
|
{
|
|
|
|
|
bDraggedOver = false;
|
|
|
|
|
|
2014-04-23 18:00:50 -04:00
|
|
|
TSharedPtr<FAssetDragDropOp> DragDropOp = DragDropEvent.GetOperationAs<FAssetDragDropOp>();
|
|
|
|
|
if (DragDropOp.IsValid() && ensure(CollectionItem.IsValid()))
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
FText Message;
|
|
|
|
|
OnAssetsDragDropped.ExecuteIfBound(DragDropOp->AssetData, CollectionItem.Pin(), Message);
|
|
|
|
|
|
|
|
|
|
// Added items to the collection or failed. Either way, display the message.
|
|
|
|
|
ContentBrowserUtils::DisplayMessage(Message, CachedGeometry.GetClippingRect(), SharedThis(this));
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCollectionListItem::HandleBeginNameChange( const FText& OldText )
|
|
|
|
|
{
|
|
|
|
|
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 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCollectionListItem::HandleNameCommitted( const FText& NewText, ETextCommit::Type CommitInfo )
|
|
|
|
|
{
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SCollectionListItem::HandleVerifyNameChanged( const FText& NewText, FText& OutErrorMessage )
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<FCollectionItem> CollectionItemPtr = CollectionItem.Pin();
|
|
|
|
|
|
|
|
|
|
if (CollectionItemPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
return !OnVerifyRenameCommit.IsBound() || OnVerifyRenameCommit.Execute(CollectionItemPtr, NewText.ToString(), CachedGeometry.GetClippingRect(), OutErrorMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FText SCollectionListItem::GetNameText() const
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<FCollectionItem> CollectionItemPtr = CollectionItem.Pin();
|
|
|
|
|
|
|
|
|
|
if ( CollectionItemPtr.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
return FText::FromString(CollectionItemPtr->CollectionName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return FText();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-23 18:13:40 -04:00
|
|
|
FSlateColor SCollectionListItem::GetCollectionColor() const
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<FCollectionItem> CollectionItemPtr = CollectionItem.Pin();
|
|
|
|
|
|
|
|
|
|
if ( CollectionItemPtr.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
const TSharedPtr<FLinearColor> Color = CollectionViewUtils::LoadColor(CollectionItemPtr->CollectionName, CollectionItemPtr->CollectionType);
|
|
|
|
|
if( Color.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
return *Color.Get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CollectionViewUtils::GetDefaultColor();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
const FSlateBrush* SCollectionListItem::GetBorderImage() const
|
|
|
|
|
{
|
|
|
|
|
return bDraggedOver ? FEditorStyle::GetBrush("Menu.Background") : FEditorStyle::GetBrush("NoBorder");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|