comparison widgets/Panner.cpp @ 174:96b8a790730a

* Wire up the Panner widget in the pane, and do some tidying in Pane
author Chris Cannam
date Thu, 19 Oct 2006 13:05:39 +0000
parents 9c40dc10c88c
children 836498e57f59
comparison
equal deleted inserted replaced
173:9c40dc10c88c 174:96b8a790730a
29 m_rectWidth(1), 29 m_rectWidth(1),
30 m_rectHeight(1), 30 m_rectHeight(1),
31 m_defaultCentreX(0), 31 m_defaultCentreX(0),
32 m_defaultCentreY(0), 32 m_defaultCentreY(0),
33 m_defaultsSet(false), 33 m_defaultsSet(false),
34 m_thumbColour(palette().highlightedText().color()),
35 m_backgroundAlpha(255),
36 m_thumbAlpha(255),
34 m_clicked(false) 37 m_clicked(false)
35 { 38 {
36 } 39 }
37 40
38 Panner::~Panner() 41 Panner::~Panner()
39 { 42 {
43 }
44
45 void
46 Panner::setAlpha(int backgroundAlpha, int thumbAlpha)
47 {
48 m_backgroundAlpha = backgroundAlpha;
49 m_thumbAlpha = thumbAlpha;
40 } 50 }
41 51
42 void 52 void
43 Panner::mousePressEvent(QMouseEvent *e) 53 Panner::mousePressEvent(QMouseEvent *e)
44 { 54 {
68 78
69 m_rectX = m_dragStartX + dx; 79 m_rectX = m_dragStartX + dx;
70 m_rectY = m_dragStartY + dy; 80 m_rectY = m_dragStartY + dy;
71 81
72 normalise(); 82 normalise();
73 emitAndUpdate(); 83 repaint();
84 emit rectExtentsChanged(m_rectX, m_rectY, m_rectWidth, m_rectHeight);
85 emit rectCentreMoved(centreX(), centreY());
74 } 86 }
75 87
76 void 88 void
77 Panner::mouseReleaseEvent(QMouseEvent *e) 89 Panner::mouseReleaseEvent(QMouseEvent *e)
78 { 90 {
100 { 112 {
101 QPainter paint(this); 113 QPainter paint(this);
102 paint.setRenderHint(QPainter::Antialiasing, false); 114 paint.setRenderHint(QPainter::Antialiasing, false);
103 115
104 QColor bg(palette().background().color()); 116 QColor bg(palette().background().color());
105 bg.setAlpha(80); 117 bg.setAlpha(m_backgroundAlpha);
106 118
107 paint.setPen(palette().dark().color()); 119 paint.setPen(palette().dark().color());
108 paint.setBrush(bg); 120 paint.setBrush(bg);
109 paint.drawRect(0, 0, width(), height()); 121 paint.drawRect(0, 0, width(), height());
110 122
111 QColor hl(palette().highlight().color()); 123 QColor hl(m_thumbColour);
112 hl.setAlpha(80); 124 hl.setAlpha(m_thumbAlpha);
113 125
114 paint.setBrush(hl); 126 paint.setBrush(hl);
115 127
116 paint.drawRect(lrintf(width() * m_rectX), 128 paint.drawRect(lrintf(width() * m_rectX),
117 lrintf(height() * m_rectY), 129 lrintf(height() * m_rectY),
145 } 157 }
146 158
147 void 159 void
148 Panner::setRectExtents(float x0, float y0, float width, float height) 160 Panner::setRectExtents(float x0, float y0, float width, float height)
149 { 161 {
162 std::cerr << "Panner::setRectExtents(" << x0 << ", " << y0 << ", "
163 << width << ", " << height << ")" << std::endl;
164
150 if (m_rectX == x0 && 165 if (m_rectX == x0 &&
151 m_rectY == y0 && 166 m_rectY == y0 &&
152 m_rectWidth == width && 167 m_rectWidth == width &&
153 m_rectHeight == height) { 168 m_rectHeight == height) {
154 return; 169 return;