EnableHighDPIAwareness
EnableHighDPIAwareness
#Overview
name: EnableHighDPIAwareness
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables or disables high dpi mode
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of EnableHighDPIAwareness is to enable or disable high DPI mode in the Unreal Engine application. This setting is primarily used for managing the user interface scaling and display quality on high-resolution screens.
This setting variable is primarily used by the Unreal Engine’s application core and user interface subsystems. Specifically, it is referenced in the ApplicationCore and Slate modules, as well as in the UnrealEd editor settings.
The value of this variable is set in multiple places:
- It can be set through a console variable (CVar) named “EnableHighDPIAwareness”.
- In the editor, it can be modified through the EditorStyleSettings (bEnableHighDPIAwareness property).
- For game mode, it’s read from the engine configuration file (GEngineIni) under the UserInterfaceSettings section.
The associated variable bEnableHighDPIAwareness interacts closely with EnableHighDPIAwareness. They share the same value and are used interchangeably in different parts of the codebase.
Developers should be aware of the following when using this variable:
- Changing this setting may require a restart of the application to take full effect.
- It affects the entire application’s UI scaling, so it should be used carefully to ensure a consistent user experience across different display resolutions.
- The setting behaves differently in editor mode versus game mode.
Best practices for using this variable include:
- Consider the target platforms and typical display resolutions when deciding whether to enable high DPI awareness.
- Test the application thoroughly on various display configurations when modifying this setting.
- Coordinate changes to this variable with adjustments to other UI scaling settings, such as ApplicationScale.
Regarding the associated variable bEnableHighDPIAwareness:
- Its purpose is the same as EnableHighDPIAwareness, serving as a boolean representation of the high DPI awareness setting.
- It is used in the EditorStyleSettings class and the GenericPlatformApplicationMisc namespace.
- Its value is set based on the EnableHighDPIAwareness console variable and can be modified through the editor UI.
- When changed in the editor, it updates the configuration file (GEditorSettingsIni) to persist the setting.
- Developers should treat it as equivalent to EnableHighDPIAwareness, ensuring consistency when working with either variable.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/GenericPlatform/GenericPlatformApplicationMisc.cpp:21
Scope: file
Source code excerpt:
FAutoConsoleVariableRef FGenericPlatformApplicationMisc::CVarEnableHighDPIAwareness(
TEXT("EnableHighDPIAwareness"),
bEnableHighDPIAwareness,
TEXT("Enables or disables high dpi mode"),
ECVF_ReadOnly
);
static bool bAllowVirtualKeyboard = false;
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorStyleClasses.cpp:98
Scope (from outer to inner):
file
function void UEditorStyleSettings::PostEditChangeProperty
Source code excerpt:
if (PropertyName == GET_MEMBER_NAME_CHECKED(UEditorStyleSettings, bEnableHighDPIAwareness))
{
GConfig->SetBool(TEXT("HDPI"), TEXT("EnableHighDPIAwareness"), bEnableHighDPIAwareness, GEditorSettingsIni);
}
else if (PropertyName.IsNone() || PropertyName == GET_MEMBER_NAME_CHECKED(UEditorStyleSettings, ApplicationScale))
{
if (FSlateApplication::IsInitialized())
{
FSlateApplication::Get().SetApplicationScale(ApplicationScale);
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:922
Scope (from outer to inner):
file
function void FSlateApplication::InitHighDPI
Source code excerpt:
if (GIsEditor)
{
GConfig->GetBool(TEXT("HDPI"), TEXT("EnableHighDPIAwareness"), bRequestEnableHighDPI, GEditorSettingsIni);
}
else
{
GConfig->GetBool(TEXT("/Script/Engine.UserInterfaceSettings"), TEXT("bAllowHighDPIInGameMode"), bRequestEnableHighDPI, GEngineIni);
}
#Associated Variable and Callsites
This variable is associated with another variable named bEnableHighDPIAwareness
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/EditorStyleSettings.h:46
Scope (from outer to inner):
file
class class UEditorStyleSettings : public UObject
Source code excerpt:
*/
UPROPERTY(EditAnywhere, Category=UserInterface, meta = (ConfigRestartRequired = true, DisplayName="Enable High DPI Support"))
bool bEnableHighDPIAwareness;
/**
* Scales the entire editor interface up or down.
*/
UPROPERTY(EditAnywhere, Config, Category=UserInterface, meta=(ClampMin=0.5, ClampMax=3.0))
float ApplicationScale = 1.0f;
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorStyleClasses.cpp:76
Scope (from outer to inner):
file
function void UEditorStyleSettings::Init
Source code excerpt:
// Set from CVar
IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("EnableHighDPIAwareness"));
bEnableHighDPIAwareness = CVar->GetInt() != 0;
}
FLinearColor UEditorStyleSettings::GetSubduedSelectionColor() const
{
FLinearColor SubduedSelectionColor = SelectionColor.LinearRGBToHSV();
SubduedSelectionColor.G *= 0.55f; // take the saturation
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorStyleClasses.cpp:96
Scope (from outer to inner):
file
function void UEditorStyleSettings::PostEditChangeProperty
Source code excerpt:
// This property is intentionally not per project so it must be manually written to the correct config file
if (PropertyName == GET_MEMBER_NAME_CHECKED(UEditorStyleSettings, bEnableHighDPIAwareness))
{
GConfig->SetBool(TEXT("HDPI"), TEXT("EnableHighDPIAwareness"), bEnableHighDPIAwareness, GEditorSettingsIni);
}
else if (PropertyName.IsNone() || PropertyName == GET_MEMBER_NAME_CHECKED(UEditorStyleSettings, ApplicationScale))
{
if (FSlateApplication::IsInitialized())
{
FSlateApplication::Get().SetApplicationScale(ApplicationScale);
#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/GenericPlatform/GenericPlatformApplicationMisc.cpp:18
Scope: file
Source code excerpt:
int32 FGenericPlatformApplicationMisc::CachedPhysicalScreenDensity = 0;
static int32 bEnableHighDPIAwareness = 1;
FAutoConsoleVariableRef FGenericPlatformApplicationMisc::CVarEnableHighDPIAwareness(
TEXT("EnableHighDPIAwareness"),
bEnableHighDPIAwareness,
TEXT("Enables or disables high dpi mode"),
ECVF_ReadOnly
);
static bool bAllowVirtualKeyboard = false;
#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/GenericPlatform/GenericPlatformApplicationMisc.cpp:103
Scope (from outer to inner):
file
function bool FGenericPlatformApplicationMisc::IsHighDPIAwarenessEnabled
Source code excerpt:
bool FGenericPlatformApplicationMisc::IsHighDPIAwarenessEnabled()
{
return bEnableHighDPIAwareness != 0;
}
void FGenericPlatformApplicationMisc::ClipboardCopy(const TCHAR* Str)
{
}