SingleColourLayer.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2007 QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_SINGLE_COLOUR_LAYER_H
17 #define SV_SINGLE_COLOUR_LAYER_H
18 
19 #include "Layer.h"
20 #include <QColor>
21 #include <vector>
22 #include <map>
23 
24 class SingleColourLayer : public Layer
25 {
26  Q_OBJECT
27 
28 public:
34  virtual void setBaseColour(int);
35 
40  virtual int getBaseColour() const;
41 
47  bool hasLightBackground() const override;
48 
53  return ColourDistinguishes;
54  }
55 
56  QPixmap getLayerPresentationPixmap(QSize size) const override;
57 
58  PropertyList getProperties() const override;
59  QString getPropertyLabel(const PropertyName &) const override;
60  PropertyType getPropertyType(const PropertyName &) const override;
61  QString getPropertyGroupName(const PropertyName &) const override;
62  int getPropertyRangeAndValue(const PropertyName &,
63  int *min, int *max, int *deflt) const override;
64  QString getPropertyValueLabel(const PropertyName &,
65  int value) const override;
66  RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const override;
67  void setProperty(const PropertyName &, int value) override;
68 
69  void toXml(QTextStream &stream, QString indent = "",
70  QString extraAttributes = "") const override;
71 
72  void setProperties(const QXmlAttributes &attributes) override;
73 
75 
76 protected:
78  virtual ~SingleColourLayer();
79 
80  virtual QColor getBaseQColor() const;
81  virtual QColor getBackgroundQColor(LayerGeometryProvider *v) const;
82  virtual QColor getForegroundQColor(LayerGeometryProvider *v) const;
83  std::vector<QColor> getPartialShades(LayerGeometryProvider *v) const;
84 
85  virtual void flagBaseColourChanged() { }
86  virtual int getDefaultColourHint(bool /* darkBackground */,
87  bool & /* impose */) { return -1; }
88 
89  typedef std::map<int, int> ColourRefCount;
90  static ColourRefCount m_colourRefCount;
91 
92  int m_colour;
95 
96 private:
97  void refColor();
98  void unrefColor();
99 };
100 
101 #endif
ColourSignificance getLayerColourSignificance() const override
Implements Layer::getLayerColourSignificance()
The base class for visual representations of the data found in a Model.
Definition: Layer.h:54
virtual void flagBaseColourChanged()
PropertyList getProperties() const override
QPixmap getLayerPresentationPixmap(QSize size) const override
virtual void setBaseColour(int)
Set the colour used to draw primary items in the layer.
virtual QColor getForegroundQColor(LayerGeometryProvider *v) const
ColourSignificance
Definition: Layer.h:348
std::vector< QColor > getPartialShades(LayerGeometryProvider *v) const
virtual QColor getBaseQColor() const
virtual int getDefaultColourHint(bool, bool &)
void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const override
Interface for classes that provide geometry information (such as size, start frame, and a large number of other properties) about the disposition of a layer.
static ColourRefCount m_colourRefCount
QString getPropertyGroupName(const PropertyName &) const override
int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const override
virtual void setDefaultColourFor(LayerGeometryProvider *v)
PropertyType getPropertyType(const PropertyName &) const override
void setProperties(const QXmlAttributes &attributes) override
Set the particular properties of a layer (those specific to the subclass) from a set of XML attribute...
QString getPropertyValueLabel(const PropertyName &, int value) const override
std::map< int, int > ColourRefCount
bool hasLightBackground() const override
Return true if the layer currently has a dark colour on a light background, false if it has a light c...
virtual QColor getBackgroundQColor(LayerGeometryProvider *v) const
RangeMapper * getNewPropertyRangeMapper(const PropertyName &) const override
void setProperty(const PropertyName &, int value) override
QString getPropertyLabel(const PropertyName &) const override
virtual int getBaseColour() const
Retrieve the current primary drawing colour, as a ColourDatabase index value.