comparison widgets/ColourMapComboBox.cpp @ 1199:73d43e410a6b levelpanwidget

Add swatches to colour map combo (optionally, as it turns out they are quite visually distracting)
author Chris Cannam
date Fri, 16 Dec 2016 15:55:59 +0000
parents 69ff93e0c624
children a34a2a25907c
comparison
equal deleted inserted replaced
1198:69ff93e0c624 1199:73d43e410a6b
23 23
24 #include <iostream> 24 #include <iostream>
25 25
26 using namespace std; 26 using namespace std;
27 27
28 ColourMapComboBox::ColourMapComboBox(QWidget *parent) : 28 ColourMapComboBox::ColourMapComboBox(bool includeSwatches, QWidget *parent) :
29 NotifyingComboBox(parent) 29 NotifyingComboBox(parent),
30 m_includeSwatches(includeSwatches)
30 { 31 {
31 setEditable(false); 32 setEditable(false);
32 rebuild(); 33 rebuild();
33 34
34 connect(this, SIGNAL(activated(int)), this, SLOT(comboActivated(int))); 35 connect(this, SIGNAL(activated(int)), this, SLOT(comboActivated(int)));
55 56
56 int size = (QFontMetrics(QFont()).height() * 2) / 3; 57 int size = (QFontMetrics(QFont()).height() * 2) / 3;
57 if (size < 12) size = 12; 58 if (size < 12) size = 12;
58 59
59 for (int i = 0; i < ColourMapper::getColourMapCount(); ++i) { 60 for (int i = 0; i < ColourMapper::getColourMapCount(); ++i) {
60 QString name = ColourMapper::getColourMapName(i); 61 QString name = ColourMapper::getColourMapName(i);
61 // addItem(db->getExamplePixmap(i, QSize(size, size)), name); 62 if (m_includeSwatches) {
62 addItem(name); 63 ColourMapper mapper(i, 0.0, 1.0);
64 addItem(mapper.getExamplePixmap(QSize(size * 2, size)), name);
65 } else {
66 addItem(name);
67 }
63 } 68 }
64 69
65 setCurrentIndex(ix); 70 setCurrentIndex(ix);
66 71
67 blockSignals(false); 72 blockSignals(false);