LibCards: Draw card stack background when the entire stack is moving

The stack background should be painted when the entire stack is being
dragged, rather than just the top card.

Fixes #7786. Regressed in 2b762ef940.
This commit is contained in:
Timothy Flynn 2021-06-04 14:28:27 -04:00 committed by Andreas Kling
parent f6d372b2ab
commit f73bb164ad
Notes: sideshowbarker 2024-07-18 16:52:22 +09:00

View file

@ -45,9 +45,13 @@ void CardStack::clear()
void CardStack::draw(GUI::Painter& painter, const Gfx::Color& background_color) void CardStack::draw(GUI::Painter& painter, const Gfx::Color& background_color)
{ {
auto draw_background_if_empty = [&]() { auto draw_background_if_empty = [&]() {
size_t number_of_moving_cards = 0;
for (const auto& card : m_stack)
number_of_moving_cards += card.is_moving();
if (m_associated_stack && !m_associated_stack->is_empty()) if (m_associated_stack && !m_associated_stack->is_empty())
return false; return false;
if (!is_empty() && !(m_stack.size() == 1 && peek().is_moving())) if (!is_empty() && (m_stack.size() != number_of_moving_cards))
return false; return false;
painter.fill_rect_with_rounded_corners(m_base, background_color.darkened(0.5), Card::card_radius); painter.fill_rect_with_rounded_corners(m_base, background_color.darkened(0.5), Card::card_radius);
painter.fill_rect_with_rounded_corners(m_base.shrunken(2, 2), background_color, Card::card_radius - 1); painter.fill_rect_with_rounded_corners(m_base.shrunken(2, 2), background_color, Card::card_radius - 1);