diff 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
line wrap: on
line diff
--- a/widgets/ColourMapComboBox.cpp	Fri Dec 16 14:16:05 2016 +0000
+++ b/widgets/ColourMapComboBox.cpp	Fri Dec 16 15:55:59 2016 +0000
@@ -25,8 +25,9 @@
 
 using namespace std;
 
-ColourMapComboBox::ColourMapComboBox(QWidget *parent) :
-    NotifyingComboBox(parent)
+ColourMapComboBox::ColourMapComboBox(bool includeSwatches, QWidget *parent) :
+    NotifyingComboBox(parent),
+    m_includeSwatches(includeSwatches)
 {
     setEditable(false);
     rebuild();
@@ -57,9 +58,13 @@
     if (size < 12) size = 12;
 
     for (int i = 0; i < ColourMapper::getColourMapCount(); ++i) {
-	QString name = ColourMapper::getColourMapName(i);
-//	addItem(db->getExamplePixmap(i, QSize(size, size)), name);
-        addItem(name);
+        QString name = ColourMapper::getColourMapName(i);
+        if (m_includeSwatches) {
+            ColourMapper mapper(i, 0.0, 1.0);
+            addItem(mapper.getExamplePixmap(QSize(size * 2, size)), name);
+        } else {
+            addItem(name);
+        }
     }
 
     setCurrentIndex(ix);