summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Label.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibGUI/Label.cpp')
-rw-r--r--Userland/Libraries/LibGUI/Label.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGUI/Label.cpp b/Userland/Libraries/LibGUI/Label.cpp
index 75f5e3df4e..8c01568377 100644
--- a/Userland/Libraries/LibGUI/Label.cpp
+++ b/Userland/Libraries/LibGUI/Label.cpp
@@ -111,7 +111,12 @@ void Label::paint_event(PaintEvent& event)
void Label::size_to_fit()
{
- set_fixed_width(static_cast<int>(ceilf(font().width(m_text))) + m_autosize_padding * 2);
+ set_fixed_width(text_calculated_preferred_width());
+}
+
+int Label::text_calculated_preferred_width() const
+{
+ return static_cast<int>(ceilf(font().width(m_text))) + m_autosize_padding * 2;
}
int Label::text_calculated_preferred_height() const
@@ -121,6 +126,7 @@ int Label::text_calculated_preferred_height() const
Optional<UISize> Label::calculated_preferred_size() const
{
- return GUI::UISize(SpecialDimension::Grow, text_calculated_preferred_height());
+ return GUI::UISize(text_calculated_preferred_width(), text_calculated_preferred_height());
}
+
}