mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibGUI: Resize Label on font changes
And set fixed preferred heights when autosizing.
This commit is contained in:
parent
5294ef918e
commit
cfac3be0b3
Notes:
sideshowbarker
2024-07-16 22:16:50 +09:00
Author: https://github.com/thankyouverycool
Commit: cfac3be0b3
Pull-request: https://github.com/SerenityOS/serenity/pull/18372
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()
|
||||
{
|
||||
set_fixed_width(text_calculated_preferred_width());
|
||||
set_fixed_height(text_calculated_preferred_height());
|
||||
}
|
||||
|
||||
int Label::text_calculated_preferred_width() const
|
||||
|
|
|
@ -49,6 +49,7 @@ protected:
|
|||
explicit Label(DeprecatedString text = {});
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual void did_change_font() override;
|
||||
virtual void did_change_text() { }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue