diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-02-14 13:10:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-14 13:10:54 +0100 |
commit | 6fb1ed2bca09e88509608a761b0ce300dd997c19 (patch) | |
tree | 7893d3c6b7c9e7193040bc0ace4c7485cd4f7497 /scene/gui | |
parent | b21f854b7f573bcbc963d5346ed37231c29446b6 (diff) | |
parent | 85dc55a82cf66827a4e776660a2985e46529e0e2 (diff) |
Merge pull request #45942 from YeldhamDev/label_height_empty
Keep Label's min height when empty
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/label.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 453ecc802c..2997a6ebe9 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -357,21 +357,25 @@ void Label::_notification(int p_what) { } Size2 Label::get_minimum_size() const { - Size2 min_style = get_theme_stylebox("normal")->get_minimum_size(); - // don't want to mutable everything if (dirty || lines_dirty) { const_cast<Label *>(this)->_shape(); } + Size2 min_size = minsize; + + Ref<Font> font = get_theme_font("font"); + min_size.height = MAX(min_size.height, font->get_height(get_theme_font_size("font_size")) + font->get_spacing(Font::SPACING_TOP) + font->get_spacing(Font::SPACING_BOTTOM)); + + Size2 min_style = get_theme_stylebox("normal")->get_minimum_size(); if (autowrap) { - return Size2(1, clip ? 1 : minsize.height) + min_style; + return Size2(1, clip ? 1 : min_size.height) + min_style; } else { - Size2 ms = minsize; if (clip) { - ms.width = 1; + min_size.width = 1; } - return ms + min_style; + + return min_size + min_style; } } |