annotate layer/ColourDatabase.h @ 1423:62e908518c71 single-point

Update to Event api in place of Clipboard points
author Chris Cannam
date Fri, 08 Mar 2019 13:37:30 +0000
parents 05d614f6e46d
children ad86aa712d11
rev   line source
Chris@376 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@376 2
Chris@376 3 /*
Chris@376 4 Sonic Visualiser
Chris@376 5 An audio file viewer and annotation editor.
Chris@376 6 Centre for Digital Music, Queen Mary, University of London.
Chris@376 7 This file copyright 2007 QMUL.
Chris@376 8
Chris@376 9 This program is free software; you can redistribute it and/or
Chris@376 10 modify it under the terms of the GNU General Public License as
Chris@376 11 published by the Free Software Foundation; either version 2 of the
Chris@376 12 License, or (at your option) any later version. See the file
Chris@376 13 COPYING included with this distribution for more information.
Chris@376 14 */
Chris@376 15
Chris@1407 16 #ifndef SV_COLOUR_DATABASE_H
Chris@1407 17 #define SV_COLOUR_DATABASE_H
Chris@376 18
Chris@376 19 #include <QObject>
Chris@376 20 #include <QString>
Chris@376 21 #include <QColor>
Chris@376 22 #include <QSize>
Chris@376 23 #include <QPixmap>
Chris@376 24 #include <vector>
Chris@376 25
Chris@376 26 class ColourDatabase : public QObject
Chris@376 27 {
Chris@376 28 Q_OBJECT
Chris@376 29
Chris@376 30 public:
Chris@376 31 static ColourDatabase *getInstance();
Chris@376 32
Chris@376 33 int getColourCount() const;
Chris@376 34 QString getColourName(int c) const;
Chris@376 35 QColor getColour(int c) const;
Chris@376 36 QColor getColour(QString name) const;
Chris@376 37 int getColourIndex(QString name) const; // -1 -> not found
Chris@376 38 int getColourIndex(QColor c) const; // returns first index of possibly many
Chris@376 39 bool haveColour(QColor c) const;
Chris@376 40
Chris@376 41 bool useDarkBackground(int c) const;
Chris@376 42 void setUseDarkBackground(int c, bool dark);
Chris@376 43
Chris@376 44 int addColour(QColor, QString); // returns index
Chris@376 45 void removeColour(QString);
Chris@376 46
Chris@376 47 // returned colour is not necessarily in database
Chris@376 48 QColor getContrastingColour(int c) const;
Chris@376 49
Chris@376 50 // for use in XML export
Chris@376 51 void getStringValues(int index,
Chris@376 52 QString &colourName,
Chris@376 53 QString &colourSpec,
Chris@376 54 QString &darkbg) const;
Chris@376 55
Chris@376 56 // for use in XML import
Chris@376 57 int putStringValues(QString colourName,
Chris@376 58 QString colourSpec,
Chris@376 59 QString darkbg);
Chris@376 60
Chris@376 61 // for use by PropertyContainer getPropertyRangeAndValue methods
Chris@376 62 void getColourPropertyRange(int *min, int *max) const;
Chris@376 63
Chris@376 64 QPixmap getExamplePixmap(int index, QSize size) const;
Chris@376 65
Chris@376 66 signals:
Chris@376 67 void colourDatabaseChanged();
Chris@376 68
Chris@376 69 protected:
Chris@376 70 ColourDatabase();
Chris@376 71
Chris@376 72 struct ColourRec {
Chris@376 73 QColor colour;
Chris@376 74 QString name;
Chris@376 75 bool darkbg;
Chris@376 76 };
Chris@376 77
Chris@376 78 typedef std::vector<ColourRec> ColourList;
Chris@376 79 ColourList m_colours;
Chris@376 80
Chris@376 81 static ColourDatabase m_instance;
Chris@376 82 };
Chris@376 83
Chris@376 84 #endif