mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 21:17:44 +00:00
LibGfx+Userland: Add width_rounded_up() helper
This commit is contained in:
parent
c9404c3a63
commit
55423b4ed0
21 changed files with 34 additions and 19 deletions
|
@ -201,7 +201,7 @@ void BookmarksBarWidget::model_did_update(unsigned)
|
|||
auto title = model()->index(item_index, 0).data().to_deprecated_string();
|
||||
auto url = model()->index(item_index, 1).data().to_deprecated_string();
|
||||
|
||||
Gfx::IntRect rect { width, 0, static_cast<int>(ceilf(font().width(title))) + 32, height() };
|
||||
Gfx::IntRect rect { width, 0, font().width_rounded_up(title) + 32, height() };
|
||||
|
||||
auto& button = add<GUI::Button>();
|
||||
m_bookmarks.append(button);
|
||||
|
|
|
@ -41,7 +41,7 @@ void KeyButton::paint_event(GUI::PaintEvent& event)
|
|||
if (text().is_empty() || text().bytes_as_string_view().starts_with('\0'))
|
||||
return;
|
||||
|
||||
Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.pixel_size_rounded_up() };
|
||||
Gfx::IntRect text_rect { 0, 0, font.width_rounded_up(text()), font.pixel_size_rounded_up() };
|
||||
text_rect.align_within(key_cap_face_rect, Gfx::TextAlignment::Center);
|
||||
|
||||
painter.draw_text(text_rect, text(), font, Gfx::TextAlignment::Center, Color::Black, Gfx::TextElision::Right);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue