Refactor vertical card stacking with clip containers for variable zone sizes (#6774)

* Refactor vertical card stacking with opt-in overflow for variable zone sizes

Introduce a shared vertical stacking layout system in SelectZone that replaces the old divideCardSpaceInZone() free function with structured layout computation (StackLayoutParams, ZoneLayout, computeZoneLayout).

By default, cards are guaranteed to fit within zone bounds (no overflow). Zones can opt-in to bottom overflow via allowBottomOverflow flag, with sqrt-scaled compression for smooth visual transitions. A clip container mechanism is available for future zones that need visual clipping.

  Key changes:
  - SelectZone: new layout engine with allowBottomOverflow opt-in; clip container infrastructure for future zones needing visual clipping
  - StackZone: uses new layout (no overflow); adds setHeight() for dynamic resizing capabilities
  - HandZone: vertical layout delegates to SelectZone's shared stacking
  - AbstractCardItem: preserves hover z-value during layout passes; invalidates scene rect on hover exit for proper sibling repainting
  - CardZone::onCardAdded made virtual for clip container reparenting
  - Zone widths updated to CardDimensions::WIDTH_F * 1.5

* Changed anonymous namespace for static and braced functions

* CI tests re-run
This commit is contained in:
DawnFire42 2026-05-10 22:10:14 -04:00 committed by GitHub
parent 5735a44a9a
commit 1a62f82aee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 402 additions and 111 deletions

View file

@ -5,6 +5,7 @@
#include "phases_toolbar.h"
#include "player/player.h"
#include "player/player_graphics_item.h"
#include "zones/select_zone.h"
#include "zones/view_zone.h"
#include "zones/view_zone_widget.h"
@ -356,12 +357,26 @@ void GameScene::updateHover(const QPointF &scenePos)
void GameScene::updateHoveredCard(CardItem *newCard)
{
if (hoveredCard && (newCard != hoveredCard))
hoveredCard->setHovered(false);
endCardHover(hoveredCard);
if (newCard && (newCard != hoveredCard))
newCard->setHovered(true);
beginCardHover(newCard);
hoveredCard = newCard;
}
void GameScene::beginCardHover(CardItem *card)
{
card->setHovered(true);
if (auto *zone = SelectZone::findOwningSelectZone(card))
zone->escapeClipForHover(card);
}
void GameScene::endCardHover(CardItem *card)
{
if (auto *zone = SelectZone::findOwningSelectZone(card))
zone->restoreClipAfterHover(card);
card->setHovered(false);
}
CardZone *GameScene::findTopmostZone(const QList<QGraphicsItem *> &items)
{
for (QGraphicsItem *item : items)
@ -496,6 +511,8 @@ bool GameScene::event(QEvent *event)
{
if (event->type() == QEvent::GraphicsSceneMouseMove)
updateHover(static_cast<QGraphicsSceneMouseEvent *>(event)->scenePos());
else if (event->type() == QEvent::Leave)
updateHoveredCard(nullptr);
return QGraphicsScene::event(event);
}