AkWaapiUri.h 5.1 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. AkWaapiUri.h
  17. ------------------------------------------------------------------------------------*/
  18. #pragma once
  19. /*------------------------------------------------------------------------------------
  20. SAkWaapiUri
  21. ------------------------------------------------------------------------------------*/
  22. #include "Widgets/Views/STableRow.h"
  23. #include "Widgets/Views/STreeView.h"
  24. #include "Kismet/BlueprintFunctionLibrary.h"
  25. #include "Widgets/Input/SSearchBox.h"
  26. #include "Misc/TextFilter.h"
  27. #include "AkWaapiUri.generated.h"
  28. /**
  29. * Structure for Uri
  30. */
  31. USTRUCT(BlueprintType)
  32. struct AKAUDIO_API FAkWaapiUri
  33. {
  34. GENERATED_BODY()
  35. /**
  36. * The Uri
  37. */
  38. UPROPERTY(EditAnywhere, BlueprintReadOnly,Category = Uri, meta = (DisplayName = "Uri"))
  39. FString Uri;
  40. };
  41. /*------------------------------------------------------------------------------------
  42. UAkWaapiUriConv
  43. ------------------------------------------------------------------------------------*/
  44. UCLASS()
  45. class AKAUDIO_API UAkWaapiUriConv : public UBlueprintFunctionLibrary
  46. {
  47. GENERATED_BODY()
  48. public:
  49. UAkWaapiUriConv(const class FObjectInitializer& ObjectInitializer);
  50. /** Converts an AkWaapiUri value to a string */
  51. UFUNCTION(BlueprintPure, meta = (DisplayName = "ToString (FAkWaapiUri)", CompactNodeTitle = "->", BlueprintAutocast), Category = "Utilities|String")
  52. static FString Conv_FAkWaapiUriToString(const FAkWaapiUri& INAkWaapiUri);
  53. /** Converts an AkWaapiUri value to a localizable text */
  54. UFUNCTION(BlueprintPure, meta = (DisplayName = "ToText (FAkWaapiUri)", CompactNodeTitle = "->", BlueprintAutocast), Category = "Utilities|Text")
  55. static FText Conv_FAkWaapiUriToText(const FAkWaapiUri& INAkWaapiUri);
  56. };
  57. typedef TTextFilter< const FString& > StringFilter;
  58. /*------------------------------------------------------------------------------------
  59. SAkWaapiUri
  60. ------------------------------------------------------------------------------------*/
  61. class AKAUDIO_API SAkWaapiUri : public SCompoundWidget
  62. {
  63. public:
  64. typedef TSlateDelegates< TSharedPtr< FString > >::FOnSelectionChanged FOnSelectionChanged;
  65. public:
  66. SLATE_BEGIN_ARGS(SAkWaapiUri)
  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. SAkWaapiUri(void);
  83. ~SAkWaapiUri();
  84. /** Returns all the Uris currently selected in the Waapi Picker view */
  85. const TArray<TSharedPtr<FString>> GetSelectedUri() const;
  86. private:
  87. /** The tree view widget */
  88. TSharedPtr< SListView< TSharedPtr<FString>> > ListViewPtr;
  89. /** The Uri list search box */
  90. TSharedPtr< SSearchBox > SearchBoxPtr;
  91. /** Filter for the search box */
  92. TSharedPtr<StringFilter> SearchBoxFilter;
  93. /** Uri list */
  94. TArray< TSharedPtr<FString> > UriList;
  95. /** Delegate to invoke when drag drop detected. */
  96. FOnDragDetected OnDragDetected;
  97. /** Delegate to invoke when a Uri 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_Uri, const TSharedRef<STableViewBase>& OwnerTable);
  104. /** Used by the search filter */
  105. void PopulateSearchStrings(const FString& in_Uri, OUT TArray< FString >& OutSearchStrings) const;
  106. void FilterUpdated();
  107. /** Handler for list view selection changes */
  108. void ListSelectionChanged(TSharedPtr< FString > in_Uri, ESelectInfo::Type SelectInfo);
  109. };