summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-08-08 17:00:46 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-08-08 17:00:46 +0200
commit0ce1ca4677ad4d9b5952747f7940e712d561655e (patch)
tree2aaa72a9a387b74db2a274304e20b7e0d5e858b7
parent310553f2a30a8937c02aa52d2f57838db0f4a650 (diff)
parent7f70ac56a09e721f6ecaa491491d6457177caaab (diff)
downloadredot-engine-0ce1ca4677ad4d9b5952747f7940e712d561655e.tar.gz
Merge pull request #80402 from timothyqiu/overrun-icon
Fix Button text when overrun is not trim nothing
-rw-r--r--scene/gui/button.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 430569432a..738778b516 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -118,6 +118,7 @@ void Button::_notification(int p_what) {
Ref<StyleBox> style = theme_cache.normal;
bool rtl = is_layout_rtl();
+ const bool is_clipped = clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING;
switch (get_draw_mode()) {
case DRAW_NORMAL: {
@@ -283,7 +284,7 @@ void Button::_notification(int p_what) {
Size2 _size = get_size() - style->get_offset() * 2;
int icon_text_separation = text.is_empty() ? 0 : theme_cache.h_separation;
_size.width -= icon_text_separation + icon_ofs_region;
- if (!clip_text && icon_align_rtl_checked != HORIZONTAL_ALIGNMENT_CENTER) {
+ if (!is_clipped && icon_align_rtl_checked != HORIZONTAL_ALIGNMENT_CENTER) {
_size.width -= text_buf->get_size().width;
}
if (vertical_icon_alignment != VERTICAL_ALIGNMENT_CENTER) {
@@ -335,9 +336,9 @@ void Button::_notification(int p_what) {
text_clip -= _internal_margin[SIDE_RIGHT] + theme_cache.h_separation;
}
- text_buf->set_width((clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? text_clip : -1);
+ text_buf->set_width(is_clipped ? text_clip : -1);
- int text_width = MAX(1, (clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x);
+ int text_width = MAX(1, is_clipped ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x);
Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - text_buf->get_size() - Point2(_internal_margin[SIDE_RIGHT] - _internal_margin[SIDE_LEFT], 0)) / 2.0;