TableZone is the grid based rect where CardItems may be placed.
More...
#include <table_zone.h>
|
| | TableZone (TableZoneLogic *_logic, bool mirrored, QGraphicsItem *parent=nullptr) |
| QRectF | boundingRect () const override |
| void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override |
| void | toggleTapped () |
| void | handleDropEvent (const QList< CardDragItem * > &dragItems, CardZoneLogic *startZone, const QPoint &dropPoint) override |
| void | handleDropEventByGrid (const QList< CardDragItem * > &dragItems, CardZoneLogic *startZone, const QPoint &gridPoint) |
| CardItem * | getCardFromGrid (const QPoint &gridPoint) const |
| CardItem * | getCardFromCoords (const QPointF &point) const |
| QPointF | closestGridPoint (const QPointF &point) override |
| void | resizeToContents () |
| int | getMinimumWidth () const |
| void | setWidth (qreal _width) |
| qreal | getWidth () const |
| void | setActive (bool _active) |
| | SelectZone (CardZoneLogic *logic, QGraphicsItem *parent=nullptr) |
| | ~SelectZone () override |
| void | onCardAdded (CardItem *addedCard) override |
| | Called when a card is added to this zone. Default: reparents card to this item.
|
| void | escapeClipForHover (QGraphicsItem *card) |
| | Temporarily reparents a card from the clip container to this zone so hover scaling is visible beyond clip bounds. Safe no-op if no clip container exists. Coordinates are preserved (clip container is at (0,0) with no transform).
|
| void | restoreClipAfterHover (QGraphicsItem *card) |
| | Restores a hover-escaped card back to the clip container. Guards against zone transitions that already reparented the card.
|
| int | type () const override |
| | CardZone (CardZoneLogic *logic, QGraphicsItem *parent=nullptr) |
| void | retranslateUi () |
| CardZoneLogic * | getLogic () const |
| void | setMenu (QMenu *_menu, QAction *_doubleClickAction=0) |
| | AbstractGraphicsItem (QGraphicsItem *parent=nullptr) |
|
| static const int | TABLEROWS = 3 |
| static const int | MARGIN_LEFT = 20 |
| static const int | MARGIN_RIGHT = 15 |
| static const int | MARGIN_TOP = 10 |
| static const int | MARGIN_BOTTOM = 30 |
| static const int | PADDING_X = 35 |
| static const int | PADDING_Y = 30 |
| static const int | MIN_WIDTH = MARGIN_LEFT + (5 * CardDimensions::WIDTH) + MARGIN_RIGHT |
| static const int | STACKED_CARD_OFFSET_X = CardDimensions::WIDTH / 3 |
| static const int | STACKED_CARD_OFFSET_Y = PADDING_Y / 3 |
| static const int | BOX_LINE_WIDTH = 10 |
| static const QColor | BACKGROUND_COLOR = QColor(100, 100, 100) |
| static const QColor | FADE_MASK = QColor(0, 0, 0, 80) |
| static const QColor | GRADIENT_COLOR = QColor(255, 255, 255, 150) |
| static const QColor | GRADIENT_COLORLESS = QColor(255, 255, 255, 0) |
|
| enum | { Type = typeZone
} |
| StackLayoutParams | buildStackParams (qreal minOffset=0.0) const |
| | Builds StackLayoutParams from the current card list and zone geometry.
|
| int | calcDropIndexFromY (qreal dropY, qreal minOffset=0.0) const |
| | Computes the card index at a given y-coordinate within the zone's vertical layout. Returns 0 if the zone has no cards or the offset is zero.
|
| void | layoutCardsVertically (const StackLayoutParams ¶ms) |
| | Positions cards vertically with alternating left/right x-offsets.
|
| void | restoreStaleEscapedCards () |
| | Restores any cards that were hover-escaped but whose hover state was not properly cleaned up. Call at the start of reorganizeCards() in zones that use a clip container.
|
| void | setupClipContainer (std::optional< qreal > zValue=std::nullopt) |
| | Creates a clip container child item that clips card overflow to zone bounds. Cards entering this zone are reparented to this container by the onCardAdded override. Disables zone-level child clipping; clipping is delegated to the container.
|
| void | updateClipRect () |
| | Updates the clip container rect to match this zone's current boundingRect().
|
| void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) override |
| void | mousePressEvent (QGraphicsSceneMouseEvent *event) override |
| void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override |
| void | mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override |
| void | mousePressEvent (QGraphicsSceneMouseEvent *event) override |
| virtual void | reorganizeCards ()=0 |
| QMenu * | getMenu () const |
| void | paintNumberEllipse (int number, int radius, const QColor &color, int position, int count, QPainter *painter) |
| static ZoneLayout | computeZoneLayout (const StackLayoutParams ¶ms) |
| | Computes layout for a vertical card stack (effective offset and start position).
|
| QMenu * | menu |
| QAction * | doubleClickAction |
| static constexpr qreal | MIN_CARD_VISIBLE = 10.0 |
| | Minimum visible pixels of each card's top edge when stacking compresses offsets in tight zones.
|
TableZone is the grid based rect where CardItems may be placed.
- Todo
- Document this file.
It is the main play zone and can be customized with background images.
- Todo
- Refactor methods to make more readable, extract logic to private methods (especially reorganizeCards()).
◆ TableZone()
| TableZone::TableZone |
( |
TableZoneLogic * | _logic, |
|
|
bool | mirrored, |
|
|
QGraphicsItem * | parent = nullptr ) |
|
explicit |
Constructs TableZone.
- Parameters
-
| _p | the Player |
| parent | defaults to null |
◆ boundingRect()
| QRectF TableZone::boundingRect |
( |
| ) |
const |
|
nodiscardoverride |
- Returns
- a QRectF of the TableZone bounding box.
◆ clampValidTableRow()
| int TableZone::clampValidTableRow |
( |
const int | row | ) |
|
|
static |
◆ closestGridPoint()
| QPointF TableZone::closestGridPoint |
( |
const QPointF & | point | ) |
|
|
overridevirtual |
◆ computeCardStackWidths()
| void TableZone::computeCardStackWidths |
( |
| ) |
|
|
private |
◆ getCardFromCoords()
| CardItem * TableZone::getCardFromCoords |
( |
const QPointF & | point | ) |
const |
|
nodiscard |
- Returns
- CardItem from coordinate location
◆ getCardFromGrid()
| CardItem * TableZone::getCardFromGrid |
( |
const QPoint & | gridPoint | ) |
const |
|
nodiscard |
◆ getCardStackMapKey()
| int TableZone::getCardStackMapKey |
( |
int | x, |
|
|
int | y ) const |
|
inlinenodiscardprivate |
◆ getMinimumWidth()
| int TableZone::getMinimumWidth |
( |
| ) |
const |
|
inlinenodiscard |
◆ getWidth()
| qreal TableZone::getWidth |
( |
| ) |
const |
|
inlinenodiscard |
◆ handleDropEvent()
| void TableZone::handleDropEvent |
( |
const QList< CardDragItem * > & | dragItems, |
|
|
CardZoneLogic * | startZone, |
|
|
const QPoint & | dropPoint ) |
|
overridevirtual |
See HandleDropEventByGrid
Implements CardZone.
◆ handleDropEventByGrid()
| void TableZone::handleDropEventByGrid |
( |
const QList< CardDragItem * > & | dragItems, |
|
|
CardZoneLogic * | startZone, |
|
|
const QPoint & | gridPoint ) |
Handles the placement of cards
◆ isInverted()
| bool TableZone::isInverted |
( |
| ) |
const |
|
nodiscardprivate |
◆ mapFromGrid()
| QPointF TableZone::mapFromGrid |
( |
QPoint | gridPoint | ) |
const |
|
nodiscardprivate |
◆ mapToGrid()
| QPoint TableZone::mapToGrid |
( |
const QPointF & | mapPoint | ) |
const |
|
nodiscardprivate |
◆ paint()
| void TableZone::paint |
( |
QPainter * | painter, |
|
|
const QStyleOptionGraphicsItem * | option, |
|
|
QWidget * | widget ) |
|
override |
◆ paintLandDivider()
| void TableZone::paintLandDivider |
( |
QPainter * | painter | ) |
|
|
private |
Render a division line for land placement
@painter QPainter object
◆ paintZoneOutline()
| void TableZone::paintZoneOutline |
( |
QPainter * | painter | ) |
|
|
private |
Render a soft outline around the edge of the TableZone.
- Parameters
-
◆ reorganizeCards
| void TableZone::reorganizeCards |
( |
| ) |
|
|
overrideslot |
◆ resizeToContents()
| void TableZone::resizeToContents |
( |
| ) |
|
Resizes the TableZone in case CardItems are within or outside of the TableZone constraints.
◆ setActive()
| void TableZone::setActive |
( |
bool | _active | ) |
|
|
inline |
◆ setMirrored
| void TableZone::setMirrored |
( |
bool | isMirrored | ) |
|
|
slot |
◆ setWidth()
| void TableZone::setWidth |
( |
qreal | _width | ) |
|
|
inline |
◆ sizeChanged
| void TableZone::sizeChanged |
( |
| ) |
|
|
signal |
◆ tableRowToGridY()
| int TableZone::tableRowToGridY |
( |
int | tableRow | ) |
|
|
static |
Converts a card's logical table row (0=creatures, 1=noncreatures, 2=lands) to the corresponding grid Y coordinate. Cards with tableRow > 2 (e.g., instants/sorceries) default to the noncreatures row.
◆ toggleTapped()
| void TableZone::toggleTapped |
( |
| ) |
|
Toggles the selected items as tapped.
◆ updateBg
| void TableZone::updateBg |
( |
| ) |
|
|
privateslot |
Loads in any found custom background and updates
◆ active
| bool TableZone::active = false |
|
private |
◆ BACKGROUND_COLOR
| const QColor TableZone::BACKGROUND_COLOR = QColor(100, 100, 100) |
|
staticprivate |
◆ backgroundPixelMap
| QPixmap TableZone::backgroundPixelMap |
|
private |
◆ BOX_LINE_WIDTH
| const int TableZone::BOX_LINE_WIDTH = 10 |
|
staticprivate |
◆ cardStackWidth
| QMap<int, int> TableZone::cardStackWidth |
|
private |
◆ currentMinimumWidth
| int TableZone::currentMinimumWidth |
|
private |
◆ FADE_MASK
| const QColor TableZone::FADE_MASK = QColor(0, 0, 0, 80) |
|
staticprivate |
◆ GRADIENT_COLOR
| const QColor TableZone::GRADIENT_COLOR = QColor(255, 255, 255, 150) |
|
staticprivate |
◆ GRADIENT_COLORLESS
| const QColor TableZone::GRADIENT_COLORLESS = QColor(255, 255, 255, 0) |
|
staticprivate |
◆ height
◆ MARGIN_BOTTOM
| const int TableZone::MARGIN_BOTTOM = 30 |
|
staticprivate |
◆ MARGIN_LEFT
| const int TableZone::MARGIN_LEFT = 20 |
|
staticprivate |
◆ MARGIN_RIGHT
| const int TableZone::MARGIN_RIGHT = 15 |
|
staticprivate |
◆ MARGIN_TOP
| const int TableZone::MARGIN_TOP = 10 |
|
staticprivate |
◆ MIN_WIDTH
◆ mirrored
| bool TableZone::mirrored = false |
|
private |
◆ PADDING_X
| const int TableZone::PADDING_X = 35 |
|
staticprivate |
◆ PADDING_Y
| const int TableZone::PADDING_Y = 30 |
|
staticprivate |
◆ STACKED_CARD_OFFSET_X
◆ STACKED_CARD_OFFSET_Y
| const int TableZone::STACKED_CARD_OFFSET_Y = PADDING_Y / 3 |
|
staticprivate |
◆ TABLEROWS
| const int TableZone::TABLEROWS = 3 |
|
staticprivate |
◆ width
The documentation for this class was generated from the following files: