=== modified file 'mixxx/src/widget/wknob.cpp' --- mixxx/src/widget/wknob.cpp 2010-11-01 05:12:23 +0000 +++ mixxx/src/widget/wknob.cpp 2011-05-01 07:45:52 +0000 @@ -116,8 +116,21 @@ void WKnob::mouseMoveEvent(QMouseEvent * e) { if (!m_bRightButtonPressed) { - m_fValue += (m_dStartValue-e->y()); - m_dStartValue = e->y(); + QPoint cur(e->globalPos()); + QPoint diff(cur - m_startPos); + double dist = sqrt(diff.x() * diff.x() + diff.y() * diff.y()); + bool y_dominant = fabs(diff.y()) > fabs(diff.x()); + + // if y is dominant, then thread an increase in dy as negative (y is + // pointed downward). Otherwise, if y is not dominant and x has + // decreased, then thread it as negative. + if ((y_dominant && diff.y() > 0) || (!y_dominant && diff.x() < 0)) { + dist = -dist; + } + + m_fValue += dist; + QCursor::setPos(m_startPos); + if (m_fValue>127.) m_fValue = 127.; else if (m_fValue<0.) @@ -129,29 +142,34 @@ void WKnob::mousePressEvent(QMouseEvent * e) { - m_dStartValue = e->y(); + m_startPos = e->globalPos(); if (e->button() == Qt::RightButton) { reset(); m_bRightButtonPressed = true; + } else { + QApplication::setOverrideCursor(Qt::BlankCursor); } } void WKnob::mouseReleaseEvent(QMouseEvent * e) { - if (e->button()==Qt::LeftButton) + if (e->button() == Qt::LeftButton) { + QCursor::setPos(m_startPos); + QApplication::restoreOverrideCursor(); emit(valueChangedLeftUp(m_fValue)); - else if (e->button()==Qt::RightButton) + } else if (e->button()==Qt::RightButton) { m_bRightButtonPressed = false; //emit(valueChangedRightUp(m_fValue)); + } update(); } void WKnob::wheelEvent(QWheelEvent *e) { - double wheelDirection = ((QWheelEvent *)e)->delta() / 120.; + double wheelDirection = ((QWheelEvent *)e)->delta() / 120.; double newValue = getValue() + (wheelDirection); this->updateValue(newValue); === modified file 'mixxx/src/widget/wknob.h' --- mixxx/src/widget/wknob.h 2010-07-11 05:46:55 +0000 +++ mixxx/src/widget/wknob.h 2011-05-01 07:49:31 +0000 @@ -57,8 +57,8 @@ QPixmap **m_pPixmaps; /** Associated background pixmap */ QPixmap *m_pPixmapBack; - /** Values used when pressing mouse */ - double m_dStartValue; + /** Starting point when left mouse button is pressed */ + QPoint m_startPos; /** True if disabled pixmaps is loaded */ bool m_bDisabledLoaded; };