Mercurial > hg > svgui
comparison view/Overview.cpp @ 871:2857e6352b06 tonioni
Make overview area easier to see
author | Chris Cannam |
---|---|
date | Mon, 10 Nov 2014 15:59:09 +0000 |
parents | c17719e488c9 |
children | 26da827e8fb5 |
comparison
equal
deleted
inserted
replaced
869:6c08e99ca0f3 | 871:2857e6352b06 |
---|---|
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 | 217 |
199 int prevx0 = -10; | |
200 int prevx1 = -10; | |
201 | |
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; |
206 | 222 |
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) { | 238 if (x1 <= x0) x1 = x0 + 1; |
239 | |
240 std::pair<int, int> extent(x0, x1); | |
241 | |
242 if (extents.find(extent) == extents.end()) { | |
243 | |
223 y += height() / 10 + 1; | 244 y += height() / 10 + 1; |
224 prevx0 = x0; | 245 extents.insert(extent); |
225 prevx1 = x1; | 246 |
226 } | 247 QRect vr(x0, y, x1 - x0, height() - 2 * y); |
227 | 248 rects.push_back(vr); |
228 if (x1 <= x0) x1 = x0 + 1; | 249 primary = vr; //!!! for now |
229 | 250 } |
230 paint.drawRect(x0, y, x1 - x0, height() - 2 * y); | 251 } |
252 | |
253 QPainterPath without; | |
254 without.addRoundedRect(primary, 8, 8); | |
255 without.addRect(rect()); | |
256 paint.setPen(Qt::NoPen); | |
257 paint.setBrush(getFillWithout()); | |
258 paint.drawPath(without); | |
259 | |
260 paint.setBrush(getFillWithin()); | |
261 paint.drawRoundedRect(primary, 8, 8); | |
262 | |
263 foreach (QRect vr, rects) { | |
264 paint.setBrush(Qt::NoBrush); | |
265 paint.setPen(QPen(getForeground(), 2)); | |
266 paint.drawRoundedRect(vr, 8, 8); | |
231 } | 267 } |
232 | 268 |
233 paint.end(); | 269 paint.end(); |
234 } | 270 } |
235 | 271 |