mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
[Button] Do not include internal margins into base button minimum size.
This commit is contained in:
parent
e351b89117
commit
35b4b5f779
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user