annotate base/ColourDatabase.h @ 308:14e0f60435b8

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