diff widgets/Panner.cpp @ 256:c492902dba40

* Make shift+mousewheel scroll vertically (where applicable) and alt+mousewheel zoom vertically (where applicable). Closes #1734844
author Chris Cannam
date Wed, 13 Jun 2007 10:27:39 +0000
parents e6d0b097d102
children 755243c67f59
line wrap: on
line diff
--- a/widgets/Panner.cpp	Wed Jun 13 09:19:33 2007 +0000
+++ b/widgets/Panner.cpp	Wed Jun 13 10:27:39 2007 +0000
@@ -29,6 +29,7 @@
     m_rectY(0),
     m_rectWidth(1),
     m_rectHeight(1),
+    m_scrollUnit(0),
     m_defaultCentreX(0),
     m_defaultCentreY(0),
     m_defaultsSet(false),
@@ -51,6 +52,31 @@
 }
 
 void
+Panner::setScrollUnit(float unit)
+{
+    m_scrollUnit = unit;
+}
+
+void
+Panner::scroll(bool up)
+{
+    float unit = m_scrollUnit;
+    if (unit == 0.f) {
+        unit = float(m_rectHeight) / (6 * float(height()));
+        if (unit < 0.01) unit = 0.01;
+    }
+
+    if (!up) {
+        m_rectY += unit;
+    } else {
+        m_rectY -= unit;
+    }
+
+    normalise();
+    emitAndUpdate();
+}
+
+void
 Panner::mousePressEvent(QMouseEvent *e)
 {
     if (e->button() == Qt::MidButton ||
@@ -104,14 +130,7 @@
 void
 Panner::wheelEvent(QWheelEvent *e)
 {
-    if (e->delta() < 0) {
-        m_rectY += 0.1;
-    } else {
-        m_rectY -= 0.1;
-    }
-
-    normalise();
-    emitAndUpdate();
+    scroll(e->delta() > 0);
 }
 
 void