changeset 872:e04d3c54d0ee tonioni

Merge
author Chris Cannam
date Mon, 10 Nov 2014 15:59:29 +0000
parents 2857e6352b06 (diff) 0cdaf382f21e (current diff)
children 9855fc0927af
files
diffstat 2 files changed, 56 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/view/Overview.cpp	Mon Nov 10 09:54:20 2014 +0000
+++ b/view/Overview.cpp	Mon Nov 10 15:59:29 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();
--- a/view/Overview.h	Mon Nov 10 09:54:20 2014 +0000
+++ b/view/Overview.h	Mon Nov 10 15:59:29 2014 +0000
@@ -59,6 +59,9 @@
     virtual void leaveEvent(QEvent *);
     virtual bool shouldLabelSelections() const { return false; }
 
+    QColor getFillWithin() const;
+    QColor getFillWithout() const;
+    
     QPoint m_clickPos;
     QPoint m_mousePos;
     bool m_clickedInRange;