Mercurial > hg > svgui
comparison view/Overview.cpp @ 945:bb80983c9e61 osx-retina
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2015 09:18:55 +0100 |
parents | 1c529a22a6a7 |
children | 73b0dc7d6ec1 |
comparison
equal
deleted
inserted
replaced
920:e39d5d2734ed | 945:bb80983c9e61 |
---|---|
142 m_playPointerFrame = f; | 142 m_playPointerFrame = f; |
143 | 143 |
144 if (changed) update(); | 144 if (changed) update(); |
145 } | 145 } |
146 | 146 |
147 QColor | |
148 Overview::getFillWithin() const | |
149 { | |
150 return Qt::transparent; | |
151 } | |
152 | |
153 QColor | |
154 Overview::getFillWithout() const | |
155 { | |
156 QColor c = palette().window().color(); | |
157 c.setAlpha(100); | |
158 return c; | |
159 } | |
160 | |
147 void | 161 void |
148 Overview::paintEvent(QPaintEvent *e) | 162 Overview::paintEvent(QPaintEvent *e) |
149 { | 163 { |
150 // Recalculate zoom in case the size of the widget has changed. | 164 // Recalculate zoom in case the size of the widget has changed. |
151 | 165 |
182 | 196 |
183 View::paintEvent(e); | 197 View::paintEvent(e); |
184 | 198 |
185 QPainter paint; | 199 QPainter paint; |
186 paint.begin(this); | 200 paint.begin(this); |
187 | 201 paint.setClipRegion(e->region()); |
202 paint.setRenderHints(QPainter::Antialiasing); | |
203 | |
188 QRect r(rect()); | 204 QRect r(rect()); |
189 | 205 |
190 if (e) { | 206 // We paint a rounded rect for each distinct set of view extents, |
191 r = e->rect(); | 207 // and we colour in the inside and outside of the rect that |
192 paint.setClipRect(r); | 208 // corresponds to the current view. (One small caveat -- we don't |
193 } | 209 // know which rect that is yet. We'll have to figure it out |
194 | 210 // somehow...) |
195 paint.setPen(getForeground()); | 211 |
212 std::set<std::pair<int, int> > extents; | |
213 std::vector<QRect> rects; | |
214 QRect primary; | |
196 | 215 |
197 int y = 0; | 216 int y = 0; |
198 | |
199 sv_frame_t prevx0 = -10; | |
200 sv_frame_t prevx1 = -10; | |
201 | 217 |
202 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { | 218 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { |
203 if (!*i) continue; | 219 if (!*i) continue; |
204 | 220 |
205 View *w = (View *)*i; | 221 View *w = (View *)*i; |
217 } | 233 } |
218 | 234 |
219 int x0 = getXForFrame(f0); | 235 int x0 = getXForFrame(f0); |
220 int x1 = getXForFrame(f1); | 236 int x1 = getXForFrame(f1); |
221 | 237 |
222 if (x0 != prevx0 || x1 != prevx1) { | |
223 y += height() / 10 + 1; | |
224 prevx0 = x0; | |
225 prevx1 = x1; | |
226 } | |
227 | 238 |
228 if (x1 <= x0) x1 = x0 + 1; | 239 if (x1 <= x0) x1 = x0 + 1; |
229 | 240 |
230 paint.drawRect(x0, y, x1 - x0, height() - 2 * y); | 241 std::pair<int, int> extent(x0, x1); |
242 | |
243 if (extents.find(extent) == extents.end()) { | |
244 | |
245 y += height() / 10 + 1; | |
246 extents.insert(extent); | |
247 | |
248 QRect vr(x0, y, x1 - x0, height() - 2 * y); | |
249 rects.push_back(vr); | |
250 primary = vr; //!!! for now | |
251 } | |
252 } | |
253 | |
254 QPainterPath without; | |
255 without.addRoundedRect(primary, 4, 4); | |
256 without.addRect(rect()); | |
257 paint.setPen(Qt::NoPen); | |
258 paint.setBrush(getFillWithout()); | |
259 paint.drawPath(without); | |
260 | |
261 paint.setBrush(getFillWithin()); | |
262 paint.drawRoundedRect(primary, 4, 4); | |
263 | |
264 foreach (QRect vr, rects) { | |
265 paint.setBrush(Qt::NoBrush); | |
266 paint.setPen(QPen(Qt::gray, 2)); | |
267 paint.drawRoundedRect(vr, 4, 4); | |
231 } | 268 } |
232 | 269 |
233 paint.end(); | 270 paint.end(); |
234 } | 271 } |
235 | 272 |