// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "StructViewerFilter.h" #include "StructViewerModule.h" #include "Widgets/SCompoundWidget.h" class IPropertyHandle; class IPropertyUtilities; class IAssetReferenceFilter; class SComboButton; /** * Filter used by the instanced struct struct picker. */ class STRUCTUTILSEDITOR_API FInstancedStructFilter : public IStructViewerFilter { public: /** The base struct for the property that classes must be a child-of. */ TWeakObjectPtr BaseStruct = nullptr; /** The array of allowed structs */ TArray> AllowedStructs; /** The array of disallowed structs */ TArray> DisallowedStructs; // A flag controlling whether we allow UserDefinedStructs bool bAllowUserDefinedStructs = false; // A flag controlling whether we allow to select the BaseStruct bool bAllowBaseStruct = true; virtual bool IsStructAllowed(const FStructViewerInitializationOptions& InInitOptions, const UScriptStruct* InStruct, TSharedRef InFilterFuncs) override; virtual bool IsUnloadedStructAllowed(const FStructViewerInitializationOptions& InInitOptions, const FSoftObjectPath& InStructPath, TSharedRef InFilterFuncs) override; // Optional filter to prevent selection of some structs e.g. ones in a plugin that is inaccessible from the object being edited TSharedPtr AssetReferenceFilter; }; class STRUCTUTILSEDITOR_API SInstancedStructPicker : public SCompoundWidget { public: SLATE_BEGIN_ARGS(SInstancedStructPicker) { } SLATE_EVENT(FOnStructPicked, OnStructPicked) SLATE_ARGUMENT(TArray>, AllowedStructs) SLATE_ARGUMENT(TArray>, DisallowedStructs) SLATE_END_ARGS() void Construct(const FArguments& InArgs, TSharedPtr InStructProperty, TSharedPtr InPropertyUtils); FOnStructPicked OnStructPicked; private: TSharedPtr ComboButton; TSharedPtr StructProperty; TSharedPtr PropUtils; /** The base struct that we're allowing to be picked (controlled by the "BaseStruct" meta-data) */ TWeakObjectPtr BaseScriptStruct = nullptr; /** The array of allowed structs (additionally to the meta-data) */ TArray> AllowedStructs; /** The array of disallowed structs (additionally to the meta-data) */ TArray> DisallowedStructs; FText GetDisplayValueString() const; FText GetTooltipText() const; const FSlateBrush* GetDisplayValueIcon() const; TSharedRef GenerateStructPicker(); void StructPicked(const UScriptStruct* InStruct); };