Fix MenuBar minimum size adding unnecessary extra spacing after the last item.

This commit is contained in:
bruvzg 2022-08-19 17:10:53 +03:00
parent b35ff86c17
commit 8f2083e6c0
No known key found for this signature in database
GPG Key ID: 7960FCF39844EC38
1 changed files with 4 additions and 2 deletions

View File

@ -749,7 +749,6 @@ Size2 MenuBar::get_minimum_size() const {
} }
Ref<StyleBox> style = get_theme_stylebox(SNAME("normal")); Ref<StyleBox> style = get_theme_stylebox(SNAME("normal"));
int hsep = get_theme_constant(SNAME("h_separation"));
Vector2 size; Vector2 size;
for (int i = 0; i < menu_cache.size(); i++) { for (int i = 0; i < menu_cache.size(); i++) {
@ -758,7 +757,10 @@ Size2 MenuBar::get_minimum_size() const {
} }
Size2 sz = menu_cache[i].text_buf->get_size() + style->get_minimum_size(); Size2 sz = menu_cache[i].text_buf->get_size() + style->get_minimum_size();
size.y = MAX(size.y, sz.y); size.y = MAX(size.y, sz.y);
size.x += sz.x + hsep; size.x += sz.x;
}
if (menu_cache.size() > 1) {
size.x += get_theme_constant(SNAME("h_separation")) * (menu_cache.size() - 1);
} }
return size; return size;
} }