AkWaapiFieldNames.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. /*------------------------------------------------------------------------------------
  16. AkWaapiFieldNames.h
  17. ------------------------------------------------------------------------------------*/
  18. #pragma once
  19. /*------------------------------------------------------------------------------------
  20. SAkWaapiFieldNames
  21. ------------------------------------------------------------------------------------*/
  22. #include "Misc/TextFilter.h"
  23. #include "Widgets/Views/STableRow.h"
  24. #include "Widgets/Views/STreeView.h"
  25. #include "Kismet/BlueprintFunctionLibrary.h"
  26. #include "Widgets/Input/SSearchBox.h"
  27. #include "AkWaapiFieldNames.generated.h"
  28. /**
  29. * Structure for Field Names
  30. */
  31. USTRUCT(BlueprintType)
  32. struct AKAUDIO_API FAkWaapiFieldNames
  33. {
  34. GENERATED_BODY()
  35. /**
  36. * The Field Name
  37. */
  38. UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = FieldName, meta = (DisplayName = "Field Name"))
  39. FString FieldName;
  40. };
  41. /*------------------------------------------------------------------------------------
  42. USAkWaapiFieldNamesConv
  43. ------------------------------------------------------------------------------------*/
  44. UCLASS()
  45. class AKAUDIO_API USAkWaapiFieldNamesConv : public UBlueprintFunctionLibrary
  46. {
  47. GENERATED_BODY()
  48. public:
  49. USAkWaapiFieldNamesConv(const class FObjectInitializer& ObjectInitializer);
  50. /** Converts an AkWaapiFieldName value to a string */
  51. UFUNCTION(BlueprintPure, meta = (DisplayName = "ToString (FAkWaapiFieldNames)", CompactNodeTitle = "->", BlueprintAutocast), Category = "Utilities|String")
  52. static FString Conv_FAkWaapiFieldNamesToString(const FAkWaapiFieldNames& INAkWaapiFieldNames);
  53. /** Converts an AkWaapiFieldName value to a localizable text */
  54. UFUNCTION(BlueprintPure, meta = (DisplayName = "ToText (FAkWaapiFieldNames)", CompactNodeTitle = "->", BlueprintAutocast), Category = "Utilities|Text")
  55. static FText Conv_FAkWaapiFieldNamesToText(const FAkWaapiFieldNames& INAkWaapiFieldNames);
  56. };
  57. typedef TTextFilter< const FString& > StringFilter;
  58. /*------------------------------------------------------------------------------------
  59. SAkWaapiFieldNames
  60. ------------------------------------------------------------------------------------*/
  61. class AKAUDIO_API SAkWaapiFieldNames : public SCompoundWidget
  62. {
  63. public:
  64. typedef TSlateDelegates< TSharedPtr< FString > >::FOnSelectionChanged FOnSelectionChanged;
  65. public:
  66. SLATE_BEGIN_ARGS(SAkWaapiFieldNames)
  67. : _FocusSearchBoxWhenOpened(true)
  68. , _SelectionMode(ESelectionMode::Multi)
  69. {}
  70. /** Content displayed to the left of the search bar */
  71. SLATE_NAMED_SLOT(FArguments, SearchContent)
  72. /** If true, the search box will be focus the frame after construction */
  73. SLATE_ARGUMENT(bool, FocusSearchBoxWhenOpened)
  74. /** The selection mode for the list view */
  75. SLATE_ARGUMENT(ESelectionMode::Type, SelectionMode)
  76. /** Handles the drag and drop operations */
  77. SLATE_EVENT(FOnDragDetected, OnDragDetected)
  78. /** Handles the selection operation */
  79. SLATE_EVENT(FOnSelectionChanged, OnSelectionChanged)
  80. SLATE_END_ARGS()
  81. void Construct(const FArguments& InArgs);
  82. SAkWaapiFieldNames(void);
  83. ~SAkWaapiFieldNames();
  84. /** Returns all the FieldNames currently selected in the Waapi Picker view */
  85. const TArray<TSharedPtr<FString>> GetSelectedFieldNames() const;
  86. private:
  87. /** The tree view widget */
  88. TSharedPtr< SListView< TSharedPtr<FString>> > ListViewPtr;
  89. /** The FieldNames list search box */
  90. TSharedPtr< SSearchBox > SearchBoxPtr;
  91. /** Filter for the search box */
  92. TSharedPtr<StringFilter> SearchBoxFilter;
  93. /** Field Names list */
  94. TArray< TSharedPtr<FString> > FieldNamesList;
  95. /** Delegate to invoke when drag drop detected. */
  96. FOnDragDetected OnDragDetected;
  97. /** Delegate to invoke when a Field Name is selected. */
  98. FOnSelectionChanged OnSelectionChanged;
  99. private:
  100. /** One-off active timer to focus the widget post-construct */
  101. EActiveTimerReturnType SetFocusPostConstruct(double InCurrentTime, float InDeltaTime);
  102. /** Generate a row in the tree view */
  103. TSharedRef<ITableRow> GenerateRow(TSharedPtr<FString> in_FieldName, const TSharedRef<STableViewBase>& OwnerTable);
  104. /** Used by the search filter */
  105. void PopulateSearchStrings(const FString& in_FieldName, OUT TArray< FString >& OutSearchStrings) const;
  106. void FilterUpdated();
  107. /** Handler for list view selection changes */
  108. void ListSelectionChanged(TSharedPtr< FString > in_FieldName, ESelectInfo::Type SelectInfo);
  109. };