UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SColorGradingComponentSpinBox.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Input/CursorReply.h"
7#include "Input/Reply.h"
8#include "InputCoreTypes.h"
9#include "HAL/Platform.h"
10#include "Misc/Attribute.h"
13#include "Styling/CoreStyle.h"
18
19namespace UE::ColorGrading
20{
21
27 : public SCompoundWidget
28{
29public:
30
33
36
55
58
59
64 SLATE_ATTRIBUTE(EColorGradingModes, ColorGradingMode)
70 SLATE_ATTRIBUTE(TOptional<float>, MinSliderValue)
72 SLATE_ATTRIBUTE(TOptional<float>, MaxSliderValue)
74 SLATE_ATTRIBUTE(bool, AlwaysUsesDeltaSnap)
76 SLATE_ATTRIBUTE(float, Delta)
78 SLATE_ATTRIBUTE(float, ShiftMultiplier)
80 SLATE_ATTRIBUTE(float, CtrlMultiplier)
82 SLATE_ATTRIBUTE(float, Sensitivity)
84 SLATE_ATTRIBUTE(int32, LinearDeltaSensitivity)
86 SLATE_ATTRIBUTE(bool, SupportDynamicSliderMaxValue)
88 SLATE_ATTRIBUTE(bool, SupportDynamicSliderMinValue)
90 SLATE_EVENT(FOnDynamicSliderMinMaxValueChanged, OnDynamicSliderMaxValueChanged)
92 SLATE_EVENT(FOnDynamicSliderMinMaxValueChanged, OnDynamicSliderMinValueChanged)
94 SLATE_ATTRIBUTE(float, SliderExponent)
96 SLATE_ATTRIBUTE(float, SliderExponentNeutralValue)
100 SLATE_EVENT(FOnValueChanged, OnValueChanged)
102 SLATE_EVENT(FSimpleDelegate, OnBeginSliderMovement)
104 SLATE_EVENT(FOnValueChanged, OnEndSliderMovement)
106 SLATE_EVENT(FOnGetCurrentVector4Value, OnQueryCurrentColor)
111
113
115
117
123 void Construct(const FArguments& InArgs);
124
125 virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
126
128
137
146
148
150
159
161
163 TAttribute<float> GetValueAttribute() const { return ValueAttribute; }
164
166 float GetValue() const { return ValueAttribute.Get(); }
173
175 float GetMinValue() const { return MinValue.Get().Get(std::numeric_limits<float>::lowest()); }
177 {
178 MinValue = InMinValue;
179 UpdateIsSpinRangeUnlimited();
180 }
181
183 float GetMaxValue() const { return MaxValue.Get().Get(std::numeric_limits<float>::max()); }
185 {
186 MaxValue = InMaxValue;
187 UpdateIsSpinRangeUnlimited();
188 }
189
191 bool IsMinSliderValueBound() const { return MinSliderValue.IsBound(); }
192
193 float GetMinSliderValue() const { return MinSliderValue.Get().Get(std::numeric_limits<float>::lowest()); }
195 {
196 MinSliderValue = (InMinSliderValue.Get().IsSet()) ? InMinSliderValue : MinValue;
197 UpdateIsSpinRangeUnlimited();
198 }
199
201 bool IsMaxSliderValueBound() const { return MaxSliderValue.IsBound(); }
202
203 float GetMaxSliderValue() const { return MaxSliderValue.Get().Get(std::numeric_limits<float>::max()); }
205 {
206 MaxSliderValue = (InMaxSliderValue.Get().IsSet()) ? InMaxSliderValue : MaxValue;;
207 UpdateIsSpinRangeUnlimited();
208 }
209
211 bool GetAlwaysUsesDeltaSnap() const { return AlwaysUsesDeltaSnap.Get(); }
212 void SetAlwaysUsesDeltaSnap(bool bNewValue) { AlwaysUsesDeltaSnap.Set(bNewValue); }
213
215 float GetDelta() const { return Delta.Get(); }
216 void SetDelta(float InDelta) { Delta.Set(InDelta); }
217
219 float GetSliderExponent() const { return SliderExponent.Get(); }
221
222 const FColorGradingSpinBoxStyle* GetWidgetStyle() const { return Style; }
225
226protected:
234
242 void CommitValue(float NewValue, double NewSpinValue, ECommitMethod CommitMethod, ETextCommit::Type OriginalCommitInfo);
243
244 void NotifyValueCommitted(float CurrentValue) const;
245
247 static float Fraction(double InValue, double InMinValue, double InMaxValue);
248
249private:
250
252 static const TArray<FLinearColor>& GetHueGradientColors();
253 static TArray<FLinearColor> HueGradientColors;
254
255 TAttribute<float> ValueAttribute;
256 FOnValueChanged OnValueChanged;
257 FSimpleDelegate OnBeginSliderMovement;
258 FOnValueChanged OnEndSliderMovement;
259 FOnGetCurrentVector4Value OnQueryCurrentColor;
260
263
265 bool bUnlimitedSpinRange;
266 void UpdateIsSpinRangeUnlimited()
267 {
268 bUnlimitedSpinRange = !((MinValue.Get().IsSet() && MaxValue.Get().IsSet()) || (MinSliderValue.Get().IsSet() && MaxSliderValue.Get().IsSet()));
269 }
270
271 const FColorGradingSpinBoxStyle* Style;
272
273 const FSlateBrush* BorderHoveredBrush;
274 const FSlateBrush* BorderActiveBrush;
275 const FSlateBrush* BorderBrush;
276 const FSlateBrush* SelectorBrush;
277 const float* SelectorWidth;
278
279 bool bAllowSpin;
280 float DistanceDragged;
281 TAttribute<float> Delta;
282 TAttribute<float> ShiftMultiplier;
283 TAttribute<float> CtrlMultiplier;
284 TAttribute<float> Sensitivity;
285 TAttribute<int32> LinearDeltaSensitivity;
286 TAttribute<float> SliderExponent;
287 TAttribute<float> SliderExponentNeutralValue;
290 TAttribute<TOptional<float>> MinSliderValue;
291 TAttribute<TOptional<float>> MaxSliderValue;
292 TAttribute<bool> AlwaysUsesDeltaSnap;
293 TAttribute<bool> SupportDynamicSliderMaxValue;
294 TAttribute<bool> SupportDynamicSliderMinValue;
295 FOnDynamicSliderMinMaxValueChanged OnDynamicSliderMaxValueChanged;
296 FOnDynamicSliderMinMaxValueChanged OnDynamicSliderMinValueChanged;
298 TAttribute<EColorGradingModes> ColorGradingMode;
299
305 float RoundIfIntegerValue(double ValueToRound) const;
306
307 void CancelMouseCapture();
308
310 TArray<FLinearColor> GetGradientColors() const;
311
313 FLinearColor GetCurrentRGBColor() const;
314
316 FLinearColor GetCurrentHSVColor() const;
317
319 int32 PointerDraggingSliderIndex;
320
322 FIntPoint CachedMousePosition;
323
329 double InternalValue;
330
332 float PreDragValue;
333
338 float CachedExternalValue;
339
341 bool bDragging;
342
344 bool bIsTextChanging;
345
346 /*
347 * Holds whether or not to prevent throttling during mouse capture
348 * When true, the viewport will be updated with every single change to the value during dragging
349 */
350 bool bPreventThrottling;
351
353 bool bEnableWheel = true;
354
356 bool bBroadcastValueChangesPerKey = false;
357};
358
359} //namespace
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
Definition AdvancedWidgets.Build.cs:6
Definition CursorReply.h:16
Definition PaintArgs.h:23
Definition Reply.h:24
Definition SlateRect.h:26
Definition DrawElements.h:220
Definition WidgetStyle.h:15
Definition SCompoundWidget.h:22
Definition Array.h:670
Definition Attribute.h:17
const ObjectType & Get() const
Definition Attribute.h:241
void Set(const OtherType &InNewValue)
Definition Attribute.h:210
bool IsBound() const
Definition Attribute.h:427
Definition SharedPointer.h:692
Definition SharedPointer.h:1295
Definition SColorGradingComponentSpinBox.h:28
float GetMaxValue() const
Definition SColorGradingComponentSpinBox.h:183
void SetMaxSliderValue(const TAttribute< TOptional< float > > &InMaxSliderValue)
Definition SColorGradingComponentSpinBox.h:204
void SetValue(const TAttribute< float > &InValueAttribute)
Definition SColorGradingComponentSpinBox.h:167
void ApplySliderMinValueChanged(float SliderDeltaToAdd, bool UpdateOnlyIfLower)
Definition SColorGradingComponentSpinBox.cpp:276
float GetMaxSliderValue() const
Definition SColorGradingComponentSpinBox.h:203
bool IsMaxSliderValueBound() const
Definition SColorGradingComponentSpinBox.h:201
void CommitValue(float NewValue, double NewSpinValue, ECommitMethod CommitMethod, ETextCommit::Type OriginalCommitInfo)
Definition SColorGradingComponentSpinBox.cpp:468
float GetMinValue() const
Definition SColorGradingComponentSpinBox.h:175
void SetAlwaysUsesDeltaSnap(bool bNewValue)
Definition SColorGradingComponentSpinBox.h:212
const bool CommitWithMultiplier(const FPointerEvent &MouseEvent)
Definition SColorGradingComponentSpinBox.cpp:182
ECommitMethod
Definition SColorGradingComponentSpinBox.h:229
@ CommittedViaSpinMultiplier
Definition SColorGradingComponentSpinBox.h:232
@ CommittedViaSpin
Definition SColorGradingComponentSpinBox.h:230
@ CommittedViaCode
Definition SColorGradingComponentSpinBox.h:231
virtual FReply OnMouseButtonUp(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent) override
Definition SColorGradingComponentSpinBox.cpp:208
float GetSliderExponent() const
Definition SColorGradingComponentSpinBox.h:219
float GetValue() const
Definition SColorGradingComponentSpinBox.h:166
virtual FReply OnMouseButtonDown(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent) override
Definition SColorGradingComponentSpinBox.cpp:187
void ApplySliderMaxValueChanged(float SliderDeltaToAdd, bool UpdateOnlyIfHigher)
Definition SColorGradingComponentSpinBox.cpp:249
virtual FReply OnMouseMove(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent) override
Definition SColorGradingComponentSpinBox.cpp:311
void InvalidateStyle()
Definition SColorGradingComponentSpinBox.h:224
DECLARE_DELEGATE_FourParams(FOnDynamicSliderMinMaxValueChanged, float, TWeakPtr< SWidget >, bool, bool)
void SetSliderExponent(const TAttribute< float > &InSliderExponent)
Definition SColorGradingComponentSpinBox.h:220
void SetMinValue(const TAttribute< TOptional< float > > &InMinValue)
Definition SColorGradingComponentSpinBox.h:176
void SetDelta(float InDelta)
Definition SColorGradingComponentSpinBox.h:216
void NotifyValueCommitted(float CurrentValue) const
Definition SColorGradingComponentSpinBox.cpp:553
virtual FCursorReply OnCursorQuery(const FGeometry &MyGeometry, const FPointerEvent &CursorEvent) const override
Definition SColorGradingComponentSpinBox.cpp:456
float GetMinSliderValue() const
Definition SColorGradingComponentSpinBox.h:193
bool GetAlwaysUsesDeltaSnap() const
Definition SColorGradingComponentSpinBox.h:211
float GetDelta() const
Definition SColorGradingComponentSpinBox.h:215
void SetWidgetStyle(const FColorGradingSpinBoxStyle *InStyle)
Definition SColorGradingComponentSpinBox.h:223
void SetMaxValue(const TAttribute< TOptional< float > > &InMaxValue)
Definition SColorGradingComponentSpinBox.h:184
void SetMinSliderValue(const TAttribute< TOptional< float > > &InMinSliderValue)
Definition SColorGradingComponentSpinBox.h:194
SLATE_BEGIN_ARGS(SColorGradingComponentSpinBox)
Definition SColorGradingComponentSpinBox.h:37
const FColorGradingSpinBoxStyle * GetWidgetStyle() const
Definition SColorGradingComponentSpinBox.h:222
void Construct(const FArguments &InArgs)
Definition SColorGradingComponentSpinBox.cpp:18
static float Fraction(double InValue, double InMinValue, double InMaxValue)
Definition SColorGradingComponentSpinBox.cpp:560
TAttribute< float > GetValueAttribute() const
Definition SColorGradingComponentSpinBox.h:163
bool IsMinSliderValueBound() const
Definition SColorGradingComponentSpinBox.h:191
virtual int32 OnPaint(const FPaintArgs &Args, const FGeometry &AllottedGeometry, const FSlateRect &MyCullingRect, FSlateWindowElementList &OutDrawElements, int32 LayerId, const FWidgetStyle &InWidgetStyle, bool bParentEnabled) const override
Definition SColorGradingComponentSpinBox.cpp:87
Type
Definition SlateEnums.h:291
@ Default
Definition SlateEnums.h:293
Definition ColorGradingUtil.cpp:7
EColorGradingComponent
Definition ColorGradingCommon.h:16
EColorGradingModes
Definition ColorGradingCommon.h:45
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition ColorGradingSpinBoxStyle.h:16
Definition Geometry.h:40
Definition Color.h:48
Definition Events.h:695
Definition SlateBrush.h:239
Definition NumericTypeInterface.h:21
Definition Optional.h:131
constexpr bool IsSet() const
Definition Optional.h:69
constexpr const OptionalType & Get(const OptionalType &DefaultValue UE_LIFETIMEBOUND) const UE_LIFETIMEBOUND
Definition Optional.h:472
Definition IntPoint.h:25