Mercurial > hg > svgui
comparison widgets/ColourMapComboBox.cpp @ 1198:69ff93e0c624 levelpanwidget
Introduce a colour map combo too. Doesn't yet have swatches
author | Chris Cannam |
---|---|
date | Fri, 16 Dec 2016 14:16:05 +0000 |
parents | widgets/ColourComboBox.cpp@b1e3ee5f1be6 |
children | 73d43e410a6b |
comparison
equal
deleted
inserted
replaced
1197:ff77b7707c95 | 1198:69ff93e0c624 |
---|---|
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-2016 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 #include "ColourMapComboBox.h" | |
17 | |
18 #include "layer/ColourMapper.h" | |
19 | |
20 #include "base/Debug.h" | |
21 | |
22 #include <QFontMetrics> | |
23 | |
24 #include <iostream> | |
25 | |
26 using namespace std; | |
27 | |
28 ColourMapComboBox::ColourMapComboBox(QWidget *parent) : | |
29 NotifyingComboBox(parent) | |
30 { | |
31 setEditable(false); | |
32 rebuild(); | |
33 | |
34 connect(this, SIGNAL(activated(int)), this, SLOT(comboActivated(int))); | |
35 | |
36 if (count() < 20 && count() > maxVisibleItems()) { | |
37 setMaxVisibleItems(count()); | |
38 } | |
39 } | |
40 | |
41 void | |
42 ColourMapComboBox::comboActivated(int index) | |
43 { | |
44 emit colourMapChanged(index); | |
45 } | |
46 | |
47 void | |
48 ColourMapComboBox::rebuild() | |
49 { | |
50 blockSignals(true); | |
51 | |
52 int ix = currentIndex(); | |
53 | |
54 clear(); | |
55 | |
56 int size = (QFontMetrics(QFont()).height() * 2) / 3; | |
57 if (size < 12) size = 12; | |
58 | |
59 for (int i = 0; i < ColourMapper::getColourMapCount(); ++i) { | |
60 QString name = ColourMapper::getColourMapName(i); | |
61 // addItem(db->getExamplePixmap(i, QSize(size, size)), name); | |
62 addItem(name); | |
63 } | |
64 | |
65 setCurrentIndex(ix); | |
66 | |
67 blockSignals(false); | |
68 } | |
69 |