Vertical stacking behaviour fix (#7054)

The overflow function covers the necessary edge case, the minimized branch of it was an artefact of earlier builds
This commit is contained in:
DawnFire42 2026-07-27 11:00:28 -04:00 committed by GitHub
parent 688c5d2a12
commit 4bb8831531
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,40 +22,32 @@ SelectZone::ZoneLayout SelectZone::computeZoneLayout(const StackLayoutParams &pa
} }
qreal effectiveOffset = params.desiredOffset; qreal effectiveOffset = params.desiredOffset;
if (params.cardCount > 1) { if (params.cardCount > 1) {
qreal fitOffset; qreal reservedForBottomCard;
if (params.totalHeight < params.cardHeight && params.minOffset > 0.0) { if (params.allowBottomOverflow) {
// Zone is shorter than a card (e.g. minimized). Compress offsets so // Allow the bottom card to partially overflow in tight zones, scaling the
// every card has at least minOffset pixels of its top visible. // overflow allowance by sqrt(cardCount-1) so offsets decrease smoothly
fitOffset = (params.totalHeight - params.minOffset) / (params.cardCount - 1); // as cards are added rather than dropping by 1/(n-1) each time.
effectiveOffset = qMax(0.0, qMin(params.desiredOffset, fitOffset)); // The 0.75 ratio was tuned experimentally to balance card visibility vs. overflow.
constexpr qreal bottomCardZoneRatio = 0.75;
const qreal adjustedRatio = bottomCardZoneRatio / qSqrt(static_cast<qreal>(params.cardCount - 1));
reservedForBottomCard = qMin(params.cardHeight, params.totalHeight * adjustedRatio);
} else { } else {
qreal reservedForBottomCard; // No overflow: reserve full card height for the bottom card
if (params.allowBottomOverflow) { reservedForBottomCard = params.cardHeight;
// Allow the bottom card to partially overflow in tight zones, scaling the }
// overflow allowance by sqrt(cardCount-1) so offsets decrease smoothly qreal fitOffset = (params.totalHeight - reservedForBottomCard) / (params.cardCount - 1);
// as cards are added rather than dropping by 1/(n-1) each time.
// The 0.75 ratio was tuned experimentally to balance card visibility vs. overflow.
constexpr qreal bottomCardZoneRatio = 0.75;
const qreal adjustedRatio = bottomCardZoneRatio / qSqrt(static_cast<qreal>(params.cardCount - 1));
reservedForBottomCard = qMin(params.cardHeight, params.totalHeight * adjustedRatio);
} else {
// No overflow: reserve full card height for the bottom card
reservedForBottomCard = params.cardHeight;
}
fitOffset = (params.totalHeight - reservedForBottomCard) / (params.cardCount - 1);
if (!params.allowBottomOverflow) { if (!params.allowBottomOverflow) {
// Constrain offset so all card tops remain within zone bounds. // Constrain offset so all card tops remain within zone bounds.
// With start=0, last card top at (cardCount-1) * effectiveOffset must be < totalHeight. // With start=0, last card top at (cardCount-1) * effectiveOffset must be < totalHeight.
qreal maxOffsetForTops = params.totalHeight / (params.cardCount - 1); qreal maxOffsetForTops = params.totalHeight / (params.cardCount - 1);
fitOffset = qMin(fitOffset, maxOffsetForTops); fitOffset = qMin(fitOffset, maxOffsetForTops);
} }
// Apply minOffset only if it fits; otherwise compress further to keep all card tops visible. // Apply minOffset only if it fits; otherwise compress further to keep all card tops visible.
effectiveOffset = qMin(params.desiredOffset, fitOffset); effectiveOffset = qMin(params.desiredOffset, fitOffset);
if (fitOffset >= params.minOffset) { if (fitOffset >= params.minOffset) {
effectiveOffset = qMax(params.minOffset, effectiveOffset); effectiveOffset = qMax(params.minOffset, effectiveOffset);
}
} }
} }
qreal stackHeight = (params.cardCount - 1) * effectiveOffset + params.cardHeight; qreal stackHeight = (params.cardCount - 1) * effectiveOffset + params.cardHeight;