annotate layer/SingleColourLayer.h @ 287:cd2492c5fe45

* Add SingleColourLayer to manage colours for layers that have a single predominant colour (i.e. most of them).
author Chris Cannam
date Thu, 12 Jul 2007 16:14:59 +0000
parents
children 15b8a4bfe855
rev   line source
Chris@287 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@287 2
Chris@287 3 /*
Chris@287 4 Sonic Visualiser
Chris@287 5 An audio file viewer and annotation editor.
Chris@287 6 Centre for Digital Music, Queen Mary, University of London.
Chris@287 7 This file copyright 2007 QMUL.
Chris@287 8
Chris@287 9 This program is free software; you can redistribute it and/or
Chris@287 10 modify it under the terms of the GNU General Public License as
Chris@287 11 published by the Free Software Foundation; either version 2 of the
Chris@287 12 License, or (at your option) any later version. See the file
Chris@287 13 COPYING included with this distribution for more information.
Chris@287 14 */
Chris@287 15
Chris@287 16 #ifndef _SINGLE_COLOUR_LAYER_H_
Chris@287 17 #define _SINGLE_COLOUR_LAYER_H_
Chris@287 18
Chris@287 19 #include "Layer.h"
Chris@287 20 #include <QColor>
Chris@287 21 #include <vector>
Chris@287 22
Chris@287 23 class SingleColourLayer : public Layer
Chris@287 24 {
Chris@287 25 public:
Chris@287 26 virtual void setBaseColour(int);
Chris@287 27 virtual int getBaseColour() const;
Chris@287 28
Chris@287 29 virtual bool hasLightBackground() const;
Chris@287 30
Chris@287 31 virtual ColourSignificance getLayerColourSignificance() const {
Chris@287 32 return ColourDistinguishes;
Chris@287 33 }
Chris@287 34
Chris@287 35 virtual PropertyList getProperties() const;
Chris@287 36 virtual QString getPropertyLabel(const PropertyName &) const;
Chris@287 37 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@287 38 virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@287 39 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@287 40 int *min, int *max, int *deflt) const;
Chris@287 41 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@287 42 int value) const;
Chris@287 43 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
Chris@287 44 virtual void setProperty(const PropertyName &, int value);
Chris@287 45
Chris@287 46 virtual QString toXmlString(QString indent = "",
Chris@287 47 QString extraAttributes = "") const;
Chris@287 48
Chris@287 49 virtual void setProperties(const QXmlAttributes &attributes);
Chris@287 50
Chris@287 51 virtual void setDefaultColourFor(View *v);
Chris@287 52
Chris@287 53 protected:
Chris@287 54 SingleColourLayer();
Chris@287 55
Chris@287 56 virtual QColor getBaseQColor() const;
Chris@287 57 virtual QColor getBackgroundQColor(View *v) const;
Chris@287 58 virtual QColor getForegroundQColor(View *v) const;
Chris@287 59 std::vector<QColor> getPartialShades(View *v) const;
Chris@287 60
Chris@287 61 virtual void flagBaseColourChanged() { }
Chris@287 62 virtual int getDefaultColourHint(bool /* darkBackground */,
Chris@287 63 bool & /* impose */) { return -1; }
Chris@287 64
Chris@287 65 typedef std::multiset<int> ColourIndexPool;
Chris@287 66 static ColourIndexPool m_usedColourIndices;
Chris@287 67
Chris@287 68 int m_colour;
Chris@287 69 };
Chris@287 70
Chris@287 71 #endif