mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
LibGUI: Make GUI::Label auto-sizing declarative
You can now set the "autosize" property on a GUI::Label and it will automatically update its width preference to fit the text.
This commit is contained in:
parent
de08e7b8c9
commit
64ba41ea13
4 changed files with 18 additions and 5 deletions
|
@ -49,7 +49,8 @@ public:
|
|||
bool should_stretch_icon() const { return m_should_stretch_icon; }
|
||||
void set_should_stretch_icon(bool b) { m_should_stretch_icon = b; }
|
||||
|
||||
void size_to_fit();
|
||||
bool is_autosize() const { return m_autosize; }
|
||||
void set_autosize(bool);
|
||||
|
||||
protected:
|
||||
explicit Label(const StringView& text = {});
|
||||
|
@ -57,10 +58,13 @@ protected:
|
|||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
private:
|
||||
void size_to_fit();
|
||||
|
||||
String m_text;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
|
||||
bool m_should_stretch_icon { false };
|
||||
bool m_autosize { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue