// Copyright Epic Games, Inc. All Rights Reserved. #include "Editor/PropertyEditorTestObject.h" #include "IDetailTreeNode.h" #include "IPropertyRowGenerator.h" #include "Modules/ModuleManager.h" #include "Widgets/Views/STableViewBase.h" #include "Widgets/Views/SListView.h" TArray APropertyEditorTestActor::GetOptionsFunc() const { return TArray { TEXT("One"), TEXT("Two"), TEXT("Three") }; } TSharedRef UPropertyEditorRowGeneratorTest::GenerateWidget() { FPropertyRowGeneratorArgs GeneratorArgs; GeneratorArgs.bAllowMultipleTopLevelObjects = true; FPropertyEditorModule& Module = FModuleManager::LoadModuleChecked( "PropertyEditor" ); PropertyRowGenerator = Module.CreatePropertyRowGenerator(GeneratorArgs); PropertyRowGenerator->OnRowsRefreshed().AddUObject(this, &UPropertyEditorRowGeneratorTest::OnRowsRefreshed); TArray Objects; for (int32 Idx = 0; Idx < 10; ++Idx) { Objects.Add(NewObject()); } ListView = SNew(SListView>) .ListItemsSource(&DetailsNodes) .OnGenerateRow_UObject(this, &UPropertyEditorRowGeneratorTest::GenerateListRow); PropertyRowGenerator->SetObjects(Objects); return ListView.ToSharedRef(); } static void AddChildrenRecursive(TSharedPtr Node, TArray>& OutNodes) { TArray> Children; Node->GetChildren(Children); for (const TSharedRef& Child : Children) { OutNodes.Add(Child); AddChildrenRecursive(Child, OutNodes); } } void UPropertyEditorRowGeneratorTest::OnRowsRefreshed() { DetailsNodes.Reset(); for (const TSharedRef& RootNode : PropertyRowGenerator->GetRootTreeNodes()) { AddChildrenRecursive(RootNode, DetailsNodes); } ListView->RebuildList(); } TSharedRef UPropertyEditorRowGeneratorTest::GenerateListRow(TSharedPtr InItem, const TSharedRef& OwnerTable) { TSharedRef>> TableRow = SNew(STableRow>, OwnerTable); FNodeWidgets NodeWidgets = InItem->CreateNodeWidgets(); if (NodeWidgets.WholeRowWidget.IsValid()) { TableRow->SetContent(NodeWidgets.WholeRowWidget.ToSharedRef()); } else if (NodeWidgets.NameWidget.IsValid() && NodeWidgets.ValueWidget.IsValid()) { TableRow->SetContent( SNew(SHorizontalBox) + SHorizontalBox::Slot() [ NodeWidgets.NameWidget.ToSharedRef() ] + SHorizontalBox::Slot() [ NodeWidgets.ValueWidget.ToSharedRef() ] ); } return TableRow; }