1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Handle portrait mode monitors in the automatic editor scale detection

Using the smallest dimension of the width and height makes it possible
to support both landscape and portrait monitors.

(cherry picked from commit 728fa3ff71)

EditorSettings: Factor code to compute auto display scale

Also fixes typo introduced in https://github.com/godotengine/godot/pull/48597/files#r652636544.

(cherry picked from commit f862f9a056)
This commit is contained in:
Hugo Locurcio
2021-05-09 23:33:45 +02:00
committed by Rémi Verschelde
parent 770de6f579
commit dd2fc60abc
4 changed files with 31 additions and 76 deletions

View File

@@ -5701,34 +5701,10 @@ EditorNode::EditorNode() {
int display_scale = EditorSettings::get_singleton()->get("interface/editor/display_scale");
switch (display_scale) {
case 0: {
case 0:
// Try applying a suitable display scale automatically.
// The code below is adapted in `editor/editor_settings.cpp` and `editor/project_manager.cpp`.
// Make sure to update those when modifying the code below.
#ifdef OSX_ENABLED
editor_set_scale(OS::get_singleton()->get_screen_max_scale());
#else
const int screen = OS::get_singleton()->get_current_screen();
float scale;
if (OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).y >= 1400) {
// hiDPI display.
scale = 2.0;
} else if (OS::get_singleton()->get_screen_size(screen).y >= 1700) {
// Likely a hiDPI display, but we aren't certain due to the returned DPI.
// Use an intermediate scale to handle this situation.
scale = 1.5;
} else if (OS::get_singleton()->get_screen_size(screen).y <= 800) {
// Small loDPI display. Use a smaller display scale so that editor elements fit more easily.
// Icons won't look great, but this is better than having editor elements overflow from its window.
scale = 0.75;
} else {
scale = 1.0;
}
editor_set_scale(scale);
#endif
} break;
editor_set_scale(EditorSettings::get_singleton()->get_auto_display_scale());
break;
case 1:
editor_set_scale(0.75);
break;