From 35b4b5f77999629527cf97e0a302b1d1bfc23307 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 13 Jun 2024 13:46:49 +0300 Subject: [PATCH] [Button] Do not include internal margins into base button minimum size. --- scene/gui/button.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 55ca5fc3ee4..4e738216de2 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -487,6 +487,8 @@ Size2 Button::_fit_icon_size(const Size2 &p_size) const { } Size2 Button::get_minimum_size_for_text_and_icon(const String &p_text, Ref p_icon) const { + // Do not include `_internal_margin`, it's already added in the `get_minimum_size` overrides. + Ref paragraph; if (p_text.is_empty()) { paragraph = text_buf; @@ -500,21 +502,6 @@ Size2 Button::get_minimum_size_for_text_and_icon(const String &p_text, Ref 0.0f) { - left_internal_margin_with_h_separation += theme_cache.h_separation; - } - - if (_internal_margin[SIDE_RIGHT] > 0.0f) { - right_internal_margin_with_h_separation += theme_cache.h_separation; - } - - minsize.width += left_internal_margin_with_h_separation + right_internal_margin_with_h_separation; // The size after the internal element is stripped. - } - if (!expand_icon && p_icon.is_valid()) { Size2 icon_size = _fit_icon_size(p_icon->get_size()); if (vertical_icon_alignment == VERTICAL_ALIGNMENT_CENTER) {