// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Containers/Array.h" #include "Containers/BitArray.h" #include "Containers/Set.h" #include "Containers/SparseArray.h" #include "Containers/UnrealString.h" #include "CoreMinimal.h" #include "CoreTypes.h" #include "Delegates/Delegate.h" #include "Fonts/SlateFontInfo.h" #include "HAL/PlatformCrt.h" #include "Internationalization/Text.h" #include "Misc/Attribute.h" #include "Misc/Optional.h" #include "SlateFwd.h" #include "Styling/CoreStyle.h" #include "Styling/ISlateStyle.h" #include "Templates/SharedPointer.h" #include "Templates/TypeHash.h" #include "Templates/UnrealTemplate.h" #include "Types/SlateConstants.h" #include "Types/SlateEnums.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "Widgets/SCompoundWidget.h" #include "Widgets/Views/STableViewBase.h" #include "Widgets/Views/STreeView.h" class ITableRow; class SComboButton; class SSearchBox; class SSuggestionTextBox; class SWidget; /** A custom widget class that provides support for Blueprint namespace entry and/or selection. */ class KISMET_API SBlueprintNamespaceEntry : public SCompoundWidget { public: DECLARE_DELEGATE_OneParam(FOnNamespaceSelected, const FString&); DECLARE_DELEGATE_OneParam(FOnGetNamespacesToExclude, TSet&); UE_DEPRECATED(5.1, "Use FOnGetNamespacesToExclude instead.") DECLARE_DELEGATE_OneParam(FOnFilterNamespaceList, TArray&); SLATE_BEGIN_ARGS(SBlueprintNamespaceEntry) : _Font(FCoreStyle::Get().GetFontStyle(TEXT("NormalFont"))) , _AllowTextEntry(true) {} /** Current namespace value. */ SLATE_ARGUMENT(FString, CurrentNamespace) /** Font color and opacity. */ SLATE_ATTRIBUTE(FSlateFontInfo, Font) /** Allow text input to manually set arbitrary values. */ SLATE_ARGUMENT(bool, AllowTextEntry) /** Allow external code to set custom combo button content. */ SLATE_NAMED_SLOT(FArguments, ButtonContent) /** Called when a valid namespace is either entered or selected. */ SLATE_EVENT(FOnNamespaceSelected, OnNamespaceSelected) /** Called to allow external code to exclude one or more namespaces from the list. */ SLATE_EVENT(FOnGetNamespacesToExclude, OnGetNamespacesToExclude) /** Tooltip used for excluded namespaces that are visible in the selection drop-down. */ SLATE_ATTRIBUTE(FText, ExcludedNamespaceTooltipText) /** [DEPRECATED] Called to allow external code to filter out the namespace list. */ PRAGMA_DISABLE_DEPRECATION_WARNINGS FOnGetNamespacesToExclude ConvertOnFilterNamespaceListFn(const FOnFilterNamespaceList& LegacyDelegate) { return FOnGetNamespacesToExclude::CreateStatic(SBlueprintNamespaceEntry::HandleLegacyOnFilterNamespaceList, LegacyDelegate); } SLATE_EVENT_DEPRECATED(5.1, "Use OnGetNamespacesToExclude instead.", FOnFilterNamespaceList, OnFilterNamespaceList, OnGetNamespacesToExclude, ConvertOnFilterNamespaceListFn) PRAGMA_ENABLE_DEPRECATION_WARNINGS SLATE_END_ARGS() void Construct(const FArguments& InArgs); /** * Set the current namespace to the given identifier. * * @param InNamespace New namespace identifier. May be an empty string. */ void SetCurrentNamespace(const FString& InNamespace); protected: struct FPathTreeNodeItem { FString NodePath; TArray> ChildNodes; bool bIsSelectable = true; }; void OnTextChanged(const FText& InText); void OnTextCommitted(const FText& NewText, ETextCommit::Type InTextCommit); void OnShowingSuggestions(const FString& InputText, TArray& OutSuggestions); TSharedRef OnGetNamespaceTreeMenuContent(); TSharedRef OnGenerateRowForNamespaceTreeItem(TSharedPtr Item, const TSharedRef& OwnerTable); void OnGetChildrenForNamespaceTreeItem(TSharedPtr Item, TArray>& OutChildren); void OnNamespaceTreeFilterTextChanged(const FText& InText); void OnNamespaceTreeSelectionChanged(TSharedPtr Item, ESelectInfo::Type SelectInfo); bool OnIsNamespaceTreeItemSelectable(TSharedPtr Item) const; FText GetCurrentNamespaceText() const; void PopulateNamespaceTree(); void SelectNamespace(const FString& InNamespace); void ExpandAllTreeViewItems(const TArray>* NodeListPtr = nullptr); const TSharedPtr* FindTreeViewNode(const FString& NodePath, const TArray>* NodeListPtr = nullptr) const; PRAGMA_DISABLE_DEPRECATION_WARNINGS static void HandleLegacyOnFilterNamespaceList(TSet& OutNamespacesToExclude, FOnFilterNamespaceList LegacyDelegate); PRAGMA_ENABLE_DEPRECATION_WARNINGS private: FString CurrentNamespace; TArray AllRegisteredPaths; TSet ExcludedTreeViewPaths; TArray> RootNodes; TSharedPtr ComboButton; TSharedPtr TextBox; TSharedPtr SearchBox; TSharedPtr>> TreeView; FOnNamespaceSelected OnNamespaceSelected; FOnGetNamespacesToExclude OnGetNamespacesToExclude; TAttribute ExcludedNamespaceTooltipText; static float NamespaceListBorderPadding; static float NamespaceListMinDesiredWidth; };