comparison 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
comparison
equal deleted inserted replaced
255:e175ade2d6b0 256:c492902dba40
27 QWidget(parent), 27 QWidget(parent),
28 m_rectX(0), 28 m_rectX(0),
29 m_rectY(0), 29 m_rectY(0),
30 m_rectWidth(1), 30 m_rectWidth(1),
31 m_rectHeight(1), 31 m_rectHeight(1),
32 m_scrollUnit(0),
32 m_defaultCentreX(0), 33 m_defaultCentreX(0),
33 m_defaultCentreY(0), 34 m_defaultCentreY(0),
34 m_defaultsSet(false), 35 m_defaultsSet(false),
35 m_thumbColour(palette().highlightedText().color()), 36 m_thumbColour(palette().highlightedText().color()),
36 m_backgroundAlpha(255), 37 m_backgroundAlpha(255),
46 void 47 void
47 Panner::setAlpha(int backgroundAlpha, int thumbAlpha) 48 Panner::setAlpha(int backgroundAlpha, int thumbAlpha)
48 { 49 {
49 m_backgroundAlpha = backgroundAlpha; 50 m_backgroundAlpha = backgroundAlpha;
50 m_thumbAlpha = thumbAlpha; 51 m_thumbAlpha = thumbAlpha;
52 }
53
54 void
55 Panner::setScrollUnit(float unit)
56 {
57 m_scrollUnit = unit;
58 }
59
60 void
61 Panner::scroll(bool up)
62 {
63 float unit = m_scrollUnit;
64 if (unit == 0.f) {
65 unit = float(m_rectHeight) / (6 * float(height()));
66 if (unit < 0.01) unit = 0.01;
67 }
68
69 if (!up) {
70 m_rectY += unit;
71 } else {
72 m_rectY -= unit;
73 }
74
75 normalise();
76 emitAndUpdate();
51 } 77 }
52 78
53 void 79 void
54 Panner::mousePressEvent(QMouseEvent *e) 80 Panner::mousePressEvent(QMouseEvent *e)
55 { 81 {
102 } 128 }
103 129
104 void 130 void
105 Panner::wheelEvent(QWheelEvent *e) 131 Panner::wheelEvent(QWheelEvent *e)
106 { 132 {
107 if (e->delta() < 0) { 133 scroll(e->delta() > 0);
108 m_rectY += 0.1;
109 } else {
110 m_rectY -= 0.1;
111 }
112
113 normalise();
114 emitAndUpdate();
115 } 134 }
116 135
117 void 136 void
118 Panner::enterEvent(QEvent *) 137 Panner::enterEvent(QEvent *)
119 { 138 {