UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SColorPicker.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"
8#include "Layout/Visibility.h"
11#include "Widgets/SWidget.h"
13#include "Widgets/SWindow.h"
15
16class FColorTheme;
17class SBorder;
18class SColorThemesViewer;
19class SComboButton;
20class SThemeColorBlocksBar;
22class SColorWheel;
23
26
27
32{
33 Red,
34 Green,
35 Blue,
36 Alpha,
37 Hue,
39 Value
40};
41
42
47{
49 Wheel
50};
51
52
57{
58 SRGB,
59 Linear
60};
61
62
67{
69 {
70 Red = Green = Blue = Alpha = nullptr;
71 }
72
73 float* Red;
74 float* Green;
75 float* Blue;
76 float* Alpha;
77};
78
85 : public SCompoundWidget
86{
87public:
88
110
112 SLATE_ATTRIBUTE(FLinearColor, TargetColorAttribute)
113
114
115 SLATE_ATTRIBUTE(const FSlateBrush*, ColorWheelBrush)
116
117
118 SLATE_ARGUMENT_DEPRECATED(TArray<FColor*>, TargetFColors, 5.2, "TargetFColors is deprecated. Use OnColorCommitted to get the selected color.")
119
120
121 SLATE_ARGUMENT_DEPRECATED(TArray<FLinearColor*>, TargetLinearColors, 5.2, "TargetLinearColors is deprecated. Use OnColorCommitted to get the selected color.")
122
127 SLATE_ARGUMENT_DEPRECATED(TArray<FColorChannels>, TargetColorChannels, 5.2, "TargetColorChannels is deprecated. Use OnColorCommitted to get the selected color.")
128
131
134
137
139 SLATE_EVENT(FOnLinearColorValueChanged, OnColorCommitted)
140
141 UE_DEPRECATED(5.2, "PreColorCommitted is deprecated. Use OnColorCommitted to update your values.")
143 SLATE_EVENT(FOnLinearColorValueChanged, PreColorCommitted)
144
146 SLATE_EVENT(FOnColorPickerCancelled, OnColorPickerCancelled)
147
149 SLATE_EVENT(FOnWindowClosed, OnColorPickerWindowClosed)
150
152 SLATE_EVENT(FSimpleDelegate, OnInteractivePickBegin)
153
155 SLATE_EVENT(FSimpleDelegate, OnInteractivePickEnd)
156
158 SLATE_ATTRIBUTE(TSharedPtr<SWindow>, ParentWindow)
159
161 SLATE_ATTRIBUTE(float, DisplayGamma)
162
164 SLATE_ARGUMENT(TOptional<bool>, sRGBOverride)
165
168
171
174
176 SLATE_ARGUMENT(bool, ClampValue)
177
179 SLATE_ATTRIBUTE(TSharedPtr<SWidget>, OptionalOwningDetailsView)
180
182
185
188
189public:
190
196 APPFRAMEWORK_API void Construct(const FArguments& InArgs);
197
200 {
201 if (OptionalOwningDetailsView.IsValid())
202 {
203 return OptionalOwningDetailsView.Pin();
204 }
205 else
206 {
207 return nullptr;
208 }
209 }
210
214
218
219protected:
220
223
224 APPFRAMEWORK_API bool ApplyNewTargetColor(bool bForceUpdate = false);
225
228
230 {
231 return CurrentColorHSV;
232 }
233
236
238 APPFRAMEWORK_API bool SetNewTargetColorRGB(const FLinearColor& NewValue, bool bForceUpdate = false);
239 APPFRAMEWORK_API bool SetNewTargetColorHSV(const FLinearColor& NewValue, bool bForceUpdate = false);
240
243
245
246 UE_DEPRECATED(5.6, "HideSmallTrash is deprecated. The delete button for theme colors is managed by the SThemeColorBlocksBar widget.")
248
249 UE_DEPRECATED(5.6, "ShowSmallTrash is deprecated. The delete button for theme colors is managed by the SThemeColorBlocksBar widget.")
251
254
262
270
277
278private:
279
280 // Callback for the active timer to animate the color post-construct
281 APPFRAMEWORK_API EActiveTimerReturnType AnimatePostConstruct(double InCurrentTime, float InDeltaTime);
282
283 // Callback for getting the end color of a color spin box gradient.
284 APPFRAMEWORK_API FLinearColor GetGradientEndColor(EColorPickerChannels Channel) const;
285
286 // Callback for getting the start color of a color spin box gradient.
287 APPFRAMEWORK_API FLinearColor GetGradientStartColor(EColorPickerChannels Channel) const;
288
289 // Callback for getting the array of colors for a color spin box gradient.
290 APPFRAMEWORK_API TArray<FLinearColor> GetGradientColors(EColorPickerChannels Channel) const;
291
292 // Callback for getting the alpha display mode of the color preview swatches.
293 APPFRAMEWORK_API EColorBlockAlphaDisplayMode HandleColorPreviewAlphaMode() const;
294
295 // Callback for clicking the Cancel button.
296 APPFRAMEWORK_API FReply HandleCancelButtonClicked();
297
298 // Callback for pressing a mouse button in the color area.
299 APPFRAMEWORK_API FReply HandleColorAreaMouseDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent);
300
301 // Callback for clicking the color picker mode button.
302 APPFRAMEWORK_API FReply HandleColorPickerModeButtonClicked();
303
304 // Callback for getting the visibility of the given color picker mode.
305 APPFRAMEWORK_API EVisibility HandleColorPickerModeVisibility(EColorPickerModes Mode) const;
306
307 // Callback for setting the visibility of the themes panel.
308 APPFRAMEWORK_API FReply ToggleThemePanelVisibility();
309
310 // Callback for getting the icon to display on the Show/Hide themes panel button.
311 APPFRAMEWORK_API const FSlateBrush* HandleThemePanelButtonImageBrush() const;
312
313 // Callback for getting the visibility of the themes panel.
314 APPFRAMEWORK_API EVisibility HandleThemesPanelVisibility() const;
315
316 // Callback for getting the tooltip for the color theme panel
317 APPFRAMEWORK_API FText GetColorThemePanelToolTipText() const;
318
319 // Callback for getting the end color of a color slider.
320 APPFRAMEWORK_API FLinearColor HandleColorSliderEndColor(EColorPickerChannels Channel) const;
321
322 // Callback for getting the start color of a color slider.
323 APPFRAMEWORK_API FLinearColor HandleColorSliderStartColor(EColorPickerChannels Channel) const;
324
325 // Callback for value changes in the color wheel picker.
326 APPFRAMEWORK_API void HandleColorWheelValueChanged(FLinearColor NewValue);
327
328 // Callback for value changes in the color spectrum picker.
329 APPFRAMEWORK_API void HandleColorSpectrumValueChanged(FLinearColor NewValue);
330
331 // Callback for getting the value of a color spin box.
332 APPFRAMEWORK_API float HandleColorSpinBoxValue(EColorPickerChannels Channel) const;
333
334 // Callback for value changes in a color spin box.
335 APPFRAMEWORK_API void HandleColorSpinBoxValueChanged(float NewValue, EColorPickerChannels Channel);
336
337 // Callback for start of eye dropper interactions.
338 APPFRAMEWORK_API void HandleEyeDropperButtonBegin();
339
340 // Callback for completed eye dropper interactions.
341 APPFRAMEWORK_API void HandleEyeDropperButtonComplete(bool bCancelled);
342
343 // Callback for getting the text in the hex linear box.
344 APPFRAMEWORK_API FText HandleHexBoxText() const;
345
346 // Callback for committed text in the hex input box (sRGB gamma).
347 APPFRAMEWORK_API void HandleHexInputTextCommitted(const FText& Text, ETextCommit::Type CommitType);
348
349 // Callback for changing the HSV value of the current color.
350 APPFRAMEWORK_API void HandleHSVColorChanged(FLinearColor NewValue);
351
352 // Callback for when interactive user input begins.
353 APPFRAMEWORK_API void HandleInteractiveChangeBegin();
354
355 // Callback for when interactive user input ends.
356 APPFRAMEWORK_API void HandleInteractiveChangeEnd();
357
358 // Callback for when interactive user input ends.
359 APPFRAMEWORK_API void HandleInteractiveChangeEnd(float NewValue);
360
361 // Callback for clicking the new color preview block.
362 APPFRAMEWORK_API FReply HandleNewColorPreviewClicked();
363
364 // Callback for clicking the old color preview block.
365 APPFRAMEWORK_API FReply HandleOldColorPreviewClicked();
366
367 // Callback for getting the visibility of the old/new color buttons
368 APPFRAMEWORK_API EVisibility HandleColorPreviewButtonVisibility() const;
369
370 // Callback for setting the visibility of the new color preview button image
371 APPFRAMEWORK_API void SetNewColorPreviewImageVisibility(EVisibility InButtonVisibility);
372
373 // Callback for setting the visibility of the old color preview button image
374 APPFRAMEWORK_API void SetOldColorPreviewImageVisibility(EVisibility InButtonVisibility);
375
376 // Callback for getting the visibility of the new color preview button image
377 APPFRAMEWORK_API EVisibility GetNewColorPreviewImageVisibility() const;
378
379 // Callback for getting the visibility of the old color preview button image
380 APPFRAMEWORK_API EVisibility GetOldColorPreviewImageVisibility() const;
381
382 // Callback for clicking the OK button.
383 APPFRAMEWORK_API FReply HandleOkButtonClicked();
384
385 // Callback for checking whether sRGB colors should be rendered.
386 APPFRAMEWORK_API bool HandleColorPickerUseSRGB() const;
387
388 // Callback for when the parent window has been closed.
389 APPFRAMEWORK_API void HandleParentWindowClosed(const TSharedRef<SWindow>& Window);
390
391 // Callback for changing the RGB value of the current color.
392 APPFRAMEWORK_API void HandleRGBColorChanged(FLinearColor NewValue);
393
394 // Callback for changing the checked state of the sRGB check box.
395 APPFRAMEWORK_API void HandleSRGBCheckBoxCheckStateChanged(ECheckBoxState InIsChecked);
396
397 // Callback for determining whether the sRGB check box should be checked.
398 APPFRAMEWORK_API ECheckBoxState HandleSRGBCheckBoxIsChecked() const;
399
400 // Callback for selecting a color in the color theme bar.
401 APPFRAMEWORK_API void HandleThemeBarColorSelected(FLinearColor NewValue);
402
403 // Build the menu widget for selecting the hexadecimal text mode
404 APPFRAMEWORK_API TSharedRef<SWidget> MakeHexModeMenu();
405
406 // Get the text to display on the hexadecimal text mode button
407 APPFRAMEWORK_API FText HandleHexModeButtonText() const;
408
409 // Callback for when the hexadecimal text mode changes
410 APPFRAMEWORK_API void OnHexModeSelected(EColorPickerHexMode InHexMode);
411
412private:
413
415 TAttribute<FLinearColor> TargetColorAttribute;
416
418 TAttribute<const FSlateBrush*> ColorWheelBrush;
419
421 FLinearColor CurrentColorHSV;
422
424 FLinearColor CurrentColorRGB;
425
427 FLinearColor OldColor;
428
430 FLinearColor ColorEnd;
431
433 FLinearColor ColorBegin;
434
436 EColorPickerModes CurrentMode;
437
439 EColorPickerHexMode HexMode;
440
442 float CurrentTime;
443
445 static APPFRAMEWORK_API const double MAX_ALLOWED_UPDATE_TIME;
446
448 bool bPerfIsTooSlowToUpdate;
449
451 TAttribute<bool> bUseAlpha;
452
454 bool bUseSRGB = false;
455
457 bool bOnlyRefreshOnMouseUp;
458
460 bool bOnlyRefreshOnOk;
461
463 bool bClosedViaOkOrCancel;
464
466 TWeakPtr<SWindow> ParentWindowPtr;
467
469 TSharedPtr<SThemeColorBlocksBar> CurrentThemeBar;
470
472 EVisibility NewColorPreviewImageVisibility;
473
475 EVisibility OldColorPreviewImageVisibility;
476
478 TAttribute<float> DisplayGamma;
479
481 bool bColorPickerIsInlineVersion;
482
484 bool bColorPickerCreationIsOverridden;
485
487 bool bIsInteractive;
488
490 bool bValidCreationOverrideExists;
491
493 bool bClampValue;
494
496 bool bIsThemePanelVisible;
497
498private:
499
501 FOnLinearColorValueChanged OnColorCommitted;
502
504 FOnColorPickerCancelled OnColorPickerCancelled;
505
507 FSimpleDelegate OnInteractivePickBegin;
508
510 FSimpleDelegate OnInteractivePickEnd;
511
513 FOnWindowClosed OnColorPickerWindowClosed;
514
516 TWeakPtr<SWidget> OptionalOwningDetailsView;
517
519 TSharedPtr<SColorWheel> ColorWheel;
520};
521
522
524{
526 bool bIsModal = false;
527
530
532 bool bUseAlpha = false;
533
535 bool bOnlyRefreshOnMouseUp = false;
536
538 bool bOnlyRefreshOnOk = false;
539
541 bool bExpandAdvancedSection = true;
542
544 bool bOpenAsMenu = false;
545
547 bool bClampValue = false;
548
550 TAttribute<float> DisplayGamma = 2.2f;
551
554
555 UE_DEPRECATED(5.2, "ColorArray is deprecated. Use OnColorCommitted to update your values.")
557 const TArray<FColor*>* ColorArray = nullptr;
558
559 UE_DEPRECATED(5.2, "LinearColorArray is deprecated. Use OnColorCommitted to update your values.")
561 const TArray<FLinearColor*>* LinearColorArray = nullptr;
562
563 UE_DEPRECATED(5.2, "ColorChannelsArray is deprecated. Use OnColorCommitted to update your values.")
565 const TArray<FColorChannels>* ColorChannelsArray = nullptr;
566
569
570 UE_DEPRECATED(5.2, "PreColorCommitted is deprecated. Use OnColorCommitted to update your values.")
572 FOnLinearColorValueChanged PreColorCommitted;
573
575 FOnWindowClosed OnColorPickerWindowClosed;
576
578 FOnColorPickerCancelled OnColorPickerCancelled;
579
581 FSimpleDelegate OnInteractivePickBegin;
582
584 FSimpleDelegate OnInteractivePickEnd;
585
586 UE_DEPRECATED(5.2, "InitialColorOverride is deprecated. Use InitialColor to set the initial color.")
588 FLinearColor InitialColorOverride = FLinearColor::White;
589
592
594 TSharedPtr<SWidget> OptionalOwningDetailsView;
595
597 FColorPickerArgs() = default;
598
603
608};
609
612
615
EGLSurface EGLint const EGLint EGLnsecsANDROID * values
Definition AndroidOpenGLFunctions.h:11
@ ForceInit
Definition CoreMiscDefines.h:155
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define SLATE_ATTRIBUTE(AttrType, AttrName)
Definition DeclarativeSyntaxSupport.h:192
#define SLATE_ARGUMENT_DEPRECATED(ArgType, ArgName, DeprecationVersion, DeprecationMessage)
Definition DeclarativeSyntaxSupport.h:215
#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
#define DECLARE_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:48
return true
Definition ExternalRpcRegistry.cpp:601
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
EColorBlockAlphaDisplayMode
Definition SColorBlock.h:16
EColorPickerHexMode
Definition SColorPicker.h:57
APPFRAMEWORK_API bool OpenColorPicker(const FColorPickerArgs &Args)
Definition SColorPicker.cpp:1447
EColorPickerChannels
Definition SColorPicker.h:32
EColorPickerModes
Definition SColorPicker.h:47
APPFRAMEWORK_API TSharedPtr< SColorPicker > GetColorPicker()
Definition SColorPicker.cpp:1435
APPFRAMEWORK_API void DestroyColorPicker()
Definition SColorPicker.cpp:1574
SColorThemeBar is deprecated SColorThemesViewer now displays a standard menu with a list of available themes _UseAlpha()
Definition SColorThemes.h:281
EActiveTimerReturnType
Definition SlateEnums.h:329
ECheckBoxState
Definition SlateTypes.h:65
decltype(auto) get(TupleType &&val)
Definition Tuple.h:940
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition SColorThemes.h:52
Definition CoreStyle.h:15
Definition Reply.h:24
Definition Text.h:385
Definition SBorder.h:31
Definition SColorPicker.h:86
APPFRAMEWORK_API void UpdateColorPick()
Definition SColorPicker.cpp:624
APPFRAMEWORK_API bool SetNewTargetColorRGB(const FLinearColor &NewValue, bool bForceUpdate=false)
Definition SColorPicker.cpp:584
APPFRAMEWORK_API TSharedRef< SWidget > MakeColorPreviewBox() const
Definition SColorPicker.cpp:801
APPFRAMEWORK_API TSharedRef< SWidget > MakeColorSpinBox(EColorPickerChannels Channel) const
Definition SColorPicker.cpp:719
APPFRAMEWORK_API void BackupColors()
SLATE_BEGIN_ARGS(SColorPicker)
Definition SColorPicker.h:89
DECLARE_DELEGATE_OneParam(FOnColorPickerCreationOverride, const TSharedRef< SColorPicker > &)
FLinearColor GetCurrentColor() const
Definition SColorPicker.h:229
APPFRAMEWORK_API void Construct(const FArguments &InArgs)
Definition SColorPicker.cpp:54
APPFRAMEWORK_API void CycleMode()
Definition SColorPicker.cpp:670
APPFRAMEWORK_API bool ApplyNewTargetColor(bool bForceUpdate=false)
Definition SColorPicker.cpp:593
APPFRAMEWORK_API void GenerateDefaultColorPickerContent(bool bAdvancedSectionExpanded)
Definition SColorPicker.cpp:129
TSharedPtr< SWidget > GetOptionalOwningDetailsView()
Definition SColorPicker.h:199
static APPFRAMEWORK_API const FVector2D DEFAULT_WINDOW_SIZE
Definition SColorPicker.h:184
static APPFRAMEWORK_API FOnColorPickerCreationOverride OnColorPickerNonModalCreateOverride
Definition SColorPicker.h:213
APPFRAMEWORK_API bool SetNewTargetColorHSV(const FLinearColor &NewValue, bool bForceUpdate=false)
Definition SColorPicker.cpp:575
APPFRAMEWORK_API void HideSmallTrash()
Definition SColorPicker.cpp:655
DECLARE_DELEGATE(FOnColorPickerDestructionOverride)
APPFRAMEWORK_API void UpdateColorPickMouseUp()
Definition SColorPicker.cpp:615
APPFRAMEWORK_API void ShowSmallTrash()
Definition SColorPicker.cpp:661
APPFRAMEWORK_API TSharedRef< SWidget > MakeColorSlider(EColorPickerChannels Channel) const
Definition SColorPicker.cpp:684
APPFRAMEWORK_API void DiscardColor()
Definition SColorPicker.cpp:561
APPFRAMEWORK_API void GenerateInlineColorPickerContent()
Definition SColorPicker.cpp:507
static APPFRAMEWORK_API FOnColorPickerDestructionOverride OnColorPickerDestroyOverride
Definition SColorPicker.h:217
APPFRAMEWORK_API void BeginAnimation(FLinearColor Start, FLinearColor End)
Definition SColorPicker.cpp:636
Definition SColorWheel.h:22
Definition SComboButton.h:25
Definition SCompoundWidget.h:22
Definition SWidget.h:165
Definition SWindow.h:243
Definition Array.h:670
Definition Attribute.h:17
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition SharedPointer.h:1295
UE_FORCEINLINE_HINT TSharedPtr< ObjectType, Mode > Pin() const &
Definition SharedPointer.h:1512
UE_FORCEINLINE_HINT bool IsValid() const
Definition SharedPointer.h:1535
Definition SlateEnums.h:289
@ false
Definition radaudio_common.h:23
Definition Visibility.h:12
Definition SColorPicker.h:67
float * Blue
Definition SColorPicker.h:75
FColorChannels()
Definition SColorPicker.h:68
float * Red
Definition SColorPicker.h:73
float * Green
Definition SColorPicker.h:74
float * Alpha
Definition SColorPicker.h:76
Definition SColorPicker.h:524
FColorPickerArgs(FColorPickerArgs &&)=default
PRAGMA_DISABLE_DEPRECATION_WARNINGS FColorPickerArgs(const FColorPickerArgs &)=default
TSharedPtr< SWidget > ParentWidget
Definition SColorPicker.h:529
Definition Color.h:486
Definition Geometry.h:40
Definition Color.h:48
Definition Events.h:695
Definition SlateBrush.h:239
Definition Optional.h:131