diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2021-03-01 14:52:04 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-02 11:57:27 +0100 |
commit | 0443cd4eed07c139f5d079cc7a96f986a56b2425 (patch) | |
tree | 9995bb925418eef0a959eac2aec00ae456641571 /Userland/Libraries/LibGUI/Label.h | |
parent | 1aa605bc038f35c1cedcc8fbc5d9cb457522c629 (diff) | |
download | serenity-0443cd4eed07c139f5d079cc7a96f986a56b2425.zip |
LibGUI: Add word wrapping to Labels
Adds basic word wrap support to Label widgets. Doesn't yet
negotiate autosize or Center/Bottom TextAlignments perfectly.
Diffstat (limited to 'Userland/Libraries/LibGUI/Label.h')
-rw-r--r-- | Userland/Libraries/LibGUI/Label.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/Label.h b/Userland/Libraries/LibGUI/Label.h index df17f28545..983bce37c1 100644 --- a/Userland/Libraries/LibGUI/Label.h +++ b/Userland/Libraries/LibGUI/Label.h @@ -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; }; } |