diff options
author | Andreas Kling <kling@serenityos.org> | 2021-04-09 11:15:41 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-09 17:08:49 +0200 |
commit | 2b9bc605d216f9b9a8f0dc93f382fe5b78c9877d (patch) | |
tree | ec1aee4c3b8a5451c7b4ff7bbd7e8dec2b032d4b /Userland/Libraries/LibGfx | |
parent | b7a25bfaac65fb2fa40b5984ff358da39afc5611 (diff) | |
download | serenity-2b9bc605d216f9b9a8f0dc93f382fe5b78c9877d.zip |
LibGfx: Add a Gfx::TextAlignment parameter to Painter::draw_ui_text()
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/Painter.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Painter.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 7b62ad4e18..389152c7ef 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1806,7 +1806,7 @@ void Painter::blit_tiled(const IntRect& dst_rect, const Gfx::Bitmap& bitmap, con } } -void Gfx::Painter::draw_ui_text(const Gfx::IntRect& rect, const StringView& text, const Gfx::Font& font, Gfx::Color color) +void Gfx::Painter::draw_ui_text(const Gfx::IntRect& rect, const StringView& text, const Gfx::Font& font, Gfx::TextAlignment text_alignment, Gfx::Color color) { auto parse_ampersand_string = [](const StringView& raw_text, Optional<size_t>& underline_offset) -> String { if (raw_text.is_empty()) @@ -1831,9 +1831,9 @@ void Gfx::Painter::draw_ui_text(const Gfx::IntRect& rect, const StringView& text auto name_to_draw = parse_ampersand_string(text, underline_offset); Gfx::IntRect text_rect { 0, 0, font.width(name_to_draw), font.glyph_height() }; - text_rect.center_within(rect); + text_rect.align_within(rect, text_alignment); - draw_text(text_rect, name_to_draw, font, Gfx::TextAlignment::CenterLeft, color); + draw_text(text_rect, name_to_draw, font, text_alignment, color); if (underline_offset.has_value()) { Utf8View utf8_view { name_to_draw }; diff --git a/Userland/Libraries/LibGfx/Painter.h b/Userland/Libraries/LibGfx/Painter.h index 9d9abc426c..a164af24ff 100644 --- a/Userland/Libraries/LibGfx/Painter.h +++ b/Userland/Libraries/LibGfx/Painter.h @@ -85,7 +85,7 @@ public: void draw_text(Function<void(const IntRect&, u32)>, const IntRect&, const StringView&, const Font&, TextAlignment = TextAlignment::TopLeft, TextElision = TextElision::None); void draw_text(Function<void(const IntRect&, u32)>, const IntRect&, const Utf8View&, const Font&, TextAlignment = TextAlignment::TopLeft, TextElision = TextElision::None); void draw_text(Function<void(const IntRect&, u32)>, const IntRect&, const Utf32View&, const Font&, TextAlignment = TextAlignment::TopLeft, TextElision = TextElision::None); - void draw_ui_text(const Gfx::IntRect&, const StringView&, const Gfx::Font&, Gfx::Color); + void draw_ui_text(const Gfx::IntRect&, const StringView&, const Gfx::Font&, TextAlignment, Gfx::Color); void draw_glyph(const IntPoint&, u32, Color); void draw_glyph(const IntPoint&, u32, const Font&, Color); void draw_emoji(const IntPoint&, const Gfx::Bitmap&, const Font&); |