mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-09 11:06:10 +00:00
LibGUI: Add word wrapping to Labels
Adds basic word wrap support to Label widgets. Doesn't yet negotiate autosize or Center/Bottom TextAlignments perfectly.
This commit is contained in:
parent
1aa605bc03
commit
0443cd4eed
Notes:
sideshowbarker
2024-07-18 21:47:04 +09:00
Author: https://github.com/thankyouverycool
Commit: 0443cd4eed
Pull-request: https://github.com/SerenityOS/serenity/pull/5590
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
2 changed files with 95 additions and 8 deletions
|
@ -53,7 +53,10 @@ public:
|
|||
bool is_autosize() const { return m_autosize; }
|
||||
void set_autosize(bool);
|
||||
|
||||
Gfx::IntRect text_rect() const;
|
||||
bool is_word_wrap() const { return m_word_wrap; }
|
||||
void set_word_wrap(bool);
|
||||
|
||||
Gfx::IntRect text_rect(size_t line = 0) const;
|
||||
|
||||
protected:
|
||||
explicit Label(String text = {});
|
||||
|
@ -63,12 +66,15 @@ protected:
|
|||
|
||||
private:
|
||||
void size_to_fit();
|
||||
void wrap_text();
|
||||
|
||||
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 };
|
||||
bool m_word_wrap { false };
|
||||
Vector<String> m_lines;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue