1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:47:35 +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:
thankyouverycool 2021-03-01 14:52:04 -05:00 committed by Andreas Kling
parent 1aa605bc03
commit 0443cd4eed
2 changed files with 95 additions and 8 deletions

View file

@ -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;
};
}