Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/view/Overview.cpp Mon Nov 10 09:20:06 2014 +0000 +++ b/view/Overview.cpp Mon Nov 10 15:59:09 2014 +0000 @@ -144,6 +144,20 @@ if (changed) update(); } +QColor +Overview::getFillWithin() const +{ + return Qt::transparent; +} + +QColor +Overview::getFillWithout() const +{ + QColor c = palette().window().color(); + c.setAlpha(100); + return c; +} + void Overview::paintEvent(QPaintEvent *e) { @@ -184,21 +198,23 @@ QPainter paint; paint.begin(this); - + paint.setClipRegion(e->region()); + paint.setRenderHints(QPainter::Antialiasing); + QRect r(rect()); - if (e) { - r = e->rect(); - paint.setClipRect(r); - } + // We paint a rounded rect for each distinct set of view extents, + // and we colour in the inside and outside of the rect that + // corresponds to the current view. (One small caveat -- we don't + // know which rect that is yet. We'll have to figure it out + // somehow...) - paint.setPen(getForeground()); + std::set<std::pair<int, int> > extents; + std::vector<QRect> rects; + QRect primary; int y = 0; - - int prevx0 = -10; - int prevx1 = -10; - + for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { if (!*i) continue; @@ -219,15 +235,35 @@ int x0 = getXForFrame(f0); int x1 = getXForFrame(f1); - if (x0 != prevx0 || x1 != prevx1) { + if (x1 <= x0) x1 = x0 + 1; + + std::pair<int, int> extent(x0, x1); + + if (extents.find(extent) == extents.end()) { + y += height() / 10 + 1; - prevx0 = x0; - prevx1 = x1; - } + extents.insert(extent); - if (x1 <= x0) x1 = x0 + 1; - - paint.drawRect(x0, y, x1 - x0, height() - 2 * y); + QRect vr(x0, y, x1 - x0, height() - 2 * y); + rects.push_back(vr); + primary = vr; //!!! for now + } + } + + QPainterPath without; + without.addRoundedRect(primary, 8, 8); + without.addRect(rect()); + paint.setPen(Qt::NoPen); + paint.setBrush(getFillWithout()); + paint.drawPath(without); + + paint.setBrush(getFillWithin()); + paint.drawRoundedRect(primary, 8, 8); + + foreach (QRect vr, rects) { + paint.setBrush(Qt::NoBrush); + paint.setPen(QPen(getForeground(), 2)); + paint.drawRoundedRect(vr, 8, 8); } paint.end();