Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/widgets/Panner.cpp Fri Jun 22 13:41:54 2018 +0100 +++ b/widgets/Panner.cpp Fri Jun 22 17:19:48 2018 +0100 @@ -64,6 +64,12 @@ void Panner::scroll(bool up) { + scroll(up, 1); +} + +void +Panner::scroll(bool up, int count) +{ float unit = m_scrollUnit; if (unit == 0.f) { unit = float(m_rectHeight) / (6 * float(height())); @@ -71,9 +77,9 @@ } if (!up) { - m_rectY += unit; + m_rectY += unit * count; } else { - m_rectY -= unit; + m_rectY -= unit * count; } normalise(); @@ -134,7 +140,8 @@ void Panner::wheelEvent(QWheelEvent *e) { - scroll(e->delta() > 0); + int delta = m_wheelCounter.count(e); + scroll(delta > 0, abs(delta)); } void