diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-11-16 16:36:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 16:36:10 +0100 |
commit | d191ffe647b5074bd939f6289957f1610159a31d (patch) | |
tree | 4c2e23b004ea19353f38341a4172dad300f20ad4 /editor | |
parent | efe3eaf6a4439189ad14d788e035ec8059853ece (diff) | |
parent | c1a65e52896ae060881bba929dd4a7ff824139b9 (diff) |
Merge pull request #43479 from Calinou/use-low-editor-scale-auto
Use 75% editor scale on small displays automatically
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 53 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 3 | ||||
-rw-r--r-- | editor/project_manager.cpp | 20 |
3 files changed, 47 insertions, 29 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index b33555f260..2e796b2dcd 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5565,46 +5565,51 @@ EditorNode::EditorNode() { { int display_scale = EditorSettings::get_singleton()->get("interface/editor/display_scale"); - float custom_display_scale = EditorSettings::get_singleton()->get("interface/editor/custom_display_scale"); switch (display_scale) { case 0: { - // Try applying a suitable display scale automatically + // Try applying a suitable display scale automatically. #ifdef OSX_ENABLED editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale()); #else const int screen = DisplayServer::get_singleton()->window_get_current_screen(); - editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0); + float scale; + if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).y >= 1400) { + // hiDPI display. + scale = 2.0; + } else if (DisplayServer::get_singleton()->screen_get_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; - case 1: { + case 1: editor_set_scale(0.75); - } break; - - case 2: { + break; + case 2: editor_set_scale(1.0); - } break; - - case 3: { + break; + case 3: editor_set_scale(1.25); - } break; - - case 4: { + break; + case 4: editor_set_scale(1.5); - } break; - - case 5: { + break; + case 5: editor_set_scale(1.75); - } break; - - case 6: { + break; + case 6: editor_set_scale(2.0); - } break; - - default: { - editor_set_scale(custom_display_scale); - } break; + break; + default: + editor_set_scale(EditorSettings::get_singleton()->get("interface/editor/custom_display_scale")); + break; } } diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 79525ced51..768e5bccbc 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -441,7 +441,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Highlighted tabs and border width Color tab_color = highlight_tabs ? base_color.lerp(font_color, contrast) : base_color; - const int border_width = CLAMP(border_size, 0, 3) * EDSCALE; + // Ensure borders are visible when using an editor scale below 100%. + const int border_width = CLAMP(border_size, 0, 3) * MAX(1, EDSCALE); const int default_margin_size = 4; const int margin_size_extra = default_margin_size + CLAMP(border_size, 0, 3); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index b67a134549..167cd3ac35 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2366,12 +2366,24 @@ ProjectManager::ProjectManager() { switch (display_scale) { case 0: { - // Try applying a suitable display scale automatically + // Try applying a suitable display scale automatically. #ifdef OSX_ENABLED editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale()); #else const int screen = DisplayServer::get_singleton()->window_get_current_screen(); - editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0); + float scale; + if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).y >= 1400) { + // hiDPI display. + scale = 2.0; + } else if (DisplayServer::get_singleton()->screen_get_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; @@ -2393,9 +2405,9 @@ ProjectManager::ProjectManager() { case 6: editor_set_scale(2.0); break; - default: { + default: editor_set_scale(EditorSettings::get_singleton()->get("interface/editor/custom_display_scale")); - } break; + break; } // Define a minimum window size to prevent UI elements from overlapping or being cut off |