mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-26 08:33:54 -07:00
Display visual feedback of where cards will go (#5737)
This is part of the code from #4974, including an improved drag-and-drop API and its use to display visual feedback of card destination on the board. It does not include the improved logic for pushing cards around as I still need to figure out edge cases there - the logic for choosing where cards go is not changed, so some of the artifacts described in #4817 and #4975 (particularly around multi-card) are still present.
This commit is contained in:
parent
bd28e04635
commit
a7641a571f
6 changed files with 230 additions and 100 deletions
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
#include "../game_scene.h"
|
#include "../game_scene.h"
|
||||||
#include "../zones/card_zone.h"
|
#include "../zones/card_zone.h"
|
||||||
#include "../zones/table_zone.h"
|
|
||||||
#include "../zones/view_zone.h"
|
|
||||||
#include "card_item.h"
|
#include "card_item.h"
|
||||||
|
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
|
|
@ -15,104 +13,112 @@ CardDragItem::CardDragItem(CardItem *_item,
|
||||||
const QPointF &_hotSpot,
|
const QPointF &_hotSpot,
|
||||||
bool _faceDown,
|
bool _faceDown,
|
||||||
AbstractCardDragItem *parentDrag)
|
AbstractCardDragItem *parentDrag)
|
||||||
: AbstractCardDragItem(_item, _hotSpot, parentDrag), id(_id), faceDown(_faceDown), occupied(false), currentZone(0)
|
: AbstractCardDragItem(_item, _hotSpot, parentDrag), id(_id), faceDown(_faceDown), currentZone(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CardDragItem::~CardDragItem()
|
||||||
|
{
|
||||||
|
if (currentZone) {
|
||||||
|
currentZone->dragLeave(this);
|
||||||
|
currentZone = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CardDragItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void CardDragItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
AbstractCardDragItem::paint(painter, option, widget);
|
AbstractCardDragItem::paint(painter, option, widget);
|
||||||
|
|
||||||
if (occupied)
|
if (!isValid) {
|
||||||
painter->fillPath(shape(), QColor(200, 0, 0, 100));
|
painter->fillPath(shape(), QColor(200, 0, 0, 100));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardDragItem::updatePosition(const QPointF &cursorScenePos)
|
void CardDragItem::updatePosition(const QPointF &cursorScenePos)
|
||||||
{
|
{
|
||||||
|
QPointF topLeftScenePos = cursorScenePos - hotSpot;
|
||||||
|
QPointF centerScenePos = topLeftScenePos + QPointF(CARD_WIDTH_HALF, CARD_HEIGHT_HALF);
|
||||||
|
|
||||||
|
// Use center of the card for intersection.
|
||||||
QList<QGraphicsItem *> colliding =
|
QList<QGraphicsItem *> colliding =
|
||||||
scene()->items(cursorScenePos, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder,
|
scene()->items(centerScenePos, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder,
|
||||||
static_cast<GameScene *>(scene())->getViewTransform());
|
static_cast<GameScene *>(scene())->getViewTransform());
|
||||||
|
|
||||||
CardZone *cardZone = 0;
|
CardZone *cardZone = nullptr;
|
||||||
ZoneViewZone *zoneViewZone = 0;
|
for (auto *item : colliding) {
|
||||||
for (int i = colliding.size() - 1; i >= 0; i--) {
|
cardZone = qgraphicsitem_cast<CardZone *>(item);
|
||||||
CardZone *temp = qgraphicsitem_cast<CardZone *>(colliding.at(i));
|
|
||||||
if (!cardZone)
|
|
||||||
cardZone = temp;
|
|
||||||
if (!zoneViewZone)
|
|
||||||
zoneViewZone = qobject_cast<ZoneViewZone *>(temp);
|
|
||||||
}
|
|
||||||
CardZone *cursorZone = 0;
|
|
||||||
if (zoneViewZone)
|
|
||||||
cursorZone = zoneViewZone;
|
|
||||||
else if (cardZone)
|
|
||||||
cursorZone = cardZone;
|
|
||||||
if (!cursorZone)
|
|
||||||
return;
|
|
||||||
currentZone = cursorZone;
|
|
||||||
|
|
||||||
QPointF zonePos = currentZone->scenePos();
|
if (cardZone) {
|
||||||
QPointF cursorPosInZone = cursorScenePos - zonePos;
|
break;
|
||||||
|
|
||||||
// If we are on a Table, we center the card around the cursor, because we
|
|
||||||
// snap it into place and no longer see it being dragged.
|
|
||||||
//
|
|
||||||
// For other zones (where we do display the card under the cursor), we use
|
|
||||||
// the hotspot to feel like the card was dragged at the corresponding
|
|
||||||
// position.
|
|
||||||
TableZone *tableZone = qobject_cast<TableZone *>(cursorZone);
|
|
||||||
QPointF closestGridPoint;
|
|
||||||
if (tableZone)
|
|
||||||
closestGridPoint = tableZone->closestGridPoint(cursorPosInZone);
|
|
||||||
else
|
|
||||||
closestGridPoint = cursorPosInZone - hotSpot;
|
|
||||||
|
|
||||||
QPointF newPos = zonePos + closestGridPoint;
|
|
||||||
|
|
||||||
if (newPos != pos()) {
|
|
||||||
for (int i = 0; i < childDrags.size(); i++)
|
|
||||||
childDrags[i]->setPos(newPos + childDrags[i]->getHotSpot());
|
|
||||||
setPos(newPos);
|
|
||||||
|
|
||||||
bool newOccupied = false;
|
|
||||||
TableZone *table = qobject_cast<TableZone *>(cursorZone);
|
|
||||||
if (table)
|
|
||||||
if (table->getCardFromCoords(closestGridPoint))
|
|
||||||
newOccupied = true;
|
|
||||||
if (newOccupied != occupied) {
|
|
||||||
occupied = newOccupied;
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cardZone != currentZone) {
|
||||||
|
if (currentZone) {
|
||||||
|
currentZone->dragLeave(this);
|
||||||
|
currentZone = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cardZone && cardZone->dragEnter(this, centerScenePos - cardZone->scenePos())) {
|
||||||
|
setValid(true);
|
||||||
|
currentZone = cardZone;
|
||||||
|
} else {
|
||||||
|
setValid(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentZone) {
|
||||||
|
currentZone->dragMove(this, centerScenePos - currentZone->scenePos());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topLeftScenePos != pos()) {
|
||||||
|
for (int i = 0; i < childDrags.size(); i++)
|
||||||
|
childDrags[i]->setPos(topLeftScenePos + childDrags[i]->getHotSpot());
|
||||||
|
setPos(topLeftScenePos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
setCursor(Qt::OpenHandCursor);
|
setCursor(Qt::OpenHandCursor);
|
||||||
QGraphicsScene *sc = scene();
|
QGraphicsScene *sc = scene();
|
||||||
QPointF sp = pos();
|
|
||||||
sc->removeItem(this);
|
sc->removeItem(this);
|
||||||
|
|
||||||
QList<CardDragItem *> dragItemList;
|
for (auto *childDrag : childDrags) {
|
||||||
CardZone *startZone = static_cast<CardItem *>(item)->getZone();
|
sc->removeItem(childDrag);
|
||||||
if (currentZone && !(static_cast<CardItem *>(item)->getAttachedTo() && (startZone == currentZone))) {
|
|
||||||
if (!occupied) {
|
|
||||||
dragItemList.append(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < childDrags.size(); i++) {
|
|
||||||
CardDragItem *c = static_cast<CardDragItem *>(childDrags[i]);
|
|
||||||
if (!occupied && !(static_cast<CardItem *>(c->item)->getAttachedTo() && (startZone == currentZone)) &&
|
|
||||||
!c->occupied) {
|
|
||||||
dragItemList.append(c);
|
|
||||||
}
|
|
||||||
sc->removeItem(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentZone) {
|
if (currentZone) {
|
||||||
currentZone->handleDropEvent(dragItemList, startZone, (sp - currentZone->scenePos()).toPoint());
|
QPointF cursorScenePos = event->scenePos();
|
||||||
|
QPointF topLeftScenePos = cursorScenePos - hotSpot;
|
||||||
|
QPointF centerScenePos = topLeftScenePos + QPointF(CARD_WIDTH_HALF, CARD_HEIGHT_HALF);
|
||||||
|
currentZone->dragAccept(this, centerScenePos - currentZone->scenePos());
|
||||||
|
currentZone = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
event->accept();
|
static_cast<CardItem *>(item)->deleteDragItem();
|
||||||
|
AbstractCardDragItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
CardZone *CardDragItem::getStartZone() const
|
||||||
|
{
|
||||||
|
return static_cast<CardItem *>(item)->getZone();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<CardDragItem *> CardDragItem::getValidItems()
|
||||||
|
{
|
||||||
|
QList<CardDragItem *> dragItemList;
|
||||||
|
CardZone *startZone = getStartZone();
|
||||||
|
if (!(static_cast<CardItem *>(item)->getAttachedTo() && startZone == currentZone)) {
|
||||||
|
dragItemList.append(this);
|
||||||
|
|
||||||
|
for (int i = 0; i < childDrags.size(); i++) {
|
||||||
|
CardDragItem *c = static_cast<CardDragItem *>(childDrags[i]);
|
||||||
|
if (!(static_cast<CardItem *>(c->item)->getAttachedTo() && startZone == currentZone)) {
|
||||||
|
dragItemList.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dragItemList;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class CardDragItem : public AbstractCardDragItem
|
||||||
private:
|
private:
|
||||||
int id;
|
int id;
|
||||||
bool faceDown;
|
bool faceDown;
|
||||||
bool occupied;
|
bool isValid = true;
|
||||||
CardZone *currentZone;
|
CardZone *currentZone;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -20,6 +20,7 @@ public:
|
||||||
const QPointF &_hotSpot,
|
const QPointF &_hotSpot,
|
||||||
bool _faceDown,
|
bool _faceDown,
|
||||||
AbstractCardDragItem *parentDrag = 0);
|
AbstractCardDragItem *parentDrag = 0);
|
||||||
|
virtual ~CardDragItem();
|
||||||
int getId() const
|
int getId() const
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
|
|
@ -31,6 +32,18 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
void updatePosition(const QPointF &cursorScenePos) override;
|
void updatePosition(const QPointF &cursorScenePos) override;
|
||||||
|
|
||||||
|
void setValid(bool _valid)
|
||||||
|
{
|
||||||
|
if (_valid != isValid) {
|
||||||
|
isValid = _valid;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CardZone *getStartZone() const;
|
||||||
|
|
||||||
|
QList<CardDragItem *> getValidItems();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
#include "card_zone.h"
|
#include "card_zone.h"
|
||||||
|
|
||||||
#include "../cards/card_database_manager.h"
|
#include "../cards/card_database_manager.h"
|
||||||
|
#include "../cards/card_drag_item.h"
|
||||||
#include "../cards/card_item.h"
|
#include "../cards/card_item.h"
|
||||||
#include "../player/player.h"
|
#include "../player/player.h"
|
||||||
#include "pb/command_move_card.pb.h"
|
#include "pb/command_move_card.pb.h"
|
||||||
#include "pb/serverinfo_user.pb.h"
|
|
||||||
#include "pile_zone.h"
|
|
||||||
#include "view_zone.h"
|
#include "view_zone.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
@ -233,7 +232,26 @@ void CardZone::moveAllToZone()
|
||||||
player->sendGameCommand(cmd);
|
player->sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF CardZone::closestGridPoint(const QPointF &point)
|
bool CardZone::dragEnter(CardDragItem *dragItem, const QPointF &pos)
|
||||||
{
|
{
|
||||||
return point;
|
Q_UNUSED(dragItem);
|
||||||
}
|
Q_UNUSED(pos);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardZone::dragMove(CardDragItem *dragItem, const QPointF &pos)
|
||||||
|
{
|
||||||
|
Q_UNUSED(dragItem);
|
||||||
|
Q_UNUSED(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardZone::dragAccept(CardDragItem *dragItem, const QPointF &pos)
|
||||||
|
{
|
||||||
|
handleDropEvent(dragItem->getValidItems(), dragItem->getStartZone(), pos.toPoint());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardZone::dragLeave(CardDragItem *dragItem)
|
||||||
|
{
|
||||||
|
Q_UNUSED(dragItem);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,26 @@ public:
|
||||||
{
|
{
|
||||||
return Type;
|
return Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called when a card is dragged on top of the zone.
|
||||||
|
|
||||||
|
Return `true` to accept the drag, `false` otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool dragEnter(CardDragItem *dragItem, const QPointF &pos);
|
||||||
|
|
||||||
|
/* Called when a card that has been accepted by `dragEnter` is moved over
|
||||||
|
the zone.
|
||||||
|
*/
|
||||||
|
virtual void dragMove(CardDragItem *dragItem, const QPointF &pos);
|
||||||
|
|
||||||
|
/* Called when a card that has been accepted by `dragEnter` is dropped onto
|
||||||
|
the zone. */
|
||||||
|
virtual void dragAccept(CardDragItem *dragItem, const QPointF &pos);
|
||||||
|
|
||||||
|
/* Called when a card that has been accepted by `dragEnter` leaves the zone.
|
||||||
|
*/
|
||||||
|
virtual void dragLeave(CardDragItem *dragItem);
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
handleDropEvent(const QList<CardDragItem *> &dragItem, CardZone *startZone, const QPoint &dropPoint) = 0;
|
handleDropEvent(const QList<CardDragItem *> &dragItem, CardZone *startZone, const QPoint &dropPoint) = 0;
|
||||||
CardZone(Player *_player,
|
CardZone(Player *_player,
|
||||||
|
|
@ -114,7 +134,6 @@ public:
|
||||||
return views;
|
return views;
|
||||||
}
|
}
|
||||||
virtual void reorganizeCards() = 0;
|
virtual void reorganizeCards() = 0;
|
||||||
virtual QPointF closestGridPoint(const QPointF &point);
|
|
||||||
bool getIsView() const
|
bool getIsView() const
|
||||||
{
|
{
|
||||||
return isView;
|
return isView;
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,66 @@ void TableZone::addCardImpl(CardItem *card, int _x, int _y)
|
||||||
card->update();
|
card->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TableZone::dragEnter(CardDragItem *dragItem, const QPointF &pos)
|
||||||
|
{
|
||||||
|
if (!SelectZone::dragEnter(dragItem, pos)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_feedbackItem) {
|
||||||
|
scene()->removeItem(m_feedbackItem);
|
||||||
|
delete m_feedbackItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_feedbackItem = new QGraphicsPathItem(dragItem->getItem()->shape(), this);
|
||||||
|
m_feedbackItem->setBrush(QColor(176, 196, 222)); // lightsteelblue
|
||||||
|
m_feedbackItem->setPen(QColor(119, 136, 153)); // lightslategray
|
||||||
|
m_feedbackItem->setZValue(2000000005);
|
||||||
|
m_feedbackItem->setTransform(dragItem->getItem()->transform());
|
||||||
|
updateFeedback(dragItem, pos);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableZone::dragMove(CardDragItem *dragItem, const QPointF &pos)
|
||||||
|
{
|
||||||
|
if (m_feedbackItem) {
|
||||||
|
updateFeedback(dragItem, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectZone::dragMove(dragItem, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableZone::dragAccept(CardDragItem *dragItem, const QPointF &pos)
|
||||||
|
{
|
||||||
|
SelectZone::dragAccept(dragItem, pos);
|
||||||
|
|
||||||
|
if (m_feedbackItem) {
|
||||||
|
scene()->removeItem(m_feedbackItem);
|
||||||
|
delete m_feedbackItem;
|
||||||
|
m_feedbackItem = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableZone::dragLeave(CardDragItem *dragItem)
|
||||||
|
{
|
||||||
|
SelectZone::dragLeave(dragItem);
|
||||||
|
|
||||||
|
if (m_feedbackItem) {
|
||||||
|
scene()->removeItem(m_feedbackItem);
|
||||||
|
delete m_feedbackItem;
|
||||||
|
m_feedbackItem = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TableZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint)
|
void TableZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint)
|
||||||
{
|
{
|
||||||
handleDropEventByGrid(dragItems, startZone, mapToGrid(dropPoint));
|
Q_UNUSED(dropPoint);
|
||||||
|
|
||||||
|
// Always use the position of the feedback item for consistency
|
||||||
|
if (m_feedbackItem && m_feedbackItem->isVisible()) {
|
||||||
|
handleDropEventByGrid(dragItems, startZone, mapToGrid(m_feedbackItem->pos()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableZone::handleDropEventByGrid(const QList<CardDragItem *> &dragItems,
|
void TableZone::handleDropEventByGrid(const QList<CardDragItem *> &dragItems,
|
||||||
|
|
@ -260,12 +317,6 @@ CardItem *TableZone::getCardFromGrid(const QPoint &gridPoint) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardItem *TableZone::getCardFromCoords(const QPointF &point) const
|
|
||||||
{
|
|
||||||
QPoint gridPoint = mapToGrid(point);
|
|
||||||
return getCardFromGrid(gridPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TableZone::computeCardStackWidths()
|
void TableZone::computeCardStackWidths()
|
||||||
{
|
{
|
||||||
// Each card stack is three grid points worth of card locations.
|
// Each card stack is three grid points worth of card locations.
|
||||||
|
|
@ -366,18 +417,36 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
||||||
int xDiff = x - xStack;
|
int xDiff = x - xStack;
|
||||||
int gridPointX = stackCol * 3 + qMin(xDiff / STACKED_CARD_OFFSET_X, 2);
|
int gridPointX = stackCol * 3 + qMin(xDiff / STACKED_CARD_OFFSET_X, 2);
|
||||||
|
|
||||||
return QPoint(gridPointX, gridPointY);
|
return QPoint((gridPointX / 3) * 3, gridPointY);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF TableZone::closestGridPoint(const QPointF &point)
|
void TableZone::updateFeedback(CardDragItem *dragItem, const QPointF &point)
|
||||||
{
|
{
|
||||||
QPoint gridPoint = mapToGrid(point);
|
QPoint gridPoint = mapToGrid(point);
|
||||||
gridPoint.setX((gridPoint.x() / 3) * 3);
|
|
||||||
if (getCardFromGrid(gridPoint))
|
for (int i = 0; i < 3; ++i) {
|
||||||
gridPoint.setX(gridPoint.x() + 1);
|
if (CardItem *existingCard = getCardFromGrid(gridPoint)) {
|
||||||
if (getCardFromGrid(gridPoint))
|
if (existingCard == dragItem->getItem()) {
|
||||||
gridPoint.setX(gridPoint.x() + 1);
|
// Dropping the card onto its existing position is a no-op, and
|
||||||
return mapFromGrid(gridPoint);
|
// we don't want to display the feedback item, but we don't want
|
||||||
|
// to display an invalid state either, because that'd be
|
||||||
|
// confusing.
|
||||||
|
dragItem->setValid(true);
|
||||||
|
m_feedbackItem->hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gridPoint.setX(gridPoint.x() + 1);
|
||||||
|
} else {
|
||||||
|
dragItem->setValid(true);
|
||||||
|
m_feedbackItem->show();
|
||||||
|
m_feedbackItem->setPos(mapFromGrid(gridPoint));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dragItem->setValid(false);
|
||||||
|
m_feedbackItem->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TableZone::clampValidTableRow(const int row)
|
int TableZone::clampValidTableRow(const int row)
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,8 @@ private:
|
||||||
*/
|
*/
|
||||||
bool active;
|
bool active;
|
||||||
|
|
||||||
|
QGraphicsPathItem *m_feedbackItem = nullptr;
|
||||||
|
|
||||||
bool isInverted() const;
|
bool isInverted() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
@ -118,6 +120,14 @@ public:
|
||||||
*/
|
*/
|
||||||
void toggleTapped();
|
void toggleTapped();
|
||||||
|
|
||||||
|
bool dragEnter(CardDragItem *dragItem, const QPointF &pos) override;
|
||||||
|
|
||||||
|
void dragMove(CardDragItem *dragItem, const QPointF &pos) override;
|
||||||
|
|
||||||
|
void dragAccept(CardDragItem *dragItem, const QPointF &pos) override;
|
||||||
|
|
||||||
|
void dragLeave(CardDragItem *dragItem) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
See HandleDropEventByGrid
|
See HandleDropEventByGrid
|
||||||
*/
|
*/
|
||||||
|
|
@ -133,13 +143,6 @@ public:
|
||||||
*/
|
*/
|
||||||
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
||||||
|
|
||||||
/**
|
|
||||||
@return CardItem from coordinate location
|
|
||||||
*/
|
|
||||||
CardItem *getCardFromCoords(const QPointF &point) const;
|
|
||||||
|
|
||||||
QPointF closestGridPoint(const QPointF &point) override;
|
|
||||||
|
|
||||||
static int clampValidTableRow(const int row);
|
static int clampValidTableRow(const int row);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -184,6 +187,8 @@ private:
|
||||||
void paintZoneOutline(QPainter *painter);
|
void paintZoneOutline(QPainter *painter);
|
||||||
void paintLandDivider(QPainter *painter);
|
void paintLandDivider(QPainter *painter);
|
||||||
|
|
||||||
|
void updateFeedback(CardDragItem *dragItem, const QPointF &point);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Calculates card stack widths so mapping functions work properly
|
Calculates card stack widths so mapping functions work properly
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue