mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 17:02:15 -07:00
track cards in rect so far and toggle isSelected on change
This commit is contained in:
parent
92cefe2a27
commit
8e9b111ae3
2 changed files with 13 additions and 1 deletions
|
|
@ -62,7 +62,17 @@ void SelectZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (card->getAttachedTo() && card->getAttachedTo()->getZone() != this) {
|
if (card->getAttachedTo() && card->getAttachedTo()->getZone() != this) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
card->setSelected(selectionRect.intersects(card->mapRectToParent(card->boundingRect())));
|
|
||||||
|
bool inRect = selectionRect.intersects(card->mapRectToParent(card->boundingRect()));
|
||||||
|
if (inRect && !cardsInSelectionRect.contains(card)) {
|
||||||
|
// selection has just expanded to cover the card
|
||||||
|
cardsInSelectionRect.insert(card);
|
||||||
|
card->setSelected(!card->isSelected());
|
||||||
|
} else if (!inRect && cardsInSelectionRect.contains(card)) {
|
||||||
|
// selection has just shrunk to no longer cover the card
|
||||||
|
cardsInSelectionRect.remove(card);
|
||||||
|
card->setSelected(!card->isSelected());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static_cast<GameScene *>(scene())->resizeRubberBand(
|
static_cast<GameScene *>(scene())->resizeRubberBand(
|
||||||
deviceTransform(static_cast<GameScene *>(scene())->getViewportTransform()).map(pos));
|
deviceTransform(static_cast<GameScene *>(scene())->getViewportTransform()).map(pos));
|
||||||
|
|
@ -85,6 +95,7 @@ void SelectZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
void SelectZone::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void SelectZone::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
selectionOrigin = QPoint();
|
selectionOrigin = QPoint();
|
||||||
|
cardsInSelectionRect.clear();
|
||||||
static_cast<GameScene *>(scene())->stopRubberBand();
|
static_cast<GameScene *>(scene())->stopRubberBand();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ class SelectZone : public CardZone
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QPointF selectionOrigin;
|
QPointF selectionOrigin;
|
||||||
|
QSet<CardItem *> cardsInSelectionRect;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue