[Button] Do not include internal margins into base button minimum size.

This commit is contained in:
bruvzg 2024-06-13 13:46:49 +03:00
parent e351b89117
commit 35b4b5f779
No known key found for this signature in database
GPG Key ID: 7960FCF39844EC38
1 changed files with 2 additions and 15 deletions

View File

@ -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<Texture2D> p_icon) const {
// Do not include `_internal_margin`, it's already added in the `get_minimum_size` overrides.
Ref<TextParagraph> 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<Textu
minsize.width = 0;
}
float left_internal_margin_with_h_separation = _internal_margin[SIDE_LEFT];
float right_internal_margin_with_h_separation = _internal_margin[SIDE_RIGHT];
{ // The width reserved for internal element in derived classes (and h_separation if needed).
if (_internal_margin[SIDE_LEFT] > 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) {