浏览代码

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

bruvzg 3 年之前
父节点
当前提交
8f2083e6c0
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      scene/gui/menu_bar.cpp

+ 4 - 2
scene/gui/menu_bar.cpp

@@ -749,7 +749,6 @@ Size2 MenuBar::get_minimum_size() const {
 	}
 
 	Ref<StyleBox> 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;
 }