diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-18 16:47:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-18 16:47:18 +0100 |
commit | eba982b9a39eeaca7977381a93d1a672eca82a3f (patch) | |
tree | 38ed2b60b29ce634fdc0cb21ecb5f04cedc07180 /editor | |
parent | eb77d0cf1b39fd03b0beb1b1c98ddc89f55074ab (diff) | |
parent | 57654508c91fa5eb166a02d4c1174a056da2afbb (diff) |
Merge pull request #45270 from Calinou/editor-tweak-font-hinting-hint
Tweak the "Auto" editor setting hints to be more indicative
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 27 | ||||
-rw-r--r-- | editor/project_manager.cpp | 2 |
3 files changed, 29 insertions, 2 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ddd9494fdd..f5260f773d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5574,6 +5574,8 @@ EditorNode::EditorNode() { switch (display_scale) { 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(DisplayServer::get_singleton()->screen_get_max_scale()); #else diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 6683867e1d..3eee7b2bfb 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -326,7 +326,26 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Editor _initial_set("interface/editor/display_scale", 0); - hints["interface/editor/display_scale"] = PropertyInfo(Variant::INT, "interface/editor/display_scale", PROPERTY_HINT_ENUM, "Auto,75%,100%,125%,150%,175%,200%,Custom", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + // Display what the Auto display scale setting effectively corresponds to. + // The code below is adapted in `editor/editor_node.cpp` and `editor/project_manager.cpp`. + // Make sure to update those when modifying the code below. +#ifdef OSX_ENABLED + float scale = DisplayServer::get_singleton()->screen_get_max_scale(); +#else + const int screen = DisplayServer::get_singleton()->window_get_current_screen(); + 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; + } +#endif + hints["interface/editor/display_scale"] = PropertyInfo(Variant::INT, "interface/editor/display_scale", PROPERTY_HINT_ENUM, vformat("Auto (%d%%),75%%,100%%,125%%,150%%,175%%,200%%,Custom", Math::round(scale * 100)), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/custom_display_scale", 1.0f); hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::FLOAT, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/main_font_size", 14); @@ -339,7 +358,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("interface/editor/code_font_custom_variations", ""); _initial_set("interface/editor/font_antialiased", true); _initial_set("interface/editor/font_hinting", 0); - hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "Auto,None,Light,Normal", PROPERTY_USAGE_DEFAULT); +#ifdef OSX_ENABLED + hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "Auto (None),None,Light,Normal", PROPERTY_USAGE_DEFAULT); +#else + hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "Auto (Light),None,Light,Normal", PROPERTY_USAGE_DEFAULT); +#endif _initial_set("interface/editor/main_font", ""); hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/main_font_bold", ""); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 1007a6c689..e46b2711c1 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2371,6 +2371,8 @@ ProjectManager::ProjectManager() { switch (display_scale) { case 0: { // Try applying a suitable display scale automatically. + // The code below is adapted in `editor/editor_settings.cpp` and `editor/editor_node.cpp`. + // Make sure to update those when modifying the code below. #ifdef OSX_ENABLED editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale()); #else |