From f3b7419790a176105e40c9b9e181ee3d0ed4929e Mon Sep 17 00:00:00 2001 From: TechnicalSoup Date: Thu, 10 Feb 2022 10:59:49 +1100 Subject: [PATCH] Center initial position project manager window Ensure that the project manager window is centered on the screen if any resizing is performed due to DPI scaling. Resizing and repositioning code has been moved to after the initialisation of the window contents to improve UI response/presentation. --- editor/project_manager.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 3ca25bb4e31..2a9f699ee68 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2525,15 +2525,6 @@ ProjectManager::ProjectManager() { editor_set_scale(EditorSettings::get_singleton()->get("interface/editor/custom_display_scale")); break; } - - // Define a minimum window size to prevent UI elements from overlapping or being cut off - DisplayServer::get_singleton()->window_set_min_size(Size2(750, 420) * EDSCALE); - - // TODO: Resize windows on hiDPI displays on Windows and Linux and remove the lines below - float scale_factor = MAX(1, EDSCALE); - Vector2i window_size = DisplayServer::get_singleton()->window_get_size(); - DisplayServer::get_singleton()->window_set_size(Vector2i(window_size.x * scale_factor, window_size.y * scale_factor)); - EditorFileDialog::get_icon_func = &ProjectManager::_file_dialog_get_icon; } @@ -2868,6 +2859,22 @@ ProjectManager::ProjectManager() { SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped)); + // Define a minimum window size to prevent UI elements from overlapping or being cut off + DisplayServer::get_singleton()->window_set_min_size(Size2(750, 420) * EDSCALE); + + // Resize the bootsplash window based on Editor display scale EDSCALE. + float scale_factor = MAX(1, EDSCALE); + if (scale_factor > 1.0) { + Vector2i window_size = DisplayServer::get_singleton()->window_get_size(); + Vector2i screen_size = DisplayServer::get_singleton()->screen_get_size(); + window_size *= scale_factor; + Vector2i window_position; + window_position.x = (screen_size.x - window_size.x) / 2; + window_position.y = (screen_size.y - window_size.y) / 2; + DisplayServer::get_singleton()->window_set_size(window_size); + DisplayServer::get_singleton()->window_set_position(window_position); + } + OS::get_singleton()->set_low_processor_usage_mode(true); }