LibCards: Fix alignment for the card labels

Previously the code didn't take into account that the label for the
"10" card is larger than for the other cards.
This commit is contained in:
Gunnar Beutner 2021-05-22 11:55:08 +02:00 committed by Linus Groh
parent ee48dac300
commit 661a8707f0
Notes: sideshowbarker 2024-07-18 17:33:39 +09:00

View file

@ -96,7 +96,8 @@ Card::Card(Type type, uint8_t value)
paint_rect.set_height(paint_rect.height() / 2); paint_rect.set_height(paint_rect.height() / 2);
paint_rect.shrink(10, 6); paint_rect.shrink(10, 6);
painter.draw_text(paint_rect, label, font, Gfx::TextAlignment::TopLeft, color()); auto text_rect = Gfx::IntRect { 4, 6, font.width("10"), font.glyph_height() };
painter.draw_text(text_rect, label, font, Gfx::TextAlignment::Center, color());
NonnullRefPtr<Gfx::CharacterBitmap> symbol = s_diamond; NonnullRefPtr<Gfx::CharacterBitmap> symbol = s_diamond;
switch (m_type) { switch (m_type) {
@ -117,7 +118,7 @@ Card::Card(Type type, uint8_t value)
} }
painter.draw_bitmap( painter.draw_bitmap(
{ paint_rect.x() + (font.width(label) - symbol->size().width()) / 2, font.glyph_height() + paint_rect.y() + 3 }, { text_rect.x() + (text_rect.width() - symbol->size().width()) / 2, text_rect.bottom() + 5 },
symbol, color()); symbol, color());
for (int y = height / 2; y < height; ++y) { for (int y = height / 2; y < height; ++y) {