From 8f2083e6c0f4b32776a48d4975b1224cbc385ab4 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Fri, 19 Aug 2022 17:10:53 +0300 Subject: Fix MenuBar minimum size adding unnecessary extra spacing after the last item. --- scene/gui/menu_bar.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp index ebe833c6e0..f450222130 100644 --- a/scene/gui/menu_bar.cpp +++ b/scene/gui/menu_bar.cpp @@ -749,7 +749,6 @@ Size2 MenuBar::get_minimum_size() const { } Ref style = get_theme_stylebox(SNAME("normal")); - int hsep = get_theme_constant(SNAME("h_separation")); Vector2 size; 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(); 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; } -- cgit v1.2.3