summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-07-25 21:20:11 +0000
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-07-26 21:14:39 +0430
commite11940fd01c6c45ccaf4994cb588becd10c154f8 (patch)
tree919e1fd8625c6d68b2e8f0f6f5a0b5d6563afbdc /Userland/Services
parenta5a32fbccef8f8f663001363a278f80ef6320efe (diff)
downloadserenity-e11940fd01c6c45ccaf4994cb588becd10c154f8.zip
Userland: Move text wrapping/elision into the new TextLayout :^)
This class now contains all the fun bits about laying out text in a rect. It will handle line wrapping at a certain width, cutting off lines that don't fit the given rect, and handling text elision. Painter::draw_text now internally uses this. Future work here would be not laying out text twice (once actually preparing the lines to be rendered and once to get the bounding box), and possibly adding left elision if necessary. Additionally, this commit makes the Utf32View versions of Painter::draw_text convert to Utf8View internally. The intention is to completely remove those versions, but they're kept at the moment to keep the scope of this PR small.
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/Taskbar/TaskbarButton.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Services/Taskbar/TaskbarButton.cpp b/Userland/Services/Taskbar/TaskbarButton.cpp
index e0a3087283..c405247ac2 100644
--- a/Userland/Services/Taskbar/TaskbarButton.cpp
+++ b/Userland/Services/Taskbar/TaskbarButton.cpp
@@ -71,8 +71,8 @@ static void paint_custom_progressbar(GUI::Painter& painter, const Gfx::IntRect&
painter.fill_rect_with_gradient(rect, start_color, end_color);
if (!text.is_null()) {
- painter.draw_text(text_rect.translated(1, 1), text, font, text_alignment, palette.base_text(), Gfx::TextElision::Right);
- painter.draw_text(text_rect, text, font, text_alignment, palette.base_text().inverted(), Gfx::TextElision::Right);
+ painter.draw_text(text_rect.translated(1, 1), text, font, text_alignment, palette.base_text(), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap);
+ painter.draw_text(text_rect, text, font, text_alignment, palette.base_text().inverted(), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap);
}
}
@@ -82,7 +82,7 @@ static void paint_custom_progressbar(GUI::Painter& painter, const Gfx::IntRect&
Gfx::PainterStateSaver saver(painter);
painter.add_clip_rect(hole_rect);
if (!text.is_null())
- painter.draw_text(text_rect, text, font, text_alignment, palette.base_text(), Gfx::TextElision::Right);
+ painter.draw_text(text_rect, text, font, text_alignment, palette.base_text(), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap);
}
void TaskbarButton::paint_event(GUI::PaintEvent& event)
@@ -138,5 +138,5 @@ void TaskbarButton::paint_event(GUI::PaintEvent& event)
}
if (!window.progress().has_value())
- paint_text(painter, text_rect, font, text_alignment());
+ paint_text(painter, text_rect, font, text_alignment(), Gfx::TextWrapping::DontWrap);
}