Touch Interface Designer 2025.2
Create touch interface with a visual editor and manage all mobile inputs like gestures
Loading...
Searching...
No Matches
SProgressBarLayer.h
Go to the documentation of this file.
1// Copyright 2025 Lost in Game Studio. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Widgets/SLeafWidget.h"
7
8class UMaterialInstanceDynamic;
9
13class TOUCHINTERFACE_API SProgressBarLayer : public SLeafWidget
14{
15public:
29
31 {
35 Draw
36 };
37
39 : _Percent(0.0f)
40 , _FillStyle(EProgressFillStyle::Scale)
41 , _FillType(EProgressFillType::BottomToTop)
42 , _StartAngle(0.0f)
43 , _EndAngle(360.0f)
44 , _AngularOffset(0.0f)
45 , _FillColor(FLinearColor(0.0f, 0.5f, 1.0f, 1.0f))
46 , _Radius(0.8f)
47 , _Thickness(4.0f)
48 , _CircleResolution(50)
49 , _bDrawBackground(true)
50 , _BackgroundColor(FLinearColor(0.1f, 0.1f, 0.1f, 0.6f))
51 , _BackgroundRadius(0.8f)
52 , _BackgroundThickness(4.0f)
53 , _AntiAliasing(true)
54 {
55 }
56 SLATE_ARGUMENT(float, Percent)
57 SLATE_ARGUMENT(EProgressFillStyle, FillStyle)
58 SLATE_ARGUMENT(EProgressFillType, FillType)
59 SLATE_ARGUMENT(float, StartAngle)
60 SLATE_ARGUMENT(float, EndAngle)
61 SLATE_ARGUMENT(float, AngularOffset)
62 SLATE_ARGUMENT(FSlateBrush, Brush)
63 SLATE_ARGUMENT(FLinearColor, FillColor)
64 SLATE_ARGUMENT(float, Radius)
65 SLATE_ARGUMENT(float, Thickness)
66 SLATE_ARGUMENT(int32, CircleResolution)
67 SLATE_ARGUMENT(bool, bDrawBackground)
68 SLATE_ARGUMENT(FSlateBrush, BackgroundBrush)
69 SLATE_ARGUMENT(FLinearColor, BackgroundColor)
70 SLATE_ARGUMENT(float, BackgroundRadius)
71 SLATE_ARGUMENT(float, BackgroundThickness)
72 SLATE_ARGUMENT(bool, AntiAliasing)
73
74 SLATE_END_ARGS()
75
77
79 void Construct(const FArguments& InArgs);
80
81 virtual FVector2D ComputeDesiredSize(float LayoutScaleMultiplier) const override;
82
83 virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
84
85private:
86 virtual void DrawFillScale(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle) const;
87
88 virtual void DrawFillMasked(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle) const;
89
90 virtual void DrawFillMaterial(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle) const;
91
92 virtual void Draw(const FGeometry& AllottedGeometry, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle) const;
93
94 void AddSliderPointToArray(TArray<FVector2D>& SliderPoints, const bool bIsUnique, const FVector2D& SliderPoint) const;
95
96public:
97 void SetPercent(const float Value);
98
99 void SetMaterial(TObjectPtr<UMaterialInstanceDynamic> Material);
100
101 void SetFillStyle(const EProgressFillStyle NewStyle) { FillStyle = NewStyle; }
102
103 void SetFillType(const EProgressFillType NewType) { FillType = NewType; }
104
105 void SetStartAngle(const float Value) { StartAngle = Value; }
106
107 void SetEndAngle(const float Value) { EndAngle = Value; }
108
109 void SetAngularOffset(const float Value) { AngularOffset = Value; }
110
111 void SetFillColor(const FLinearColor Color) { FillColor = Color; }
112
113 void SetRadius(const float Value) { Radius = Value; }
114
115 void SetThickness(const float Value) { Thickness = Value; }
116
117 void SetBackgroundVisibility(const bool bVisible) { bDrawBackground = bVisible; }
118
119 void SetBackgroundColor(const FLinearColor Color) { BackgroundColor = Color; }
120
121 void SetBackgroundRadius(const float Value) { BackgroundRadius = Value; }
122
123 void SetBackgroundThickness(const float Value) { BackgroundThickness = Value; }
124
125 void SetCircleResolution(const int32 Value) { CircleResolution = Value; }
126
127 void EnableAntiAliasing(const bool bEnable) { bAntiAliasing = bEnable; }
128
129private:
130 //Percent (0 = empty to 1 = full)
131 float Percent;
132
133 // Fill style of progress bar
134 EProgressFillStyle FillStyle;
135
136 // Fill type of progress bar
137 EProgressFillType FillType;
138
139 // Start angle value in degree
140 float StartAngle;
141
142 // End angle value in degree
143 float EndAngle;
144
145 // Rotation of circular progress
146 float AngularOffset;
147
148 FSlateBrush Brush;
149
150 // Color of fill bar
151 FLinearColor FillColor;
152
153 // Radius of fill bar
154 float Radius;
155
156 // Thickness of fill bar
157 float Thickness;
158
159
160 // If enabled, add background under fill bar
161 uint8 bDrawBackground:1;
162
163 // Slate brush for background bar
164 FSlateBrush BackgroundBrush;
165
166 // Color of background bar
167 FLinearColor BackgroundColor;
168
169 // Radius of background bar
170 float BackgroundRadius;
171
172 // Thickness of background bar
173 float BackgroundThickness;
174
175 //TODO: Material property: Smoothness, thickness, division, etc
176
177 //UPROPERTY(Category="Progress Bar Layer|Advanced", EditAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess="true"))
178 //uint8 bUseDivision:1;
179
180 //UPROPERTY(Category="Progress Bar Layer|Advanced", EditAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess="true"), meta=(EditCondition="bUseDivision==true", EditConditionHides))
181 //int32 Division;
182
183 // Precision of circle
184 int32 CircleResolution;
185
186 // Whether or not, the anti-aliasing is used for drawing
187 uint8 bAntiAliasing:1;
188};
EProgressFillStyle
Definition ProgressBarLayer.h:30
@ Draw
Definition ProgressBarLayer.h:43
@ Masked
Definition ProgressBarLayer.h:37
@ Scale
Definition ProgressBarLayer.h:33
@ Material
Definition ProgressBarLayer.h:40
EProgressFillType
Definition ProgressBarLayer.h:14
@ FromCenter
Definition ProgressBarLayer.h:17
@ BottomToTop
Definition ProgressBarLayer.h:21
@ CounterClockwise
Definition ProgressBarLayer.h:23
@ FromCenterVertical
Definition ProgressBarLayer.h:19
@ RightToLeft
Definition ProgressBarLayer.h:16
@ Clockwise
Definition ProgressBarLayer.h:22
@ LeftToRight
Definition ProgressBarLayer.h:15
@ TopToBottom
Definition ProgressBarLayer.h:20
@ FromCenterHorizontal
Definition ProgressBarLayer.h:18
Definition SProgressBarLayer.h:14
void SetBackgroundRadius(const float Value)
Definition SProgressBarLayer.h:121
void SetFillStyle(const EProgressFillStyle NewStyle)
Definition SProgressBarLayer.h:101
SProgressBarLayer()
Definition SProgressBarLayer.cpp:11
void SetRadius(const float Value)
Definition SProgressBarLayer.h:113
void SetFillColor(const FLinearColor Color)
Definition SProgressBarLayer.h:111
void SetThickness(const float Value)
Definition SProgressBarLayer.h:115
void SetStartAngle(const float Value)
Definition SProgressBarLayer.h:105
SLATE_BEGIN_ARGS(SProgressBarLayer)
Definition SProgressBarLayer.h:38
void SetBackgroundColor(const FLinearColor Color)
Definition SProgressBarLayer.h:119
void SetCircleResolution(const int32 Value)
Definition SProgressBarLayer.h:125
EProgressFillStyle
Definition SProgressBarLayer.h:31
void SetFillType(const EProgressFillType NewType)
Definition SProgressBarLayer.h:103
void EnableAntiAliasing(const bool bEnable)
Definition SProgressBarLayer.h:127
void SetBackgroundVisibility(const bool bVisible)
Definition SProgressBarLayer.h:117
void SetBackgroundThickness(const float Value)
Definition SProgressBarLayer.h:123
EProgressFillType
Definition SProgressBarLayer.h:17
void SetEndAngle(const float Value)
Definition SProgressBarLayer.h:107
void SetAngularOffset(const float Value)
Definition SProgressBarLayer.h:109