summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-06-15 18:27:48 +0200
committerGitHub <noreply@github.com>2021-06-15 18:27:48 +0200
commit3f01b38185dd3f94587688c64462265a6bc9db4d (patch)
treec7b5ec7f5d483ee1ec096ab73b986e870a890133 /editor
parent5bd0692d0c959900aa539140fc97bd58a60bc7a4 (diff)
parent728fa3ff71361f527e0bf18c46cf9152ec5a3d6d (diff)
Merge pull request #48597 from Calinou/editor-scale-auto-portrait
Handle portrait mode monitors in the automatic editor scale detection
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp8
-rw-r--r--editor/editor_settings.cpp8
-rw-r--r--editor/project_manager.cpp8
3 files changed, 15 insertions, 9 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 4f874687b4..b6df9f6088 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -5697,15 +5697,17 @@ EditorNode::EditorNode() {
editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale());
#else
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;
- 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.
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.
// Use an intermediate scale to handle this situation.
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.
// Icons won't look great, but this is better than having editor elements overflow from its window.
scale = 0.75;
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index fa7980b95f..d81c94bd35 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -379,15 +379,17 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
float scale = DisplayServer::get_singleton()->screen_get_max_scale();
#else
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;
- 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.
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.
// Use an intermediate scale to handle this situation.
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.
// Icons won't look great, but this is better than having editor elements overflow from its window.
scale = 0.75;
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 12490f687e..5490fbbbc7 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -2408,15 +2408,17 @@ ProjectManager::ProjectManager() {
editor_set_scale(DisplayServer::get_singleton()->screen_get_max_scale());
#else
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;
- 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.
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.
// Use an intermediate scale to handle this situation.
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.
// Icons won't look great, but this is better than having editor elements overflow from its window.
scale = 0.75;