// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "StructViewerFilter.h" #include "StructViewerModule.h" #include "Widgets/SCompoundWidget.h" #define UE_API STRUCTUTILSEDITOR_API class IPropertyHandle; class IPropertyUtilities; class IAssetReferenceFilter; class SComboButton; /** * Filter used by the instanced struct struct picker. */ class 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; UE_API virtual bool IsStructAllowed(const FStructViewerInitializationOptions& InInitOptions, const UScriptStruct* InStruct, TSharedRef InFilterFuncs) override; UE_API 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 SInstancedStructPicker : public SCompoundWidget { public: SLATE_BEGIN_ARGS(SInstancedStructPicker) { } SLATE_EVENT(FOnStructPicked, OnStructPicked) SLATE_ARGUMENT(TArray>, AllowedStructs) SLATE_ARGUMENT(TArray>, DisallowedStructs) SLATE_END_ARGS() UE_API void Construct(const FArguments& InArgs, TSharedPtr InStructProperty, TSharedPtr InPropertyUtils); const UScriptStruct* GetBaseScriptStruct() const; bool CanChangeStructType() const { return bCanChangeStructType; } FOnStructPicked OnStructPicked; private: TSharedPtr ComboButton; TSharedPtr StructProperty; TSharedPtr PropUtils; /** Can we change the struct type at all? (controlled by the "StructTypeConst" meta-data) */ bool bCanChangeStructType = true; /** The array of allowed structs (additionally to the meta-data) */ TArray> AllowedStructs; /** The array of disallowed structs (additionally to the meta-data) */ TArray> DisallowedStructs; UE_API FText GetDisplayValueString() const; UE_API FText GetTooltipText() const; UE_API const FSlateBrush* GetDisplayValueIcon() const; UE_API TSharedRef GenerateStructPicker(); UE_API void StructPicked(const UScriptStruct* InStruct); }; #undef UE_API