// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "SlateFwd.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "Widgets/SWidget.h" #include "Widgets/SCompoundWidget.h" #include "Widgets/Views/STableViewBase.h" #include "Widgets/Views/STableRow.h" #include "Widgets/Views/STreeView.h" class IEditableSkeleton; class SComboButton; DECLARE_DELEGATE_OneParam(FOnBoneSelectionChanged, FName); DECLARE_DELEGATE_RetVal_OneParam(FName, FGetSelectedBone, bool& /*bMultipleValues*/); DECLARE_DELEGATE_RetVal(const struct FReferenceSkeleton&, FGetReferenceSkeleton); DECLARE_DELEGATE_RetVal(const TArray&, FGetSocketList); class PERSONA_API SBoneTreeMenu : public SCompoundWidget { public: // Storage object for bone hierarchy struct FBoneNameInfo { FBoneNameInfo(FName Name) : BoneName(Name) {} FName BoneName; TArray> Children; }; SLATE_BEGIN_ARGS(SBoneTreeMenu) : _bShowVirtualBones(true) , _bShowSocket(false) , _bShowNone(false) , _OnGetReferenceSkeleton() , _OnBoneSelectionChanged() , _OnGetSocketList() {} SLATE_ARGUMENT(FText, Title) SLATE_ARGUMENT(bool, bShowVirtualBones) SLATE_ARGUMENT(bool, bShowSocket) SLATE_ARGUMENT(bool, bShowNone) SLATE_ARGUMENT(FName, SelectedBone) SLATE_EVENT(FGetReferenceSkeleton, OnGetReferenceSkeleton) SLATE_EVENT(FOnBoneSelectionChanged, OnBoneSelectionChanged) SLATE_EVENT(FGetSocketList, OnGetSocketList) SLATE_END_ARGS(); /** * Construct this widget * * @param InArgs The declaration data for this widget */ void Construct(const FArguments& InArgs); /** Get the filter text widget, e.g. for focus */ TSharedPtr GetFilterTextWidget(); private: // SWidget interface virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override; // Using the current filter, repopulate the tree view void RebuildBoneList(const FName& SelectedBone); // Make a single tree row widget TSharedRef MakeTreeRowWidget(TSharedPtr InInfo, const TSharedRef& OwnerTable); // Get the children for the provided bone info void GetChildrenForInfo(TSharedPtr InInfo, TArray< TSharedPtr >& OutChildren); // Called when the user changes the search filter void OnFilterTextChanged(const FText& InFilterText); // Handle the tree view selection changing void OnSelectionChanged(TSharedPtr BoneInfo, ESelectInfo::Type SelectInfo); // Select a specific bone, helper for UI handler functions void SelectBone(TSharedPtr BoneInfo); // Tree info entries for bone picker TArray> SkeletonTreeInfo; // Mirror of SkeletonTreeInfo but flattened for searching TArray> SkeletonTreeInfoFlat; // Text to filter bone tree with FText FilterText; // Tree view used in the button menu TSharedPtr>> TreeView; //Filter text widget TSharedPtr FilterTextWidget; FOnBoneSelectionChanged OnSelectionChangedDelegate; FGetReferenceSkeleton OnGetReferenceSkeletonDelegate; FGetSocketList OnGetSocketListDelegate; bool bShowVirtualBones; bool bShowSocket; bool bShowNone; }; class PERSONA_API SBoneSelectionWidget : public SCompoundWidget { public: SLATE_BEGIN_ARGS( SBoneSelectionWidget ) : _bShowSocket(false) , _bShowVirtualBones(true) , _bShowNone(false) , _OnBoneSelectionChanged() , _OnGetSelectedBone() , _OnGetReferenceSkeleton() , _OnGetSocketList() {} SLATE_ARGUMENT(bool, bShowSocket) /** Should show skeletons virtual bones in tree */ SLATE_ARGUMENT(bool, bShowVirtualBones) /** Whether or not to show 'None' as a selectable bone name */ SLATE_ARGUMENT(bool, bShowNone) /** set selected bone name */ SLATE_EVENT(FOnBoneSelectionChanged, OnBoneSelectionChanged); /** get selected bone name **/ SLATE_EVENT(FGetSelectedBone, OnGetSelectedBone); /** Get Reference skeleton */ SLATE_EVENT(FGetReferenceSkeleton, OnGetReferenceSkeleton) /** Get Socket List */ SLATE_EVENT(FGetSocketList, OnGetSocketList) SLATE_END_ARGS(); /** * Construct this widget * * @param InArgs The declaration data for this widget */ void Construct( const FArguments& InArgs ); private: // Creates the combo button menu when clicked TSharedRef CreateSkeletonWidgetMenu(); // Called when the user selects a bone name void OnSelectionChanged(FName BoneName); // Gets the current bone name, used to get the right name for the combo button FText GetCurrentBoneName() const; FText GetFinalToolTip() const; // Base combo button TSharedPtr BonePickerButton; // delegates FOnBoneSelectionChanged OnBoneSelectionChanged; FGetSelectedBone OnGetSelectedBone; FGetReferenceSkeleton OnGetReferenceSkeleton; FGetSocketList OnGetSocketList; bool bShowSocket; bool bShowVirtualBones; bool bShowNone; // Cache supplied tooltip FText SuppliedToolTip; };