RealtimeStyleTransferRuntime/Source/LyraGame/UI/Common/LyraListView.cpp

52 lines
1.3 KiB
C++
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#include "LyraListView.h"
#include "LyraWidgetFactory.h"
#if WITH_EDITOR
#include "Editor/WidgetCompilerLog.h"
#endif
#define LOCTEXT_NAMESPACE "LyraListView"
ULyraListView::ULyraListView(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
#if WITH_EDITOR
void ULyraListView::ValidateCompiledDefaults(IWidgetCompilerLog& InCompileLog) const
{
Super::ValidateCompiledDefaults(InCompileLog);
if (FactoryRules.Num() == 0)
{
InCompileLog.Error(FText::Format(FText::FromString("{0} has no Factory Rules defined, can't create widgets without them."), FText::FromString(GetName())));
}
}
#endif
UUserWidget& ULyraListView::OnGenerateEntryWidgetInternal(UObject* Item, TSubclassOf<UUserWidget> DesiredEntryClass, const TSharedRef<STableViewBase>& OwnerTable)
{
TSubclassOf<UUserWidget> WidgetClass = DesiredEntryClass;
for (const ULyraWidgetFactory* Rule : FactoryRules)
{
if (Rule)
{
if (const TSubclassOf<UUserWidget> EntryClass = Rule->FindWidgetClassForData(Item))
{
WidgetClass = EntryClass;
break;
}
}
}
UUserWidget& EntryWidget = GenerateTypedEntry<UUserWidget>(WidgetClass, OwnerTable);
return EntryWidget;
}
#undef LOCTEXT_NAMESPACE