1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-29 01:27:44 +00:00

LibGfx+Userland: Add width_rounded_up() helper

This commit is contained in:
thankyouverycool 2023-04-14 08:52:47 -04:00 committed by Andreas Kling
parent c9404c3a63
commit 55423b4ed0
21 changed files with 34 additions and 19 deletions

View file

@ -585,7 +585,7 @@ void BrickGame::paint_cell(GUI::Painter& painter, Gfx::IntRect rect, BrickGame::
void BrickGame::paint_sidebar_text(GUI::Painter& painter, int row, StringView text)
{
auto const text_width = static_cast<int>(ceilf(font().width(text)));
auto const text_width = font().width_rounded_up(text);
auto const entire_area_rect { frame_inner_rect() };
auto const margin = 4;
auto const rect { Gfx::IntRect { entire_area_rect.x() + entire_area_rect.width() - 116,
@ -597,7 +597,7 @@ void BrickGame::paint_sidebar_text(GUI::Painter& painter, int row, StringView te
void BrickGame::paint_paused_text(GUI::Painter& painter)
{
auto const paused_text = "Paused"sv;
auto const paused_text_width = static_cast<int>(ceilf(font().width(paused_text)));
auto const paused_text_width = font().width_rounded_up(paused_text);
auto const more_or_less_font_height = static_cast<int>(font().pixel_size_rounded_up());
auto const entire_area_rect { frame_inner_rect() };
auto const margin = more_or_less_font_height * 2;

View file

@ -71,7 +71,7 @@ void ScoreCard::paint_event(GUI::PaintEvent& event)
for (int score_index = 0; score_index < (int)player.scores.size(); score_index++) {
auto text_rect = cell_rect(player_index, 1 + score_index);
auto score_text = DeprecatedString::formatted("{}", player.scores[score_index]);
auto score_text_width = static_cast<int>(ceilf(font.width(score_text)));
auto score_text_width = font.width_rounded_up(score_text);
if (score_index != (int)player.scores.size() - 1) {
painter.draw_line(
{ text_rect.left() + text_rect.width() / 2 - score_text_width / 2 - 3, text_rect.top() + font.pixel_size_rounded_up() / 2 },