summaryrefslogtreecommitdiffstats
path: root/src/widget
diff options
context:
space:
mode:
authorSwiftb0y <12380386+Swiftb0y@users.noreply.github.com>2021-01-03 17:04:16 +0100
committerSwiftb0y <12380386+Swiftb0y@users.noreply.github.com>2021-01-03 17:04:16 +0100
commitd5356e3d12d8d1ccd254be784cef1694f0c656e8 (patch)
tree4729c29183771e952f8992a7beff06f38cfe0835 /src/widget
parentb3d5c8f62f7ac31f908716ef5182c4c1e858135d (diff)
fix KnobEventHandler when used on touchscreens
Diffstat (limited to 'src/widget')
-rw-r--r--src/widget/knobeventhandler.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widget/knobeventhandler.h b/src/widget/knobeventhandler.h
index f06fbc26ce..5ab63c85df 100644
--- a/src/widget/knobeventhandler.h
+++ b/src/widget/knobeventhandler.h
@@ -22,13 +22,13 @@ class KnobEventHandler {
double valueFromMouseEvent(T* pWidget, QMouseEvent* e) {
QPoint cur(e->globalPos());
- QPoint diff(cur - m_startPos);
+ QPoint diff(cur - m_prevPos);
double dist = sqrt(static_cast<double>(diff.x() * diff.x() + diff.y() * diff.y()));
bool y_dominant = abs(diff.y()) > abs(diff.x());
- // if y is dominant, then thread an increase in dy as negative (y is
+ // if y is dominant, then treat 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.
+ // decreased, then treat it as negative.
if ((y_dominant && diff.y() > 0) || (!y_dominant && diff.x() < 0)) {
dist = -dist;
}
@@ -44,10 +44,10 @@ class KnobEventHandler {
void mouseMoveEvent(T* pWidget, QMouseEvent* e) {
if (!m_bRightButtonPressed) {
- QCursor::setPos(m_startPos);
double value = valueFromMouseEvent(pWidget, e);
pWidget->setControlParameterDown(value);
pWidget->inputActivity();
+ m_prevPos = e->globalPos();
}
}
@@ -60,6 +60,7 @@ class KnobEventHandler {
case Qt::LeftButton:
case Qt::MiddleButton:
m_startPos = e->globalPos();
+ m_prevPos = m_startPos;
// Somehow using Qt::BlankCursor does not work on Windows
// https://mixxx.org/forums/viewtopic.php?p=40298#p40298
QApplication::setOverrideCursor(m_blankCursor);
@@ -107,5 +108,6 @@ class KnobEventHandler {
// Starting point when left mouse button is pressed
QPoint m_startPos;
+ QPoint m_prevPos;
QCursor m_blankCursor;
};