1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +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

@ -65,7 +65,7 @@ void CheckBox::paint_event(PaintEvent& event)
auto text_rect = rect();
if (m_checkbox_position == CheckBoxPosition::Left)
text_rect.set_left(box_rect.right() + 1 + gap_between_box_and_rect());
text_rect.set_width(static_cast<int>(ceilf(font().width(text()))));
text_rect.set_width(font().width_rounded_up(text()));
text_rect.set_top(height() / 2 - font().pixel_size_rounded_up() / 2);
text_rect.set_height(font().pixel_size_rounded_up());
@ -101,7 +101,7 @@ void CheckBox::set_autosize(bool autosize)
void CheckBox::size_to_fit()
{
set_fixed_width(box_rect().width() + gap_between_box_and_rect() + static_cast<int>(ceilf(font().width(text()))) + horizontal_padding() * 2);
set_fixed_width(box_rect().width() + gap_between_box_and_rect() + font().width_rounded_up(text()) + horizontal_padding() * 2);
}
Optional<UISize> CheckBox::calculated_min_size() const