comparison widgets/PluginParameterBox.cpp @ 168:d4be66d61c04

* Make audio dial remember its more accurate mapped value as well as its display position * Add tool tip support to audio dial to show values
author Chris Cannam
date Tue, 17 Oct 2006 13:04:49 +0000
parents 53b9c7656798
children 42118892f428
comparison
equal deleted inserted replaced
167:53b9c7656798 168:d4be66d61c04
161 dial->setValue(lrintf((value - min) / qtz)); 161 dial->setValue(lrintf((value - min) / qtz));
162 dial->setFixedWidth(32); 162 dial->setFixedWidth(32);
163 dial->setFixedHeight(32); 163 dial->setFixedHeight(32);
164 dial->setRangeMapper(new LinearRangeMapper 164 dial->setRangeMapper(new LinearRangeMapper
165 (imin, imax, min, max, unit)); 165 (imin, imax, min, max, unit));
166 dial->setShowToolTip(true);
166 connect(dial, SIGNAL(valueChanged(int)), 167 connect(dial, SIGNAL(valueChanged(int)),
167 this, SLOT(dialChanged(int))); 168 this, SLOT(dialChanged(int)));
168 m_layout->addWidget(dial, i + offset, 1); 169 m_layout->addWidget(dial, i + offset, 1);
169 170
170 QDoubleSpinBox *spinbox = new QDoubleSpinBox; 171 QDoubleSpinBox *spinbox = new QDoubleSpinBox;
206 Vamp::PluginBase::ParameterDescriptor params = m_params[name].param; 207 Vamp::PluginBase::ParameterDescriptor params = m_params[name].param;
207 208
208 float min = params.minValue; 209 float min = params.minValue;
209 float max = params.maxValue; 210 float max = params.maxValue;
210 211
212 float newValue;
213
211 float qtz = 0.0; 214 float qtz = 0.0;
212 if (params.isQuantized) qtz = params.quantizeStep; 215 if (params.isQuantized) qtz = params.quantizeStep;
216
217 AudioDial *ad = dynamic_cast<AudioDial *>(obj);
213 218
214 if (qtz == 0.0) { 219 if (ad && ad->rangeMapper()) {
215 qtz = (max - min) / 100.0; 220
216 } 221 newValue = ad->mappedValue();
217 222 if (newValue < min) newValue = min;
218 float newValue = min + ival * qtz; 223 if (newValue > max) newValue = max;
224 if (qtz != 0.0) {
225 ival = lrintf((newValue - min) / qtz);
226 newValue = min + ival * qtz;
227 }
228
229 } else {
230 if (qtz == 0.0) {
231 qtz = (max - min) / 100.0;
232 }
233 newValue = min + ival * qtz;
234 }
219 235
220 QDoubleSpinBox *spin = m_params[name].spin; 236 QDoubleSpinBox *spin = m_params[name].spin;
221 if (spin) { 237 if (spin) {
222 spin->blockSignals(true); 238 spin->blockSignals(true);
223 spin->setValue(newValue); 239 spin->setValue(newValue);