From cc86322d8dcdf671349d611f47ebf472f5ee1251 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 12 May 2024 23:58:13 +0200 Subject: [PATCH] Increase the project manager's default window size This makes the project manager feel less cramped when many projects are imported, or when browsing templates in the asset library. On displays smaller than 1152x800 (e.g. 1366x768), window height is automatically limited by DisplayServer when setting the window size. This also tweaks splash screen size when starting the project manager to match the project manager's default window size, and allows the `--resolution` and `--position` CLI arguments to affect the project manager. Lastly, this increases the minimum width slightly to prevent the UI from being cut off with the default theme. --- editor/project_manager.cpp | 12 ++++++++---- editor/project_manager.h | 3 +++ main/main.cpp | 9 +++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 9a82ec879d5..cde0c96bf4c 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -150,8 +150,8 @@ void ProjectManager::_build_icon_type_cache(Ref p_theme) { // Main layout. void ProjectManager::_update_size_limits() { - const Size2 minimum_size = Size2(680, 450) * EDSCALE; - const Size2 default_size = Size2(1024, 600) * EDSCALE; + const Size2 minimum_size = Size2(720, 450) * EDSCALE; + const Size2 default_size = Size2(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT) * EDSCALE; // Define a minimum window size to prevent UI elements from overlapping or being cut off. Window *w = Object::cast_to(SceneTree::get_singleton()->get_root()); @@ -159,8 +159,12 @@ void ProjectManager::_update_size_limits() { // Calling Window methods this early doesn't sync properties with DS. w->set_min_size(minimum_size); DisplayServer::get_singleton()->window_set_min_size(minimum_size); - w->set_size(default_size); - DisplayServer::get_singleton()->window_set_size(default_size); + if (DisplayServer::get_singleton()->window_get_size() == default_size) { + // Only set window size if it currently matches the default, which is defined in `main/main.cpp`. + // This allows CLI arguments to override the window size. + w->set_size(default_size); + DisplayServer::get_singleton()->window_set_size(default_size); + } } Rect2i screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(DisplayServer::get_singleton()->window_get_current_screen()); diff --git a/editor/project_manager.h b/editor/project_manager.h index 1cb963a6500..8ae76475a39 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -250,6 +250,9 @@ protected: public: static ProjectManager *get_singleton() { return singleton; } + static constexpr int DEFAULT_WINDOW_WIDTH = 1152; + static constexpr int DEFAULT_WINDOW_HEIGHT = 800; + // Project list. bool is_initialized() const { return initialized; } diff --git a/main/main.cpp b/main/main.cpp index 07c319c088d..f3df10f2a94 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2459,6 +2459,15 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); OS::get_singleton()->set_current_rendering_method(rendering_method); +#ifdef TOOLS_ENABLED + if (!force_res && project_manager) { + // Ensure splash screen size matches the project manager window size + // (see `editor/project_manager.cpp` for defaults). + window_size.width = ProjectManager::DEFAULT_WINDOW_WIDTH; + window_size.height = ProjectManager::DEFAULT_WINDOW_HEIGHT; + } +#endif + if (use_custom_res) { if (!force_res) { window_size.width = GLOBAL_GET("display/window/size/viewport_width");