Fix card stacking overflow when vertical zone has many cards

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:
DawnFire42 2026-05-22 00:12:27 -04:00
parent 74102aa1ec
commit 2e38b0268a
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33

View file

@ -42,7 +42,19 @@ SelectZone::ZoneLayout SelectZone::computeZoneLayout(const StackLayoutParams &pa
reservedForBottomCard = params.cardHeight;
}
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;