comparison widgets/PluginParameterBox.cpp @ 908:4a578a360011 cxx11

More type fixes
author Chris Cannam
date Tue, 10 Mar 2015 13:22:10 +0000
parents 1fdd895063c5
children 01778052e663
comparison
equal deleted inserted replaced
907:28d05ae8741c 908:4a578a360011
68 68
69 std::string currentProgram = m_plugin->getCurrentProgram(); 69 std::string currentProgram = m_plugin->getCurrentProgram();
70 70
71 m_programCombo = new QComboBox; 71 m_programCombo = new QComboBox;
72 m_programCombo->setMaxVisibleItems 72 m_programCombo->setMaxVisibleItems
73 (m_programs.size() < 25 ? m_programs.size() : 20); 73 (int(m_programs.size() < 25 ? m_programs.size() : 20));
74 74
75 for (size_t i = 0; i < m_programs.size(); ++i) { 75 for (int i = 0; in_range_for(m_programs, i); ++i) {
76 m_programCombo->addItem(m_programs[i].c_str()); 76 m_programCombo->addItem(m_programs[i].c_str());
77 if (m_programs[i] == currentProgram) { 77 if (m_programs[i] == currentProgram) {
78 m_programCombo->setCurrentIndex(i); 78 m_programCombo->setCurrentIndex(int(i));
79 } 79 }
80 } 80 }
81 81
82 m_layout->addWidget(new QLabel(tr("Program")), 0, 0); 82 m_layout->addWidget(new QLabel(tr("Program")), 0, 0);
83 m_layout->addWidget(m_programCombo, 0, 1, 1, 2); 83 m_layout->addWidget(m_programCombo, 0, 1, 1, 2);
86 this, SLOT(programComboChanged(const QString &))); 86 this, SLOT(programComboChanged(const QString &)));
87 87
88 offset = 1; 88 offset = 1;
89 } 89 }
90 90
91 for (size_t i = 0; i < params.size(); ++i) { 91 for (int i = 0; in_range_for(params, i); ++i) {
92 92
93 QString identifier = params[i].identifier.c_str(); 93 QString identifier = params[i].identifier.c_str();
94 QString name = params[i].name.c_str(); 94 QString name = params[i].name.c_str();
95 QString unit = params[i].unit.c_str(); 95 QString unit = params[i].unit.c_str();
96 96
118 118
119 int imin = 0, imax = 100; 119 int imin = 0, imax = 100;
120 120
121 if (!(hint & PortHint::Logarithmic)) { 121 if (!(hint & PortHint::Logarithmic)) {
122 if (qtz > 0.0) { 122 if (qtz > 0.0) {
123 imax = lrintf((max - min) / qtz); 123 imax = int(lrintf((max - min) / qtz));
124 } else { 124 } else {
125 qtz = (max - min) / 100.0; 125 qtz = (max - min) / 100.f;
126 } 126 }
127 } 127 }
128 128
129 //!!! would be nice to ensure the default value corresponds to 129 //!!! would be nice to ensure the default value corresponds to
130 // an integer! 130 // an integer!
243 243
244 AudioDial *ad = dynamic_cast<AudioDial *>(obj); 244 AudioDial *ad = dynamic_cast<AudioDial *>(obj);
245 245
246 if (ad && ad->rangeMapper()) { 246 if (ad && ad->rangeMapper()) {
247 247
248 newValue = ad->mappedValue(); 248 newValue = float(ad->mappedValue());
249 if (newValue < min) newValue = min; 249 if (newValue < min) newValue = min;
250 if (newValue > max) newValue = max; 250 if (newValue > max) newValue = max;
251 if (qtz != 0.0) { 251 if (qtz != 0.0) {
252 ival = lrintf((newValue - min) / qtz); 252 ival = int(lrintf((newValue - min) / qtz));
253 newValue = min + ival * qtz; 253 newValue = min + float(ival) * qtz;
254 } 254 }
255 255
256 } else { 256 } else {
257 if (qtz == 0.0) { 257 if (qtz == 0.f) {
258 qtz = (max - min) / 100.0; 258 qtz = (max - min) / 100.f;
259 } 259 }
260 newValue = min + ival * qtz; 260 newValue = min + float(ival) * qtz;
261 } 261 }
262 262
263 // SVDEBUG << "PluginParameterBox::dialChanged: newValue = " << newValue << endl; 263 // SVDEBUG << "PluginParameterBox::dialChanged: newValue = " << newValue << endl;
264 264
265 QDoubleSpinBox *spin = m_params[identifier].spin; 265 QDoubleSpinBox *spin = m_params[identifier].spin;
327 327
328 float qtz = 0.0; 328 float qtz = 0.0;
329 if (params.isQuantized) qtz = params.quantizeStep; 329 if (params.isQuantized) qtz = params.quantizeStep;
330 330
331 if (qtz > 0.0) { 331 if (qtz > 0.0) {
332 int step = lrintf((value - min) / qtz); 332 int step = int(lrintf(float(value - min) / qtz));
333 value = min + step * qtz; 333 value = min + float(step) * qtz;
334 } 334 }
335 335
336 // int imax = 100; 336 // int imax = 100;
337 337
338 if (qtz > 0.0) { 338 if (qtz > 0.0) {
339 // imax = lrintf((max - min) / qtz); 339 // imax = lrintf((max - min) / qtz);
340 } else { 340 } else {
341 qtz = (max - min) / 100.0; 341 qtz = (max - min) / 100.f;
342 } 342 }
343 343
344 int ival = lrintf((value - min) / qtz); 344 int ival = int(lrintf(float(value - min) / qtz));
345 345
346 AudioDial *dial = m_params[identifier].dial; 346 AudioDial *dial = m_params[identifier].dial;
347 if (dial) { 347 if (dial) {
348 dial->blockSignals(true); 348 dial->blockSignals(true);
349 if (dial->rangeMapper()) { 349 if (dial->rangeMapper()) {
354 dial->blockSignals(false); 354 dial->blockSignals(false);
355 } 355 }
356 356
357 SVDEBUG << "setting plugin parameter \"" << identifier << "\" to value " << value << endl; 357 SVDEBUG << "setting plugin parameter \"" << identifier << "\" to value " << value << endl;
358 358
359 m_plugin->setParameter(identifier.toStdString(), value); 359 m_plugin->setParameter(identifier.toStdString(), float(value));
360 360
361 updateProgramCombo(); 361 updateProgramCombo();
362 362
363 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); 363 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString());
364 } 364 }
387 387
388 float qtz = 0.0; 388 float qtz = 0.0;
389 if (param.isQuantized) qtz = param.quantizeStep; 389 if (param.isQuantized) qtz = param.quantizeStep;
390 390
391 if (qtz == 0.0) { 391 if (qtz == 0.0) {
392 qtz = (max - min) / 100.0; 392 qtz = (max - min) / 100.f;
393 } 393 }
394 394
395 i->second.dial->blockSignals(true); 395 i->second.dial->blockSignals(true);
396 i->second.dial->setValue(lrintf((value - min) / qtz)); 396 i->second.dial->setValue(int(lrintf(float(value - min) / qtz)));
397 i->second.dial->blockSignals(false); 397 i->second.dial->blockSignals(false);
398 } 398 }
399 399
400 if (i->second.combo) { 400 if (i->second.combo) {
401 i->second.combo->blockSignals(true); 401 i->second.combo->blockSignals(true);
402 i->second.combo->setCurrentIndex(lrintf(value)); 402 i->second.combo->setCurrentIndex(int(lrintf(value)));
403 i->second.combo->blockSignals(false); 403 i->second.combo->blockSignals(false);
404 } 404 }
405 405
406 if (i->second.check) { 406 if (i->second.check) {
407 i->second.check->blockSignals(true); 407 i->second.check->blockSignals(true);
418 { 418 {
419 if (!m_programCombo || m_programs.empty()) return; 419 if (!m_programCombo || m_programs.empty()) return;
420 420
421 std::string currentProgram = m_plugin->getCurrentProgram(); 421 std::string currentProgram = m_plugin->getCurrentProgram();
422 422
423 for (size_t i = 0; i < m_programs.size(); ++i) { 423 for (int i = 0; in_range_for(m_programs, i); ++i) {
424 if (m_programs[i] == currentProgram) { 424 if (m_programs[i] == currentProgram) {
425 m_programCombo->setCurrentIndex(i); 425 m_programCombo->setCurrentIndex(i);
426 } 426 }
427 } 427 }
428 } 428 }