diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-06-04 07:40:16 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-04 19:11:45 +0200 |
commit | 2b762ef94075b8a6e1ae8dd61e535b6b6cf7c064 (patch) | |
tree | cd8a6ee1dd64459b9e1f1996fbd36b4d0040e144 /Userland/Libraries/LibCards/Card.cpp | |
parent | 4903186cc512b884df44718a2e50586632f76197 (diff) | |
download | serenity-2b762ef94075b8a6e1ae8dd61e535b6b6cf7c064.zip |
Solitaire+LibCards: Draw card stacks with rounded corners
Now that the cards have rounded corners, draw the stack box behind the
cards with rounded corners as well. This way, the corner of the stack
box doesn't peek out from behind the cards.
The caveat here is that the "play" card stack now needs to hold a
reference to the "waste" stack beneath it so it knows when not to draw
its background on top of the waste stack. To faciliate that, the array
of card stacks is now a NonnullRefPtrVector so the play stack can store
a smart pointer to the waste stack (instead of a raw pointer or
reference).
Diffstat (limited to 'Userland/Libraries/LibCards/Card.cpp')
-rw-r--r-- | Userland/Libraries/LibCards/Card.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibCards/Card.cpp b/Userland/Libraries/LibCards/Card.cpp index cc7552fe2d..2a88e45e82 100644 --- a/Userland/Libraries/LibCards/Card.cpp +++ b/Userland/Libraries/LibCards/Card.cpp @@ -81,9 +81,9 @@ Card::Card(Type type, uint8_t value) float aspect_ratio = image->width() / static_cast<float>(image->height()); auto target_size = Gfx::IntSize(static_cast<int>(aspect_ratio * (height - 5)), height - 5); - bg_painter.fill_rect_with_rounded_corners(paint_rect, Color::Black, 5, 5, 5, 5); + bg_painter.fill_rect_with_rounded_corners(paint_rect, Color::Black, card_radius); auto inner_paint_rect = paint_rect.shrunken(2, 2); - bg_painter.fill_rect_with_rounded_corners(inner_paint_rect, Color::White, 4, 4, 4, 4); + bg_painter.fill_rect_with_rounded_corners(inner_paint_rect, Color::White, card_radius - 1); bg_painter.draw_scaled_bitmap( { { (width - target_size.width()) / 2, (height - target_size.height()) / 2 }, target_size }, @@ -96,9 +96,9 @@ Card::Card(Type type, uint8_t value) auto& font = Gfx::FontDatabase::default_font().bold_variant(); auto label = labels[value]; - painter.fill_rect_with_rounded_corners(paint_rect, Color::Black, 5, 5, 5, 5); + painter.fill_rect_with_rounded_corners(paint_rect, Color::Black, card_radius); paint_rect.shrink(2, 2); - painter.fill_rect_with_rounded_corners(paint_rect, Color::White, 4, 4, 4, 4); + painter.fill_rect_with_rounded_corners(paint_rect, Color::White, card_radius - 1); paint_rect.set_height(paint_rect.height() / 2); paint_rect.shrink(10, 6); |