Mercurial > hg > svgui
comparison widgets/PluginParameterBox.cpp @ 74:195ad6178ef8
* Support latest changes to Vamp API (value names for parameters, FFT
alignment, value -> bin terminology change)
author | Chris Cannam |
---|---|
date | Wed, 05 Apr 2006 16:52:30 +0000 |
parents | 72fa239a4880 |
children | 967193b6c7aa |
comparison
equal
deleted
inserted
replaced
73:ad1fe715b480 | 74:195ad6178ef8 |
---|---|
93 float value = m_plugin->getParameter(params[i].name); | 93 float value = m_plugin->getParameter(params[i].name); |
94 | 94 |
95 float qtz = 0.0; | 95 float qtz = 0.0; |
96 if (params[i].isQuantized) qtz = params[i].quantizeStep; | 96 if (params[i].isQuantized) qtz = params[i].quantizeStep; |
97 | 97 |
98 std::vector<std::string> valueNames = params[i].valueNames; | |
99 | |
98 // construct an integer range | 100 // construct an integer range |
99 | 101 |
100 int imin = 0, imax = 100; | 102 int imin = 0, imax = 100; |
101 | 103 |
102 if (qtz > 0.0) { | 104 if (qtz > 0.0) { |
114 ParamRec rec; | 116 ParamRec rec; |
115 rec.param = params[i]; | 117 rec.param = params[i]; |
116 rec.dial = 0; | 118 rec.dial = 0; |
117 rec.spin = 0; | 119 rec.spin = 0; |
118 rec.check = 0; | 120 rec.check = 0; |
121 rec.combo = 0; | |
119 | 122 |
120 if (min == 0.0 && max == 1.0 && qtz == 1.0) { | 123 if (params[i].isQuantized && !valueNames.empty()) { |
124 | |
125 QComboBox *combobox = new QComboBox; | |
126 combobox->setObjectName(name); | |
127 for (unsigned int j = 0; j < valueNames.size(); ++j) { | |
128 combobox->addItem(valueNames[j].c_str()); | |
129 if (lrintf((value - min) / qtz) == j) { | |
130 combobox->setCurrentIndex(j); | |
131 } | |
132 } | |
133 connect(combobox, SIGNAL(activated(int)), | |
134 this, SLOT(dialChanged(int))); | |
135 m_layout->addWidget(combobox, i + offset, 1, 1, 2); | |
136 rec.combo = combobox; | |
137 | |
138 } else if (min == 0.0 && max == 1.0 && qtz == 1.0) { | |
121 | 139 |
122 QCheckBox *checkbox = new QCheckBox; | 140 QCheckBox *checkbox = new QCheckBox; |
123 checkbox->setObjectName(name); | 141 checkbox->setObjectName(name); |
124 checkbox->setCheckState(value == 0.0 ? Qt::Unchecked : Qt::Checked); | 142 checkbox->setCheckState(value == 0.0 ? Qt::Unchecked : Qt::Checked); |
125 connect(checkbox, SIGNAL(stateChanged(int)), | 143 connect(checkbox, SIGNAL(stateChanged(int)), |
133 dial->setObjectName(name); | 151 dial->setObjectName(name); |
134 dial->setMinimum(imin); | 152 dial->setMinimum(imin); |
135 dial->setMaximum(imax); | 153 dial->setMaximum(imax); |
136 dial->setPageStep(1); | 154 dial->setPageStep(1); |
137 dial->setNotchesVisible((imax - imin) <= 12); | 155 dial->setNotchesVisible((imax - imin) <= 12); |
138 dial->setDefaultValue(int((deft - min) / qtz)); | 156 dial->setDefaultValue(lrintf((deft - min) / qtz)); |
139 dial->setValue(int((value - min) / qtz)); | 157 dial->setValue(lrintf((value - min) / qtz)); |
140 dial->setFixedWidth(32); | 158 dial->setFixedWidth(32); |
141 dial->setFixedHeight(32); | 159 dial->setFixedHeight(32); |
142 connect(dial, SIGNAL(valueChanged(int)), | 160 connect(dial, SIGNAL(valueChanged(int)), |
143 this, SLOT(dialChanged(int))); | 161 this, SLOT(dialChanged(int))); |
144 m_layout->addWidget(dial, i + offset, 1); | 162 m_layout->addWidget(dial, i + offset, 1); |
291 if (qtz == 0.0) { | 309 if (qtz == 0.0) { |
292 qtz = (max - min) / 100.0; | 310 qtz = (max - min) / 100.0; |
293 } | 311 } |
294 | 312 |
295 i->second.dial->blockSignals(true); | 313 i->second.dial->blockSignals(true); |
296 i->second.dial->setValue(int((value - min) / qtz)); | 314 i->second.dial->setValue(lrintf((value - min) / qtz)); |
297 i->second.dial->blockSignals(false); | 315 i->second.dial->blockSignals(false); |
298 } | 316 } |
317 | |
318 if (i->second.combo) { | |
319 i->second.combo->blockSignals(true); | |
320 i->second.combo->setCurrentIndex(value); | |
321 i->second.combo->blockSignals(false); | |
322 } | |
299 } | 323 } |
300 | 324 |
301 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); | 325 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); |
302 } | 326 } |
303 | 327 |