1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 11:35:07 +00:00

LibGUI: Elide the text in GCheckBox and GRadioButton when low on space.

This commit is contained in:
Andreas Kling 2019-05-25 04:01:22 +02:00
parent be62b42352
commit 817ac9c22b
2 changed files with 12 additions and 10 deletions

View file

@ -49,7 +49,11 @@ void GButton::paint_event(GPaintEvent& event)
content_rect.set_width(content_rect.width() - m_icon->width() - 4);
}
paint_text(painter, content_rect, font, text_alignment());
Rect text_rect { 0, 0, font.width(text()), font.glyph_height() };
if (text_rect.width() > content_rect.width())
text_rect.set_width(content_rect.width());
text_rect.center_within(content_rect);
paint_text(painter, text_rect, font, text_alignment());
}
void GButton::click()