UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SSlider.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Misc/Attribute.h"
7#include "Input/Reply.h"
10#include "Styling/SlateColor.h"
11#include "Styling/SlateTypes.h"
12#include "Styling/CoreStyle.h"
14#include "Widgets/SLeafWidget.h"
15
16class FPaintArgs;
18
22class SSlider : public SLeafWidget
23{
25
26public:
27
48
50 SLATE_ATTRIBUTE( bool, IndentHandle )
51
52
53 SLATE_ARGUMENT( bool, MouseUsesStep )
54
55
56 SLATE_ARGUMENT( bool, RequiresControllerLock )
57
58
59 SLATE_ATTRIBUTE( bool, Locked )
60
61
63
64
65 SLATE_ATTRIBUTE( FSlateColor, SliderBarColor )
66
67
68 SLATE_ATTRIBUTE( FSlateColor, SliderHandleColor )
69
70
72
73
75
76
77 SLATE_ATTRIBUTE( float, Value )
78
79
83
84
85 SLATE_ARGUMENT(bool, IsFocusable)
86
87
88 SLATE_EVENT(FSimpleDelegate, OnMouseCaptureBegin)
89
90
91 SLATE_EVENT(FSimpleDelegate, OnMouseCaptureEnd)
92
93
94 SLATE_EVENT(FSimpleDelegate, OnControllerCaptureBegin)
95
96
97 SLATE_EVENT(FSimpleDelegate, OnControllerCaptureEnd)
98
99
100 SLATE_EVENT( FOnFloatValueChanged, OnValueChanged )
101
102
103 SLATE_ARGUMENT(bool, PreventThrottling)
104
106
109
115 SLATE_API void Construct( const SSlider::FArguments& InDeclaration );
116
119
121 float GetMinValue() const { return MinValue; }
122
124 float GetMaxValue() const { return MaxValue; }
125
127 SLATE_API float GetValue() const;
128
130 SLATE_API float GetNormalizedValue() const;
131
134
137
140
143
146
149
152
154 SLATE_API float GetStepSize() const;
155
158
160 SLATE_API void SetMouseUsesStep(bool MouseUsesStep);
161
163 SLATE_API void SetRequiresControllerLock(bool RequiresControllerLock);
164
165public:
166
167 // SWidget overrides
168
169 SLATE_API virtual int32 OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const override;
170 SLATE_API virtual FVector2D ComputeDesiredSize(float) const override;
174 SLATE_API virtual FReply OnMouseMove( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) override;
178 SLATE_API virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override;
179 SLATE_API virtual FReply OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override;
180 SLATE_API virtual void OnFocusLost(const FFocusEvent& InFocusEvent) override;
182
183 SLATE_API virtual bool SupportsKeyboardFocus() const override;
184 SLATE_API virtual bool IsInteractable() const override;
185#if WITH_ACCESSIBILITY
187#endif
188
190 SLATE_API bool IsLocked() const;
191
192protected:
193
199 SLATE_API virtual void CommitValue(float NewValue);
200
209
210 SLATE_API const FSlateBrush* GetBarImage() const;
211 SLATE_API const FSlateBrush* GetThumbImage() const;
212
213protected:
216 {
217 return TSlateAttributeRef<float>(SharedThis(this), ValueSlateAttribute);
218 }
219
222 {
223 return TSlateAttributeRef<bool>(SharedThis(this), IndentHandleSlateAttribute);
224 }
225
228 {
229 return TSlateAttributeRef<bool>(SharedThis(this), LockedSlateAttribute);
230 }
231
234 {
235 return TSlateAttributeRef<FSlateColor>(SharedThis(this), SliderBarColorSlateAttribute);
236 }
237
240 {
241 return TSlateAttributeRef<FSlateColor>(SharedThis(this), SliderHandleColorSlateAttribute);
242 }
243
244 // Holds the style passed to the widget upon construction.
246
247 // Holds the slider's orientation.
249
250 // Holds the initial cursor in case a custom cursor has been specified, so we can restore it after dragging the slider
252
255
258
259 float MinValue;
260 float MaxValue;
261
262 // Holds a flag indicating whether a controller/keyboard is manipulating the slider's value.
263 // When true, navigation away from the widget is prevented until a new value has been accepted or canceled.
265
268
271
274
275 /*
276 * Holds whether or not to prevent throttling during mouse capture
277 * When true, the viewport will be updated with every single change to the value during dragging
278 */
279 bool bPreventThrottling = false;
280
281private:
282
283 // Resets controller input state. Fires delegates.
284 SLATE_API void ResetControllerState();
285
286 // Holds the slider's current value.
287 TSlateAttribute<float> ValueSlateAttribute;
288
289 // Holds a flag indicating whether the slideable area should be indented to fit the handle.
290 TSlateAttribute<bool> IndentHandleSlateAttribute;
291
292 // Holds a flag indicating whether the slider is locked.
293 TSlateAttribute<bool> LockedSlateAttribute;
294
295 // Holds the color of the slider bar.
296 TSlateAttribute<FSlateColor> SliderBarColorSlateAttribute;
297
298 // Holds the color of the slider handle.
299 TSlateAttribute<FSlateColor> SliderHandleColorSlateAttribute;
300
301 // Holds a delegate that is executed when the mouse is pressed and a capture begins.
302 FSimpleDelegate OnMouseCaptureBegin;
303
304 // Holds a delegate that is executed when the mouse is let up and a capture ends.
305 FSimpleDelegate OnMouseCaptureEnd;
306
307 // Holds a delegate that is executed when capture begins for controller or keyboard.
308 FSimpleDelegate OnControllerCaptureBegin;
309
310 // Holds a delegate that is executed when capture ends for controller or keyboard.
311 FSimpleDelegate OnControllerCaptureEnd;
312
313 // Holds a delegate that is executed when the slider's value changed.
314 FOnFloatValueChanged OnValueChanged;
315};
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define SLATE_STYLE_ARGUMENT(ArgType, ArgName)
Definition DeclarativeSyntaxSupport.h:280
#define SLATE_ATTRIBUTE(AttrType, AttrName)
Definition DeclarativeSyntaxSupport.h:192
#define SLATE_EVENT(DelegateName, EventName)
Definition DeclarativeSyntaxSupport.h:458
#define SLATE_END_ARGS()
Definition DeclarativeSyntaxSupport.h:116
#define SLATE_ARGUMENT(ArgType, ArgName)
Definition DeclarativeSyntaxSupport.h:208
return true
Definition ExternalRpcRegistry.cpp:601
#define SLATE_DECLARE_WIDGET_API(WidgetType, ParentType, ModuleApiDefine)
Definition SlateControlledConstruction.h:22
EOrientation
Definition SlateEnums.h:261
Definition CoreStyle.h:15
Definition NavigationReply.h:43
Definition PaintArgs.h:23
Definition Reply.h:24
Definition SlateRect.h:26
Definition DrawElements.h:220
Definition WidgetStyle.h:15
Definition SLeafWidget.h:29
Definition SSlider.h:23
SLATE_API void Construct(const SSlider::FArguments &InDeclaration)
Definition SSlider.cpp:40
TSlateAttributeRef< float > GetValueAttribute() const
Definition SSlider.h:215
virtual SLATE_API FReply OnMouseButtonDown(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent) override
Definition SSlider.cpp:293
SLATE_API float GetStepSize() const
Definition SSlider.cpp:580
SLATE_API void SetIndentHandle(TAttribute< bool > InIndentHandle)
Definition SSlider.cpp:551
virtual SLATE_API void CommitValue(float NewValue)
Definition SSlider.cpp:415
virtual SLATE_API FNavigationReply OnNavigation(const FGeometry &MyGeometry, const FNavigationEvent &InNavigationEvent) override
Definition SSlider.cpp:193
EOrientation Orientation
Definition SSlider.h:248
bool bMouseUsesStep
Definition SSlider.h:267
virtual SLATE_API FReply OnKeyUp(const FGeometry &MyGeometry, const FKeyEvent &InKeyEvent) override
Definition SSlider.cpp:273
SLATE_API bool IsLocked() const
Definition SSlider.cpp:169
SLATE_API float GetNormalizedValue() const
Definition SSlider.cpp:520
bool bRequiresControllerLock
Definition SSlider.h:270
bool bIsFocusable
Definition SSlider.h:273
TSlateAttributeRef< bool > GetLockedAttribute() const
Definition SSlider.h:227
EMouseCursor::Type CachedCursor
Definition SSlider.h:251
SLATE_API void SetStyle(const FSliderStyle *InStyle)
Definition SSlider.cpp:163
virtual SLATE_API void OnMouseCaptureLost(const FCaptureLostEvent &CaptureLostEvent) override
Definition SSlider.cpp:330
SLATE_BEGIN_ARGS(SSlider)
Definition SSlider.h:28
virtual SLATE_API bool SupportsKeyboardFocus() const override
Definition SSlider.cpp:179
virtual SLATE_API bool IsInteractable() const override
Definition SSlider.cpp:174
bool bPreventThrottling
Definition SSlider.h:279
SLATE_API float PositionToValue(const FGeometry &MyGeometry, const UE::Slate::FDeprecateVector2DParameter &AbsolutePosition)
Definition SSlider.cpp:432
SLATE_API void SetValue(TAttribute< float > InValueAttribute)
Definition SSlider.cpp:532
SLATE_API void SetRequiresControllerLock(bool RequiresControllerLock)
Definition SSlider.cpp:595
float MaxValue
Definition SSlider.h:260
virtual SLATE_API FReply OnTouchMoved(const FGeometry &MyGeometry, const FPointerEvent &InTouchEvent) override
Definition SSlider.cpp:367
SLATE_API float GetValue() const
Definition SSlider.cpp:515
float GetMaxValue() const
Definition SSlider.h:124
virtual SLATE_API FReply OnTouchEnded(const FGeometry &MyGeometry, const FPointerEvent &InTouchEvent) override
Definition SSlider.cpp:397
TSlateAttributeRef< FSlateColor > GetSliderBarColorAttribute() const
Definition SSlider.h:233
SLATE_API void SetSliderHandleColor(TAttribute< FSlateColor > InSliderHandleColor)
Definition SSlider.cpp:575
virtual SLATE_API FReply OnKeyDown(const FGeometry &MyGeometry, const FKeyEvent &InKeyEvent) override
Definition SSlider.cpp:236
virtual SLATE_API FVector2D ComputeDesiredSize(float) const override
Definition SSlider.cpp:143
SLATE_API const FSlateBrush * GetThumbImage() const
Definition SSlider.cpp:499
float GetMinValue() const
Definition SSlider.h:121
virtual SLATE_API int32 OnPaint(const FPaintArgs &Args, const FGeometry &AllottedGeometry, const FSlateRect &MyCullingRect, FSlateWindowElementList &OutDrawElements, int32 LayerId, const FWidgetStyle &InWidgetStyle, bool bParentEnabled) const override
Definition SSlider.cpp:68
virtual SLATE_API FReply OnMouseMove(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent) override
Definition SSlider.cpp:336
SLATE_API void SetLocked(TAttribute< bool > InLocked)
Definition SSlider.cpp:556
SLATE_API void SetOrientation(EOrientation InOrientation)
Definition SSlider.cpp:561
SLATE_API void SetSliderBarColor(TAttribute< FSlateColor > InSliderBarColor)
Definition SSlider.cpp:570
UE::Slate::FDeprecateVector2DResult PressedScreenSpaceTouchDownPosition
Definition SSlider.h:254
SLATE_API void SetMinAndMaxValues(float InMinValue, float InMaxValue)
Definition SSlider.cpp:537
const FSliderStyle * Style
Definition SSlider.h:245
TAttribute< float > StepSize
Definition SSlider.h:257
SLATE_API void SetStepSize(TAttribute< float > InStepSize)
Definition SSlider.cpp:585
bool bControllerInputCaptured
Definition SSlider.h:264
virtual SLATE_API void OnFocusLost(const FFocusEvent &InFocusEvent) override
Definition SSlider.cpp:283
TSlateAttributeRef< bool > GetIndentHandleAttribute() const
Definition SSlider.h:221
SLATE_API void SetMouseUsesStep(bool MouseUsesStep)
Definition SSlider.cpp:590
float MinValue
Definition SSlider.h:259
TSlateAttributeRef< FSlateColor > GetSliderHandleColorAttribute() const
Definition SSlider.h:239
virtual SLATE_API FReply OnTouchStarted(const FGeometry &MyGeometry, const FPointerEvent &InTouchEvent) override
Definition SSlider.cpp:352
SLATE_API const FSlateBrush * GetBarImage() const
Definition SSlider.cpp:483
virtual SLATE_API FReply OnMouseButtonUp(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent) override
Definition SSlider.cpp:315
Definition Attribute.h:17
static UE_FORCEINLINE_HINT TSharedRef< OtherType, Mode > SharedThis(OtherType *ThisPtr)
Definition SharedPointer.h:1780
Definition SharedPointer.h:153
Type
Definition ICursor.h:18
FDeprecateSlateVector2D FDeprecateVector2DResult
Definition SlateVector2.h:469
@ false
Definition radaudio_common.h:23
Definition Events.h:106
Definition Events.h:51
Definition Geometry.h:40
Definition Events.h:431
Definition Color.h:48
Definition Events.h:1148
Definition Events.h:695
Definition SlateBrush.h:239
Definition SlateColor.h:42
Definition SlateTypes.h:1340
Definition SWidget.h:255
Definition SWidget.h:189
Definition SlateVector2.h:485