Merge lp:~mixxxdevelopers/mixxx/features_knobs into lp:~mixxxdevelopers/mixxx/trunk

Proposed by William Good
Status: Merged
Merged at revision: 2784
Proposed branch: lp:~mixxxdevelopers/mixxx/features_knobs
Merge into: lp:~mixxxdevelopers/mixxx/trunk
Diff against target: 81 lines (+26/-8)
2 files modified
mixxx/src/widget/wknob.cpp (+24/-6)
mixxx/src/widget/wknob.h (+2/-2)
To merge this branch: bzr merge lp:~mixxxdevelopers/mixxx/features_knobs
Reviewer Review Type Date Requested Status
William Good Approve
Review via email: mp+59726@code.launchpad.net

Description of the change

Provides various enhancements to the knob widget.

1. Hides mouse cursor and captures mouse input on left-mouse-down on a wknob. Cursor re-appears where mouse-down occurred on mouse-up.
2. Knobs can now be turned by both vertical and horizontal (new) movement.

Both effectively fix bug 767409, and should give a much nicer interface to Mixxx controls represented by wknob.

To post a comment you must log in.
Revision history for this message
William Good (bkgood) wrote :

Confirmed working on Windows, jus tested successfully on osx, RJ and I both tested on Linux/X11. Merging as per https://bugs.launchpad.net/mixxx/+bug/767409/comments/11 .

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mixxx/src/widget/wknob.cpp'
2--- mixxx/src/widget/wknob.cpp 2010-11-01 05:12:23 +0000
3+++ mixxx/src/widget/wknob.cpp 2011-05-03 03:28:26 +0000
4@@ -116,8 +116,21 @@
5 void WKnob::mouseMoveEvent(QMouseEvent * e)
6 {
7 if (!m_bRightButtonPressed) {
8- m_fValue += (m_dStartValue-e->y());
9- m_dStartValue = e->y();
10+ QPoint cur(e->globalPos());
11+ QPoint diff(cur - m_startPos);
12+ double dist = sqrt(static_cast<double>(diff.x() * diff.x() + diff.y() * diff.y()));
13+ bool y_dominant = abs(diff.y()) > abs(diff.x());
14+
15+ // if y is dominant, then thread an increase in dy as negative (y is
16+ // pointed downward). Otherwise, if y is not dominant and x has
17+ // decreased, then thread it as negative.
18+ if ((y_dominant && diff.y() > 0) || (!y_dominant && diff.x() < 0)) {
19+ dist = -dist;
20+ }
21+
22+ m_fValue += dist;
23+ QCursor::setPos(m_startPos);
24+
25 if (m_fValue>127.)
26 m_fValue = 127.;
27 else if (m_fValue<0.)
28@@ -129,29 +142,34 @@
29
30 void WKnob::mousePressEvent(QMouseEvent * e)
31 {
32- m_dStartValue = e->y();
33+ m_startPos = e->globalPos();
34
35 if (e->button() == Qt::RightButton)
36 {
37 reset();
38 m_bRightButtonPressed = true;
39+ } else {
40+ QApplication::setOverrideCursor(Qt::BlankCursor);
41 }
42 }
43
44 void WKnob::mouseReleaseEvent(QMouseEvent * e)
45 {
46- if (e->button()==Qt::LeftButton)
47+ if (e->button() == Qt::LeftButton) {
48+ QCursor::setPos(m_startPos);
49+ QApplication::restoreOverrideCursor();
50 emit(valueChangedLeftUp(m_fValue));
51- else if (e->button()==Qt::RightButton)
52+ } else if (e->button()==Qt::RightButton) {
53 m_bRightButtonPressed = false;
54 //emit(valueChangedRightUp(m_fValue));
55+ }
56
57 update();
58 }
59
60 void WKnob::wheelEvent(QWheelEvent *e)
61 {
62- double wheelDirection = ((QWheelEvent *)e)->delta() / 120.;
63+ double wheelDirection = ((QWheelEvent *)e)->delta() / 120.;
64 double newValue = getValue() + (wheelDirection);
65 this->updateValue(newValue);
66
67
68=== modified file 'mixxx/src/widget/wknob.h'
69--- mixxx/src/widget/wknob.h 2010-07-11 05:46:55 +0000
70+++ mixxx/src/widget/wknob.h 2011-05-03 03:28:26 +0000
71@@ -57,8 +57,8 @@
72 QPixmap **m_pPixmaps;
73 /** Associated background pixmap */
74 QPixmap *m_pPixmapBack;
75- /** Values used when pressing mouse */
76- double m_dStartValue;
77+ /** Starting point when left mouse button is pressed */
78+ QPoint m_startPos;
79 /** True if disabled pixmaps is loaded */
80 bool m_bDisabledLoaded;
81 };

Subscribers

People subscribed via source and target branches