瀏覽代碼

Merge pull request #97389 from timothyqiu/button-autowrap-min-size

Fix button text autowrap overflow when inside a container
Rémi Verschelde 11 月之前
父節點
當前提交
775edd568b
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      scene/gui/button.cpp

+ 3 - 2
scene/gui/button.cpp

@@ -30,9 +30,7 @@
 
 
 #include "button.h"
 #include "button.h"
 
 
-#include "core/string/translation.h"
 #include "scene/theme/theme_db.h"
 #include "scene/theme/theme_db.h"
-#include "servers/rendering_server.h"
 
 
 Size2 Button::get_minimum_size() const {
 Size2 Button::get_minimum_size() const {
 	Ref<Texture2D> _icon = icon;
 	Ref<Texture2D> _icon = icon;
@@ -437,6 +435,9 @@ void Button::_notification(int p_what) {
 				text_buf->set_alignment(align_rtl_checked);
 				text_buf->set_alignment(align_rtl_checked);
 
 
 				float text_buf_width = Math::ceil(MAX(1.0f, drawable_size_remained.width)); // The space's width filled by the text_buf.
 				float text_buf_width = Math::ceil(MAX(1.0f, drawable_size_remained.width)); // The space's width filled by the text_buf.
+				if (autowrap_mode != TextServer::AUTOWRAP_OFF && !Math::is_equal_approx(text_buf_width, text_buf->get_width())) {
+					update_minimum_size();
+				}
 				text_buf->set_width(text_buf_width);
 				text_buf->set_width(text_buf_width);
 
 
 				Point2 text_ofs;
 				Point2 text_ofs;