From 7a4187495db5af8cf46ce03292c2ae707d54f4e4 Mon Sep 17 00:00:00 2001 From: Hendrik Brucker Date: Tue, 10 May 2022 22:27:48 +0200 Subject: [PATCH] Fix button icon expansion calculation with empty text (cherry picked from commit c09a5e277410761733a59a2b207d7320131b2511) --- scene/gui/button.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index d8aad4b7d2f..d8f8dfc7af5 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -199,7 +199,8 @@ void Button::_notification(int p_what) { if (expand_icon) { Size2 _size = get_size() - style->get_offset() * 2; - _size.width -= get_constant("hseparation") + icon_ofs_region; + int icon_text_separation = text.empty() ? 0 : get_constant("h_separation"); + _size.width -= icon_text_separation + icon_ofs_region; if (!clip_text && icon_align != ALIGN_CENTER) { _size.width -= get_font("font")->get_string_size(xl_text).width; }