Skip to content

Commit

Permalink
Merge pull request #48597 from Calinou/editor-scale-auto-portrait
Browse files Browse the repository at this point in the history
Handle portrait mode monitors in the automatic editor scale detection
  • Loading branch information
akien-mga authored Jun 15, 2021
2 parents 5bd0692 + 728fa3f commit 3f01b38
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 5 additions & 3 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3f01b38

Please sign in to comment.