/******************************************************************************* The content of this file includes portions of the proprietary AUDIOKINETIC Wwise Technology released in source code form as part of the game integration package. The content of this file may not be used without valid licenses to the AUDIOKINETIC Wwise Technology. Note that the use of the game engine is subject to the Unreal(R) Engine End User License Agreement at https://www.unrealengine.com/en-US/eula/unreal License Usage Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use this file in accordance with the end user license agreement provided with the software or, alternatively, in accordance with the terms contained in a written agreement between you and Audiokinetic Inc. Copyright (c) 2023 Audiokinetic Inc. *******************************************************************************/ #pragma once #include "CoreMinimal.h" #include "Input/Reply.h" #include "Styling/SlateWidgetStyleAsset.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "Styling/SlateTypes.h" #include "Styling/CoreStyle.h" #include "Framework/SlateDelegates.h" #include "Widgets/SCompoundWidget.h" class SSlider; /** * A Slate slider control is a linear scale and draggable handle. */ class AKAUDIO_API AkSSlider : public SCompoundWidget { public: SLATE_BEGIN_ARGS(AkSSlider) : _Style(&FCoreStyle::Get().GetWidgetStyle("Slider")) , _IsFocusable(true) , _OnValueChanged() , _OnDrop() {} /** The style used to draw the slider. */ SLATE_STYLE_ARGUMENT(FSliderStyle, Style) /** Sometimes a slider should only be mouse-clickable and never keyboard focusable. */ SLATE_ARGUMENT(bool, IsFocusable) /** Called when the value is changed by the slider. */ SLATE_EVENT(FOnFloatValueChanged, OnValueChanged) /** Called when an item is dropped into the slider. */ SLATE_EVENT(FOnDrop, OnDrop) /** Slot for this designers content (optional) */ SLATE_DEFAULT_SLOT(FArguments, Content) SLATE_END_ARGS() /** * Construct the widget. * * @param InDeclaration A declaration from which to construct the widget. */ void Construct( const AkSSlider::FArguments& InDeclaration ); TSharedPtr GetAkSilder() const; /** * Getter to access the current value of the slider * * @Return the current value of the slider */ TOptional GetAkSliderValue() const; /** * Getter to access the current property controlled by the slider * * @Return the current property of the slider */ FText GetAkSliderProperty() const; /** * Getter to access the name of the current item controlled by the slider * * @Return the item name of the item controlled */ FText GetAkSliderItemControlled() const; void SetAkSliderItemProperty(const FString& ItemProperty); const FString& GetAkSliderItemProperty() const; void SetAkSliderItemId(const FString& ItemId); const FString& GetAkSliderItemId() const; /** * Setters to update the min and max range of a property */ void SetAkSliderRangeMin(const double in_NewValue); void SetAkSliderRangeMax(const double in_NewValue); /** * Getters to access the min and max range of a property */ TOptional GetAkSliderRangeMin() const; TOptional GetAkSliderRangeMax() const; /** * Called when the user is dropping something onto a widget; terminates drag and drop. * * @param MyGeometry The geometry of the widget receiving the event. * @param DragDropEvent The drag and drop event. * * @return A reply that indicated whether this event was handled. */ FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override; /** * Called when the user changes the value of the slider. * * @param newValue The new value to set for the slider. */ void OnValueCommitted(double newValue, ETextCommit::Type Commit); private: /** Holds the scrubber slider. */ TSharedPtr AkScrubberSSlider; /** holds the current value of the slider*/ FText AkSliderValue; /** holds the property of the item to be controlled*/ FString AkSliderItemProperty; /** holds the ID of the current item to control*/ FString AkSliderItemId; /** holds the name of the current item to control*/ FString ItemControlled; /** Executed when an item is dropped onto the slider*/ FOnDrop OnDropDelegate; /** The max range of the property controlled by the current slider*/ double UIMaxValue; /** The min range of the property controlled by the current slider*/ double UIMinValue; private: /** Callback for changing the value of the 'Position' slider. */ void HandleAkSliderValueChanged(float NewValue); protected: inline void UpdateRange(); };