123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- /*******************************************************************************
- 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 "UObject/ObjectMacros.h"
- #include "Styling/SlateTypes.h"
- #include "Widgets/SWidget.h"
- #include "Components/ContentWidget.h"
- #include "AkSlider.h"
- #include "Widgets/SCompoundWidget.h"
- #include "AkItemBoolProperties.h"
- #include "AkCheckBox.generated.h"
- class SCheckBox;
- class USlateBrushAsset;
- class USlateWidgetStyleAsset;
- DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam( FAkOnCheckBoxComponentStateChanged, bool, bIsChecked );
- /** A delegate type invoked when an item is being dragged. */
- DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnWwiseItemDropDetected, FGuid, ItemDroppedID);
- /** A delegate type invoked when a property is being dragged. */
- DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnBoolPropertyDropDetected, FString, PropertyDropped);
- /**
- * The checkbox widget allows you to display a toggled state of 'unchecked', 'checked' and
- * 'indeterminable. You can use the checkbox for a classic checkbox, or as a toggle button,
- * or as radio buttons.
- *
- * * Single Child
- * * Toggle
- */
- UCLASS(config = Editor, defaultconfig)
- class AKAUDIO_API UAkCheckBox : public UContentWidget, public SCompoundWidget
- {
- GENERATED_BODY()
- public:
- UAkCheckBox(const FObjectInitializer& ObjectInitializer);
- /** Whether the check box is currently in a checked state */
- UPROPERTY(EditAnywhere, Category=Appearance)
- ECheckBoxState CheckedState = ECheckBoxState::Undetermined;
- /** A bindable delegate for the IsChecked. */
- UPROPERTY()
- FGetCheckBoxState CheckedStateDelegate;
- public:
- /** The checkbox bar style */
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Style", meta=( DisplayName="Style" ))
- FCheckBoxStyle WidgetStyle;
- /** How the content of the toggle button should align within the given space */
- UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Appearance)
- TEnumAsByte<EHorizontalAlignment> HorizontalAlignment = EHorizontalAlignment::HAlign_Left;
- /** Sometimes a button should only be mouse-clickable and never keyboard focusable. */
- UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Interaction")
- bool IsFocusable = false;
- UPROPERTY(EditAnywhere, Category = "Audiokinetic|WAAPI|Checkbox", meta = (DisplayName = "Property to control"))
- FAkBoolPropertyToControl ThePropertyToControl;
- UPROPERTY(Config, VisibleAnywhere, Category = "Audiokinetic|WAAPI|Checkbox", meta = (DisplayName = "Item to control"))
- FAkWwiseItemToControl ItemToControl;
- public:
- /** Called when the checked state has changed */
- UPROPERTY(BlueprintAssignable, Category="CheckBox|Event")
- FAkOnCheckBoxComponentStateChanged AkOnCheckStateChanged;
- /** Called when the item selection changes. */
- UPROPERTY(BlueprintAssignable, Category = "Widget Event")
- FOnWwiseItemDropDetected OnItemDropped;
- /** Called when the item selection changes. */
- UPROPERTY(BlueprintAssignable, Category = "Widget Event")
- FOnBoolPropertyDropDetected OnPropertyDropped;
- public:
- /** Returns true if this button is currently pressed */
- UFUNCTION(BlueprintCallable, Category="Widget")
- bool IsPressed() const;
-
- /** Returns true if the checkbox is currently checked */
- UFUNCTION(BlueprintCallable, Category="Widget")
- bool IsChecked() const;
- /** @return the full current checked state. */
- UFUNCTION(BlueprintCallable, Category="Widget")
- ECheckBoxState GetCheckedState() const;
- /** Sets the checked state. */
- UFUNCTION(BlueprintCallable, Category="Widget")
- void SetIsChecked(bool InIsChecked);
- /** Sets the checked state. */
- UFUNCTION(BlueprintCallable, Category="Widget")
- void SetCheckedState(ECheckBoxState InCheckedState);
- /** Set the item id to the new one.
- * @param ItemId - value (new id) to set
- */
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|WAAPI|Checkbox", meta = (Keywords = "Set Item Id"))
- void SetAkItemId(const FGuid& ItemId);
- /** Returns the current item id.
- *
- * @return an id as GUID.
- */
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|WAAPI|Checkbox", meta = (Keywords = "Get Item Id"))
- const FGuid GetAkItemId() const;
- /** Set the item property to the new one.
- * @param ItemId - value (new id) to set
- */
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|WAAPI|Checkbox", meta = (Keywords = "Set Item Property"))
- void SetAkBoolProperty(const FString& ItemProperty);
- /** Returns the current item property.
- *
- * @return a property as string.
- */
- UFUNCTION(BlueprintCallable, Category = "Audiokinetic|WAAPI|Checkbox", meta = (Keywords = "Get Item Property"))
- const FString GetAkProperty() const;
- public:
-
- //~ Begin UWidget Interface
- virtual void SynchronizeProperties() override;
- //~ End UWidget Interface
- //~ Begin UVisual Interface
- virtual void ReleaseSlateResources(bool bReleaseChildren) override;
- //~ End UVisual Interface
- virtual void BeginDestroy() override;
- #if WITH_EDITOR
- virtual const FText GetPaletteCategory() override;
- #endif
- /**
- * 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 OnDropHandler(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent);
- protected:
- // UPanelWidget
- virtual void OnSlotAdded(UPanelSlot* Slot) override;
- virtual void OnSlotRemoved(UPanelSlot* Slot) override;
- // End UPanelWidget
- protected:
- //~ Begin UWidget Interface
- virtual TSharedRef<SWidget> RebuildWidget() override;
- //~ End UWidget Interface
- void SlateOnCheckStateChangedCallback(ECheckBoxState NewState);
- private:
- void SetAkItemControlled(const FString& Item);
- FText GetAkItemControlled();
- FText GetAkBoolProperty() const;
- void SynchronizePropertyWithWwise();
- protected:
- TSharedPtr<SCheckBox> MyCheckbox;
- FString ItemControlled;
- FString IdItemToControl;
- FString BoolPropertyToControl;
- uint64 SubscriptionId = 0;
- uint64 SubscriptionIdNameChanged = 0;
- PROPERTY_BINDING_IMPLEMENTATION(ECheckBoxState, CheckedState);
-
- };
|