comparison base/ColourDatabase.h @ 277:3b8008d09541

* Add a colour database, and Add New Colour function to the colour combo in property box. The colour property is only correctly handled in the waveform layer so far. * Add en_GB translation, to translate those annoying Color texts in the Qt colour picker dialog.
author Chris Cannam
date Wed, 11 Jul 2007 17:21:37 +0000
parents
children 9a13687c078b
comparison
equal deleted inserted replaced
276:657825878970 277:3b8008d09541
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 _COLOUR_DATABASE_H_
17 #define _COLOUR_DATABASE_H_
18
19 #include <QObject>
20 #include <QString>
21 #include <QColor>
22 #include <vector>
23
24 class ColourDatabase : public QObject
25 {
26 Q_OBJECT
27
28 public:
29 static ColourDatabase *getInstance();
30
31 int getColourCount() const;
32 QString getColourName(int c) const;
33 QColor getColour(int c) const;
34 QColor getColour(QString name) const;
35 int getColourIndex(QString name) const; // -1 -> not found
36 int getColourIndex(QColor c) const; // returns first index of possibly many
37 bool haveColour(QColor c) const;
38
39 bool useDarkBackground(int c) const;
40 void setUseDarkBackground(int c, bool dark);
41
42 int addColour(QColor, QString); // returns index
43 void removeColour(QString);
44
45 // returned colour is not necessarily in database
46 QColor getContrastingColour(int c) const;
47
48 // for use in XML export
49 void getStringValues(int index,
50 QString &colourName,
51 QString &colourSpec,
52 QString &darkbg) const;
53
54 // for use in XML import
55 int putStringValues(QString colourName,
56 QString colourSpec,
57 QString darkbg);
58
59 // for use by PropertyContainer getPropertyRangeAndValue methods
60 void getColourPropertyRange(int *min, int *max) const;
61
62 signals:
63 void colourDatabaseChanged();
64
65 protected:
66 ColourDatabase();
67
68 struct ColourRec {
69 QColor colour;
70 QString name;
71 bool darkbg;
72 };
73
74 typedef std::vector<ColourRec> ColourList;
75 ColourList m_colours;
76
77 static ColourDatabase m_instance;
78 };
79
80 #endif