Skip to content

Commit

Permalink
Merge pull request #83961 from bruvzg/menu_bar_update_size
Browse files Browse the repository at this point in the history
[Menu Bar] Update min. size when items are added/removed/changed.
  • Loading branch information
akien-mga committed Oct 26, 2023
2 parents cb167fd + 961e8af commit d298200
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scene/gui/menu_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ void MenuBar::add_child_notify(Node *p_child) {
int index = DisplayServer::get_singleton()->global_menu_add_submenu_item("_main", atr(menu.name), submenu_name, _find_global_start_index() + menu_cache.size() - 1);
DisplayServer::get_singleton()->global_menu_set_item_tag("_main", index, global_menu_name + "#" + itos(menu_cache.size() - 1));
}
update_minimum_size();
}

void MenuBar::move_child_notify(Node *p_child) {
Expand Down Expand Up @@ -621,6 +622,8 @@ void MenuBar::remove_child_notify(Node *p_child) {
p_child->disconnect("renamed", callable_mp(this, &MenuBar::_refresh_menu_names));
p_child->disconnect("about_to_popup", callable_mp(this, &MenuBar::_popup_visibility_changed));
p_child->disconnect("popup_hide", callable_mp(this, &MenuBar::_popup_visibility_changed));

update_minimum_size();
}

void MenuBar::_bind_methods() {
Expand Down Expand Up @@ -808,6 +811,7 @@ void MenuBar::set_menu_title(int p_menu, const String &p_title) {
if (!global_menu_name.is_empty()) {
DisplayServer::get_singleton()->global_menu_set_item_text("_main", _find_global_start_index() + p_menu, atr(menu_cache[p_menu].name));
}
update_minimum_size();
}

String MenuBar::get_menu_title(int p_menu) const {
Expand Down Expand Up @@ -849,6 +853,7 @@ void MenuBar::set_menu_hidden(int p_menu, bool p_hidden) {
if (!global_menu_name.is_empty()) {
DisplayServer::get_singleton()->global_menu_set_item_hidden("_main", _find_global_start_index() + p_menu, p_hidden);
}
update_minimum_size();
}

bool MenuBar::is_menu_hidden(int p_menu) const {
Expand Down

0 comments on commit d298200

Please sign in to comment.