changeset 183:5f86ae638b04

* Omit translucent blue fill for selection rectangles that are superimposed over layers that use colours for meaningful purposes such as the spectrogram (CHARM change request)
author Chris Cannam
date Fri, 24 Nov 2006 16:56:15 +0000
parents 42118892f428
children 3a6fea0abf56
files layer/Colour3DPlotLayer.h layer/Layer.h layer/SpectrogramLayer.h view/View.cpp view/View.h
diffstat 5 files changed, 46 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.h	Fri Nov 17 16:27:39 2006 +0000
+++ b/layer/Colour3DPlotLayer.h	Fri Nov 24 16:56:15 2006 +0000
@@ -62,6 +62,8 @@
 
     virtual bool isLayerScrollable(const View *v) const;
 
+    virtual bool isLayerColourSignificant() const { return true; }
+
     void setModel(const DenseThreeDimensionalModel *model);
 
     virtual int getCompletion(View *) const { return m_model->getCompletion(); }
--- a/layer/Layer.h	Fri Nov 17 16:27:39 2006 +0000
+++ b/layer/Layer.h	Fri Nov 24 16:56:15 2006 +0000
@@ -201,6 +201,16 @@
     virtual bool isLayerOpaque() const { return false; }
 
     /**
+     * This should return true if the layer uses colours to indicate
+     * meaningful information (as opposed to just using a single
+     * colour of the user's choice).  If this is the case, the view
+     * will show selections using unfilled rectangles instead of
+     * translucent filled rectangles, so as not to disturb the colours
+     * underneath.
+     */
+    virtual bool isLayerColourSignificant() const { return false; }
+
+    /**
      * This should return true if the layer can be edited by the user.
      * If this is the case, the appropriate edit tools may be made
      * available by the application and the layer's drawStart/Drag/End
--- a/layer/SpectrogramLayer.h	Fri Nov 17 16:27:39 2006 +0000
+++ b/layer/SpectrogramLayer.h	Fri Nov 24 16:56:15 2006 +0000
@@ -187,6 +187,7 @@
     }
 
     virtual bool isLayerOpaque() const { return true; }
+    virtual bool isLayerColourSignificant() const { return true; }
 
     float getYForFrequency(View *v, float frequency) const;
     float getFrequencyForY(View *v, int y) const;
--- a/view/View.cpp	Fri Nov 17 16:27:39 2006 +0000
+++ b/view/View.cpp	Fri Nov 24 16:56:15 2006 +0000
@@ -1027,6 +1027,16 @@
     return candidate;
 }
 
+bool
+View::areLayerColoursSignificant() const
+{
+    for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
+	if ((*i)->isLayerColourSignificant()) return true;
+        if ((*i)->isLayerOpaque()) break;
+    }
+    return false;
+}
+
 void
 View::zoom(bool in)
 {
@@ -1396,7 +1406,14 @@
     }
 
     paint.save();
-    paint.setBrush(QColor(150, 150, 255, 80));
+
+    bool translucent = !areLayerColoursSignificant();
+
+    if (translucent) {
+        paint.setBrush(QColor(150, 150, 255, 80));
+    } else {
+        paint.setBrush(Qt::NoBrush);
+    }
 
     int sampleRate = getModelsSampleRate();
 
@@ -1426,7 +1443,16 @@
 	    (illuminateFrame >= 0 && i->contains(illuminateFrame));
 
 	paint.setPen(QColor(150, 150, 255));
-	paint.drawRect(p0, -1, p1 - p0, height() + 1);
+
+        if (translucent && shouldLabelSelections()) {
+            paint.drawRect(p0, -1, p1 - p0, height() + 1);
+        } else {
+            // Make the top & bottom lines of the box visible if we
+            // are lacking some of the other visual cues.  There's no
+            // particular logic to this, it's just a question of what
+            // I happen to think looks nice.
+            paint.drawRect(p0, 0, p1 - p0, height() - 1);
+        }
 
 	if (illuminateThis) {
 	    paint.save();
--- a/view/View.h	Fri Nov 17 16:27:39 2006 +0000
+++ b/view/View.h	Fri Nov 24 16:56:15 2006 +0000
@@ -277,6 +277,11 @@
 				      ZoomConstraint::RoundingDirection dir =
 				      ZoomConstraint::RoundNearest) const;
 
+    // True if the top layer(s) use colours for meaningful things.  If
+    // this is the case, selections will be shown using unfilled boxes
+    // rather than with a translucent fill.
+    bool areLayerColoursSignificant() const;
+
     bool setCentreFrame(size_t f, bool doEmit);
 
     void checkProgress(void *object);