Merge pull request #48597 from Calinou/editor-scale-auto-portrait

Handle portrait mode monitors in the automatic editor scale detection
This commit is contained in:
Rémi Verschelde 2021-06-15 18:27:48 +02:00 committed by GitHub
commit 3f01b38185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 9 deletions

View File

@ -5697,15 +5697,17 @@ EditorNode::EditorNode() {
editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale()); editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale());
#else #else
const int screen = DisplayServer::get_singleton()->window_get_current_screen(); const int screen = DisplayServer::get_singleton()->window_get_current_screen();
// Use the smallest dimension to use a correct display scale on portait displays.
const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
float scale; float scale;
if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).y >= 1400) { if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
// hiDPI display. // hiDPI display.
scale = 2.0; scale = 2.0;
} else if (DisplayServer::get_singleton()->screen_get_size(screen).y >= 1700) { } else if (smallest_dimension >= 1700) {
// Likely a hiDPI display, but we aren't certain due to the returned DPI. // Likely a hiDPI display, but we aren't certain due to the returned DPI.
// Use an intermediate scale to handle this situation. // Use an intermediate scale to handle this situation.
scale = 1.5; scale = 1.5;
} else if (DisplayServer::get_singleton()->screen_get_size(screen).y <= 800) { } else if (smallest_dimension <= 800) {
// Small loDPI display. Use a smaller display scale so that editor elements fit more easily. // 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. // Icons won't look great, but this is better than having editor elements overflow from its window.
scale = 0.75; scale = 0.75;

View File

@ -379,15 +379,17 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
float scale = DisplayServer::get_singleton()->screen_get_max_scale(); float scale = DisplayServer::get_singleton()->screen_get_max_scale();
#else #else
const int screen = DisplayServer::get_singleton()->window_get_current_screen(); const int screen = DisplayServer::get_singleton()->window_get_current_screen();
// Use the smallest dimension to use a correct display scale on portait displays.
const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
float scale; float scale;
if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).y >= 1400) { if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
// hiDPI display. // hiDPI display.
scale = 2.0; scale = 2.0;
} else if (DisplayServer::get_singleton()->screen_get_size(screen).y >= 1700) { } else if (smallest_dimension <= 1700) {
// Likely a hiDPI display, but we aren't certain due to the returned DPI. // Likely a hiDPI display, but we aren't certain due to the returned DPI.
// Use an intermediate scale to handle this situation. // Use an intermediate scale to handle this situation.
scale = 1.5; scale = 1.5;
} else if (DisplayServer::get_singleton()->screen_get_size(screen).y <= 800) { } else if (smallest_dimension <= 800) {
// Small loDPI display. Use a smaller display scale so that editor elements fit more easily. // 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. // Icons won't look great, but this is better than having editor elements overflow from its window.
scale = 0.75; scale = 0.75;

View File

@ -2408,15 +2408,17 @@ ProjectManager::ProjectManager() {
editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale()); editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale());
#else #else
const int screen = DisplayServer::get_singleton()->window_get_current_screen(); const int screen = DisplayServer::get_singleton()->window_get_current_screen();
// Use the smallest dimension to use a correct display scale on portait displays.
const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y);
float scale; float scale;
if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).y >= 1400) { if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) {
// hiDPI display. // hiDPI display.
scale = 2.0; scale = 2.0;
} else if (DisplayServer::get_singleton()->screen_get_size(screen).y >= 1700) { } else if (smallest_dimension >= 1700) {
// Likely a hiDPI display, but we aren't certain due to the returned DPI. // Likely a hiDPI display, but we aren't certain due to the returned DPI.
// Use an intermediate scale to handle this situation. // Use an intermediate scale to handle this situation.
scale = 1.5; scale = 1.5;
} else if (DisplayServer::get_singleton()->screen_get_size(screen).y <= 800) { } else if (smallest_dimension <= 800) {
// Small loDPI display. Use a smaller display scale so that editor elements fit more easily. // 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. // Icons won't look great, but this is better than having editor elements overflow from its window.
scale = 0.75; scale = 0.75;