Widget Studio
All Classes Functions Variables
WSButtonGroup.h
1
10#pragma once
11
12#include "CoreMinimal.h"
13
14#include "Widgets/WSBase.h"
15#include "Widgets/WSButtonBase.h"
16#include "Widgets/Modern/WSModernCheckBox.h"
17#include "WSButtonGroup.generated.h"
18
19DECLARE_DYNAMIC_MULTICAST_DELEGATE(FWSButtonGroupChangedDelegate);
20DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWSButtonGroupDelegate, int32, Index);
21
25UCLASS()
26class WIDGETSTUDIORUNTIME_API UWidgetStudioButtonGroup : public UWidgetStudioBase
27{
28 GENERATED_BODY()
29
30 virtual void NativePreConstruct() override;
31 virtual void NativeConstruct() override;
32 virtual void SynchronizeProperties() override;;
33
34protected:
35
36 UFUNCTION()
37 void OnButtonPressed(UWidgetStudioButtonBase* Button);
38
39 UFUNCTION()
40 void UpdateCurrentIndex();
41
42 UFUNCTION()
43 void UpdateButtonCheckedStates();
44
45private:
46 /* The button selection method.
47 * Inclusive: Multiple buttons can be selected at a time.
48 * Exclusive: Only a single button can be selected at a time.
49 */
50 UPROPERTY(EditAnywhere, Category = "Widget Studio")
51 EClusivity SelectionMethod = EClusivity::Exclusive;
52
54 UPROPERTY(EditAnywhere, Category = "Widget Studio")
55 int32 CurrentIndex = -1;
56
58 UPROPERTY(EditAnywhere, Category = "Widget Studio")
59 TArray<UWidgetStudioButtonBase*> Buttons;
60
62 UPROPERTY()
63 TArray<UWidgetStudioButtonBase*> ManagedButtons = {};
64
66 UPROPERTY()
67 UWidgetStudioButtonBase* CurrentButton = nullptr;
68
69public:
70 /* Bindings */
71
72 UPROPERTY(BlueprintAssignable, Category = "Widget Studio|Event")
73 FWSButtonGroupDelegate OnCurrentIndexChanged;
74
75 UPROPERTY(BlueprintAssignable, Category = "Widget Studio|Event")
76 FWSButtonGroupChangedDelegate OnButtonsChanged;
77
78
79 /* Helpers */
80
82 UFUNCTION(BlueprintPure, Category = "Widget Studio|Helper")
83 int32 GetCurrentIndex() const;
84
86 UFUNCTION(BlueprintPure, Category = "Widget Studio|Helper")
87 TArray<UWidgetStudioButtonBase*> GetButtons() const;
88
93 UFUNCTION(BlueprintPure, Category = "Widget Studio|Helper")
94 UWidgetStudioButtonBase* GetButtonAtIndex(int32 Index);
95
97 UFUNCTION(BlueprintPure, Category = "Widget Studio|Helper")
98 UWidgetStudioButtonBase* GetCurrentButton();
99
101 UFUNCTION(BlueprintPure, Category = "Widget Studio|Helper")
102 int32 GetButtonCount() const;
103
105 UFUNCTION(BlueprintPure, Category = "Widget Studio|Helper")
106 EClusivity GetSelectionMethod() const;
107
108
109 /* Modifiers */
110
115 UFUNCTION(BlueprintCallable, Category = "Widget Studio|Modifier")
116 void AddButton(UWidgetStudioButtonBase* NewButton);
117
122 UFUNCTION(BlueprintCallable, Category = "Widget Studio|Modifier")
123 bool RemoveButton(UWidgetStudioButtonBase* ButtonToRemove);
124
129 UFUNCTION(BlueprintCallable, Category = "Widget Studio|Modifier")
130 void RemoveButtonAtIndex(int32 Index);
131
133 UFUNCTION(BlueprintCallable, Category = "Widget Studio|Modifier")
134 void RemoveAllButtons();
135
141 UFUNCTION(BlueprintCallable, Category = "Widget Studio|Modifier")
142 void SetCurrentIndex(int32 Index, bool bBroadcast = true);
143
148 UFUNCTION(BlueprintCallable, Category = "Widget Studio|Modifier")
149 void SetSelectionMethod(EClusivity NewMethod);
150
151};
The base User Widget class for Widget Studio.
Definition: WSBase.h:32
Contain the fundamental logic for a Widget Studio button.
Definition: WSButtonBase.h:27
A utility widget to group buttons and their logic together.
Definition: WSButtonGroup.h:27