2019-12-26 15:33:43 -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 "SOutlinerTreeView.h"
|
|
|
|
|
#include "Framework/Application/SlateApplication.h"
|
2022-05-09 13:12:28 -04:00
|
|
|
#include "Styling/AppStyle.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 "ISceneOutlinerColumn.h"
|
2022-05-24 06:58:06 -04:00
|
|
|
#include "ISceneOutlinerMode.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 "SceneOutlinerPublicTypes.h"
|
|
|
|
|
#include "DragAndDrop/DecoratedDragDropOp.h"
|
|
|
|
|
#include "SceneOutlinerDragDrop.h"
|
|
|
|
|
#include "SSceneOutliner.h"
|
2022-02-15 11:19:12 -05:00
|
|
|
#include "Styling/StyleColors.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2020-07-22 09:35:57 -04:00
|
|
|
#include "FolderTreeItem.h"
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
#define LOCTEXT_NAMESPACE "SSceneOutliner"
|
|
|
|
|
|
2020-07-28 09:25:56 -04:00
|
|
|
static void UpdateOperationDecorator(const FDragDropEvent& Event, const FSceneOutlinerDragValidationInfo& ValidationInfo)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2022-05-09 13:12:28 -04:00
|
|
|
const FSlateBrush* Icon = ValidationInfo.IsValid() ? FAppStyle::GetBrush(TEXT("Graph.ConnectorFeedback.OK")) : FAppStyle::GetBrush(TEXT("Graph.ConnectorFeedback.Error"));
|
2020-07-28 09:25:56 -04:00
|
|
|
|
|
|
|
|
FDragDropOperation* Operation = Event.GetOperation().Get();
|
2021-02-10 17:41:49 -04:00
|
|
|
if (Operation && Operation->IsOfType<FDecoratedDragDropOp>())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2021-02-10 17:41:49 -04:00
|
|
|
auto* DecoratedOp = static_cast<FDecoratedDragDropOp*>(Operation);
|
|
|
|
|
DecoratedOp->SetToolTip(ValidationInfo.ValidationText, Icon);
|
2014-11-10 10:09:21 -05:00
|
|
|
}
|
2020-07-28 09:25:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ResetOperationDecorator(const FDragDropEvent& Event)
|
|
|
|
|
{
|
|
|
|
|
FDragDropOperation* Operation = Event.GetOperation().Get();
|
|
|
|
|
if (Operation)
|
|
|
|
|
{
|
|
|
|
|
if (Operation->IsOfType<FSceneOutlinerDragDropOp>())
|
|
|
|
|
{
|
|
|
|
|
static_cast<FSceneOutlinerDragDropOp*>(Operation)->ResetTooltip();
|
|
|
|
|
}
|
|
|
|
|
else if (Operation->IsOfType<FDecoratedDragDropOp>())
|
|
|
|
|
{
|
|
|
|
|
static_cast<FDecoratedDragDropOp*>(Operation)->ResetToDefaultToolTip();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static FReply HandleOnDragDetected( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, TWeakPtr<SSceneOutlinerTreeView> Table )
|
|
|
|
|
{
|
|
|
|
|
auto TablePtr = Table.Pin();
|
|
|
|
|
if (TablePtr.IsValid() && MouseEvent.IsMouseButtonDown( EKeys::LeftMouseButton ))
|
|
|
|
|
{
|
2022-02-16 11:58:08 -05:00
|
|
|
auto Operation = TablePtr->GetOutlinerPtr().Pin()->CreateDragDropOperation(MouseEvent, TablePtr->GetSelectedItems());
|
2020-07-28 09:25:56 -04:00
|
|
|
|
|
|
|
|
if (Operation.IsValid())
|
|
|
|
|
{
|
|
|
|
|
return FReply::Handled().BeginDragDrop(Operation.ToSharedRef());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply HandleDrop(TSharedPtr<SSceneOutliner> SceneOutlinerPtr, const FDragDropEvent& DragDropEvent, ISceneOutlinerTreeItem& DropTarget, FSceneOutlinerDragValidationInfo& ValidationInfo, bool bApplyDrop = false)
|
|
|
|
|
{
|
|
|
|
|
if (!SceneOutlinerPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-26 14:07:52 -04:00
|
|
|
// Don't handle this if we're not showing a hierarchy
|
|
|
|
|
const FSharedSceneOutlinerData& SharedData = SceneOutlinerPtr->GetSharedData();
|
|
|
|
|
if (!SharedData.bShowParentTree)
|
|
|
|
|
{
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-28 09:25:56 -04:00
|
|
|
// Don't handle this if the scene outliner is not in a mode which supports drag and drop
|
|
|
|
|
if (!SceneOutlinerPtr->CanSupportDragAndDrop())
|
|
|
|
|
{
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 15:17:40 -04:00
|
|
|
FSceneOutlinerDragDropPayload DraggedObjects(*DragDropEvent.GetOperation());
|
2020-07-28 09:25:56 -04:00
|
|
|
// Validate now to make sure we don't doing anything we shouldn't
|
|
|
|
|
if (!SceneOutlinerPtr->ParseDragDrop(DraggedObjects, *DragDropEvent.GetOperation()))
|
|
|
|
|
{
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValidationInfo = SceneOutlinerPtr->ValidateDrop(StaticCast<ISceneOutlinerTreeItem&>(DropTarget), DraggedObjects);
|
|
|
|
|
|
|
|
|
|
if (!ValidationInfo.IsValid())
|
|
|
|
|
{
|
|
|
|
|
// Return handled here to stop anything else trying to handle it - the operation is invalid as far as we're concerned
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bApplyDrop)
|
|
|
|
|
{
|
|
|
|
|
SceneOutlinerPtr->OnDropPayload(DropTarget, DraggedObjects, ValidationInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 06:58:06 -04:00
|
|
|
FReply HandleDropFromWeak(TWeakPtr<SSceneOutliner> SceneOutlinerWeak, const FDragDropEvent& DragDropEvent, FSceneOutlinerDragValidationInfo& ValidationInfo, bool bApplyDrop = false)
|
2020-07-28 09:25:56 -04:00
|
|
|
{
|
2022-05-24 06:58:06 -04:00
|
|
|
const ISceneOutlinerMode* Mode = SceneOutlinerWeak.IsValid() ? SceneOutlinerWeak.Pin()->GetMode() : nullptr;
|
|
|
|
|
FFolder::FRootObject RootObject = Mode ? Mode->GetRootObject() : FFolder::GetInvalidRootObject();
|
|
|
|
|
FFolder RootFolder(RootObject);
|
|
|
|
|
FFolderTreeItem DropTarget(RootFolder);
|
2020-07-28 09:25:56 -04:00
|
|
|
return HandleDrop(SceneOutlinerWeak.Pin(), DragDropEvent, DropTarget, ValidationInfo, bApplyDrop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerTreeView::Construct(const SSceneOutlinerTreeView::FArguments& InArgs, TSharedRef<SSceneOutliner> Owner)
|
|
|
|
|
{
|
|
|
|
|
SceneOutlinerWeak = Owner;
|
|
|
|
|
STreeView::Construct(InArgs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerTreeView::FlashHighlightOnItem( FSceneOutlinerTreeItemPtr FlashHighlightOnItem )
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr< SSceneOutlinerTreeRow > RowWidget = StaticCastSharedPtr< SSceneOutlinerTreeRow >( WidgetGenerator.GetWidgetForItem( FlashHighlightOnItem ) );
|
|
|
|
|
if( RowWidget.IsValid() )
|
|
|
|
|
{
|
|
|
|
|
RowWidget->FlashHighlight();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SSceneOutlinerTreeView::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
|
|
|
|
|
{
|
|
|
|
|
FSceneOutlinerDragValidationInfo ValidationInfo = FSceneOutlinerDragValidationInfo::Invalid();
|
2022-05-24 06:58:06 -04:00
|
|
|
auto Reply = HandleDropFromWeak(SceneOutlinerWeak, DragDropEvent, ValidationInfo);
|
2020-08-26 14:07:52 -04:00
|
|
|
if (Reply.IsEventHandled())
|
|
|
|
|
{
|
|
|
|
|
UpdateOperationDecorator(DragDropEvent, ValidationInfo);
|
|
|
|
|
}
|
2020-07-28 09:25:56 -04:00
|
|
|
|
|
|
|
|
return Reply;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerTreeView::OnDragLeave(const FDragDropEvent& DragDropEvent)
|
|
|
|
|
{
|
|
|
|
|
if( SceneOutlinerWeak.Pin()->GetSharedData().bShowParentTree )
|
|
|
|
|
{
|
|
|
|
|
ResetOperationDecorator(DragDropEvent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SSceneOutlinerTreeView::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
|
|
|
|
|
{
|
|
|
|
|
FSceneOutlinerDragValidationInfo ValidationInfo = FSceneOutlinerDragValidationInfo::Invalid();
|
2022-05-24 06:58:06 -04:00
|
|
|
return HandleDropFromWeak(SceneOutlinerWeak, DragDropEvent, ValidationInfo, true);
|
2020-07-28 09:25:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SSceneOutlinerTreeRow::OnDrop( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
|
|
|
{
|
|
|
|
|
auto ItemPtr = Item.Pin();
|
|
|
|
|
auto SceneOutlinerPtr = SceneOutlinerWeak.Pin();
|
|
|
|
|
if (ItemPtr.IsValid() && SceneOutlinerPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
FSceneOutlinerDragValidationInfo ValidationInfo = FSceneOutlinerDragValidationInfo::Invalid();
|
|
|
|
|
return HandleDrop(SceneOutlinerPtr, DragDropEvent, *ItemPtr, ValidationInfo, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerTreeRow::OnDragEnter( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent )
|
|
|
|
|
{
|
|
|
|
|
auto ItemPtr = Item.Pin();
|
|
|
|
|
auto SceneOutlinerPtr = SceneOutlinerWeak.Pin();
|
|
|
|
|
if (ItemPtr.IsValid() && SceneOutlinerPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
FSceneOutlinerDragValidationInfo ValidationInfo = FSceneOutlinerDragValidationInfo::Invalid();
|
|
|
|
|
|
2020-08-26 14:07:52 -04:00
|
|
|
FReply Reply = HandleDrop(SceneOutlinerPtr, DragDropEvent, *ItemPtr, ValidationInfo, false);
|
|
|
|
|
if (Reply.IsEventHandled())
|
|
|
|
|
{
|
|
|
|
|
UpdateOperationDecorator(DragDropEvent, ValidationInfo);
|
|
|
|
|
}
|
2020-07-28 09:25:56 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerTreeRow::OnDragLeave( const FDragDropEvent& DragDropEvent )
|
|
|
|
|
{
|
|
|
|
|
auto ItemPtr = Item.Pin();
|
|
|
|
|
auto SceneOutlinerPtr = SceneOutlinerWeak.Pin();
|
|
|
|
|
|
|
|
|
|
ResetOperationDecorator(DragDropEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SSceneOutlinerTreeRow::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
|
|
|
|
|
{
|
|
|
|
|
auto SceneOutlinerPtr = SceneOutlinerWeak.Pin();
|
|
|
|
|
if (SSceneOutliner* SceneOutliner = SceneOutlinerPtr.Get())
|
|
|
|
|
{
|
|
|
|
|
if (const auto* ItemPtr = Item.Pin().Get())
|
|
|
|
|
{
|
|
|
|
|
return SceneOutliner->OnDragOverItem(DragDropEvent, *ItemPtr);
|
|
|
|
|
}
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SSceneOutlinerTreeRow::OnMouseButtonDown( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent )
|
|
|
|
|
{
|
|
|
|
|
auto ItemPtr = Item.Pin();
|
|
|
|
|
if (ItemPtr.IsValid() && ItemPtr->CanInteract())
|
|
|
|
|
{
|
|
|
|
|
if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
|
|
|
|
|
{
|
|
|
|
|
FReply Reply = SMultiColumnTableRow<FSceneOutlinerTreeItemPtr>::OnMouseButtonDown( MyGeometry, MouseEvent );
|
|
|
|
|
|
|
|
|
|
if (SceneOutlinerWeak.Pin()->CanSupportDragAndDrop())
|
|
|
|
|
{
|
|
|
|
|
return Reply.DetectDrag( SharedThis(this) , EKeys::LeftMouseButton );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Reply.PreventThrottling();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SSceneOutlinerTreeRow::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
|
|
|
{
|
|
|
|
|
auto ItemPtr = Item.Pin();
|
|
|
|
|
// We don't to change the selection when it is a left click since this was handle in the on mouse down
|
|
|
|
|
if (ItemPtr.IsValid() && ItemPtr->CanInteract())
|
|
|
|
|
{
|
|
|
|
|
return SMultiColumnTableRow<FSceneOutlinerTreeItemPtr>::OnMouseButtonUp(MyGeometry, MouseEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-16 12:55:20 -05:00
|
|
|
FReply SSceneOutlinerTreeRow::OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
|
|
|
{
|
|
|
|
|
auto ItemPtr = Item.Pin();
|
|
|
|
|
// We don't want to act on double click on an item that can't be interacted with
|
|
|
|
|
if (ItemPtr.IsValid() && ItemPtr->CanInteract())
|
|
|
|
|
{
|
|
|
|
|
return SMultiColumnTableRow<FSceneOutlinerTreeItemPtr>::OnMouseButtonDoubleClick(MyGeometry, MouseEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-28 09:25:56 -04:00
|
|
|
TSharedRef<SWidget> SSceneOutlinerTreeRow::GenerateWidgetForColumn( const FName& ColumnName )
|
|
|
|
|
{
|
|
|
|
|
auto ItemPtr = Item.Pin();
|
|
|
|
|
if (!ItemPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
return SNullWidget::NullWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto Outliner = SceneOutlinerWeak.Pin();
|
|
|
|
|
check(Outliner.IsValid());
|
|
|
|
|
|
|
|
|
|
// Create the widget for this item
|
|
|
|
|
TSharedRef<SWidget> NewItemWidget = SNullWidget::NullWidget;
|
|
|
|
|
|
|
|
|
|
auto Column = Outliner->GetColumns().FindRef(ColumnName);
|
|
|
|
|
if (Column.IsValid())
|
|
|
|
|
{
|
|
|
|
|
NewItemWidget = Column->ConstructRowWidget(ItemPtr.ToSharedRef(), *this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( ColumnName == FSceneOutlinerBuiltInColumnTypes::Label() )
|
|
|
|
|
{
|
|
|
|
|
// The first column gets the tree expansion arrow for this row
|
2021-02-24 20:39:07 -04:00
|
|
|
return SNew(SBox)
|
|
|
|
|
.MinDesiredHeight(FSceneOutlinerDefaultTreeItemMetrics::RowHeight())
|
2020-07-28 09:25:56 -04:00
|
|
|
[
|
2021-02-24 20:39:07 -04:00
|
|
|
SNew( SHorizontalBox )
|
2020-07-28 09:25:56 -04:00
|
|
|
|
2021-02-24 20:39:07 -04:00
|
|
|
+SHorizontalBox::Slot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.Padding(6, 0, 0, 0)
|
|
|
|
|
[
|
|
|
|
|
SNew( SExpanderArrow, SharedThis(this) ).IndentAmount(12)
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
+SHorizontalBox::Slot()
|
|
|
|
|
.FillWidth(1.0f)
|
|
|
|
|
[
|
|
|
|
|
NewItemWidget
|
|
|
|
|
]
|
2020-07-28 09:25:56 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Other columns just get widget content -- no expansion arrow needed
|
|
|
|
|
return NewItemWidget;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerTreeRow::Construct( const FArguments& InArgs, const TSharedRef<SSceneOutlinerTreeView>& OutlinerTreeView, TSharedRef<SSceneOutliner> SceneOutliner )
|
|
|
|
|
{
|
|
|
|
|
Item = InArgs._Item->AsShared();
|
|
|
|
|
SceneOutlinerWeak = SceneOutliner;
|
|
|
|
|
LastHighlightInteractionTime = 0.0;
|
|
|
|
|
|
|
|
|
|
auto Args = FSuperRowType::FArguments()
|
2022-05-09 13:12:28 -04:00
|
|
|
.Style(&FAppStyle::Get().GetWidgetStyle<FTableRowStyle>("SceneOutliner.TableViewRow"));
|
2020-07-28 09:25:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Args.OnDragDetected_Static(HandleOnDragDetected, TWeakPtr<SSceneOutlinerTreeView>(OutlinerTreeView));
|
|
|
|
|
|
|
|
|
|
SMultiColumnTableRow<FSceneOutlinerTreeItemPtr>::Construct(Args, OutlinerTreeView);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float SSceneOutlinerTreeRow::HighlightRectLeftOffset = 0.0f;
|
|
|
|
|
const float SSceneOutlinerTreeRow::HighlightRectRightOffset = 0.0f;
|
|
|
|
|
const float SSceneOutlinerTreeRow::HighlightTargetSpringConstant = 25.0f;
|
|
|
|
|
const float SSceneOutlinerTreeRow::HighlightTargetEffectDuration = 0.5f;
|
|
|
|
|
const float SSceneOutlinerTreeRow::HighlightTargetOpacity = 0.8f;
|
|
|
|
|
const float SSceneOutlinerTreeRow::LabelChangedAnimOffsetPercent = 0.2f;
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerTreeRow::FlashHighlight()
|
|
|
|
|
{
|
|
|
|
|
LastHighlightInteractionTime = FSlateApplication::Get().GetCurrentTime();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerTreeRow::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
// Call parent implementation.
|
|
|
|
|
SCompoundWidget::Tick( AllottedGeometry, InCurrentTime, InDeltaTime );
|
|
|
|
|
|
|
|
|
|
// We'll draw with the 'focused' look if we're either focused or we have a context menu summoned
|
|
|
|
|
const bool bShouldAppearFocused = HasKeyboardFocus();
|
|
|
|
|
|
|
|
|
|
// Update highlight 'target' effect
|
|
|
|
|
{
|
|
|
|
|
const float HighlightLeftX = HighlightRectLeftOffset;
|
|
|
|
|
const float HighlightRightX = HighlightRectRightOffset + AllottedGeometry.GetLocalSize().X;
|
|
|
|
|
|
|
|
|
|
HighlightTargetLeftSpring.SetTarget( HighlightLeftX );
|
|
|
|
|
HighlightTargetRightSpring.SetTarget( HighlightRightX );
|
|
|
|
|
|
|
|
|
|
float TimeSinceHighlightInteraction = (float)( InCurrentTime - LastHighlightInteractionTime );
|
|
|
|
|
if( TimeSinceHighlightInteraction <= HighlightTargetEffectDuration || bShouldAppearFocused )
|
|
|
|
|
{
|
|
|
|
|
HighlightTargetLeftSpring.Tick( InDeltaTime );
|
|
|
|
|
HighlightTargetRightSpring.Tick( InDeltaTime );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32 SSceneOutlinerTreeRow::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
|
|
|
|
|
{
|
|
|
|
|
int32 StartLayer = SMultiColumnTableRow::OnPaint( Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled );
|
|
|
|
|
|
|
|
|
|
const int32 TextLayer = 1;
|
|
|
|
|
|
|
|
|
|
// See if a disabled effect should be used
|
|
|
|
|
bool bEnabled = ShouldBeEnabled( bParentEnabled );
|
|
|
|
|
ESlateDrawEffect DrawEffects = (bEnabled) ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
|
|
|
|
|
|
|
|
|
|
const double CurrentTime = FSlateApplication::Get().GetCurrentTime();
|
|
|
|
|
|
|
|
|
|
// We'll draw with the 'focused' look if we're either focused or we have a context menu summoned
|
|
|
|
|
const bool bShouldAppearFocused = HasKeyboardFocus();
|
|
|
|
|
|
|
|
|
|
// Draw highlight targeting effect
|
|
|
|
|
const float TimeSinceHighlightInteraction = (float)( CurrentTime - LastHighlightInteractionTime );
|
|
|
|
|
if( TimeSinceHighlightInteraction <= HighlightTargetEffectDuration )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Compute animation progress
|
|
|
|
|
float EffectAlpha = FMath::Clamp( TimeSinceHighlightInteraction / HighlightTargetEffectDuration, 0.0f, 1.0f );
|
|
|
|
|
EffectAlpha = 1.0f - EffectAlpha * EffectAlpha; // Inverse square falloff (looks nicer!)
|
|
|
|
|
|
|
|
|
|
// Apply extra opacity falloff when dehighlighting
|
|
|
|
|
float EffectOpacity = EffectAlpha;
|
|
|
|
|
|
|
|
|
|
// Figure out a universally visible highlight color.
|
2021-03-10 07:13:29 -04:00
|
|
|
FLinearColor HighlightTargetColorAndOpacity = ( (FLinearColor::White - GetColorAndOpacity())*0.5f + FLinearColor(+0.4f, +0.1f, -0.2f)) * InWidgetStyle.GetColorAndOpacityTint();
|
2020-07-28 09:25:56 -04:00
|
|
|
HighlightTargetColorAndOpacity.A = HighlightTargetOpacity * EffectOpacity * 255.0f;
|
|
|
|
|
|
|
|
|
|
// Compute the bounds offset of the highlight target from where the highlight target spring
|
|
|
|
|
// extents currently lie. This is used to "grow" or "shrink" the highlight as needed.
|
|
|
|
|
const float LabelChangedAnimOffset = LabelChangedAnimOffsetPercent * AllottedGeometry.GetLocalSize().Y;
|
|
|
|
|
|
|
|
|
|
// Choose an offset amount depending on whether we're highlighting, or clearing highlight
|
|
|
|
|
const float EffectOffset = EffectAlpha * LabelChangedAnimOffset;
|
|
|
|
|
|
|
|
|
|
const float HighlightLeftX = HighlightTargetLeftSpring.GetPosition() - EffectOffset;
|
|
|
|
|
const float HighlightRightX = HighlightTargetRightSpring.GetPosition() + EffectOffset;
|
|
|
|
|
const float HighlightTopY = 0.0f - LabelChangedAnimOffset;
|
|
|
|
|
const float HighlightBottomY = AllottedGeometry.GetLocalSize().Y + EffectOffset;
|
|
|
|
|
|
|
|
|
|
const FVector2D DrawPosition = FVector2D( HighlightLeftX, HighlightTopY );
|
|
|
|
|
const FVector2D DrawSize = FVector2D( HighlightRightX - HighlightLeftX, HighlightBottomY - HighlightTopY );
|
|
|
|
|
|
2022-05-09 13:12:28 -04:00
|
|
|
const FSlateBrush* StyleInfo = FAppStyle::GetBrush("SceneOutliner.ChangedItemHighlight");
|
2020-07-28 09:25:56 -04:00
|
|
|
|
|
|
|
|
// NOTE: We rely on scissor clipping for the highlight rectangle
|
|
|
|
|
FSlateDrawElement::MakeBox(
|
|
|
|
|
OutDrawElements,
|
|
|
|
|
LayerId + TextLayer,
|
|
|
|
|
AllottedGeometry.ToPaintGeometry( DrawPosition, DrawSize ), // Position, Size, Scale
|
|
|
|
|
StyleInfo, // Style
|
|
|
|
|
DrawEffects, // Effects to use
|
|
|
|
|
HighlightTargetColorAndOpacity ); // Color
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-02 05:29:19 -05:00
|
|
|
return FMath::Max(StartLayer, LayerId + TextLayer);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2022-02-15 11:19:12 -05:00
|
|
|
void SSceneOutlinerPinnedTreeRow::Construct(const FArguments& InArgs, const TSharedRef<SSceneOutlinerTreeView>& OutlinerTreeView, TSharedRef<SSceneOutliner> SceneOutliner)
|
|
|
|
|
{
|
|
|
|
|
Item = InArgs._Item->AsShared();
|
|
|
|
|
SceneOutlinerWeak = SceneOutliner;
|
|
|
|
|
OutlinerTreeViewWeak = OutlinerTreeView;
|
|
|
|
|
|
|
|
|
|
FSuperRowType::FArguments Args = FSuperRowType::FArguments()
|
2022-05-09 13:31:58 -04:00
|
|
|
.Style(&FAppStyle::Get().GetWidgetStyle<FTableRowStyle>("SceneOutliner.TableViewRow"));
|
2022-02-15 11:19:12 -05:00
|
|
|
|
|
|
|
|
Args.OnDragDetected_Static(HandleOnDragDetected, TWeakPtr<SSceneOutlinerTreeView>(OutlinerTreeView));
|
|
|
|
|
|
|
|
|
|
SMultiColumnTableRow<FSceneOutlinerTreeItemPtr>::Construct(Args, OutlinerTreeView);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> SSceneOutlinerPinnedTreeRow::GenerateWidgetForColumn(const FName& ColumnName)
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<ISceneOutlinerTreeItem> ItemPtr = Item.Pin();
|
|
|
|
|
if (!ItemPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
return SNullWidget::NullWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedPtr<SSceneOutliner> Outliner = SceneOutlinerWeak.Pin();
|
|
|
|
|
check(Outliner.IsValid());
|
|
|
|
|
|
|
|
|
|
// Create the widget for this item
|
|
|
|
|
TSharedRef<SWidget> NewItemWidget = SNullWidget::NullWidget;
|
|
|
|
|
|
|
|
|
|
TSharedPtr<ISceneOutlinerColumn> Column = Outliner->GetColumns().FindRef(ColumnName);
|
|
|
|
|
|
|
|
|
|
if (Column.IsValid())
|
|
|
|
|
{
|
|
|
|
|
// Construct the actual column widget first
|
|
|
|
|
TSharedRef<SWidget> ActualWidget = Column->ConstructRowWidget(ItemPtr.ToSharedRef(), *this);
|
|
|
|
|
|
|
|
|
|
if (ColumnName == FSceneOutlinerBuiltInColumnTypes::Label())
|
|
|
|
|
{
|
|
|
|
|
// We add space for the expander arrow for the label widget to make sure the spacing/indentation is consistent with non-pinned rows
|
|
|
|
|
NewItemWidget = SNew(SBox)
|
|
|
|
|
.MinDesiredHeight(FSceneOutlinerDefaultTreeItemMetrics::RowHeight())
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
.Padding(6, 0, 0, 0)
|
|
|
|
|
[
|
|
|
|
|
SNew(SExpanderArrow, SharedThis(this)).IndentAmount(12)
|
|
|
|
|
.Visibility(EVisibility::Hidden) // Hidden SExpanderArrow to occupy the same space as non-pinned rows
|
|
|
|
|
]
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.FillWidth(1.0f)
|
|
|
|
|
[
|
|
|
|
|
ActualWidget
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ActualWidget != SNullWidget::NullWidget)
|
|
|
|
|
{
|
|
|
|
|
// Get the sorted column IDs from the outliner
|
|
|
|
|
TArray<FName> SortedColumnIDs;
|
|
|
|
|
Outliner->GetSortedColumnIDs(SortedColumnIDs);
|
|
|
|
|
|
|
|
|
|
// Get the current column and label column index to compare
|
|
|
|
|
int32 ColumnIndex = SortedColumnIDs.Find(ColumnName);
|
|
|
|
|
int32 LabelColumnIndex = SortedColumnIDs.Find(FSceneOutlinerBuiltInColumnTypes::Label());
|
|
|
|
|
|
|
|
|
|
// If either of the columns don't exist, this widget does not need to occupy space
|
|
|
|
|
if (ColumnIndex == INDEX_NONE || LabelColumnIndex == INDEX_NONE)
|
|
|
|
|
{
|
|
|
|
|
ActualWidget->SetVisibility(EVisibility::Collapsed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If this column is to the LEFT of the label column, it is hidden but occupies space to ensure proper indentation
|
|
|
|
|
if (ColumnIndex < LabelColumnIndex)
|
|
|
|
|
{
|
|
|
|
|
ActualWidget->SetVisibility(EVisibility::Hidden);
|
|
|
|
|
}
|
|
|
|
|
// If this column is to the RIGHT of the label colum, it should not occupy space
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ActualWidget->SetVisibility(EVisibility::Collapsed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NewItemWidget = ActualWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NewItemWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SSceneOutlinerPinnedTreeRow::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<ISceneOutlinerTreeItem> ItemPtr = Item.Pin();
|
|
|
|
|
TSharedPtr<SSceneOutliner> SceneOutlinerPtr = SceneOutlinerWeak.Pin();
|
|
|
|
|
if (ItemPtr.IsValid() && SceneOutlinerPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
FSceneOutlinerDragValidationInfo ValidationInfo = FSceneOutlinerDragValidationInfo::Invalid();
|
|
|
|
|
return HandleDrop(SceneOutlinerPtr, DragDropEvent, *ItemPtr, ValidationInfo, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerPinnedTreeRow::OnDragEnter(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<ISceneOutlinerTreeItem> ItemPtr = Item.Pin();
|
|
|
|
|
TSharedPtr<SSceneOutliner> SceneOutlinerPtr = SceneOutlinerWeak.Pin();
|
|
|
|
|
if (ItemPtr.IsValid() && SceneOutlinerPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
FSceneOutlinerDragValidationInfo ValidationInfo = FSceneOutlinerDragValidationInfo::Invalid();
|
|
|
|
|
|
|
|
|
|
FReply Reply = HandleDrop(SceneOutlinerPtr, DragDropEvent, *ItemPtr, ValidationInfo, false);
|
|
|
|
|
if (Reply.IsEventHandled())
|
|
|
|
|
{
|
|
|
|
|
UpdateOperationDecorator(DragDropEvent, ValidationInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SSceneOutlinerPinnedTreeRow::OnDragLeave(const FDragDropEvent& DragDropEvent)
|
|
|
|
|
{
|
|
|
|
|
ResetOperationDecorator(DragDropEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FReply SSceneOutlinerPinnedTreeRow::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<SSceneOutliner> SceneOutlinerPtr = SceneOutlinerWeak.Pin();
|
|
|
|
|
if (SSceneOutliner* SceneOutliner = SceneOutlinerPtr.Get())
|
|
|
|
|
{
|
|
|
|
|
if (const ISceneOutlinerTreeItem* ItemPtr = Item.Pin().Get())
|
|
|
|
|
{
|
|
|
|
|
return SceneOutliner->OnDragOverItem(DragDropEvent, *ItemPtr);
|
|
|
|
|
}
|
|
|
|
|
return FReply::Unhandled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE
|