mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
LibGUI: Resize Label on font changes
And set fixed preferred heights when autosizing.
This commit is contained in:
parent
5294ef918e
commit
cfac3be0b3
2 changed files with 8 additions and 0 deletions
|
@ -109,9 +109,16 @@ void Label::paint_event(PaintEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Label::did_change_font()
|
||||||
|
{
|
||||||
|
if (m_autosize)
|
||||||
|
size_to_fit();
|
||||||
|
}
|
||||||
|
|
||||||
void Label::size_to_fit()
|
void Label::size_to_fit()
|
||||||
{
|
{
|
||||||
set_fixed_width(text_calculated_preferred_width());
|
set_fixed_width(text_calculated_preferred_width());
|
||||||
|
set_fixed_height(text_calculated_preferred_height());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Label::text_calculated_preferred_width() const
|
int Label::text_calculated_preferred_width() const
|
||||||
|
|
|
@ -49,6 +49,7 @@ protected:
|
||||||
explicit Label(DeprecatedString text = {});
|
explicit Label(DeprecatedString text = {});
|
||||||
|
|
||||||
virtual void paint_event(PaintEvent&) override;
|
virtual void paint_event(PaintEvent&) override;
|
||||||
|
virtual void did_change_font() override;
|
||||||
virtual void did_change_text() { }
|
virtual void did_change_text() { }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue