Refactor/z value constants (#6651)

* feat(z-values): add centralized Z-value constants infrastructure

Magic numbers scattered across the codebase make Z-value layering
hard to understand and maintain. Centralizing them provides:
- Self-documenting layer hierarchy
- Validation utilities for development
- Single source of truth for Z-value ranges

Two-tier header design:
- z_value_layer_manager.h: Foundation with constants and validation
- z_values.h: User-facing namespace with semantic constants

* refactor(z-values): replace magic Z-value numbers with ZValues constants

Magic numbers like 2000000007 are impossible to understand without
context. Named constants (ZValues::DRAG_ITEM) are self-documenting.

This intentionally renumbers overlay Z-values to use a cleaner offset
sequence. The relative stacking order is preserved, which is what
matters for correct rendering.

Each consumer now includes z_values.h and uses semantic constants
instead of magic numbers.

* refactor(z-values): removed redundant inline with contexpr, Updated doc, magic numbers removed from TableZone.
This commit is contained in:
DawnFire42 2026-03-05 14:47:14 -05:00 committed by GitHub
parent 1bcea27a44
commit 04f06206b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 234 additions and 10 deletions

View file

@ -1,6 +1,7 @@
#include "abstract_card_drag_item.h"
#include "../../client/settings/cache_settings.h"
#include "../z_values.h"
#include <QCursor>
#include <QDebug>
@ -18,13 +19,13 @@ AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
{
if (parentDrag) {
parentDrag->addChildDrag(this);
setZValue(2000000007 + hotSpot.x() * 1000000 + hotSpot.y() * 1000 + 1000);
setZValue(ZValues::childDragZValue(hotSpot.x(), hotSpot.y()));
connect(parentDrag, &QObject::destroyed, this, &AbstractCardDragItem::deleteLater);
} else {
hotSpot = QPointF{qBound(0.0, hotSpot.x(), static_cast<qreal>(CARD_WIDTH - 1)),
qBound(0.0, hotSpot.y(), static_cast<qreal>(CARD_HEIGHT - 1))};
setCursor(Qt::ClosedHandCursor);
setZValue(2000000007);
setZValue(ZValues::DRAG_ITEM);
}
if (item->getTapped())
setTransform(QTransform()