UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SColorThemes.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/DragAndDrop.h"
8#include "Input/Reply.h"
9#include "Layout/Visibility.h"
11#include "Styling/SlateColor.h"
12#include "Layout/Children.h"
15#include "Widgets/SPanel.h"
16#include "Widgets/SOverlay.h"
20
23class SErrorText;
24class STextBlock;
25class SThemeColorBlocksBar;
26class UToolMenu;
27
29{
31
33
35 {
36 Color = InColor;
37 Label = FText();
38 }
39
41 {
42 Color = InColor;
43 Label = InLabel;
44 }
45};
46
52{
53public:
54
55 FColorTheme(const FString& InName = TEXT(""), const TArray< TSharedPtr<FColorInfo> >& InColors = TArray< TSharedPtr<FColorInfo> >());
56
59 {
60 return Colors;
61 }
62
66
68 int32 FindApproxColor(const FLinearColor& InColor, float Tolerance = KINDA_SMALL_NUMBER) const;
69
71 void RemoveAll();
72
75
76 FString Name;
77
80 {
81 return RefreshEvent;
82 }
83
84private:
85
87
88 FRefreshEvent RefreshEvent;
89};
90
91
96class UE_DEPRECATED(5.6, "SColorTrash is deprecated. SThemeColorBlocksBar now uses a simple SButton for its delete button.") SColorTrash
97 : public SCompoundWidget
98{
99public:
100
103 { }
104
107
108 void Construct( const FArguments& InArgs );
109
110protected:
111
119 virtual void OnDragEnter( const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent ) override;
120
127 virtual void OnDragLeave( const FDragDropEvent& DragDropEvent ) override;
128
137
138 const FSlateBrush* GetBorderStyle() const;
139
140private:
141
143 bool bBorderActivated;
144};
145
146
154{
155public:
156
158 : _Color()
159 , _ColorInfo()
161 , _Parent()
164 , _UseSRGB()
165 , _UseAlpha()
167 { }
168
171
172
174
175
177
178
180
181
182 SLATE_EVENT(FSimpleDelegate, ShowTrashCallback)
183
184
185 SLATE_EVENT(FSimpleDelegate, HideTrashCallback)
186
187
189
190
192
193
195
197
198
203 void Construct(const FArguments& InArgs );
204
205
206private:
207 void OnColorBlockRename();
208 FText GetLabel() const;
209 void SetLabel(const FText& NewColorLabel, ETextCommit::Type CommitInfo);
211 virtual FReply OnMouseButtonUp( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) override;
212 virtual FReply OnDragDetected( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) override;
213
214 FLinearColor GetColor() const;
215
216 FText GetRedText() const;
217 FText GetGreenText() const;
218 FText GetBlueText() const;
219 FText GetAlphaText() const;
220 FText GetHueText() const;
221 FText GetSaturationText() const;
222 FText GetValueText() const;
223
227 FText FormatToolTipText(const FText& ColorIdentifier, float Value) const;
228
229 EColorBlockAlphaDisplayMode OnGetAlphaDisplayMode() const;
230 bool OnReadShowBackgroundForAlpha() const;
231 EVisibility OnGetAlphaVisibility() const;
232
233 EVisibility OnGetLabelVisibility() const;
234
236 TWeakPtr<FLinearColor> ColorPtr;
237
239 TSharedPtr<FColorInfo> ColorInfo;
240
242 TWeakPtr<SThemeColorBlocksBar> ParentPtr;
243
245 FOnLinearColorValueChanged OnSelectColor;
246
248 FSimpleDelegate ShowTrashCallback;
249
251 FSimpleDelegate HideTrashCallback;
252
254 TAttribute<bool> bUseSRGB;
255
257 TAttribute<bool> bUseAlpha;
258
260 TAttribute<bool> bSupportsDrag;
261};
262
263
265
266
271class UE_DEPRECATED(5.6, "SColorThemeBar is deprecated. SColorThemesViewer now displays a standard menu with a list of available themes.") SColorThemeBar
273{
274public:
276 : _ColorTheme()
282 { }
283
286
287
288 SLATE_EVENT(FOnCurrentThemeChanged, OnCurrentThemeChanged)
289
290
291 SLATE_EVENT(FSimpleDelegate, ShowTrashCallback)
293 SLATE_EVENT(FSimpleDelegate, HideTrashCallback)
294
295
297
298
300
302
303 void Construct(const FArguments& InArgs);
304
313
314private:
315
316 FText GetThemeName() const;
317
319 TSharedPtr<STextBlock> ThemeNameText;
320
322 TWeakPtr<FColorTheme> ColorTheme;
323
325 FOnCurrentThemeChanged OnCurrentThemeChanged;
326
328 FSimpleDelegate ShowTrashCallback;
329
331 FSimpleDelegate HideTrashCallback;
332
334 TAttribute<bool> bUseSRGB;
335
337 TAttribute<bool> bUseAlpha;
338};
339
340
344class SColorThemesViewer : public SCompoundWidget
345{
346public:
347
348 SLATE_BEGIN_ARGS(SColorThemesViewer)
349 { }
350
351 SLATE_ATTRIBUTE_DEPRECATED(bool, UseAlpha, 5.6, "UseAlpha is deprecated. Set the UseAlpha attribute of SThemeColorBlocksBar to control the opacity of theme colors.")
352
354
355 void Construct(const FArguments& InArgs);
356
358 TSharedPtr<FColorTheme> GetCurrentColorTheme() const;
359
361 TSharedPtr<FColorTheme> GetRecents() const;
362
363 UE_DEPRECATED(5.6, "SetUseAlpha is deprecated. Set the UseAlpha attribute of SThemeColorBlocksBar to control the opacity of theme colors.")
364 void SetUseAlpha(const TAttribute<bool>& InUseAlpha);
365
367 static void LoadColorThemesFromIni();
368
370 static void SaveColorThemesToIni();
371
373 DECLARE_EVENT( SColorThemesViewer, FCurrentThemeChangedEvent );
374 FCurrentThemeChangedEvent& OnCurrentThemeChanged()
375 {
376 return CurrentThemeChangedEvent;
377 }
378
379 UE_DEPRECATED(5.6, "bSRGBEnabled is deprecated. Set the UseSRGB attribute of SThemeColorBlocksBar to control the sRGB display of theme colors.")
380 static bool bSRGBEnabled;
381
382 UE_DEPRECATED(5.6, "MenuToStandardNoReturn is deprecated. SColorThemesViewer completely manages its own ToolsMenu.")
383 void MenuToStandardNoReturn();
384
386 bool IsRecentsThemeActive() const;
387
388private:
390 void BuildMenu(FMenuBuilder& MenuBuilder);
391
393 void StartRename();
394
396 void StopRename();
397
399 void RefreshMenuWidget();
400
401 void NewColorTheme();
402 void DuplicateColorTheme();
403 void DeleteColorTheme();
404
406 void CommitThemeName(const FText& InText, ETextCommit::Type InCommitType);
407 void UpdateThemeNameFromTextBox();
408
410 void SetCurrentColorTheme(TSharedPtr<FColorTheme> NewTheme);
411
413 void OnMenuOpenChanged(bool bIsOpen);
414
415 const FSlateBrush* GetComboButtonImage() const;
416
418 static TSharedPtr<FColorTheme> GetDefaultColorTheme(bool bCreateNew = false);
420 static TSharedPtr<FColorTheme> GetColorTheme(const FString& ThemeName);
422 static TSharedPtr<FColorTheme> IsColorTheme(const FString& ThemeName);
424 static FString MakeUniqueThemeName(const FString& ThemeName);
426 static TSharedPtr<FColorTheme> NewColorTheme(const FString& ThemeName, const TArray< TSharedPtr<FColorInfo> >& ThemeColors = TArray< TSharedPtr<FColorInfo> >());
427
428private:
430 TSharedPtr<SMultiBoxWidget> MultiBoxWidget;
431
433 TSharedPtr<SEditableTextBox> RenameTextBox;
434
436 FCurrentThemeChangedEvent CurrentThemeChangedEvent;
437
439 TAttribute<bool> bUseAlpha;
440
442 static TArray<TSharedPtr<FColorTheme>> ColorThemes;
443
445 static TSharedPtr<FColorTheme> Recents;
446
448 static TWeakPtr<FColorTheme> CurrentlySelectedThemePtr;
449};
450
451
455class SThemeColorBlocksBar : public SPanel
456{
457public:
458
461
462 SLATE_BEGIN_ARGS(SThemeColorBlocksBar)
465 , _UseSRGB()
466 , _UseAlpha()
467 { }
468
470 SLATE_ATTRIBUTE_DEPRECATED(TSharedPtr<FColorTheme>, ColorTheme, 5.6, "ColorTheme Attribute is deprecated. This widget owns a SColorThemesViewer which supplies the current color theme.")
471
472
474
476 SLATE_EVENT(FOnGetActiveColor, OnGetActiveColor)
477
478 UE_DEPRECATED(5.6, "ShowTrashCallback is deprecated. Visibility of the delete button is managed by this widget internally.")
479 SLATE_EVENT(FSimpleDelegate, ShowTrashCallback)
480
481 UE_DEPRECATED(5.6, "HideTrashCallback is deprecated. Visibility of the delete button is managed by this widget internally.")
482 SLATE_EVENT(FSimpleDelegate, HideTrashCallback)
483
486
489
492
494
495 SThemeColorBlocksBar();
496
497 void Construct(const FArguments& InArgs);
498
499 // Begin SWidget overrides
500 virtual void OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const override;
501 virtual FVector2D ComputeDesiredSize(float) const override;
502 virtual FChildren* GetChildren() override;
503 virtual void OnDragEnter(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
504 virtual void OnDragLeave(const FDragDropEvent& DragDropEvent) override;
507 // End SWidget overrides
508
514 void AddNewColorBlock(FLinearColor Color, int32 InsertPosition, bool bAllowRepeat = false);
515
517 void AddToRecents(FLinearColor Color);
518
520 bool IsRecentsThemeActive() const;
521
527 int32 RemoveColorBlock(TSharedPtr<FLinearColor> ColorToRemove);
528
529 UE_DEPRECATED(5.6, "RemoveRefreshCallback is deprecated. Color theme changes are handled by this widget internally")
530 void RemoveRefreshCallback();
531
532 UE_DEPRECATED(5.6, "RemoveRefreshCallback is deprecated. Color theme changes are handled by this widget internally")
533 void AddRefreshCallback();
534
538 void Refresh();
539
540 UE_DEPRECATED(5.6, "SetPlaceholderGrabOffset is deprecated. The Placeholder position is managed by this widget internally.")
541 void SetPlaceholderGrabOffset(FVector2D GrabOffset);
542
544 void ShowDeleteButton();
545
547 void HideDeleteButton();
548
549private:
551 FReply OnAddButtonClicked();
552
554 void OnThemeChanged();
555
557 EVisibility GetAddButtonVisibility() const;
558
560 EVisibility GetDeleteButtonVisibility() const;
561
563 TSlotlessChildren<SWidget> Children;
564
566 TArray<TSharedPtr<SThemeColorBlock>> ColorBlocks;
567
572 TSharedPtr<FColorTheme> ColorTheme;
573
575 FOnLinearColorValueChanged OnSelectColor;
576
578 FOnGetActiveColor OnGetActiveColor;
579
581 FSimpleDelegate RefreshCallback;
582
584 FDelegateHandle RefreshCallbackHandle;
585
587 TAttribute<bool> bUseSRGB;
588
590 TAttribute<bool> bUseAlpha;
591
593 bool bShowDeleteButton = false;
594
596 TSharedPtr<SBorder> DragShadow;
597
599 TSharedPtr<SOverlay> AddDeleteOverlay;
600
602 TSharedPtr<SColorThemesViewer> ThemesViewer;
603
605 TOptional<int32> PlaceholderIndex;
606};
607
608
613class FColorDragDrop : public FDragDropOperation
614{
615public:
616
618
620
621 // Begin FDragDropOperation overrides
622 virtual void OnDrop( bool bDropWasHandled, const FPointerEvent& MouseEvent ) override;
623 virtual void OnDragged( const class FDragDropEvent& DragDropEvent ) override;
624 virtual TSharedPtr<SWidget> GetDefaultDecorator() const override;
625 // End FDragDropOperation overrides
626
628 void MarkForAdd();
629
631 void MarkForDelete();
632
643 static TSharedRef<FColorDragDrop> New(FLinearColor InColor, bool bSRGB, bool bUseAlpha,
646
649
651 bool bUseSRGB;
652
654 bool bUseAlpha;
655
656 UE_DEPRECATED(5.6, "OriginBar is deprecated. This operation no longer needs direct access to the SThemeColorBlocksBar widget.")
657 TWeakPtr<SThemeColorBlocksBar> OriginBar;
658
659 UE_DEPRECATED(5.6, "OriginBarPosition is deprecated. This operation no longer needs to know its position in the SThemeColorBlocksBar widget.")
660 int32 OriginBarPosition;
661
663 FSimpleDelegate ShowTrash;
664
666 FSimpleDelegate HideTrash;
667
668 UE_DEPRECATED(5.6, "bSetForDeletion is deprecated. This operation no longer deletes any color blocks from the SThemeColorBlocksBar widget.")
669 bool bSetForDeletion;
670
671 UE_DEPRECATED(5.6, "BlockSize is deprecated. This operation now uses the size of the cursor decorator window internally.")
672 FVector2D BlockSize;
673};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
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_ATTRIBUTE(AttrType, AttrName)
Definition DeclarativeSyntaxSupport.h:192
#define SLATE_ARGUMENT_DEPRECATED(ArgType, ArgName, DeprecationVersion, DeprecationMessage)
Definition DeclarativeSyntaxSupport.h:215
#define SLATE_BEGIN_ARGS(InWidgetType)
Definition DeclarativeSyntaxSupport.h:63
#define SLATE_ATTRIBUTE_DEPRECATED(AttrType, AttrName, DeprecationVersion, DeprecationMessage)
Definition DeclarativeSyntaxSupport.h:199
#define SLATE_EVENT(DelegateName, EventName)
Definition DeclarativeSyntaxSupport.h:458
#define SLATE_END_ARGS()
Definition DeclarativeSyntaxSupport.h:116
#define DECLARE_DELEGATE_RetVal(ReturnValueType, DelegateName)
Definition DelegateCombinations.h:41
#define DECLARE_EVENT(OwningType, EventName)
Definition DelegateCombinations.h:32
#define DECLARE_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:48
#define DRAG_DROP_OPERATOR_TYPE(TYPE, BASE)
Definition DragAndDrop.h:207
return true
Definition ExternalRpcRegistry.cpp:601
T * New(FMemStackBase &Mem, int32 Count=1, int32 Align=DEFAULT_ALIGNMENT)
Definition MemStack.h:259
EColorBlockAlphaDisplayMode
Definition SColorBlock.h:16
SColorThemeBar is deprecated SColorThemesViewer now displays a standard menu with a list of available themes _UseAlpha()
Definition SColorThemes.h:281
SColorThemeBar is deprecated SColorThemesViewer now displays a standard menu with a list of available themes SColorThemeBar
Definition SColorThemes.h:277
void Construct(const FArguments &InArgs)
SColorThemeBar is deprecated SColorThemesViewer now displays a standard menu with a list of available themes _ShowTrashCallback()
SColorThemeBar is deprecated SColorThemesViewer now displays a standard menu with a list of available themes _HideTrashCallback()
virtual FReply OnMouseButtonDown(const FGeometry &MyGeometry, const FPointerEvent &MouseEvent)
SColorThemeBar is deprecated SColorThemesViewer now displays a standard menu with a list of available themes _OnCurrentThemeChanged()
SColorThemeBar is deprecated SColorThemesViewer now displays a standard menu with a list of available themes _UseSRGB()
#define KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:67
Definition ArrangedChildren.h:15
Definition ChildrenBase.h:27
Definition SColorThemes.h:52
FString Name
Definition SColorThemes.h:76
FRefreshEvent & OnRefresh()
Definition SColorThemes.h:79
const TArray< TSharedPtr< FColorInfo > > & GetColors() const
Definition SColorThemes.h:58
DECLARE_EVENT(FColorTheme, FRefreshEvent)
int32 RemoveColor(const TSharedPtr< FLinearColor > InColor)
Definition SColorThemes.cpp:135
void InsertNewColor(TSharedPtr< FLinearColor > InColor, int32 InsertPosition)
Definition SColorThemes.cpp:108
int32 FindApproxColor(const FLinearColor &InColor, float Tolerance=KINDA_SMALL_NUMBER) const
Definition SColorThemes.cpp:115
void RemoveAll()
Definition SColorThemes.cpp:129
Definition IDelegateInstance.h:14
Definition DragAndDrop.h:141
Definition DragAndDrop.h:21
Definition MultiBoxBuilder.h:310
Definition Reply.h:24
Definition Text.h:385
Definition SBorder.h:31
Definition SCompoundWidget.h:22
Definition SEditableTextBox.h:29
Definition SErrorText.h:37
Definition SOverlay.h:44
Definition SPanel.h:30
Definition STextBlock.h:45
Definition SColorThemes.h:154
SLATE_BEGIN_ARGS(SThemeColorBlock)
Definition SColorThemes.h:157
Definition SWidget.h:165
Definition Array.h:670
Definition Attribute.h:17
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition Children.h:836
Definition SharedPointer.h:1295
Definition SlateEnums.h:289
Type
Definition SlateEnums.h:291
@ false
Definition radaudio_common.h:23
Definition Visibility.h:12
Definition SColorThemes.h:29
FColorInfo(TSharedPtr< FLinearColor > InColor, FText InLabel)
Definition SColorThemes.h:40
FColorInfo(TSharedPtr< FLinearColor > InColor)
Definition SColorThemes.h:34
TSharedPtr< FLinearColor > Color
Definition SColorThemes.h:30
FText Label
Definition SColorThemes.h:32
Definition Geometry.h:40
Definition Color.h:48
Definition Events.h:695
Definition SlateBrush.h:239
Definition Optional.h:131