changeset 270:61a704654497

...
author Chris Cannam
date Tue, 26 Jun 2007 14:57:29 +0000
parents 7b58c5e91f20
children 1a49bd0d8375
files layer/Layer.cpp layer/Layer.h view/Pane.cpp view/View.cpp view/View.h
diffstat 5 files changed, 44 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Layer.cpp	Tue Jun 26 12:27:47 2007 +0000
+++ b/layer/Layer.cpp	Tue Jun 26 14:57:29 2007 +0000
@@ -257,17 +257,18 @@
 Layer::paintMeasurementRects(View *v, QPainter &paint) const
 {
     if (m_haveDraggingRect) {
-        paintMeasurementRect(v, paint, m_draggingRect);
+        paintMeasurementRect(v, paint, m_draggingRect, true);
     }
 
     for (MeasureRectSet::const_iterator i = m_measureRects.begin(); 
          i != m_measureRects.end(); ++i) {
-        paintMeasurementRect(v, paint, *i);
+        paintMeasurementRect(v, paint, *i, true);
     }
 }
 
 void
-Layer::paintMeasurementRect(View *v, QPainter &paint, const MeasureRect &r) const
+Layer::paintMeasurementRect(View *v, QPainter &paint,
+                            const MeasureRect &r, bool focus) const
 {
     if (r.haveFrames) {
         
@@ -287,7 +288,7 @@
         r.pixrect = pr;
     }
     
-    v->drawMeasurementRect(paint, this, r.pixrect);
+    v->drawMeasurementRect(paint, this, r.pixrect, focus);
 }
 
 QString
--- a/layer/Layer.h	Tue Jun 26 12:27:47 2007 +0000
+++ b/layer/Layer.h	Tue Jun 26 14:57:29 2007 +0000
@@ -461,7 +461,7 @@
     bool m_haveDraggingRect;
 
     void paintMeasurementRect(View *v, QPainter &paint,
-                              const MeasureRect &r) const;
+                              const MeasureRect &r, bool focus) const;
 
 private:
     mutable QMutex m_dormancyMutex;
--- a/view/Pane.cpp	Tue Jun 26 12:27:47 2007 +0000
+++ b/view/Pane.cpp	Tue Jun 26 14:57:29 2007 +0000
@@ -1268,10 +1268,7 @@
 
         Layer *layer = getTopLayer();
         if (layer) layer->measureDrag(this, e);
-
-        if (hasTopLayerTimeXAxis()) {
-            edgeScrollMaybe(e->x());
-        }
+        if (layer->hasTimeXAxis()) edgeScrollMaybe(e->x());
 
         update();
     }
--- a/view/View.cpp	Tue Jun 26 12:27:47 2007 +0000
+++ b/view/View.cpp	Tue Jun 26 14:57:29 2007 +0000
@@ -1638,13 +1638,47 @@
 }
 
 void
-View::drawMeasurementRect(QPainter &paint, const Layer *topLayer, QRect r) const
+View::drawMeasurementRect(QPainter &paint, const Layer *topLayer, QRect r,
+                          bool focus) const
 {
 //    std::cerr << "View::drawMeasurementRect(" << r.x() << "," << r.y() << " "
 //              << r.width() << "x" << r.height() << ")" << std::endl;
 
     if (r.x() + r.width() < 0 || r.x() >= width()) return;
 
+    if (r.width() != 0 || r.height() != 0) {
+        paint.save();
+        if (focus) {
+            paint.setPen(Qt::NoPen);
+            QColor brushColour(Qt::green);
+            brushColour.setAlpha(30);
+            paint.setBrush(brushColour);
+            if (r.x() > 0) {
+                paint.drawRect(0, 0, r.x(), height());
+            }
+            if (r.x() + r.width() < width()) {
+                paint.drawRect(r.x() + r.width(), 0, width()-r.x()-r.width(), height());
+            }
+            if (r.y() > 0) {
+                paint.drawRect(r.x(), 0, r.width(), r.y());
+            }
+            if (r.y() + r.height() < height()) {
+                paint.drawRect(r.x(), r.y() + r.height(), r.width(), height()-r.y()-r.height());
+            }
+            paint.setBrush(Qt::NoBrush);
+        }
+        paint.setPen(Qt::green);
+        paint.drawRect(r);
+        paint.restore();
+    } else {
+        paint.save();
+        paint.setPen(Qt::green);
+        paint.drawPoint(r.x(), r.y());
+        paint.restore();
+    }
+
+    if (!focus) return;
+
     int fontHeight = paint.fontMetrics().height();
     int fontAscent = paint.fontMetrics().ascent();
 
@@ -1784,13 +1818,6 @@
         drawVisibleText(paint, dxx, dxy, dys, OutlinedText);
         dxy += fontHeight;
     }
-
-    if (r.width() != 0 || r.height() != 0) {
-        paint.save();
-        paint.setPen(Qt::green);
-        paint.drawRect(r);
-        paint.restore();
-    }
 }
 
 bool
--- a/view/View.h	Tue Jun 26 12:27:47 2007 +0000
+++ b/view/View.h	Tue Jun 26 14:57:29 2007 +0000
@@ -190,7 +190,8 @@
     virtual void drawVisibleText(QPainter &p, int x, int y,
 				 QString text, TextStyle style) const;
 
-    virtual void drawMeasurementRect(QPainter &p, const Layer *, QRect rect) const;
+    virtual void drawMeasurementRect(QPainter &p, const Layer *,
+                                     QRect rect, bool focus) const;
 
     virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const {
 	return false;