mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
refactor: extract CARD_HEIGHT to shared CardDimensions header (#6668)
* refactor: extract CARD_HEIGHT to shared CardDimensions header Move duplicated CARD_WIDTH/CARD_HEIGHT constants to card_dimensions.h. Fixed documentation in z_value_layer_manager.h. * WIDTH_F used directly instead of casting * Improved consistency and added missing newlines at end of files
This commit is contained in:
parent
14f1925edc
commit
bd5cbb89d4
18 changed files with 108 additions and 78 deletions
|
|
@ -8,8 +8,6 @@
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
static const float CARD_WIDTH_HALF = CARD_WIDTH / 2;
|
|
||||||
static const float CARD_HEIGHT_HALF = CARD_HEIGHT / 2;
|
|
||||||
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>(CARD_WIDTH - 1)),
|
hotSpot = QPointF{qBound(0.0, hotSpot.x(), CardDimensions::WIDTH_F - 1),
|
||||||
qBound(0.0, hotSpot.y(), static_cast<qreal>(CARD_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 * CARD_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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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, CARD_WIDTH, CARD_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;
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ AbstractCardItem::~AbstractCardItem()
|
||||||
|
|
||||||
QRectF AbstractCardItem::boundingRect() const
|
QRectF AbstractCardItem::boundingRect() const
|
||||||
{
|
{
|
||||||
return QRectF(0, 0, CARD_WIDTH, CARD_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 * CARD_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 ? CARD_WIDTH / 2 : 0, _hovered ? CARD_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)CARD_WIDTH / 2, (float)CARD_HEIGHT / 2)
|
.translate(CardDimensions::WIDTH_HALF_F, CardDimensions::HEIGHT_HALF_F)
|
||||||
.rotate(tapAngle)
|
.rotate(tapAngle)
|
||||||
.translate((float)-CARD_WIDTH / 2, (float)-CARD_HEIGHT / 2));
|
.translate(-CardDimensions::WIDTH_HALF_F, -CardDimensions::HEIGHT_HALF_F));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#define ABSTRACTCARDITEM_H
|
#define ABSTRACTCARDITEM_H
|
||||||
|
|
||||||
#include "../../game_graphics/board/graphics_item_type.h"
|
#include "../../game_graphics/board/graphics_item_type.h"
|
||||||
|
#include "../card_dimensions.h"
|
||||||
#include "arrow_target.h"
|
#include "arrow_target.h"
|
||||||
|
|
||||||
#include <libcockatrice/card/printing/exact_card.h>
|
#include <libcockatrice/card/printing/exact_card.h>
|
||||||
|
|
@ -15,9 +16,6 @@
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
|
|
||||||
const int CARD_WIDTH = 72;
|
|
||||||
const int CARD_HEIGHT = 102;
|
|
||||||
|
|
||||||
class AbstractCardItem : public ArrowTarget
|
class AbstractCardItem : public ArrowTarget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
||||||
|
|
@ -367,8 +367,9 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (zone->getHasCardAttr())
|
if (zone->getHasCardAttr())
|
||||||
childPos = card->pos() - pos();
|
childPos = card->pos() - pos();
|
||||||
else
|
else
|
||||||
childPos = QPointF(childIndex * CARD_WIDTH / 2, 0);
|
childPos = QPointF(childIndex * CardDimensions::WIDTH_HALF_F, 0);
|
||||||
CardDragItem *drag = new CardDragItem(card, card->getId(), childPos, forceFaceDown, dragItem);
|
CardDragItem *drag =
|
||||||
|
new CardDragItem(card, card->getId(), childPos, card->getFaceDown() || forceFaceDown, dragItem);
|
||||||
drag->setPos(dragItem->pos() + childPos);
|
drag->setPos(dragItem->pos() + childPos);
|
||||||
scene()->addItem(drag);
|
scene()->addItem(drag);
|
||||||
}
|
}
|
||||||
|
|
@ -475,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();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 = CARD_WIDTH / 2;
|
|
||||||
const float CARD_HEIGHT_HALF = CARD_HEIGHT / 2;
|
|
||||||
const int ROTATION_DEGREES_PER_FRAME = 10;
|
const int ROTATION_DEGREES_PER_FRAME = 10;
|
||||||
|
|
||||||
class CardItem : public AbstractCardItem
|
class CardItem : public AbstractCardItem
|
||||||
|
|
|
||||||
29
cockatrice/src/game/card_dimensions.h
Normal file
29
cockatrice/src/game/card_dimensions.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef CARD_DIMENSIONS_H
|
||||||
|
#define CARD_DIMENSIONS_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file card_dimensions.h
|
||||||
|
* @brief Canonical card dimension constants for layout and Z-value calculations.
|
||||||
|
*
|
||||||
|
* These values represent the logical pixel dimensions of a standard card graphic.
|
||||||
|
* They are used throughout the game scene for layout, rendering, and Z-value computation.
|
||||||
|
*/
|
||||||
|
namespace CardDimensions
|
||||||
|
{
|
||||||
|
/// Card width in pixels
|
||||||
|
constexpr int WIDTH = 72;
|
||||||
|
/// Card height in pixels
|
||||||
|
constexpr int HEIGHT = 102;
|
||||||
|
|
||||||
|
/// Pre-converted for floating-point contexts (Z-value calculations)
|
||||||
|
constexpr qreal WIDTH_F = static_cast<qreal>(WIDTH);
|
||||||
|
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
|
||||||
|
|
||||||
|
#endif // CARD_DIMENSIONS_H
|
||||||
|
|
@ -95,8 +95,9 @@ 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 * (CARD_WIDTH - 3) : 0.0;
|
qreal cardRadius = SettingsCache::instance().getRoundCardCorners() ? 0.05 * (CardDimensions::WIDTH_F - 3) : 0.0;
|
||||||
painter->drawRoundedRect(QRectF(1.5, 1.5, CARD_WIDTH - 3., CARD_HEIGHT - 3.), cardRadius, cardRadius);
|
painter->drawRoundedRect(QRectF(1.5, 1.5, CardDimensions::WIDTH_F - 3, CardDimensions::HEIGHT_F - 3), cardRadius,
|
||||||
|
cardRadius);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,7 +123,7 @@ void DeckViewCard::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (c == this)
|
if (c == this)
|
||||||
continue;
|
continue;
|
||||||
++j;
|
++j;
|
||||||
auto childPos = QPointF(j * CARD_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);
|
||||||
|
|
@ -204,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 = CARD_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;
|
||||||
|
|
||||||
|
|
@ -260,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 += CARD_HEIGHT * rowsAndCols[i].first + paddingY;
|
totalHeight += CardDimensions::HEIGHT_F * rowsAndCols[i].first + paddingY;
|
||||||
if (CARD_WIDTH * rowsAndCols[i].second > totalWidth)
|
if (CardDimensions::WIDTH_F * rowsAndCols[i].second > totalWidth)
|
||||||
totalWidth = CARD_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);
|
||||||
|
|
@ -289,9 +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) * CARD_WIDTH, yUntilNow + (j / tempCols) * CARD_HEIGHT);
|
card->setPos(x + (j % tempCols) * CardDimensions::WIDTH_F,
|
||||||
|
yUntilNow + (j / tempCols) * CardDimensions::HEIGHT_F);
|
||||||
}
|
}
|
||||||
yUntilNow += tempRows * CARD_HEIGHT + paddingY;
|
yUntilNow += tempRows * CardDimensions::HEIGHT_F + paddingY;
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
@ -392,7 +394,7 @@ void DeckViewScene::applySideboardPlan(const QList<MoveCard_ToZone> &plan)
|
||||||
|
|
||||||
void DeckViewScene::rearrangeItems()
|
void DeckViewScene::rearrangeItems()
|
||||||
{
|
{
|
||||||
const int spacing = CARD_HEIGHT / 3;
|
const int spacing = CardDimensions::HEIGHT / 3;
|
||||||
QList<DeckViewCardContainer *> contList = cardContainers.values();
|
QList<DeckViewCardContainer *> contList = cardContainers.values();
|
||||||
|
|
||||||
// Initialize space requirements
|
// Initialize space requirements
|
||||||
|
|
|
||||||
|
|
@ -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 + CARD_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,8 +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 + (CARD_HEIGHT - CARD_WIDTH + 15) / 2.0,
|
auto base = QPointF(counterAreaWidth + (CardDimensions::HEIGHT_F - CardDimensions::WIDTH_F + 15) / 2.0,
|
||||||
10 + playerTarget->boundingRect().height() + 5 - (CARD_HEIGHT - CARD_WIDTH) / 2.0);
|
10 + playerTarget->boundingRect().height() + 5 -
|
||||||
|
(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;
|
||||||
|
|
@ -95,7 +97,7 @@ QRectF PlayerGraphicsItem::boundingRect() const
|
||||||
|
|
||||||
qreal PlayerGraphicsItem::getMinimumWidth() const
|
qreal PlayerGraphicsItem::getMinimumWidth() const
|
||||||
{
|
{
|
||||||
qreal result = tableZoneGraphicsItem->getMinimumWidth() + CARD_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();
|
||||||
|
|
@ -112,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 - CARD_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();
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +154,7 @@ void PlayerGraphicsItem::rearrangeCounters()
|
||||||
|
|
||||||
void PlayerGraphicsItem::rearrangeZones()
|
void PlayerGraphicsItem::rearrangeZones()
|
||||||
{
|
{
|
||||||
auto base = QPointF(CARD_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()) {
|
||||||
|
|
@ -203,7 +205,7 @@ void PlayerGraphicsItem::rearrangeZones()
|
||||||
void PlayerGraphicsItem::updateBoundingRect()
|
void PlayerGraphicsItem::updateBoundingRect()
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
qreal width = CARD_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;
|
||||||
|
|
@ -214,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(CARD_HEIGHT + counterAreaWidth + 15, bRect.height());
|
playerArea->setSize(CardDimensions::HEIGHT_F + counterAreaWidth + 15, bRect.height());
|
||||||
|
|
||||||
emit sizeChanged();
|
emit sizeChanged();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* - Cards within zones (1.0 base + index)
|
* - Cards within zones (1.0 base + index)
|
||||||
*
|
*
|
||||||
* 2. **Card Layer (1-40,000,000)**: Dynamic card rendering on the table zone
|
* 2. **Card Layer (1-40,000,000)**: Dynamic card rendering on the table zone
|
||||||
* - Cards use formula: (actualY + CARD_HEIGHT) * 100000 + (actualX + 1) * 100
|
* - Cards use formula: (actualY + CardDimensions::HEIGHT) * 100000 + (actualX + 1) * 100
|
||||||
* - Maximum card Z-value: ~40,000,000 (with 3 rows, actualY <= ~289)
|
* - Maximum card Z-value: ~40,000,000 (with 3 rows, actualY <= ~289)
|
||||||
*
|
*
|
||||||
* 3. **Overlay Layer (2,000,000,000+)**: UI elements that must appear above all cards
|
* 3. **Overlay Layer (2,000,000,000+)**: UI elements that must appear above all cards
|
||||||
|
|
@ -77,9 +77,9 @@ enum class Layer
|
||||||
/**
|
/**
|
||||||
* @brief Maximum Z-value a card can have on the table zone.
|
* @brief Maximum Z-value a card can have on the table zone.
|
||||||
*
|
*
|
||||||
* Based on table zone formula: (actualY + CARD_HEIGHT) * 100000 + (actualX + 1) * 100
|
* Based on table zone formula: (actualY + CardDimensions::HEIGHT) * 100000 + (actualX + 1) * 100
|
||||||
* With maximum 3 rows and CARD_HEIGHT ~96, actualY <= ~289.
|
* With maximum 3 rows and CardDimensions::HEIGHT = 102, actualY <= ~289.
|
||||||
* Maximum: (289 + 96) * 100000 + 100 * 100 = 38,510,000
|
* Maximum: (289 + 102) * 100000 + 100 * 100 = 39,110,000
|
||||||
*
|
*
|
||||||
* We use 40,000,000 as a safe upper bound with margin.
|
* We use 40,000,000 as a safe upper bound with margin.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef Z_VALUES_H
|
#ifndef Z_VALUES_H
|
||||||
#define Z_VALUES_H
|
#define Z_VALUES_H
|
||||||
|
|
||||||
|
#include "card_dimensions.h"
|
||||||
#include "z_value_layer_manager.h"
|
#include "z_value_layer_manager.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -70,8 +71,7 @@ constexpr qreal TOP_UI = ZValueLayerManager::overlayZValue(7.0);
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] constexpr qreal tableCardZValue(qreal x, qreal y)
|
[[nodiscard]] constexpr qreal tableCardZValue(qreal x, qreal y)
|
||||||
{
|
{
|
||||||
constexpr qreal CARD_HEIGHT_FOR_Z = 102.0;
|
return (y + CardDimensions::HEIGHT_F) * 100000.0 + (x + 1) * 100.0;
|
||||||
return (y + CARD_HEIGHT_FOR_Z) * 100000.0 + (x + 1) * 100.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Card layering (general architecture, not command-zone specific)
|
// Card layering (general architecture, not command-zone specific)
|
||||||
|
|
|
||||||
|
|
@ -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, CARD_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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ PileZone::PileZone(PileZoneLogic *_logic, QGraphicsItem *parent) : CardZone(_log
|
||||||
setCursor(Qt::OpenHandCursor);
|
setCursor(Qt::OpenHandCursor);
|
||||||
|
|
||||||
setTransform(QTransform()
|
setTransform(QTransform()
|
||||||
.translate((float)CARD_WIDTH / 2, (float)CARD_HEIGHT / 2)
|
.translate(CardDimensions::WIDTH_HALF_F, CardDimensions::HEIGHT_HALF_F)
|
||||||
.rotate(90)
|
.rotate(90)
|
||||||
.translate((float)-CARD_WIDTH / 2, (float)-CARD_HEIGHT / 2));
|
.translate(-CardDimensions::WIDTH_HALF_F, -CardDimensions::HEIGHT_HALF_F));
|
||||||
|
|
||||||
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, CARD_WIDTH, CARD_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 * CARD_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)CARD_WIDTH / 2, (float)CARD_HEIGHT / 2);
|
painter->translate(CardDimensions::WIDTH_HALF_F, CardDimensions::HEIGHT_HALF_F);
|
||||||
painter->rotate(-90);
|
painter->rotate(-90);
|
||||||
painter->translate((float)-CARD_WIDTH / 2, (float)-CARD_HEIGHT / 2);
|
painter->translate(-CardDimensions::WIDTH_HALF_F, -CardDimensions::HEIGHT_HALF_F);
|
||||||
paintNumberEllipse(getLogic()->getCards().size(), 28, Qt::white, -1, -1, painter);
|
paintNumberEllipse(getLogic()->getCards().size(), 28, Qt::white, -1, -1, painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ TableZone::TableZone(TableZoneLogic *_logic, QGraphicsItem *parent) : SelectZone
|
||||||
|
|
||||||
updateBg();
|
updateBg();
|
||||||
|
|
||||||
height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CARD_HEIGHT + (TABLEROWS - 1) * PADDING_Y;
|
height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CardDimensions::HEIGHT + (TABLEROWS - 1) * PADDING_Y;
|
||||||
width = MIN_WIDTH;
|
width = MIN_WIDTH;
|
||||||
currentMinimumWidth = width;
|
currentMinimumWidth = width;
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ void TableZone::paintLandDivider(QPainter *painter)
|
||||||
{
|
{
|
||||||
// Place the line 2 grid heights down then back it off just enough to allow
|
// Place the line 2 grid heights down then back it off just enough to allow
|
||||||
// some space between a 3-card stack and the land area.
|
// some space between a 3-card stack and the land area.
|
||||||
qreal separatorY = MARGIN_TOP + 2 * (CARD_HEIGHT + PADDING_Y) - STACKED_CARD_OFFSET_Y / 2;
|
qreal separatorY = MARGIN_TOP + 2 * (CardDimensions::HEIGHT + PADDING_Y) - STACKED_CARD_OFFSET_Y / 2;
|
||||||
if (isInverted())
|
if (isInverted())
|
||||||
separatorY = height - separatorY;
|
separatorY = height - separatorY;
|
||||||
painter->setPen(QColor(255, 255, 255, 40));
|
painter->setPen(QColor(255, 255, 255, 40));
|
||||||
|
|
@ -232,7 +232,7 @@ void TableZone::resizeToContents()
|
||||||
|
|
||||||
// Minimum width is the rightmost card position plus enough room for
|
// Minimum width is the rightmost card position plus enough room for
|
||||||
// another card with padding, then margin.
|
// another card with padding, then margin.
|
||||||
currentMinimumWidth = xMax + (2 * CARD_WIDTH) + PADDING_X + MARGIN_RIGHT;
|
currentMinimumWidth = xMax + (2 * CardDimensions::WIDTH) + PADDING_X + MARGIN_RIGHT;
|
||||||
|
|
||||||
if (currentMinimumWidth < MIN_WIDTH)
|
if (currentMinimumWidth < MIN_WIDTH)
|
||||||
currentMinimumWidth = MIN_WIDTH;
|
currentMinimumWidth = MIN_WIDTH;
|
||||||
|
|
@ -282,10 +282,10 @@ void TableZone::computeCardStackWidths()
|
||||||
const int key = getCardStackMapKey(gridPoint.x() / 3, gridPoint.y());
|
const int key = getCardStackMapKey(gridPoint.x() / 3, gridPoint.y());
|
||||||
const int stackCount = cardStackCount.value(key, 0);
|
const int stackCount = cardStackCount.value(key, 0);
|
||||||
if (stackCount == 1)
|
if (stackCount == 1)
|
||||||
cardStackWidth.insert(key, CARD_WIDTH + getLogic()->getCards()[i]->getAttachedCards().size() *
|
cardStackWidth.insert(key, CardDimensions::WIDTH + getLogic()->getCards()[i]->getAttachedCards().size() *
|
||||||
STACKED_CARD_OFFSET_X);
|
STACKED_CARD_OFFSET_X);
|
||||||
else
|
else
|
||||||
cardStackWidth.insert(key, CARD_WIDTH + (stackCount - 1) * STACKED_CARD_OFFSET_X);
|
cardStackWidth.insert(key, CardDimensions::WIDTH + (stackCount - 1) * STACKED_CARD_OFFSET_X);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ QPointF TableZone::mapFromGrid(QPoint gridPoint) const
|
||||||
// Add in width of card stack plus padding for each column
|
// Add in width of card stack plus padding for each column
|
||||||
for (int i = 0; i < gridPoint.x() / 3; ++i) {
|
for (int i = 0; i < gridPoint.x() / 3; ++i) {
|
||||||
const int key = getCardStackMapKey(i, gridPoint.y());
|
const int key = getCardStackMapKey(i, gridPoint.y());
|
||||||
x += cardStackWidth.value(key, CARD_WIDTH) + PADDING_X;
|
x += cardStackWidth.value(key, CardDimensions::WIDTH) + PADDING_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInverted())
|
if (isInverted())
|
||||||
|
|
@ -310,7 +310,7 @@ QPointF TableZone::mapFromGrid(QPoint gridPoint) const
|
||||||
|
|
||||||
// Add in card size and padding for each row
|
// Add in card size and padding for each row
|
||||||
for (int i = 0; i < gridPoint.y(); ++i)
|
for (int i = 0; i < gridPoint.y(); ++i)
|
||||||
y += CARD_HEIGHT + PADDING_Y;
|
y += CardDimensions::HEIGHT + PADDING_Y;
|
||||||
|
|
||||||
return QPointF(x, y);
|
return QPointF(x, y);
|
||||||
}
|
}
|
||||||
|
|
@ -324,7 +324,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
||||||
int y = mapPoint.y() - MARGIN_TOP;
|
int y = mapPoint.y() - MARGIN_TOP;
|
||||||
|
|
||||||
// Below calculation effectively rounds to the nearest grid point.
|
// Below calculation effectively rounds to the nearest grid point.
|
||||||
const int gridPointHeight = CARD_HEIGHT + PADDING_Y;
|
const int gridPointHeight = CardDimensions::HEIGHT + PADDING_Y;
|
||||||
int gridPointY = (y + PADDING_Y / 2) / gridPointHeight;
|
int gridPointY = (y + PADDING_Y / 2) / gridPointHeight;
|
||||||
|
|
||||||
gridPointY = clampValidTableRow(gridPointY);
|
gridPointY = clampValidTableRow(gridPointY);
|
||||||
|
|
@ -340,7 +340,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
||||||
|
|
||||||
// Maximum value is a card width from the right margin, referenced to the
|
// Maximum value is a card width from the right margin, referenced to the
|
||||||
// grid area.
|
// grid area.
|
||||||
const int xMax = width - MARGIN_LEFT - MARGIN_RIGHT - CARD_WIDTH;
|
const int xMax = width - MARGIN_LEFT - MARGIN_RIGHT - CardDimensions::WIDTH;
|
||||||
|
|
||||||
int xStack = 0;
|
int xStack = 0;
|
||||||
int xNextStack = 0;
|
int xNextStack = 0;
|
||||||
|
|
@ -348,7 +348,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
||||||
while ((xNextStack <= x) && (xNextStack <= xMax)) {
|
while ((xNextStack <= x) && (xNextStack <= xMax)) {
|
||||||
xStack = xNextStack;
|
xStack = xNextStack;
|
||||||
const int key = getCardStackMapKey(nextStackCol, gridPointY);
|
const int key = getCardStackMapKey(nextStackCol, gridPointY);
|
||||||
xNextStack += cardStackWidth.value(key, CARD_WIDTH) + PADDING_X;
|
xNextStack += cardStackWidth.value(key, CardDimensions::WIDTH) + PADDING_X;
|
||||||
nextStackCol++;
|
nextStackCol++;
|
||||||
}
|
}
|
||||||
int stackCol = qMax(nextStackCol - 1, 0);
|
int stackCol = qMax(nextStackCol - 1, 0);
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,12 @@ private:
|
||||||
/*
|
/*
|
||||||
Minimum width of the table zone including margins.
|
Minimum width of the table zone including margins.
|
||||||
*/
|
*/
|
||||||
static const int MIN_WIDTH = MARGIN_LEFT + (5 * CARD_WIDTH) + MARGIN_RIGHT;
|
static const int MIN_WIDTH = MARGIN_LEFT + (5 * CardDimensions::WIDTH) + MARGIN_RIGHT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Offset sizes when cards are stacked on each other in the grid
|
Offset sizes when cards are stacked on each other in the grid
|
||||||
*/
|
*/
|
||||||
static const int STACKED_CARD_OFFSET_X = CARD_WIDTH / 3;
|
static const int STACKED_CARD_OFFSET_X = CardDimensions::WIDTH / 3;
|
||||||
static const int STACKED_CARD_OFFSET_Y = PADDING_Y / 3;
|
static const int STACKED_CARD_OFFSET_Y = PADDING_Y / 3;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -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 * CARD_WIDTH + (CARD_WIDTH / 2) + HORIZONTAL_PADDING;
|
qreal awidth = gridSize.cols * CardDimensions::WIDTH_F + CardDimensions::WIDTH_HALF_F + HORIZONTAL_PADDING;
|
||||||
qreal aheight = (gridSize.rows * CARD_HEIGHT) / 3 + CARD_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 * CARD_WIDTH;
|
qreal x = col * CardDimensions::WIDTH_F;
|
||||||
qreal y = row * CARD_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) * CARD_WIDTH;
|
qreal x = (i / rows) * CardDimensions::WIDTH_F;
|
||||||
qreal y = (i % rows) * CARD_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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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) * (CARD_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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -574,4 +574,4 @@ void ZoneViewWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->pos().y() <= 0) {
|
if (event->pos().y() <= 0) {
|
||||||
expandWindow();
|
expandWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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)CARD_HEIGHT / (qreal)CARD_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();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue