Widget Studio
WSModernSwitch.h
1/*
2* Copyright (c) 2021 THEIA INTERACTIVE. All rights reserved.
3*
4* Website: https://widgetstudio.design
5* Documentation: https://docs.widgetstudio.design
6* Support: marketplace@theia.io
7* Marketplace FAQ: https://marketplacehelp.epicgames.com
8*/
9
10#pragma once
11
12#include "CoreMinimal.h"
13#include "Widgets/WSButtonBase.h"
14#include "Widgets/Basic/WSText.h"
15#include "Components/HorizontalBox.h"
16#include "Components/Image.h"
17#include "Components/InvalidationBox.h"
18#include "Components/Overlay.h"
19#include "Components/ScaleBox.h"
20#include "Components/SizeBox.h"
21
22#include "WSModernSwitch.generated.h"
23
24UENUM(BlueprintType)
25enum class ELabelPlacement : uint8
26{
27 Hide UMETA(DisplayName="Hide"),
28 Left UMETA(DisplayName="Left"),
29 Right UMETA(DisplayName="Right"),
30
31 LabelPlacement_Max UMETA(Hidden),
32};
33
37UCLASS()
38class WIDGETSTUDIORUNTIME_API UWidgetStudioModernSwitch : public UWidgetStudioButtonBase
39{
40 GENERATED_BODY()
41
42protected:
43
44 virtual TSharedRef<SWidget> RebuildWidget() override;
45 virtual int32 NativePaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
46 virtual void SynchronizeProperties() override;
47 virtual void InitializeStyling() override;
48 virtual void UpdateStyling() override;
49
50 /* Widget Components */
51
52 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
53 UInvalidationBox* Retainer = nullptr;
54
55 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
56 UHorizontalBox* HBox = nullptr;
57
58 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
59 UOverlay* Overlay = nullptr;
60
61 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
62 USizeBox* TrackSizeBox = nullptr;
63
64 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
65 UScaleBox* TrackScaleBox = nullptr;
66
67 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
68 UOverlay* TrackOverlay = nullptr;
69
70 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
71 UImage* TrackDropShadow = nullptr;
72
73 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
74 UImage* Track = nullptr;
75
76 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
77 UScaleBox* HandleScaleBox = nullptr;
78
79 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
80 UOverlay* HandleOverlay = nullptr;
81
82 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
83 UImage* HandleDropShadow = nullptr;
84
85 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
86 UImage* Handle = nullptr;
87
88 UPROPERTY(BlueprintReadOnly, Category = "Widgets")
89 UWidgetStudioText* LabelItem = nullptr;
90
91private:
92
93 /* Properties */
94
96 UPROPERTY(EditAnywhere, Category = "Widget Studio|Advanced|Deprecated",Meta=(DeprecatedProperty, DeprecationMessage="Per-widget labeling is no longer supported. Place this widget in the Label Widget instead."))
97 ELabelPlacement LabelPlacement = ELabelPlacement::Hide;
98
100 UPROPERTY(EditAnywhere, Category = "Widget Studio|Advanced|Deprecated",Meta=(DeprecatedProperty, DeprecationMessage="Per-widget labeling is no longer supported. Place this widget in the Label Widget instead."))
101 FText Label = FText().FromString("Switch");
102
104 UPROPERTY(EditAnywhere, Category="Widget Studio|Color")
105 EPalette TrackColor = EPalette::TertiaryBackground;
106
108 UPROPERTY(EditAnywhere, Category="Widget Studio|Color")
109 EPalette HandleColor = EPalette::PrimaryAccent;
110
112 UPROPERTY(EditAnywhere, Category="Widget Studio|Color", Meta = (EditCondition="LabelPlacement != ELabelPlacement::Hide", EditConditionHides))
113 EPalette LabelColor = EPalette::PrimaryBackground;
114
115public:
116
117 /* Helpers */
118
120 UFUNCTION(BlueprintPure, Category = "Widget Studio|Advanced|Deprecated",Meta=(DeprecatedProperty, DeprecationMessage="Per-widget labeling is no longer supported. Place this widget in the Label Widget instead."))
121 FText GetLabel() const;
122
124 UFUNCTION(BlueprintPure, Category = "Widget Studio|Advanced|Deprecated",Meta=(DeprecatedProperty, DeprecationMessage="Per-widget labeling is no longer supported. Place this widget in the Label Widget instead."))
125 bool IsLabelVisible() const;
126
128 UFUNCTION(BlueprintPure, Category="Widget Studio|Helper")
129 EPalette GetTrackColor() const;
130
132 UFUNCTION(BlueprintPure, Category="Widget Studio|Helper")
133 EPalette GetHandleColor() const;
134
136 UFUNCTION(BlueprintPure, Category = "Widget Studio|Advanced|Deprecated",Meta=(DeprecatedProperty, DeprecationMessage="Per-widget labeling is no longer supported. Place this widget in the Label Widget instead."))
137 EPalette GetLabelColor() const;
138
139 /* Modifier Functions */
140
142 UFUNCTION(BlueprintCallable, Category = "Widget Studio|Advanced|Deprecated",Meta=(DeprecatedProperty, DeprecationMessage="Per-widget labeling is no longer supported. Place this widget in the Label Widget instead."))
143 void SetLabelPlacement(const ELabelPlacement NewPlacement);
144
146 UFUNCTION(BlueprintCallable, Category = "Widget Studio|Advanced|Deprecated",Meta=(DeprecatedProperty, DeprecationMessage="Per-widget labeling is no longer supported. Place this widget in the Label Widget instead."))
147 void SetLabel(FText NewLabel);
148
153 UFUNCTION(BlueprintCallable, Category="Widget Studio|Modifier")
154 void SetTrackColor(EPalette NewColor);
155
160 UFUNCTION(BlueprintCallable, Category="Widget Studio|Modifier")
161 void SetHandleColor(EPalette NewColor);
162
164 UFUNCTION(BlueprintCallable, Category = "Widget Studio|Advanced|Deprecated",Meta=(DeprecatedProperty, DeprecationMessage="Per-widget labeling is no longer supported. Place this widget in the Label Widget instead."))
165 void SetLabelColor(EPalette NewColor);
166
167};
Contain the fundamental logic for a Widget Studio button.
Definition: WSButtonBase.h:27
A modern styled switch.
Definition: WSModernSwitch.h:39
A custom text widget setup to work with the Typography Styling.
Definition: WSText.h:92