comparison widgets/Panner.cpp @ 1303:13f5f84fbfad

Collect the bits of bookkeeping for mouse wheel events, and use in all widgets
author Chris Cannam
date Fri, 22 Jun 2018 17:19:48 +0100
parents 4d0ca1ab4cd0
children cb51d061cc25
comparison
equal deleted inserted replaced
1302:f3d3fab250ac 1303:13f5f84fbfad
62 } 62 }
63 63
64 void 64 void
65 Panner::scroll(bool up) 65 Panner::scroll(bool up)
66 { 66 {
67 scroll(up, 1);
68 }
69
70 void
71 Panner::scroll(bool up, int count)
72 {
67 float unit = m_scrollUnit; 73 float unit = m_scrollUnit;
68 if (unit == 0.f) { 74 if (unit == 0.f) {
69 unit = float(m_rectHeight) / (6 * float(height())); 75 unit = float(m_rectHeight) / (6 * float(height()));
70 if (unit < 0.01f) unit = 0.01f; 76 if (unit < 0.01f) unit = 0.01f;
71 } 77 }
72 78
73 if (!up) { 79 if (!up) {
74 m_rectY += unit; 80 m_rectY += unit * count;
75 } else { 81 } else {
76 m_rectY -= unit; 82 m_rectY -= unit * count;
77 } 83 }
78 84
79 normalise(); 85 normalise();
80 emitAndUpdate(); 86 emitAndUpdate();
81 } 87 }
132 } 138 }
133 139
134 void 140 void
135 Panner::wheelEvent(QWheelEvent *e) 141 Panner::wheelEvent(QWheelEvent *e)
136 { 142 {
137 scroll(e->delta() > 0); 143 int delta = m_wheelCounter.count(e);
144 scroll(delta > 0, abs(delta));
138 } 145 }
139 146
140 void 147 void
141 Panner::enterEvent(QEvent *) 148 Panner::enterEvent(QEvent *)
142 { 149 {