mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-07 16:53:00 -07:00
Fix card stacking overflow when vertical zone has many cards (#6925)
Previously, minOffset (10px) was enforced unconditionally, causing card tops to overflow zone bounds when many cards were stacked. For example, 50 cards in a 200px zone would place the last card's top at y=490. Now offsets compress below minOffset when necessary to keep all card tops visible. The constraint is guarded by !allowBottomOverflow to preserve future clipping zone semantics.
This commit is contained in:
parent
8dca14933c
commit
81a2712b92
1 changed files with 13 additions and 1 deletions
|
|
@ -42,7 +42,19 @@ SelectZone::ZoneLayout SelectZone::computeZoneLayout(const StackLayoutParams &pa
|
||||||
reservedForBottomCard = params.cardHeight;
|
reservedForBottomCard = params.cardHeight;
|
||||||
}
|
}
|
||||||
fitOffset = (params.totalHeight - reservedForBottomCard) / (params.cardCount - 1);
|
fitOffset = (params.totalHeight - reservedForBottomCard) / (params.cardCount - 1);
|
||||||
effectiveOffset = qMax(params.minOffset, qMin(params.desiredOffset, fitOffset));
|
|
||||||
|
if (!params.allowBottomOverflow) {
|
||||||
|
// Constrain offset so all card tops remain within zone bounds.
|
||||||
|
// With start=0, last card top at (cardCount-1) * effectiveOffset must be < totalHeight.
|
||||||
|
qreal maxOffsetForTops = params.totalHeight / (params.cardCount - 1);
|
||||||
|
fitOffset = qMin(fitOffset, maxOffsetForTops);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply minOffset only if it fits; otherwise compress further to keep all card tops visible.
|
||||||
|
effectiveOffset = qMin(params.desiredOffset, fitOffset);
|
||||||
|
if (fitOffset >= params.minOffset) {
|
||||||
|
effectiveOffset = qMax(params.minOffset, effectiveOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qreal stackHeight = (params.cardCount - 1) * effectiveOffset + params.cardHeight;
|
qreal stackHeight = (params.cardCount - 1) * effectiveOffset + params.cardHeight;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue