WIDTH_F used directly instead of casting

This commit is contained in:
DawnFire42 2026-03-05 18:31:06 -05:00
parent db3d80ff69
commit f24b2d54a9
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33
13 changed files with 56 additions and 53 deletions

View file

@ -8,8 +8,6 @@
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QPainter> #include <QPainter>
static const float CARD_WIDTH_HALF = CardDimensions::WIDTH / 2.0f;
static const float CARD_HEIGHT_HALF = CardDimensions::HEIGHT / 2.0f;
const QColor GHOST_MASK = QColor(255, 255, 255, 50); const QColor GHOST_MASK = QColor(255, 255, 255, 50);
AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item, AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
@ -22,16 +20,16 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
setZValue(ZValues::childDragZValue(hotSpot.x(), hotSpot.y())); setZValue(ZValues::childDragZValue(hotSpot.x(), hotSpot.y()));
connect(parentDrag, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater); connect(parentDrag, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater);
} else { } else {
hotSpot = QPointF{qBound(0.0, hotSpot.x(), static_cast<qreal>(CardDimensions::WIDTH - 1)), hotSpot = QPointF{qBound(0.0, hotSpot.x(), CardDimensions::WIDTH_F - 1),
qBound(0.0, hotSpot.y(), static_cast<qreal>(CardDimensions::HEIGHT - 1))}; qBound(0.0, hotSpot.y(), CardDimensions::HEIGHT_F - 1)};
setCursor(Qt::ClosedHandCursor); setCursor(Qt::ClosedHandCursor);
setZValue(ZValues::DRAG_ITEM); setZValue(ZValues::DRAG_ITEM);
} }
if (item->getTapped()) if (item->getTapped())
setTransform(QTransform() setTransform(QTransform()
.translate(CARD_WIDTH_HALF, CARD_HEIGHT_HALF) .translate(CardDimensions::WIDTH_HALF_F, CardDimensions::HEIGHT_HALF_F)
.rotate(90) .rotate(90)
.translate(-CARD_WIDTH_HALF, -CARD_HEIGHT_HALF)); .translate(-CardDimensions::WIDTH_HALF_F, -CardDimensions::HEIGHT_HALF_F));
setCacheMode(DeviceCoordinateCache); setCacheMode(DeviceCoordinateCache);
@ -48,7 +46,7 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
QPainterPath AbstractCardDragItem::shape() const QPainterPath AbstractCardDragItem::shape() const
{ {
QPainterPath shape; QPainterPath shape;
qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CardDimensions::WIDTH : 0.0; qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CardDimensions::WIDTH_F : 0.0;
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
return shape; return shape;
} }

View file

@ -34,7 +34,7 @@ public:
AbstractCardDragItem(AbstractCardItem *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag = 0); AbstractCardDragItem(AbstractCardItem *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag = 0);
[[nodiscard]] QRectF boundingRect() const override [[nodiscard]] QRectF boundingRect() const override
{ {
return QRectF(0, 0, CardDimensions::WIDTH, CardDimensions::HEIGHT); return QRectF(0, 0, CardDimensions::WIDTH_F, CardDimensions::HEIGHT_F);
} }
[[nodiscard]] QPainterPath shape() const override; [[nodiscard]] QPainterPath shape() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;

View file

@ -39,13 +39,13 @@ AbstractCardItem::~AbstractCardItem()
QRectF AbstractCardItem::boundingRect() const QRectF AbstractCardItem::boundingRect() const
{ {
return QRectF(0, 0, CardDimensions::WIDTH, CardDimensions::HEIGHT); return QRectF(0, 0, CardDimensions::WIDTH_F, CardDimensions::HEIGHT_F);
} }
QPainterPath AbstractCardItem::shape() const QPainterPath AbstractCardItem::shape() const
{ {
QPainterPath shape; QPainterPath shape;
qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CardDimensions::WIDTH : 0.0; qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CardDimensions::WIDTH_F : 0.0;
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
return shape; return shape;
} }
@ -218,7 +218,7 @@ void AbstractCardItem::setHovered(bool _hovered)
isHovered = _hovered; isHovered = _hovered;
setZValue(_hovered ? ZValues::HOVERED_CARD : realZValue); setZValue(_hovered ? ZValues::HOVERED_CARD : realZValue);
setScale(_hovered && SettingsCache::instance().getScaleCards() ? 1.1 : 1); setScale(_hovered && SettingsCache::instance().getScaleCards() ? 1.1 : 1);
setTransformOriginPoint(_hovered ? CardDimensions::WIDTH / 2 : 0, _hovered ? CardDimensions::HEIGHT / 2 : 0); setTransformOriginPoint(_hovered ? CardDimensions::WIDTH_HALF_F : 0, _hovered ? CardDimensions::HEIGHT_HALF_F : 0);
update(); update();
} }
@ -274,9 +274,9 @@ void AbstractCardItem::setTapped(bool _tapped, bool canAnimate)
else { else {
tapAngle = tapped ? 90 : 0; tapAngle = tapped ? 90 : 0;
setTransform(QTransform() setTransform(QTransform()
.translate((float)CardDimensions::WIDTH / 2, (float)CardDimensions::HEIGHT / 2) .translate(CardDimensions::WIDTH_HALF_F, CardDimensions::HEIGHT_HALF_F)
.rotate(tapAngle) .rotate(tapAngle)
.translate((float)-CardDimensions::WIDTH / 2, (float)-CardDimensions::HEIGHT / 2)); .translate(-CardDimensions::WIDTH_HALF_F, -CardDimensions::HEIGHT_HALF_F));
update(); update();
} }
} }

View file

@ -367,7 +367,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (zone->getHasCardAttr()) if (zone->getHasCardAttr())
childPos = card->pos() - pos(); childPos = card->pos() - pos();
else else
childPos = QPointF(childIndex * CardDimensions::WIDTH / 2, 0); childPos = QPointF(childIndex * CardDimensions::WIDTH_HALF_F, 0);
CardDragItem *drag = CardDragItem *drag =
new CardDragItem(card, card->getId(), childPos, card->getFaceDown() || forceFaceDown, dragItem); new CardDragItem(card, card->getId(), childPos, card->getFaceDown() || forceFaceDown, dragItem);
drag->setPos(dragItem->pos() + childPos); drag->setPos(dragItem->pos() + childPos);
@ -476,9 +476,9 @@ bool CardItem::animationEvent()
} }
setTransform(QTransform() setTransform(QTransform()
.translate(CARD_WIDTH_HALF, CARD_HEIGHT_HALF) .translate(CardDimensions::WIDTH_HALF_F, CardDimensions::HEIGHT_HALF_F)
.rotate(tapAngle) .rotate(tapAngle)
.translate(-CARD_WIDTH_HALF, -CARD_HEIGHT_HALF)); .translate(-CardDimensions::WIDTH_HALF_F, -CardDimensions::HEIGHT_HALF_F));
setHovered(false); setHovered(false);
update(); update();

View file

@ -21,8 +21,6 @@ class QAction;
class QColor; class QColor;
const int MAX_COUNTERS_ON_CARD = 999; const int MAX_COUNTERS_ON_CARD = 999;
const float CARD_WIDTH_HALF = CardDimensions::WIDTH / 2.0f;
const float CARD_HEIGHT_HALF = CardDimensions::HEIGHT / 2.0f;
const int ROTATION_DEGREES_PER_FRAME = 10; const int ROTATION_DEGREES_PER_FRAME = 10;
class CardItem : public AbstractCardItem class CardItem : public AbstractCardItem

View file

@ -20,6 +20,10 @@ constexpr int HEIGHT = 102;
/// Pre-converted for floating-point contexts (Z-value calculations) /// Pre-converted for floating-point contexts (Z-value calculations)
constexpr qreal WIDTH_F = static_cast<qreal>(WIDTH); constexpr qreal WIDTH_F = static_cast<qreal>(WIDTH);
constexpr qreal HEIGHT_F = static_cast<qreal>(HEIGHT); constexpr qreal HEIGHT_F = static_cast<qreal>(HEIGHT);
/// Half-dimensions for centering and rotation transforms
constexpr qreal WIDTH_HALF_F = WIDTH_F / 2;
constexpr qreal HEIGHT_HALF_F = HEIGHT_F / 2;
} // namespace CardDimensions } // namespace CardDimensions
#endif // CARD_DIMENSIONS_H #endif // CARD_DIMENSIONS_H

View file

@ -95,8 +95,8 @@ void DeckViewCard::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
pen.setJoinStyle(Qt::MiterJoin); pen.setJoinStyle(Qt::MiterJoin);
pen.setColor(originZone == DECK_ZONE_MAIN ? Qt::green : Qt::red); pen.setColor(originZone == DECK_ZONE_MAIN ? Qt::green : Qt::red);
painter->setPen(pen); painter->setPen(pen);
qreal cardRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * (CardDimensions::WIDTH - 3) : 0.0; qreal cardRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * (CardDimensions::WIDTH_F - 3) : 0.0;
painter->drawRoundedRect(QRectF(1.5, 1.5, CardDimensions::WIDTH - 3., CardDimensions::HEIGHT - 3.), cardRadius, painter->drawRoundedRect(QRectF(1.5, 1.5, CardDimensions::WIDTH_F - 3, CardDimensions::HEIGHT_F - 3), cardRadius,
cardRadius); cardRadius);
painter->restore(); painter->restore();
} }
@ -123,7 +123,7 @@ void DeckViewCard::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (c == this) if (c == this)
continue; continue;
++j; ++j;
auto childPos = QPointF(j * CardDimensions::WIDTH / 2, 0); auto childPos = QPointF(j * CardDimensions::WIDTH_HALF_F, 0);
auto *drag = new DeckViewCardDragItem(c, childPos, dragItem); auto *drag = new DeckViewCardDragItem(c, childPos, dragItem);
drag->setPos(dragItem->pos() + childPos); drag->setPos(dragItem->pos() + childPos);
scene()->addItem(drag); scene()->addItem(drag);
@ -205,7 +205,7 @@ void DeckViewCardContainer::paint(QPainter *painter, const QStyleOptionGraphicsI
painter->setPen(QColor(255, 255, 255, 100)); painter->setPen(QColor(255, 255, 255, 100));
painter->drawLine(QPointF(0, yUntilNow - paddingY / 2), QPointF(width, yUntilNow - paddingY / 2)); painter->drawLine(QPointF(0, yUntilNow - paddingY / 2), QPointF(width, yUntilNow - paddingY / 2));
} }
qreal thisRowHeight = CardDimensions::HEIGHT * currentRowsAndCols[i].first; qreal thisRowHeight = CardDimensions::HEIGHT_F * currentRowsAndCols[i].first;
QRectF textRect(0, yUntilNow, totalTextWidth, thisRowHeight); QRectF textRect(0, yUntilNow, totalTextWidth, thisRowHeight);
yUntilNow += thisRowHeight + paddingY; yUntilNow += thisRowHeight + paddingY;
@ -261,9 +261,9 @@ QSizeF DeckViewCardContainer::calculateBoundingRect(const QList<QPair<int, int>>
// Calculate space needed for cards // Calculate space needed for cards
for (int i = 0; i < rowsAndCols.size(); ++i) { for (int i = 0; i < rowsAndCols.size(); ++i) {
totalHeight += CardDimensions::HEIGHT * rowsAndCols[i].first + paddingY; totalHeight += CardDimensions::HEIGHT_F * rowsAndCols[i].first + paddingY;
if (CardDimensions::WIDTH * rowsAndCols[i].second > totalWidth) if (CardDimensions::WIDTH_F * rowsAndCols[i].second > totalWidth)
totalWidth = CardDimensions::WIDTH * rowsAndCols[i].second; totalWidth = CardDimensions::WIDTH_F * rowsAndCols[i].second;
} }
return QSizeF(getCardTypeTextWidth() + totalWidth, totalHeight + separatorY + paddingY); return QSizeF(getCardTypeTextWidth() + totalWidth, totalHeight + separatorY + paddingY);
@ -290,10 +290,10 @@ void DeckViewCardContainer::rearrangeItems(const QList<QPair<int, int>> &rowsAnd
std::sort(row.begin(), row.end(), DeckViewCardContainer::sortCardsByName); std::sort(row.begin(), row.end(), DeckViewCardContainer::sortCardsByName);
for (int j = 0; j < row.size(); ++j) { for (int j = 0; j < row.size(); ++j) {
DeckViewCard *card = row[j]; DeckViewCard *card = row[j];
card->setPos(x + (j % tempCols) * CardDimensions::WIDTH, card->setPos(x + (j % tempCols) * CardDimensions::WIDTH_F,
yUntilNow + (j / tempCols) * CardDimensions::HEIGHT); yUntilNow + (j / tempCols) * CardDimensions::HEIGHT_F);
} }
yUntilNow += tempRows * CardDimensions::HEIGHT + paddingY; yUntilNow += tempRows * CardDimensions::HEIGHT_F + paddingY;
} }
prepareGeometryChange(); prepareGeometryChange();

View file

@ -19,7 +19,8 @@ PlayerGraphicsItem::PlayerGraphicsItem(Player *_player) : player(_player)
playerArea = new PlayerArea(this); playerArea = new PlayerArea(this);
playerTarget = new PlayerTarget(player, playerArea); playerTarget = new PlayerTarget(player, playerArea);
qreal avatarMargin = (counterAreaWidth + CardDimensions::HEIGHT + 15 - playerTarget->boundingRect().width()) / 2.0; qreal avatarMargin =
(counterAreaWidth + CardDimensions::HEIGHT_F + 15 - playerTarget->boundingRect().width()) / 2.0;
playerTarget->setPos(QPointF(avatarMargin, avatarMargin)); playerTarget->setPos(QPointF(avatarMargin, avatarMargin));
initializeZones(); initializeZones();
@ -55,9 +56,9 @@ void PlayerGraphicsItem::onPlayerActiveChanged(bool _active)
void PlayerGraphicsItem::initializeZones() void PlayerGraphicsItem::initializeZones()
{ {
deckZoneGraphicsItem = new PileZone(player->getDeckZone(), this); deckZoneGraphicsItem = new PileZone(player->getDeckZone(), this);
auto base = QPointF(counterAreaWidth + (CardDimensions::HEIGHT - CardDimensions::WIDTH + 15) / 2.0, auto base = QPointF(counterAreaWidth + (CardDimensions::HEIGHT_F - CardDimensions::WIDTH_F + 15) / 2.0,
10 + playerTarget->boundingRect().height() + 5 - 10 + playerTarget->boundingRect().height() + 5 -
(CardDimensions::HEIGHT - CardDimensions::WIDTH) / 2.0); (CardDimensions::HEIGHT_F - CardDimensions::WIDTH_F) / 2.0);
deckZoneGraphicsItem->setPos(base); deckZoneGraphicsItem->setPos(base);
qreal h = deckZoneGraphicsItem->boundingRect().width() + 5; qreal h = deckZoneGraphicsItem->boundingRect().width() + 5;
@ -96,7 +97,7 @@ QRectF PlayerGraphicsItem::boundingRect() const
qreal PlayerGraphicsItem::getMinimumWidth() const qreal PlayerGraphicsItem::getMinimumWidth() const
{ {
qreal result = tableZoneGraphicsItem->getMinimumWidth() + CardDimensions::HEIGHT + 15 + counterAreaWidth + qreal result = tableZoneGraphicsItem->getMinimumWidth() + CardDimensions::HEIGHT_F + 15 + counterAreaWidth +
stackZoneGraphicsItem->boundingRect().width(); stackZoneGraphicsItem->boundingRect().width();
if (!SettingsCache::instance().getHorizontalHand()) { if (!SettingsCache::instance().getHorizontalHand()) {
result += handZoneGraphicsItem->boundingRect().width(); result += handZoneGraphicsItem->boundingRect().width();
@ -113,8 +114,8 @@ void PlayerGraphicsItem::paint(QPainter * /*painter*/,
void PlayerGraphicsItem::processSceneSizeChange(int newPlayerWidth) void PlayerGraphicsItem::processSceneSizeChange(int newPlayerWidth)
{ {
// Extend table (and hand, if horizontal) to accommodate the new player width. // Extend table (and hand, if horizontal) to accommodate the new player width.
qreal tableWidth = qreal tableWidth = newPlayerWidth - CardDimensions::HEIGHT_F - 15 - counterAreaWidth -
newPlayerWidth - CardDimensions::HEIGHT - 15 - counterAreaWidth - stackZoneGraphicsItem->boundingRect().width(); stackZoneGraphicsItem->boundingRect().width();
if (!SettingsCache::instance().getHorizontalHand()) { if (!SettingsCache::instance().getHorizontalHand()) {
tableWidth -= handZoneGraphicsItem->boundingRect().width(); tableWidth -= handZoneGraphicsItem->boundingRect().width();
} }
@ -153,7 +154,7 @@ void PlayerGraphicsItem::rearrangeCounters()
void PlayerGraphicsItem::rearrangeZones() void PlayerGraphicsItem::rearrangeZones()
{ {
auto base = QPointF(CardDimensions::HEIGHT + counterAreaWidth + 15, 0); auto base = QPointF(CardDimensions::HEIGHT_F + counterAreaWidth + 15, 0);
if (SettingsCache::instance().getHorizontalHand()) { if (SettingsCache::instance().getHorizontalHand()) {
if (mirrored) { if (mirrored) {
if (player->getHandZone()->contentsKnown()) { if (player->getHandZone()->contentsKnown()) {
@ -204,7 +205,7 @@ void PlayerGraphicsItem::rearrangeZones()
void PlayerGraphicsItem::updateBoundingRect() void PlayerGraphicsItem::updateBoundingRect()
{ {
prepareGeometryChange(); prepareGeometryChange();
qreal width = CardDimensions::HEIGHT + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width(); qreal width = CardDimensions::HEIGHT_F + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width();
if (SettingsCache::instance().getHorizontalHand()) { if (SettingsCache::instance().getHorizontalHand()) {
qreal handHeight = qreal handHeight =
player->getPlayerInfo()->getHandVisible() ? handZoneGraphicsItem->boundingRect().height() : 0; player->getPlayerInfo()->getHandVisible() ? handZoneGraphicsItem->boundingRect().height() : 0;
@ -215,7 +216,7 @@ void PlayerGraphicsItem::updateBoundingRect()
0, 0, width + handZoneGraphicsItem->boundingRect().width() + tableZoneGraphicsItem->boundingRect().width(), 0, 0, width + handZoneGraphicsItem->boundingRect().width() + tableZoneGraphicsItem->boundingRect().width(),
tableZoneGraphicsItem->boundingRect().height()); tableZoneGraphicsItem->boundingRect().height());
} }
playerArea->setSize(CardDimensions::HEIGHT + counterAreaWidth + 15, bRect.height()); playerArea->setSize(CardDimensions::HEIGHT_F + counterAreaWidth + 15, bRect.height());
emit sizeChanged(); emit sizeChanged();
} }

View file

@ -56,7 +56,7 @@ void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
QRectF HandZone::boundingRect() const QRectF HandZone::boundingRect() const
{ {
if (SettingsCache::instance().getHorizontalHand()) if (SettingsCache::instance().getHorizontalHand())
return QRectF(0, 0, width, CardDimensions::HEIGHT + 10); return QRectF(0, 0, width, CardDimensions::HEIGHT_F + 10);
else else
return QRectF(0, 0, 100, zoneHeight); return QRectF(0, 0, 100, zoneHeight);
} }

View file

@ -19,9 +19,9 @@ PileZone::PileZone(PileZoneLogic *_logic, QGraphicsItem *parent) : CardZone(_log
setCursor(Qt::OpenHandCursor); setCursor(Qt::OpenHandCursor);
setTransform(QTransform() setTransform(QTransform()
.translate((float)CardDimensions::WIDTH / 2, (float)CardDimensions::HEIGHT / 2) .translate(CardDimensions::WIDTH_F / 2, CardDimensions::HEIGHT_F / 2)
.rotate(90) .rotate(90)
.translate((float)-CardDimensions::WIDTH / 2, (float)-CardDimensions::HEIGHT / 2)); .translate(-CardDimensions::WIDTH_F / 2, -CardDimensions::HEIGHT_F / 2));
connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) { connect(&SettingsCache::instance(), &SettingsCache::roundCardCornersChanged, this, [this](bool _roundCardCorners) {
Q_UNUSED(_roundCardCorners); Q_UNUSED(_roundCardCorners);
@ -33,13 +33,13 @@ PileZone::PileZone(PileZoneLogic *_logic, QGraphicsItem *parent) : CardZone(_log
QRectF PileZone::boundingRect() const QRectF PileZone::boundingRect() const
{ {
return QRectF(0, 0, CardDimensions::WIDTH, CardDimensions::HEIGHT); return QRectF(0, 0, CardDimensions::WIDTH_F, CardDimensions::HEIGHT_F);
} }
QPainterPath PileZone::shape() const QPainterPath PileZone::shape() const
{ {
QPainterPath shape; QPainterPath shape;
qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CardDimensions::WIDTH : 0.0; qreal cardCornerRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * CardDimensions::WIDTH_F : 0.0;
shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius); shape.addRoundedRect(boundingRect(), cardCornerRadius, cardCornerRadius);
return shape; return shape;
} }
@ -52,9 +52,9 @@ void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*optio
getLogic()->getCards().at(0)->paintPicture(painter, getLogic()->getCards().at(0)->getTranslatedSize(painter), getLogic()->getCards().at(0)->paintPicture(painter, getLogic()->getCards().at(0)->getTranslatedSize(painter),
90); 90);
painter->translate((float)CardDimensions::WIDTH / 2, (float)CardDimensions::HEIGHT / 2); painter->translate(CardDimensions::WIDTH_F / 2, CardDimensions::HEIGHT_F / 2);
painter->rotate(-90); painter->rotate(-90);
painter->translate((float)-CardDimensions::WIDTH / 2, (float)-CardDimensions::HEIGHT / 2); painter->translate(-CardDimensions::WIDTH_F / 2, -CardDimensions::HEIGHT_F / 2);
paintNumberEllipse(getLogic()->getCards().size(), 28, Qt::white, -1, -1, painter); paintNumberEllipse(getLogic()->getCards().size(), 28, Qt::white, -1, -1, painter);
} }

View file

@ -118,7 +118,9 @@ void ZoneViewZone::zoneDumpReceived(const Response &r)
qobject_cast<ZoneViewZoneLogic *>(getLogic())->updateCardIds(ZoneViewZoneLogic::INITIALIZE); qobject_cast<ZoneViewZoneLogic *>(getLogic())->updateCardIds(ZoneViewZoneLogic::INITIALIZE);
reorganizeCards(); reorganizeCards();
emit getLogic()->cardCountChanged(); // clang-format off
emit getLogic()->cardCountChanged(); // emit keyword causes spurious spacing around ->
// clang-format on
} }
// Because of boundingRect(), this function must not be called before the zone was added to a scene. // Because of boundingRect(), this function must not be called before the zone was added to a scene.
@ -166,8 +168,8 @@ void ZoneViewZone::reorganizeCards()
// determine bounding rect // determine bounding rect
qreal aleft = 0; qreal aleft = 0;
qreal atop = 0; qreal atop = 0;
qreal awidth = gridSize.cols * CardDimensions::WIDTH + (CardDimensions::WIDTH / 2) + HORIZONTAL_PADDING; qreal awidth = gridSize.cols * CardDimensions::WIDTH_F + CardDimensions::WIDTH_HALF_F + HORIZONTAL_PADDING;
qreal aheight = (gridSize.rows * CardDimensions::HEIGHT) / 3 + CardDimensions::HEIGHT * 1.3; qreal aheight = (gridSize.rows * CardDimensions::HEIGHT_F) / 3 + CardDimensions::HEIGHT_F * 1.3;
optimumRect = QRectF(aleft, atop, awidth, aheight); optimumRect = QRectF(aleft, atop, awidth, aheight);
updateGeometry(); updateGeometry();
@ -210,8 +212,8 @@ ZoneViewZone::GridSize ZoneViewZone::positionCardsForDisplay(CardList &cards, Ca
} }
lastColumnProp = columnProp; lastColumnProp = columnProp;
qreal x = col * CardDimensions::WIDTH; qreal x = col * CardDimensions::WIDTH_F;
qreal y = row * CardDimensions::HEIGHT / 3; qreal y = row * CardDimensions::HEIGHT_F / 3;
c->setPos(HORIZONTAL_PADDING + x, VERTICAL_PADDING + y); c->setPos(HORIZONTAL_PADDING + x, VERTICAL_PADDING + y);
c->setRealZValue(i); c->setRealZValue(i);
longestRow = qMax(row, longestRow); longestRow = qMax(row, longestRow);
@ -238,8 +240,8 @@ ZoneViewZone::GridSize ZoneViewZone::positionCardsForDisplay(CardList &cards, Ca
for (int i = 0; i < cardCount; i++) { for (int i = 0; i < cardCount; i++) {
CardItem *c = cards.at(i); CardItem *c = cards.at(i);
qreal x = (i / rows) * CardDimensions::WIDTH; qreal x = (i / rows) * CardDimensions::WIDTH_F;
qreal y = (i % rows) * CardDimensions::HEIGHT / 3; qreal y = (i % rows) * CardDimensions::HEIGHT_F / 3;
c->setPos(HORIZONTAL_PADDING + x, VERTICAL_PADDING + y); c->setPos(HORIZONTAL_PADDING + x, VERTICAL_PADDING + y);
c->setRealZValue(i); c->setRealZValue(i);
} }

View file

@ -458,7 +458,7 @@ void ZoneViewWidget::resizeScrollbar(const qreal newZoneHeight)
*/ */
static qreal rowsToHeight(int rows) static qreal rowsToHeight(int rows)
{ {
const qreal cardsHeight = (rows + 1) * (CardDimensions::HEIGHT / 3); const qreal cardsHeight = (rows + 1) * (CardDimensions::HEIGHT_F / 3);
return cardsHeight + 5; // +5 padding to make the cutoff look nicer return cardsHeight + 5; // +5 padding to make the cutoff look nicer
} }

View file

@ -10,7 +10,7 @@
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
CardInfoDisplayWidget::CardInfoDisplayWidget(const CardRef &cardRef, QWidget *parent, Qt::WindowFlags flags) CardInfoDisplayWidget::CardInfoDisplayWidget(const CardRef &cardRef, QWidget *parent, Qt::WindowFlags flags)
: QFrame(parent, flags), aspectRatio((qreal)CardDimensions::HEIGHT / (qreal)CardDimensions::WIDTH) : QFrame(parent, flags), aspectRatio(CardDimensions::HEIGHT_F / CardDimensions::WIDTH_F)
{ {
setContentsMargins(3, 3, 3, 3); setContentsMargins(3, 3, 3, 3);
pic = new CardInfoPictureWidget(); pic = new CardInfoPictureWidget();