File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Userland/Libraries/LibGUI Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -34,11 +34,12 @@ Label::Label(String text)
34
34
REGISTER_STRING_PROPERTY (" icon" , icon, set_icon_from_path);
35
35
}
36
36
37
- void Label::set_autosize (bool autosize)
37
+ void Label::set_autosize (bool autosize, size_t padding )
38
38
{
39
- if (m_autosize == autosize)
39
+ if (m_autosize == autosize && m_autosize_padding == padding )
40
40
return ;
41
41
m_autosize = autosize;
42
+ m_autosize_padding = padding;
42
43
if (m_autosize)
43
44
size_to_fit ();
44
45
}
@@ -108,7 +109,7 @@ void Label::paint_event(PaintEvent& event)
108
109
109
110
void Label::size_to_fit ()
110
111
{
111
- set_fixed_width (font ().width (m_text));
112
+ set_fixed_width (font ().width (m_text) + m_autosize_padding * 2 );
112
113
}
113
114
114
115
int Label::preferred_height () const
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class Label : public Frame {
37
37
void set_should_stretch_icon (bool b) { m_should_stretch_icon = b; }
38
38
39
39
bool is_autosize () const { return m_autosize; }
40
- void set_autosize (bool );
40
+ void set_autosize (bool , size_t padding = 0 );
41
41
42
42
int preferred_height () const ;
43
43
@@ -58,6 +58,7 @@ class Label : public Frame {
58
58
Gfx::TextWrapping m_text_wrapping { Gfx::TextWrapping::Wrap };
59
59
bool m_should_stretch_icon { false };
60
60
bool m_autosize { false };
61
+ size_t m_autosize_padding { 0 };
61
62
};
62
63
63
64
}
You can’t perform that action at this time.
0 commit comments