mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 11:45:06 +00:00
GButton: Align the button text according to text_alignment().
Added a Rect::align_within(other_rect, alignment) helper that seemed useful.
This commit is contained in:
parent
75b0e5cce5
commit
cca510162e
3 changed files with 27 additions and 4 deletions
|
@ -52,8 +52,8 @@ void GButton::paint_event(GPaintEvent& event)
|
|||
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());
|
||||
text_rect.align_within(content_rect, text_alignment());
|
||||
paint_text(painter, text_rect, font, TextAlignment::Center);
|
||||
}
|
||||
|
||||
void GButton::click()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue