move padding into constants

This commit is contained in:
RickyRister 2024-11-26 01:58:43 -08:00
parent 099eadaf8a
commit 3b8e5271e8
2 changed files with 10 additions and 6 deletions

View file

@ -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);

View file

@ -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<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint);