From 3b8e5271e82b59c4e15003ffd518a5aea411a8a9 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Tue, 26 Nov 2024 01:58:43 -0800 Subject: [PATCH] move padding into constants --- cockatrice/src/game/zones/view_zone.cpp | 13 +++++++------ cockatrice/src/game/zones/view_zone.h | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cockatrice/src/game/zones/view_zone.cpp b/cockatrice/src/game/zones/view_zone.cpp index e60372467..1e30dc6ea 100644 --- a/cockatrice/src/game/zones/view_zone.cpp +++ b/cockatrice/src/game/zones/view_zone.cpp @@ -145,26 +145,27 @@ void ZoneViewZone::reorganizeCards() } lastCardType = cardType; - qreal x = 7 + (typeColumn * CARD_WIDTH); + qreal x = typeColumn * CARD_WIDTH; qreal y = typeRow * CARD_HEIGHT / 3; - c->setPos(x + 5, y + 5); + c->setPos(HORIZONTAL_PADDING + x, VERTICAL_PADDING + y); c->setRealZValue(i); longestRow = qMax(typeRow, longestRow); } } else { for (int i = 0; i < cardCount; i++) { CardItem *c = cardsToDisplay.at(i); - qreal x = 7 + ((i / rows) * CARD_WIDTH); + qreal x = (i / rows) * CARD_WIDTH; qreal y = (i % rows) * CARD_HEIGHT / 3; - c->setPos(x + 5, y + 5); + c->setPos(HORIZONTAL_PADDING + x, VERTICAL_PADDING + y); c->setRealZValue(i); } } qreal aleft = 0; qreal atop = 0; - qreal awidth = (pileView && sortByType) ? qMax(typeColumn + 1, 3) * CARD_WIDTH + (CARD_WIDTH / 2) + 12 - : qMax(cols, 1) * CARD_WIDTH + (CARD_WIDTH / 2) + 12; + qreal awidth = (pileView && sortByType) + ? qMax(typeColumn + 1, 3) * CARD_WIDTH + (CARD_WIDTH / 2) + HORIZONTAL_PADDING + : qMax(cols, 1) * CARD_WIDTH + (CARD_WIDTH / 2) + HORIZONTAL_PADDING; qreal aheight = (pileView && sortByType) ? (longestRow * CARD_HEIGHT) / 3 + CARD_HEIGHT * 1.3 : (rows * CARD_HEIGHT) / 3 + CARD_HEIGHT * 1.3; optimumRect = QRectF(aleft, atop, awidth, aheight); diff --git a/cockatrice/src/game/zones/view_zone.h b/cockatrice/src/game/zones/view_zone.h index a0e17b6c3..a0bc15291 100644 --- a/cockatrice/src/game/zones/view_zone.h +++ b/cockatrice/src/game/zones/view_zone.h @@ -15,6 +15,9 @@ class ZoneViewZone : public SelectZone, public QGraphicsLayoutItem Q_OBJECT Q_INTERFACES(QGraphicsLayoutItem) private: + static constexpr int HORIZONTAL_PADDING = 12; + static constexpr int VERTICAL_PADDING = 5; + QRectF bRect, optimumRect; int minRows, numberCards; void handleDropEvent(const QList &dragItems, CardZone *startZone, const QPoint &dropPoint);