Files
UnrealEngineUWP/Engine/Source/Editor/PropertyEditor/Private/DetailCustomBuilderRow.cpp
sebastian nordgren b2dd11e5ae Fixed issues while searching details panels (most notably Project Settings) introduced by change 19171653.
Fixed crash when accessing and invalid PropertyEditor in FDetailPropertyRow.

Fixed performance issue caused by calling GetWidgetRow() on FDetailPropertyRow for every row, which caused the row's widgets to be constructed again when filtering.

Added GetCustomResetToDefault() to IDetailLayoutRow, which allows us to bypass the performance penalty of creating the WidgetRow by directly accessing the FResetToDefaultOverride of the row.

#jira UE-144131
#rb paul.chipchase
#preflight 621de59f037be0078cecb0e4
#preflight 621df0563e14f0c7e5276836

[CL 19196340 by sebastian nordgren in ue5-main branch]
2022-03-01 05:20:41 -05:00

110 lines
3.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "DetailCustomBuilderRow.h"
#include "IDetailCustomNodeBuilder.h"
#include "DetailCategoryBuilderImpl.h"
#include "DetailItemNode.h"
#include "CustomChildBuilder.h"
FDetailCustomBuilderRow::FDetailCustomBuilderRow( TSharedRef<IDetailCustomNodeBuilder> CustomBuilder )
: CustomNodeBuilder( CustomBuilder )
{
}
TOptional<FResetToDefaultOverride> FDetailCustomBuilderRow::GetCustomResetToDefault() const
{
if (HeaderRow.IsValid())
{
return HeaderRow->GetCustomResetToDefault();
}
return TOptional<FResetToDefaultOverride>();
}
void FDetailCustomBuilderRow::Tick( float DeltaTime )
{
return CustomNodeBuilder->Tick( DeltaTime );
}
bool FDetailCustomBuilderRow::RequiresTick() const
{
return CustomNodeBuilder->RequiresTick();
}
bool FDetailCustomBuilderRow::HasColumns() const
{
return HeaderRow->HasColumns();
}
bool FDetailCustomBuilderRow::ShowOnlyChildren() const
{
return !HeaderRow->HasAnyContent();
}
void FDetailCustomBuilderRow::OnItemNodeInitialized( TSharedRef<FDetailItemNode> InTreeNode, TSharedRef<FDetailCategoryImpl> InParentCategory, const TAttribute<bool>& InIsParentEnabled )
{
ParentCategory = InParentCategory;
IsParentEnabled = InIsParentEnabled;
const bool bUpdateFilteredNodes = true;
// Set a delegate on the interface that it will call to rebuild this nodes children
CustomNodeBuilder->SetOnRebuildChildren(FSimpleDelegate::CreateSP(InTreeNode, &FDetailItemNode::GenerateChildren, bUpdateFilteredNodes));
CustomNodeBuilder->SetOnToggleExpansion(FOnToggleNodeExpansion::CreateSP(InTreeNode, &FDetailItemNode::SetExpansionState));
HeaderRow = MakeShared<FDetailWidgetRow>();
CustomNodeBuilder->GenerateHeaderRowContent(*HeaderRow);
}
FName FDetailCustomBuilderRow::GetCustomBuilderName() const
{
return CustomNodeBuilder->GetName();
}
TSharedPtr<IPropertyHandle> FDetailCustomBuilderRow::GetPropertyHandle() const
{
return CustomNodeBuilder->GetPropertyHandle();
}
void FDetailCustomBuilderRow::OnGenerateChildren( FDetailNodeList& OutChildren )
{
ChildrenBuilder = MakeShared<FCustomChildrenBuilder>(ParentCategory.Pin().ToSharedRef());
CustomNodeBuilder->GenerateChildContent( *ChildrenBuilder );
const TArray< FDetailLayoutCustomization >& ChildRows = ChildrenBuilder->GetChildCustomizations();
for( int32 ChildIndex = 0; ChildIndex < ChildRows.Num(); ++ChildIndex )
{
TSharedRef<FDetailItemNode> ChildNodeItem = MakeShareable( new FDetailItemNode( ChildRows[ChildIndex], ParentCategory.Pin().ToSharedRef(), IsParentEnabled ) );
ChildNodeItem->Initialize();
OutChildren.Add( ChildNodeItem );
}
}
bool FDetailCustomBuilderRow::IsInitiallyCollapsed() const
{
return CustomNodeBuilder->InitiallyCollapsed();
}
TSharedPtr<FDetailWidgetRow> FDetailCustomBuilderRow::GetWidgetRow() const
{
return HeaderRow;
}
bool FDetailCustomBuilderRow::AreChildCustomizationsHidden() const
{
if (ChildrenBuilder && ChildrenBuilder->GetChildCustomizations().Num() > 0)
{
for (const FDetailLayoutCustomization& ChildCustomizations : ChildrenBuilder->GetChildCustomizations())
{
if (!ChildCustomizations.IsHidden())
{
return false;
}
}
return true;
}
return false;
}