ApplicationScale
ApplicationScale
#Overview
name: ApplicationScale
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 ApplicationScale is to control the overall scaling of the user interface in Unreal Engine. This setting variable is primarily used for adjusting the UI elements’ size across different display resolutions and DPI settings.
ApplicationScale is utilized by various Unreal Engine subsystems and modules, particularly those related to the user interface and editor. Based on the callsites, it’s primarily used in the following areas:
- UnrealEd module (Editor UI)
- Slate framework (UI rendering)
- Engine module (User Interface Settings)
- Interchange module (UI components)
The value of this variable is typically set in the EditorStyleSettings or UserInterfaceSettings classes. It can be modified through the editor’s settings menu or programmatically.
ApplicationScale interacts with other UI-related variables and systems, such as DPI scaling, window sizes, and UI component dimensions. It’s often used in calculations involving screen space and UI element sizing.
Developers should be aware that changing ApplicationScale affects the entire UI, including the editor interface and in-game UI elements. It’s crucial to test UI layouts and functionality across different scale values to ensure proper display and usability.
Best practices when using this variable include:
- Use it consistently across the project to maintain a uniform UI scale.
- Consider its impact on different screen resolutions and aspect ratios.
- Combine it with other scaling methods (like DPI scaling) for more fine-grained control.
- Test UI layouts thoroughly after adjusting the ApplicationScale.
- Be cautious when modifying it at runtime, as it may affect performance or cause unexpected layout changes.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:237, section: [/Script/Engine.UserInterfaceSettings]
- INI Section:
/Script/Engine.UserInterfaceSettings
- Raw value:
1.000000
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/EditorStyleSettings.h:52
Scope (from outer to inner):
file
class class UEditorStyleSettings : public UObject
Source code excerpt:
*/
UPROPERTY(EditAnywhere, Config, Category=UserInterface, meta=(ClampMin=0.5, ClampMax=3.0))
float ApplicationScale = 1.0f;
/**
* Whether to enable the Editor UI Layout configuration tools for the user.
* If disabled, the "Save Layout As" and "Remove Layout" menus will be removed, as well as the "Import Layout..." sub-menu.
*/
UPROPERTY(EditAnywhere, config, Category = UserInterface)
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorStyleClasses.cpp:71
Scope (from outer to inner):
file
function void UEditorStyleSettings::Init
Source code excerpt:
if (FSlateApplication::IsInitialized())
{
FSlateApplication::Get().SetApplicationScale(ApplicationScale);
}
// Set from CVar
IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("EnableHighDPIAwareness"));
bEnableHighDPIAwareness = CVar->GetInt() != 0;
}
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorStyleClasses.cpp:100
Scope (from outer to inner):
file
function void UEditorStyleSettings::PostEditChangeProperty
Source code excerpt:
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);
}
}
// if (!FUnrealEdMisc::Get().IsDeletePreferences())
{
SaveConfig();
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/UserInterfaceSettings.h:165
Scope (from outer to inner):
file
class class UUserInterfaceSettings : public UDeveloperSettings
Source code excerpt:
*/
UPROPERTY(config, EditAnywhere, Category="DPI Scaling")
float ApplicationScale;
/**
* The rule used when trying to decide what scale to apply.
*/
UPROPERTY(config, EditAnywhere, Category="DPI Scaling", meta=( DisplayName="DPI Scale Rule" ))
EUIScalingRule UIScaleRule;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterfaceSettings.cpp:13
Scope (from outer to inner):
file
function UUserInterfaceSettings::UUserInterfaceSettings
Source code excerpt:
: Super(ObjectInitializer)
, RenderFocusRule(ERenderFocusRule::NavigationOnly)
, ApplicationScale(1)
, bLoadWidgetsOnDedicatedServer(true)
, bAuthorizeAutomaticWidgetVariableCreation(true)
#if WITH_EDITORONLY_DATA
, CustomFontDPI(FontConstants::RenderDPI)
, FontDPIPreset(ConvertToEFontDPI(CustomFontDPI))
, bUseCustomFontDPI(false)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterfaceSettings.cpp:104
Scope (from outer to inner):
file
function float UUserInterfaceSettings::GetDPIScaleBasedOnSize
Source code excerpt:
}
return FMath::Max(Scale * ApplicationScale, 0.01f);
}
float UUserInterfaceSettings::CalculateScale(FIntPoint Size, bool& bError) const
{
bError = false;
#Loc: <Workspace>/Engine/Source/Runtime/Interchange/Core/Public/InterchangePipelineBase.h:152
Scope (from outer to inner):
file
class class SInterchangeBaseConflictWidget : public SCompoundWidget
function FVector2D GetMinimumSize
Source code excerpt:
}
FVector2D GetMinimumSize(float ApplicationScale) const
{
return ComputeDesiredSize(ApplicationScale);
}
protected:
TSharedPtr<SWindow> WidgetWindow = nullptr;
};
UCLASS(BlueprintType, Blueprintable, editinlinenew, Abstract, MinimalAPI)
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/MenuStack.cpp:366
Scope (from outer to inner):
file
function FMenuStack::FPrePushResults FMenuStack::PrePush
Source code excerpt:
// Calc the max height available on screen for the menu
float MaxHeight;
const float ApplicationScale = FSlateApplication::Get().GetApplicationScale() * HostWindow->GetNativeWindow()->GetDPIScaleFactor();
if (ActiveMethod.GetPopupMethod() == EPopupMethod::CreateNewWindow)
{
FSlateRect WorkArea = FSlateApplication::Get().GetWorkArea(InArgs.Anchor);
MaxHeight = FMenuStackDefs::MaxMenuScreenHeightFraction * WorkArea.GetSize().Y / ApplicationScale;
}
else
{
MaxHeight = FMenuStackDefs::MaxMenuScreenHeightFraction * HostWindow->GetClientSizeInScreen().Y / ApplicationScale;
}
bool bAnchorSetsMinWidth = InArgs.TransitionEffect.SlideDirection == FPopupTransitionEffect::ComboButton;
// Wrap menu content in a box needed for various sizing and tracking purposes
FOptionalSize OptionalMinWidth = bAnchorSetsMinWidth ? InArgs.Anchor.GetSize().X : FOptionalSize();
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/MenuStack.cpp:388
Scope (from outer to inner):
file
function FMenuStack::FPrePushResults FMenuStack::PrePush
Source code excerpt:
OutResults.WrappedContent = WrapContent(TempContent, OptionalMinWidth, OptionalMinHeight);
OutResults.WrappedContent->SlatePrepass(ApplicationScale);
// @todo slate: Doesn't take into account potential window border size
OutResults.ExpectedSize = OutResults.WrappedContent->GetDesiredSize() * ApplicationScale;
EOrientation Orientation = (InArgs.TransitionEffect.SlideDirection == FPopupTransitionEffect::SubMenu) ? Orient_Horizontal : Orient_Vertical;
// Calculate the correct position for the menu based on the popup method
if (ActiveMethod.GetPopupMethod() == EPopupMethod::CreateNewWindow)
{
#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/UI/Weapons/SCircumferenceMarkerWidget.cpp:62
Scope (from outer to inner):
file
function int32 SCircumferenceMarkerWidget::OnPaint
Source code excerpt:
{
const float BaseRadius = Radius.Get();
const float ApplicationScale = GetDefault<UUserInterfaceSettings>()->ApplicationScale;
for (const FCircumferenceMarkerEntry& Marker : MarkerList)
{
const FSlateRenderTransform MarkerTransform = GetMarkerRenderTransform(Marker, BaseRadius, ApplicationScale);
const FPaintGeometry Geometry(AllottedGeometry.ToPaintGeometry(MarkerBrush->ImageSize, FSlateLayoutTransform(LocalCenter - (MarkerBrush->ImageSize * 0.5f)), MarkerTransform, FVector2D(0.0f, 0.0f)));
FSlateDrawElement::MakeBox(OutDrawElements, LayerId, Geometry, MarkerBrush, DrawEffects, MarkerColor);
}
}
}