1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:47:34 +00:00

LibCards: Support highlighting cards of interest

For example, in Solitaire, when dragging a card around, it's common for
other implementations to highlight the card underneath the dragged card
if that other card is a valid drop target. This implementation will draw
a rounded rectangle within the edges of the highlighted card, using a
rudimentary complementary color of the board background color.
This commit is contained in:
Timothy Flynn 2023-01-04 18:25:23 -05:00 committed by Sam Atkins
parent eeb6072f15
commit 2a09807f2e
5 changed files with 54 additions and 1 deletions

View file

@ -26,7 +26,10 @@ void Card::paint(GUI::Painter& painter) const
auto bitmap = [&]() {
if (m_inverted)
return m_upside_down ? card_painter.card_back_inverted() : card_painter.card_front_inverted(m_suit, m_rank);
if (m_highlighted) {
VERIFY(!m_upside_down);
return card_painter.card_front_highlighted(m_suit, m_rank);
}
return m_upside_down ? card_painter.card_back() : card_painter.card_front(m_suit, m_rank);
}();
painter.blit(position(), bitmap, bitmap->rect());