diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-08-22 22:40:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-22 22:40:59 +0200 |
commit | b9ea0e1338b1364fc6ecfd5731d038c32170e660 (patch) | |
tree | b37606a48065d25aa7a474a56b912ff9c8e52b34 /scene/gui/button.cpp | |
parent | b8a64313f0675a7e781e21b530a43d824651f44d (diff) | |
parent | 4a3a15c30433f1c9b28873a74c23bec6564a3bc8 (diff) | |
download | redot-engine-b9ea0e1338b1364fc6ecfd5731d038c32170e660.tar.gz |
Merge pull request #64218 from Rindbee/fix-button-minimum-size-calculation
Diffstat (limited to 'scene/gui/button.cpp')
-rw-r--r-- | scene/gui/button.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 0a163b65ff..e163f4355c 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -34,11 +34,9 @@ #include "servers/rendering_server.h" Size2 Button::get_minimum_size() const { - Ref<Texture2D> _icon; - if (icon.is_null() && has_theme_icon(SNAME("icon"))) { + Ref<Texture2D> _icon = icon; + if (_icon.is_null() && has_theme_icon(SNAME("icon"))) { _icon = Control::get_theme_icon(SNAME("icon")); - } else { - _icon = icon; } return get_minimum_size_for_text_and_icon("", _icon); @@ -342,13 +340,13 @@ Size2 Button::get_minimum_size_for_text_and_icon(const String &p_text, Ref<Textu minsize.width = 0; } - if (!expand_icon && !p_icon.is_null()) { + if (!expand_icon && p_icon.is_valid()) { minsize.height = MAX(minsize.height, p_icon->get_height()); if (icon_alignment != HORIZONTAL_ALIGNMENT_CENTER) { minsize.width += p_icon->get_width(); if (!xl_text.is_empty() || !p_text.is_empty()) { - minsize.width += get_theme_constant(SNAME("hseparation")); + minsize.width += MAX(0, get_theme_constant(SNAME("h_separation"))); } } else { minsize.width = MAX(minsize.width, p_icon->get_width()); |