X Tutup
Skip to content

Fix center buttons offset#113612

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
BrotherShort:fix-center-buttons-offset
Dec 8, 2025
Merged

Fix center buttons offset#113612
Repiteo merged 1 commit intogodotengine:masterfrom
BrotherShort:fix-center-buttons-offset

Conversation

@BrotherShort
Copy link
Contributor

@BrotherShort BrotherShort commented Dec 5, 2025

Fix #113401.
Move the calculation in the update function.
Remove set_custom_minimum_sizes.
After:
center_buttons

@BrotherShort BrotherShort requested review from a team as code owners December 5, 2025 08:41
@BrotherShort BrotherShort requested a review from a team December 5, 2025 08:41
@AThousandShips AThousandShips added this to the 4.6 milestone Dec 5, 2025
Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working fine. Tested on Windows and macOS (with global menu).

There are few extra lines that can be removed (called if menu style is changed in runtime):

diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index cc070096c2..dc918500fc 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -7778,13 +7778,6 @@ void EditorNode::_update_main_menu_type() {
                }
                memdelete_notnull(main_menu_bar);
                main_menu_bar = nullptr;
-
-               if (project_run_bar != nullptr) {
-                       // Adjust spacers to center 2D / 3D / Script buttons.
-                       int max_w = MAX(project_run_bar->get_minimum_size().x + right_menu_hb->get_minimum_size().x, main_menu_button->get_minimum_size().x);
-                       left_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - main_menu_button->get_minimum_size().x), 0));
-                       right_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - project_run_bar->get_minimum_size().x - right_menu_hb->get_minimum_size().x), 0));
-               }
        } else {
                main_menu_bar = memnew(MenuBar);
                main_menu_bar->set_mouse_filter(Control::MOUSE_FILTER_STOP);
@@ -7815,13 +7808,6 @@ void EditorNode::_update_main_menu_type() {
                memdelete_notnull(main_menu_button);
                menu_btn_spacer = nullptr;
                main_menu_button = nullptr;
-
-               if (project_run_bar != nullptr) {
-                       // Adjust spacers to center 2D / 3D / Script buttons.
-                       int max_w = MAX(project_run_bar->get_minimum_size().x + right_menu_hb->get_minimum_size().x, main_menu_bar->get_minimum_size().x);
-                       left_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - main_menu_bar->get_minimum_size().x), 0));
-                       right_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - project_run_bar->get_minimum_size().x - right_menu_hb->get_minimum_size().x), 0));
-               }
        }
 }

Remove set spacers
@BrotherShort BrotherShort force-pushed the fix-center-buttons-offset branch from ebcb06e to 75ba00b Compare December 7, 2025 19:25
@BrotherShort
Copy link
Contributor Author

BrotherShort commented Dec 7, 2025

Seems to be working fine. Tested on Windows and macOS (with global menu).

There are few extra lines that can be removed (called if menu style is changed in runtime):

diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index cc070096c2..dc918500fc 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -7778,13 +7778,6 @@ void EditorNode::_update_main_menu_type() {
                }
                memdelete_notnull(main_menu_bar);
                main_menu_bar = nullptr;
-
-               if (project_run_bar != nullptr) {
-                       // Adjust spacers to center 2D / 3D / Script buttons.
-                       int max_w = MAX(project_run_bar->get_minimum_size().x + right_menu_hb->get_minimum_size().x, main_menu_button->get_minimum_size().x);
-                       left_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - main_menu_button->get_minimum_size().x), 0));
-                       right_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - project_run_bar->get_minimum_size().x - right_menu_hb->get_minimum_size().x), 0));
-               }
        } else {
                main_menu_bar = memnew(MenuBar);
                main_menu_bar->set_mouse_filter(Control::MOUSE_FILTER_STOP);
@@ -7815,13 +7808,6 @@ void EditorNode::_update_main_menu_type() {
                memdelete_notnull(main_menu_button);
                menu_btn_spacer = nullptr;
                main_menu_button = nullptr;
-
-               if (project_run_bar != nullptr) {
-                       // Adjust spacers to center 2D / 3D / Script buttons.
-                       int max_w = MAX(project_run_bar->get_minimum_size().x + right_menu_hb->get_minimum_size().x, main_menu_bar->get_minimum_size().x);
-                       left_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - main_menu_bar->get_minimum_size().x), 0));
-                       right_spacer->set_custom_minimum_size(Size2(MAX(0, max_w - project_run_bar->get_minimum_size().x - right_menu_hb->get_minimum_size().x), 0));
-               }
        }
 }

Done. And I undid the code I modified. Your code in EditorTitleBar::_notification is right. All I need to do is remove set_custom_minimum_sizes.

@Repiteo Repiteo merged commit 979b619 into godotengine:master Dec 8, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 8, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Main screen buttons are on longer centered

4 participants

X Tutup