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:
parent
eeb6072f15
commit
2a09807f2e
5 changed files with 54 additions and 1 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue