bSRGBEnabled
bSRGBEnabled
#Overview
name: bSRGBEnabled
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 10
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of bSRGBEnabled is to control whether the color picker and color themes in Unreal Engine 5 use sRGB color space for display and calculations. This setting is primarily used in the color picker and color theme viewer components of the engine’s user interface.
This setting variable is mainly relied upon by the AppFramework module, specifically in the color-related widgets such as SColorPicker and SColorThemesViewer.
The value of this variable is set in several places:
- It can be overridden when constructing an SColorPicker widget.
- It’s loaded from the project’s configuration file (GEditorPerProjectIni) when initializing the color picker.
- It can be toggled by the user through a checkbox in the color picker UI.
bSRGBEnabled interacts with other variables related to color management, such as CurrentColorHSV and OldColor in the color picker. It’s used when creating color drag-and-drop operations and when handling color changes.
Developers must be aware that:
- This variable affects how colors are displayed and interpreted in the UI.
- Changes to this variable are persisted in the project’s configuration file.
- It’s a static variable, meaning its value is shared across all instances of SColorThemesViewer.
Best practices when using this variable include:
- Respect the user’s choice and project settings when initializing color-related UI components.
- Consider the implications of changing this value on color accuracy and consistency across different parts of the engine and game.
- When working with colors programmatically, be aware of whether they’re in sRGB or linear color space, and convert as necessary based on this setting.
- If overriding this value for a specific color picker instance, remember to restore the original value when the color picker is closed to maintain consistency with other parts of the UI.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:465, section: [ColorPickerUI]
- INI Section:
ColorPickerUI
- Raw value:
True
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Private/Widgets/Colors/SColorPicker.cpp:80
Scope (from outer to inner):
file
function void SColorPicker::Construct
Source code excerpt:
if ( InArgs._sRGBOverride.IsSet() )
{
OriginalSRGBOption = SColorThemesViewer::bSRGBEnabled;
SColorThemesViewer::bSRGBEnabled = InArgs._sRGBOverride.GetValue();
}
RegisterActiveTimer( 0.f, FWidgetActiveTimerDelegate::CreateSP( this, &SColorPicker::AnimatePostConstruct ) );
// We need a parent window to set the close callback
if (ParentWindowPtr.IsValid())
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Private/Widgets/Colors/SColorPicker.cpp:106
Scope (from outer to inner):
file
function void SColorPicker::Construct
Source code excerpt:
GConfig->GetBool(TEXT("ColorPickerUI"), TEXT("bWheelMode"), WheelMode, GEditorPerProjectIni);
GConfig->GetBool(TEXT("ColorPickerUI"), TEXT("bAdvancedSectionExpanded"), bAdvancedSectionExpanded, GEditorPerProjectIni);
GConfig->GetBool(TEXT("ColorPickerUI"), TEXT("bSRGBEnabled"), SColorThemesViewer::bSRGBEnabled, GEditorPerProjectIni);
CurrentMode = WheelMode ? EColorPickerModes::Wheel : EColorPickerModes::Spectrum;
}
bAdvancedSectionExpanded |= InArgs._ExpandAdvancedSection;
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Private/Widgets/Colors/SColorPicker.cpp:1347
Scope (from outer to inner):
file
function FReply SColorPicker::HandleNewColorBlockMouseButtonDown
Source code excerpt:
TSharedRef<FColorDragDrop> Operation = FColorDragDrop::New(
CurrentColorHSV,
SColorThemesViewer::bSRGBEnabled,
bCheckAlpha ? bUseAlpha.Get() : false,
FSimpleDelegate::CreateSP(this, &SColorPicker::ShowSmallTrash),
FSimpleDelegate::CreateSP(this, &SColorPicker::HideSmallTrash)
);
return FReply::Handled().BeginDragDrop(Operation);
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Private/Widgets/Colors/SColorPicker.cpp:1384
Scope (from outer to inner):
file
function FReply SColorPicker::HandleOldColorBlockMouseButtonDown
Source code excerpt:
TSharedRef<FColorDragDrop> Operation = FColorDragDrop::New(
OldColor,
SColorThemesViewer::bSRGBEnabled,
bCheckAlpha ? bUseAlpha.Get() : false,
FSimpleDelegate::CreateSP(this, &SColorPicker::ShowSmallTrash),
FSimpleDelegate::CreateSP(this, &SColorPicker::HideSmallTrash)
);
return FReply::Handled().BeginDragDrop(Operation);
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Private/Widgets/Colors/SColorPicker.cpp:1399
Scope (from outer to inner):
file
function bool SColorPicker::HandleColorPickerUseSRGB
Source code excerpt:
bool SColorPicker::HandleColorPickerUseSRGB() const
{
return SColorThemesViewer::bSRGBEnabled;
}
void SColorPicker::HandleParentWindowClosed( const TSharedRef<SWindow>& Window )
{
check(Window == ParentWindowPtr.Pin());
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Private/Widgets/Colors/SColorPicker.cpp:1428
Scope (from outer to inner):
file
function void SColorPicker::HandleParentWindowClosed
Source code excerpt:
if ( OriginalSRGBOption.IsSet() )
{
SColorThemesViewer::bSRGBEnabled = OriginalSRGBOption.GetValue();
}
}
void SColorPicker::HandleRGBColorChanged( FLinearColor NewValue )
{
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Private/Widgets/Colors/SColorPicker.cpp:1441
Scope (from outer to inner):
file
function void SColorPicker::HandleSRGBCheckBoxCheckStateChanged
Source code excerpt:
void SColorPicker::HandleSRGBCheckBoxCheckStateChanged( ECheckBoxState InIsChecked )
{
SColorThemesViewer::bSRGBEnabled = (InIsChecked == ECheckBoxState::Checked);
if (FPaths::FileExists(GEditorPerProjectIni))
{
GConfig->SetBool(TEXT("ColorPickerUI"), TEXT("bSRGBEnabled"), SColorThemesViewer::bSRGBEnabled, GEditorPerProjectIni);
}
}
ECheckBoxState SColorPicker::HandleSRGBCheckBoxIsChecked() const
{
return SColorThemesViewer::bSRGBEnabled ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
}
void SColorPicker::HandleThemeBarColorSelected( FLinearColor NewValue )
{
// Force the alpha component to 1 when we don't care about the alpha
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Private/Widgets/Colors/SColorThemes.cpp:818
Scope: file
Source code excerpt:
TArray< TSharedPtr<FColorTheme> > SColorThemesViewer::ColorThemes;
TWeakPtr<FColorTheme> SColorThemesViewer::CurrentlySelectedThemePtr;
bool SColorThemesViewer::bSRGBEnabled = true;
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SColorThemesViewer::Construct(const FArguments& InArgs)
{
#define LOCTEXT_NAMESPACE "ColorThemesViewer"
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Private/Widgets/Colors/SColorThemes.cpp:1159
Scope (from outer to inner):
file
function bool SColorThemesViewer::OnReadUseSRGB
Source code excerpt:
bool SColorThemesViewer::OnReadUseSRGB() const
{
return bSRGBEnabled;
}
bool SColorThemesViewer::OnReadUseAlpha() const
{
return bUseAlpha.Get();
}
#Loc: <Workspace>/Engine/Source/Runtime/AppFramework/Public/Widgets/Colors/SColorThemes.h:566
Scope (from outer to inner):
file
class class SColorThemesViewer : public SCompoundWidget
Source code excerpt:
/** Whether to use display sRGB color */
static bool bSRGBEnabled;
void MenuToStandardNoReturn();
private:
FReply NewColorTheme();