Chris@287: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@287: 
Chris@287: /*
Chris@287:     Sonic Visualiser
Chris@287:     An audio file viewer and annotation editor.
Chris@287:     Centre for Digital Music, Queen Mary, University of London.
Chris@287:     This file copyright 2007 QMUL.
Chris@287:     
Chris@287:     This program is free software; you can redistribute it and/or
Chris@287:     modify it under the terms of the GNU General Public License as
Chris@287:     published by the Free Software Foundation; either version 2 of the
Chris@287:     License, or (at your option) any later version.  See the file
Chris@287:     COPYING included with this distribution for more information.
Chris@287: */
Chris@287: 
Chris@287: #ifndef _SINGLE_COLOUR_LAYER_H_
Chris@287: #define _SINGLE_COLOUR_LAYER_H_
Chris@287: 
Chris@287: #include "Layer.h"
Chris@287: #include <QColor>
Chris@287: #include <vector>
Chris@293: #include <map>
Chris@287: 
Chris@287: class SingleColourLayer : public Layer
Chris@287: {
Chris@397:     Q_OBJECT
Chris@397:     
Chris@287: public:
Chris@615:     /**
Chris@615:      * Set the colour used to draw primary items in the layer. The
Chris@615:      * colour value is a colour database index as returned by
Chris@615:      * ColourDatabase::getColourIndex().
Chris@615:      */
Chris@287:     virtual void setBaseColour(int);
Chris@615: 
Chris@615:     /**
Chris@615:      * Retrieve the current primary drawing colour, as a
Chris@615:      * ColourDatabase index value.
Chris@615:      */
Chris@287:     virtual int getBaseColour() const;
Chris@287: 
Chris@615:     /**
Chris@615:      * Return true if the layer currently has a dark colour on a light
Chris@615:      * background, false if it has a light colour on a dark
Chris@615:      * background.
Chris@615:      */
Chris@287:     virtual bool hasLightBackground() const;
Chris@287: 
Chris@615:     /**
Chris@615:      * Implements Layer::getLayerColourSignificance()
Chris@615:      */
Chris@287:     virtual ColourSignificance getLayerColourSignificance() const {
Chris@287:         return ColourDistinguishes;
Chris@287:     }
Chris@287: 
Chris@299:     virtual QPixmap getLayerPresentationPixmap(QSize size) const;
Chris@299: 
Chris@287:     virtual PropertyList getProperties() const;
Chris@287:     virtual QString getPropertyLabel(const PropertyName &) const;
Chris@287:     virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@287:     virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@287:     virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@287:                                          int *min, int *max, int *deflt) const;
Chris@287:     virtual QString getPropertyValueLabel(const PropertyName &,
Chris@1266:                                           int value) const;
Chris@287:     virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
Chris@287:     virtual void setProperty(const PropertyName &, int value);
Chris@287: 
Chris@316:     virtual void toXml(QTextStream &stream, QString indent = "",
Chris@316:                        QString extraAttributes = "") const;
Chris@287: 
Chris@287:     virtual void setProperties(const QXmlAttributes &attributes);
Chris@287: 
Chris@919:     virtual void setDefaultColourFor(LayerGeometryProvider *v);
Chris@287: 
Chris@287: protected:
Chris@287:     SingleColourLayer();
jakob@768:     virtual ~SingleColourLayer();
Chris@287: 
Chris@287:     virtual QColor getBaseQColor() const;
Chris@919:     virtual QColor getBackgroundQColor(LayerGeometryProvider *v) const;
Chris@919:     virtual QColor getForegroundQColor(LayerGeometryProvider *v) const;
Chris@919:     std::vector<QColor> getPartialShades(LayerGeometryProvider *v) const;
Chris@287: 
Chris@287:     virtual void flagBaseColourChanged() { }
Chris@287:     virtual int getDefaultColourHint(bool /* darkBackground */,
Chris@287:                                      bool & /* impose */) { return -1; }
Chris@287: 
Chris@293:     typedef std::map<int, int> ColourRefCount;
Chris@293:     static ColourRefCount m_colourRefCount;
Chris@287: 
Chris@287:     int m_colour;
Chris@294:     bool m_colourExplicitlySet;
Chris@366:     bool m_defaultColourSet;
jakob@768: 
jakob@768: private:
jakob@768:     void refColor();
jakob@768:     void unrefColor();
Chris@287: };
Chris@287: 
Chris@287: #endif