annotate widgets/ColourMapComboBox.cpp @ 1447:8afea53332f3 single-point

Add option to make pane sizes auto-resize-only (i.e. remove user control via a splitter); also place alignment views above panes instead of below, meaning the extra bit of space that we currently have for the pane without one at least goes to the primary pane
author Chris Cannam
date Tue, 30 Apr 2019 15:53:21 +0100
parents d79e21855aef
children
rev   line source
Chris@1196 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1196 2
Chris@1196 3 /*
Chris@1196 4 Sonic Visualiser
Chris@1196 5 An audio file viewer and annotation editor.
Chris@1196 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1196 7 This file copyright 2007-2016 QMUL.
Chris@1196 8
Chris@1196 9 This program is free software; you can redistribute it and/or
Chris@1196 10 modify it under the terms of the GNU General Public License as
Chris@1196 11 published by the Free Software Foundation; either version 2 of the
Chris@1196 12 License, or (at your option) any later version. See the file
Chris@1196 13 COPYING included with this distribution for more information.
Chris@1196 14 */
Chris@1196 15
Chris@1198 16 #include "ColourMapComboBox.h"
Chris@1196 17
Chris@1198 18 #include "layer/ColourMapper.h"
Chris@1196 19
Chris@1196 20 #include "base/Debug.h"
Chris@1196 21
Chris@1196 22 #include <QFontMetrics>
Chris@1196 23
Chris@1196 24 #include <iostream>
Chris@1196 25
Chris@1196 26 using namespace std;
Chris@1196 27
Chris@1199 28 ColourMapComboBox::ColourMapComboBox(bool includeSwatches, QWidget *parent) :
Chris@1199 29 NotifyingComboBox(parent),
Chris@1199 30 m_includeSwatches(includeSwatches)
Chris@1196 31 {
Chris@1196 32 setEditable(false);
Chris@1196 33 rebuild();
Chris@1196 34
Chris@1196 35 connect(this, SIGNAL(activated(int)), this, SLOT(comboActivated(int)));
Chris@1196 36
Chris@1196 37 if (count() < 20 && count() > maxVisibleItems()) {
Chris@1266 38 setMaxVisibleItems(count());
Chris@1196 39 }
Chris@1196 40 }
Chris@1196 41
Chris@1196 42 void
Chris@1198 43 ColourMapComboBox::comboActivated(int index)
Chris@1196 44 {
Chris@1198 45 emit colourMapChanged(index);
Chris@1196 46 }
Chris@1196 47
Chris@1196 48 void
Chris@1198 49 ColourMapComboBox::rebuild()
Chris@1196 50 {
Chris@1196 51 blockSignals(true);
Chris@1196 52
Chris@1196 53 int ix = currentIndex();
Chris@1196 54
Chris@1196 55 clear();
Chris@1196 56
Chris@1196 57 int size = (QFontMetrics(QFont()).height() * 2) / 3;
Chris@1196 58 if (size < 12) size = 12;
Chris@1196 59
Chris@1198 60 for (int i = 0; i < ColourMapper::getColourMapCount(); ++i) {
Chris@1362 61 QString name = ColourMapper::getColourMapLabel(i);
Chris@1199 62 if (m_includeSwatches) {
Chris@1362 63 ColourMapper mapper(i, false, 0.0, 1.0);
Chris@1199 64 addItem(mapper.getExamplePixmap(QSize(size * 2, size)), name);
Chris@1199 65 } else {
Chris@1199 66 addItem(name);
Chris@1199 67 }
Chris@1196 68 }
Chris@1196 69
Chris@1196 70 setCurrentIndex(ix);
Chris@1196 71
Chris@1196 72 blockSignals(false);
Chris@1196 73 }
Chris@1196 74