diff -r 0f80a2e5e42b -r 1a9eac27698d src/ui/canvas.cpp --- a/src/ui/canvas.cpp Fri Feb 07 02:02:16 2020 +0200 +++ b/src/ui/canvas.cpp Fri Feb 07 23:59:06 2020 +0200 @@ -11,10 +11,39 @@ this->setMouseTracking(true); } +void Canvas::handleSelectionChange(const QSet& selectedIds, const QSet& deselectedIds) +{ + this->selection.subtract(deselectedIds); + this->selection.unite(selectedIds); + this->compiler->setSelectedObjects(this->selection); + this->update(); +} + void Canvas::mouseMoveEvent(QMouseEvent* event) { const ldraw::Id id = this->pick(event->pos()); this->newStatusText("Selected: %1"_q.arg(id.value)); - this->setHighlight(id); + this->highlighted = id; + this->totalMouseMove += (event->pos() - this->lastMousePosition).manhattanLength(); + this->lastMousePosition = event->pos(); PartRenderer::mouseMoveEvent(event); } + +void Canvas::mousePressEvent(QMouseEvent* event) +{ + this->totalMouseMove = 0; + this->lastMousePosition = event->pos(); + PartRenderer::mousePressEvent(event); +} + +void Canvas::mouseReleaseEvent(QMouseEvent* event) +{ + if (this->totalMouseMove < (2.0 / sqrt(2)) * 5.0) + { + this->selection = {this->highlighted}; + this->compiler->setSelectedObjects(this->selection); + emit selectionChanged(this->selection); + this->update(); + } + PartRenderer::mouseReleaseEvent(event); +}