# HG changeset patch # User Santeri Piippo # Date 1404513881 -10800 # Node ID 7dd8f19159f7df20ce361b54409e6e8ad1b623b2 # Parent 82469b40567e09bb5cade7d777607ee69b892ce5 - and now it works fine too diff -r 82469b40567e -r 7dd8f19159f7 src/editmodes/magicwandmode.cc --- a/src/editmodes/magicwandmode.cc Sat Jul 05 01:17:48 2014 +0300 +++ b/src/editmodes/magicwandmode.cc Sat Jul 05 01:44:41 2014 +0300 @@ -198,7 +198,7 @@ if (Super::mouseReleased (data)) return true; - if (data.releasedButtons & Qt::LeftButton) + if (data.releasedButtons & Qt::LeftButton && not data.mouseMoved) { MagicType wandtype = MagicWandMode::Set; diff -r 82469b40567e -r 7dd8f19159f7 src/editmodes/selectmode.cc --- a/src/editmodes/selectmode.cc Sat Jul 05 01:17:48 2014 +0300 +++ b/src/editmodes/selectmode.cc Sat Jul 05 01:44:41 2014 +0300 @@ -6,18 +6,18 @@ #include "../glRenderer.h" SelectMode::SelectMode (GLRenderer* renderer) : - Super (renderer) {} + Super (renderer), + _rangepick (false) {} EditModeType SelectMode::type() const { return EditModeType::Select; } - void SelectMode::render (QPainter& painter) const { // If we're range-picking, draw a rectangle encompassing the selection area. - if (_rangepick && not renderer()->mouseHasMoved()) + if (_rangepick) { int x0 = _rangeStart.x(), y0 = _rangeStart.y(), @@ -53,9 +53,17 @@ int const my = data.ev->y(); if (not _rangepick) - area = QRect (mx, my, mx + 1, my + 1); + { + area = QRect (mx, my, 1, 1); + } else - area = QRect (_rangeStart.x(), _rangeStart.y(), mx, my); + { + int const x = min (_rangeStart.x(), mx); + int const y = min (_rangeStart.y(), my); + int const width = abs (_rangeStart.x() - mx); + int const height = abs (_rangeStart.y() - my); + area = QRect (x, y, width, height); + } renderer()->pick (area, _addpick); } @@ -105,7 +113,7 @@ return false; } -bool SelectMode::mouseMoved (QMouseEvent*) +bool SelectMode::mouseMoved (QMouseEvent* ev) { - return not _rangepick; + return _rangepick; } diff -r 82469b40567e -r 7dd8f19159f7 src/glRenderer.cc --- a/src/glRenderer.cc Sat Jul 05 01:17:48 2014 +0300 +++ b/src/glRenderer.cc Sat Jul 05 01:44:41 2014 +0300 @@ -778,13 +778,13 @@ // void GLRenderer::mouseMoveEvent (QMouseEvent* ev) { + int dx = ev->x() - m_mousePosition.x(); + int dy = ev->y() - m_mousePosition.y(); + m_totalmove += abs (dx) + abs (dy); + setCameraMoving (false); + if (not m_editmode->mouseMoved (ev)) { - int dx = ev->x() - m_mousePosition.x(); - int dy = ev->y() - m_mousePosition.y(); - m_totalmove += abs (dx) + abs (dy); - setCameraMoving (false); - const bool left = ev->buttons() & Qt::LeftButton, mid = ev->buttons() & Qt::MidButton, shift = ev->modifiers() & Qt::ShiftModifier; @@ -909,8 +909,8 @@ int x0 = range.left(); int y0 = range.top(); - int x1 = range.right(); - int y1 = range.bottom(); + int x1 = x0 + range.width(); + int y1 = y0 + range.height(); // Clamp the values to ensure they're within bounds x0 = max (0, x0); @@ -954,7 +954,7 @@ // If this is an additive single pick and the object is currently selected, // we remove it from selection instead. - if (range.isNull() && additive) + if (additive) { if (obj->isSelected()) { @@ -1603,7 +1603,7 @@ bool GLRenderer::mouseHasMoved() const { - return m_totalmove < 10; + return m_totalmove >= 10; } QPoint const& GLRenderer::mousePosition() const