From 5978aedc30542c5a1402d3061d4c611524e1a5ef Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Wed, 12 Feb 2020 11:52:05 -0600 Subject: [PATCH] Fix bug where dragging the metatile selector would visually extend beyond map boundary --- src/ui/cursortilerect.cpp | 2 ++ src/ui/mappixmapitem.cpp | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ui/cursortilerect.cpp b/src/ui/cursortilerect.cpp index b74da4d2..e0c6c9d2 100644 --- a/src/ui/cursortilerect.cpp +++ b/src/ui/cursortilerect.cpp @@ -100,6 +100,8 @@ void CursorTileRect::updateLocation(int coordX, int coordY) } } + coordX = qMax(coordX, 0); + coordY = qMax(coordY, 0); this->setX(coordX * 16); this->setY(coordY * 16); this->setVisible(*this->enabled && this->visible); diff --git a/src/ui/mappixmapitem.cpp b/src/ui/mappixmapitem.cpp index de3de4f6..103a15c5 100644 --- a/src/ui/mappixmapitem.cpp +++ b/src/ui/mappixmapitem.cpp @@ -226,11 +226,10 @@ void MapPixmapItem::updateMetatileSelection(QGraphicsSceneMouseEvent *event) { Block *block = map->getBlock(x, y); this->metatileSelector->selectFromMap(block->tile, block->collision, block->elevation); } else if (event->type() == QEvent::GraphicsSceneMouseMove) { - QPoint pos = QPoint(x, y); int x1 = selection_origin.x(); int y1 = selection_origin.y(); - int x2 = pos.x(); - int y2 = pos.y(); + int x2 = x; + int y2 = y; if (x1 > x2) SWAP(x1, x2); if (y1 > y2) SWAP(y1, y2); selection.clear();