Files
UnrealEngineUWP/Engine/Source/Editor/PropertyEditor/Private/SDetailExpanderArrow.cpp
sebastian nordgren b571dc8c45 SDetailExpanderArrow and SDetailRowIndent no longer hold TSharedPtr to their owning rows, which was causing the owning rows to never be GC'd.
[REVIEW] [at]lauren.barnes
#jira UE-108254

#ROBOMERGE-SOURCE: CL 15377566 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)

[CL 15378776 by sebastian nordgren in ue5-main branch]
2021-02-10 15:20:13 -04:00

108 lines
2.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SDetailExpanderArrow.h"
#include "SDetailTableRowBase.h"
#include "SConstrainedBox.h"
#include "Widgets/Images/SImage.h"
#include "Widgets/Input/SButton.h"
void SDetailExpanderArrow::Construct(const FArguments& InArgs, TSharedRef<SDetailTableRowBase> DetailsRow)
{
Row = DetailsRow;
ChildSlot
[
SNew(SConstrainedBox)
.MinWidth(16)
.Visibility(this, &SDetailExpanderArrow::GetExpanderVisibility)
[
SAssignNew(ExpanderArrow, SButton)
.ButtonStyle(FCoreStyle::Get(), "NoBorder")
.VAlign(VAlign_Center)
.HAlign(HAlign_Center)
.ClickMethod(EButtonClickMethod::MouseDown)
.OnClicked(this, &SDetailExpanderArrow::OnExpanderClicked)
.ContentPadding(FMargin(0))
.IsFocusable(false)
[
SNew(SImage)
.Image(this, &SDetailExpanderArrow::GetExpanderImage)
.ColorAndOpacity(FSlateColor::UseForeground())
]
]
];
}
EVisibility SDetailExpanderArrow::GetExpanderVisibility() const
{
TSharedPtr<SDetailTableRowBase> RowPtr = Row.Pin();
if (!RowPtr.IsValid())
{
return EVisibility::Collapsed;
}
return RowPtr->DoesItemHaveChildren() ? EVisibility::Visible : EVisibility::Collapsed;
}
const FSlateBrush* SDetailExpanderArrow::GetExpanderImage() const
{
TSharedPtr<SDetailTableRowBase> RowPtr = Row.Pin();
if (!RowPtr.IsValid())
{
return FAppStyle::Get().GetBrush("NoBrush");
}
const bool bIsItemExpanded = RowPtr->IsItemExpanded();
FName ResourceName;
if (bIsItemExpanded)
{
if (ExpanderArrow->IsHovered())
{
static const FName ExpandedHoveredName = "TreeArrow_Expanded_Hovered";
ResourceName = ExpandedHoveredName;
}
else
{
static const FName ExpandedName = "TreeArrow_Expanded";
ResourceName = ExpandedName;
}
}
else
{
if (ExpanderArrow->IsHovered())
{
static const FName CollapsedHoveredName = "TreeArrow_Collapsed_Hovered";
ResourceName = CollapsedHoveredName;
}
else
{
static const FName CollapsedName = "TreeArrow_Collapsed";
ResourceName = CollapsedName;
}
}
return FAppStyle::Get().GetBrush(ResourceName);
}
FReply SDetailExpanderArrow::OnExpanderClicked()
{
TSharedPtr<SDetailTableRowBase> RowPtr = Row.Pin();
if (!RowPtr.IsValid())
{
return FReply::Unhandled();
}
// Recurse the expansion if "shift" is being pressed
const FModifierKeysState ModKeyState = FSlateApplication::Get().GetModifierKeys();
if (ModKeyState.IsShiftDown())
{
RowPtr->Private_OnExpanderArrowShiftClicked();
}
else
{
RowPtr->ToggleExpansion();
}
return FReply::Handled();
}