Skip to content

Commit

Permalink
Merge pull request #97389 from timothyqiu/button-autowrap-min-size
Browse files Browse the repository at this point in the history
Fix button text autowrap overflow when inside a container
  • Loading branch information
akien-mga committed Sep 26, 2024
2 parents 344ce2b + 0f98b32 commit 775edd5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scene/gui/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@

#include "button.h"

#include "core/string/translation.h"
#include "scene/theme/theme_db.h"
#include "servers/rendering_server.h"

Size2 Button::get_minimum_size() const {
Ref<Texture2D> _icon = icon;
Expand Down Expand Up @@ -437,6 +435,9 @@ void Button::_notification(int p_what) {
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.
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);

Point2 text_ofs;
Expand Down

0 comments on commit 775edd5

Please sign in to comment.