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/CardStack.h | |
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/CardStack.h')
-rw-r--r-- | Userland/Libraries/LibCards/CardStack.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCards/CardStack.h b/Userland/Libraries/LibCards/CardStack.h index 36acc824df..75259b57b2 100644 --- a/Userland/Libraries/LibCards/CardStack.h +++ b/Userland/Libraries/LibCards/CardStack.h @@ -8,11 +8,12 @@ #include "Card.h" #include <AK/Format.h> +#include <AK/RefCounted.h> #include <AK/Vector.h> namespace Cards { -class CardStack final { +class CardStack final : public RefCounted<CardStack> { public: enum Type { Invalid, @@ -25,6 +26,7 @@ public: CardStack(); CardStack(const Gfx::IntPoint& position, Type type); + CardStack(const Gfx::IntPoint& position, Type type, NonnullRefPtr<CardStack> associated_stack); bool is_empty() const { return m_stack.is_empty(); } bool is_focused() const { return m_focused; } @@ -75,6 +77,7 @@ private: void calculate_bounding_box(); + RefPtr<CardStack> m_associated_stack; NonnullRefPtrVector<Card> m_stack; Vector<Gfx::IntPoint> m_stack_positions; Gfx::IntPoint m_position; |