# HG changeset patch # User Chris Cannam # Date 1164387375 0 # Node ID 5f86ae638b046e56b57f7d808bbbdece649d4344 # Parent 42118892f42847de11395e8107757da042ebf878 * 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) diff -r 42118892f428 -r 5f86ae638b04 layer/Colour3DPlotLayer.h --- 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(); } diff -r 42118892f428 -r 5f86ae638b04 layer/Layer.h --- 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 diff -r 42118892f428 -r 5f86ae638b04 layer/SpectrogramLayer.h --- 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; diff -r 42118892f428 -r 5f86ae638b04 view/View.cpp --- 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(); diff -r 42118892f428 -r 5f86ae638b04 view/View.h --- 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);