Mercurial > hg > svgui
comparison widgets/PluginParameterBox.cpp @ 293:15b8a4bfe855
* continue to pick "new" colours for coloured layers even when all colours
have been used at least once, rather than sticking on the last one
* some messing about with application palette settings
* when replacing an audio file, retain the previous playback settings for
any layers that depended on the old file
* re-check plugin program setting when a parameter changes -- so a plugin
can decide to reset the program if the parameters no longer match those
for the current program
* fix failure to update check-boxes for toggled plugin parameters when their
parameters are changed by program changes
author | Chris Cannam |
---|---|
date | Thu, 09 Aug 2007 14:40:03 +0000 |
parents | e6d0b097d102 |
children | a904364dfb6e |
comparison
equal
deleted
inserted
replaced
292:24fc90078754 | 293:15b8a4bfe855 |
---|---|
33 | 33 |
34 #include <cmath> | 34 #include <cmath> |
35 | 35 |
36 PluginParameterBox::PluginParameterBox(Vamp::PluginBase *plugin, QWidget *parent) : | 36 PluginParameterBox::PluginParameterBox(Vamp::PluginBase *plugin, QWidget *parent) : |
37 QFrame(parent), | 37 QFrame(parent), |
38 m_plugin(plugin) | 38 m_plugin(plugin), |
39 m_programCombo(0) | |
39 { | 40 { |
40 m_layout = new QGridLayout; | 41 m_layout = new QGridLayout; |
41 setLayout(m_layout); | 42 setLayout(m_layout); |
42 populate(); | 43 populate(); |
43 } | 44 } |
48 | 49 |
49 void | 50 void |
50 PluginParameterBox::populate() | 51 PluginParameterBox::populate() |
51 { | 52 { |
52 Vamp::PluginBase::ParameterList params = m_plugin->getParameterDescriptors(); | 53 Vamp::PluginBase::ParameterList params = m_plugin->getParameterDescriptors(); |
53 Vamp::PluginBase::ProgramList programs = m_plugin->getPrograms(); | 54 m_programs = m_plugin->getPrograms(); |
54 | 55 |
55 m_params.clear(); | 56 m_params.clear(); |
56 | 57 |
57 if (params.empty() && programs.empty()) { | 58 if (params.empty() && m_programs.empty()) { |
58 m_layout->addWidget | 59 m_layout->addWidget |
59 (new QLabel(tr("This plugin has no adjustable parameters.")), | 60 (new QLabel(tr("This plugin has no adjustable parameters.")), |
60 0, 0); | 61 0, 0); |
61 } | 62 } |
62 | 63 |
63 int offset = 0; | 64 int offset = 0; |
64 | 65 |
65 if (!programs.empty()) { | 66 if (!m_programs.empty()) { |
66 | 67 |
67 std::string currentProgram = m_plugin->getCurrentProgram(); | 68 std::string currentProgram = m_plugin->getCurrentProgram(); |
68 | 69 |
69 QComboBox *programCombo = new QComboBox; | 70 m_programCombo = new QComboBox; |
70 programCombo->setMaxVisibleItems(20); | 71 m_programCombo->setMaxVisibleItems |
71 | 72 (m_programs.size() < 25 ? m_programs.size() : 20); |
72 for (size_t i = 0; i < programs.size(); ++i) { | 73 |
73 programCombo->addItem(programs[i].c_str()); | 74 for (size_t i = 0; i < m_programs.size(); ++i) { |
74 if (programs[i] == currentProgram) { | 75 m_programCombo->addItem(m_programs[i].c_str()); |
75 programCombo->setCurrentIndex(i); | 76 if (m_programs[i] == currentProgram) { |
77 m_programCombo->setCurrentIndex(i); | |
76 } | 78 } |
77 } | 79 } |
78 | 80 |
79 m_layout->addWidget(new QLabel(tr("Program")), 0, 0); | 81 m_layout->addWidget(new QLabel(tr("Program")), 0, 0); |
80 m_layout->addWidget(programCombo, 0, 1, 1, 2); | 82 m_layout->addWidget(m_programCombo, 0, 1, 1, 2); |
81 | 83 |
82 connect(programCombo, SIGNAL(currentIndexChanged(const QString &)), | 84 connect(m_programCombo, SIGNAL(currentIndexChanged(const QString &)), |
83 this, SLOT(programComboChanged(const QString &))); | 85 this, SLOT(programComboChanged(const QString &))); |
84 | 86 |
85 offset = 1; | 87 offset = 1; |
86 } | 88 } |
87 | 89 |
144 | 146 |
145 } else if (min == 0.0 && max == 1.0 && qtz == 1.0) { | 147 } else if (min == 0.0 && max == 1.0 && qtz == 1.0) { |
146 | 148 |
147 QCheckBox *checkbox = new QCheckBox; | 149 QCheckBox *checkbox = new QCheckBox; |
148 checkbox->setObjectName(identifier); | 150 checkbox->setObjectName(identifier); |
149 checkbox->setCheckState(value == 0.0 ? Qt::Unchecked : Qt::Checked); | 151 checkbox->setCheckState(value < 0.5 ? Qt::Unchecked : Qt::Checked); |
150 connect(checkbox, SIGNAL(stateChanged(int)), | 152 connect(checkbox, SIGNAL(stateChanged(int)), |
151 this, SLOT(checkBoxChanged(int))); | 153 this, SLOT(checkBoxChanged(int))); |
152 m_layout->addWidget(checkbox, i + offset, 2); | 154 m_layout->addWidget(checkbox, i + offset, 2); |
153 rec.check = checkbox; | 155 rec.check = checkbox; |
154 | 156 |
243 spin->blockSignals(false); | 245 spin->blockSignals(false); |
244 } | 246 } |
245 | 247 |
246 m_plugin->setParameter(identifier.toStdString(), newValue); | 248 m_plugin->setParameter(identifier.toStdString(), newValue); |
247 | 249 |
250 updateProgramCombo(); | |
251 | |
248 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); | 252 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); |
249 } | 253 } |
250 | 254 |
251 void | 255 void |
252 PluginParameterBox::checkBoxChanged(int state) | 256 PluginParameterBox::checkBoxChanged(int state) |
266 | 270 |
267 Vamp::PluginBase::ParameterDescriptor params = m_params[identifier].param; | 271 Vamp::PluginBase::ParameterDescriptor params = m_params[identifier].param; |
268 | 272 |
269 if (state) m_plugin->setParameter(identifier.toStdString(), 1.0); | 273 if (state) m_plugin->setParameter(identifier.toStdString(), 1.0); |
270 else m_plugin->setParameter(identifier.toStdString(), 0.0); | 274 else m_plugin->setParameter(identifier.toStdString(), 0.0); |
275 | |
276 updateProgramCombo(); | |
271 | 277 |
272 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); | 278 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); |
273 } | 279 } |
274 | 280 |
275 void | 281 void |
318 dial->blockSignals(false); | 324 dial->blockSignals(false); |
319 } | 325 } |
320 | 326 |
321 m_plugin->setParameter(identifier.toStdString(), value); | 327 m_plugin->setParameter(identifier.toStdString(), value); |
322 | 328 |
329 updateProgramCombo(); | |
330 | |
323 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); | 331 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); |
324 } | 332 } |
325 | 333 |
326 void | 334 void |
327 PluginParameterBox::programComboChanged(const QString &newProgram) | 335 PluginParameterBox::programComboChanged(const QString &newProgram) |
360 if (i->second.combo) { | 368 if (i->second.combo) { |
361 i->second.combo->blockSignals(true); | 369 i->second.combo->blockSignals(true); |
362 i->second.combo->setCurrentIndex(lrintf(value)); | 370 i->second.combo->setCurrentIndex(lrintf(value)); |
363 i->second.combo->blockSignals(false); | 371 i->second.combo->blockSignals(false); |
364 } | 372 } |
373 | |
374 if (i->second.check) { | |
375 i->second.check->blockSignals(true); | |
376 i->second.check->setCheckState(value < 0.5 ? Qt::Unchecked : Qt::Checked); | |
377 i->second.check->blockSignals(false); | |
378 } | |
365 } | 379 } |
366 | 380 |
367 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); | 381 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); |
368 } | 382 } |
369 | 383 |
384 void | |
385 PluginParameterBox::updateProgramCombo() | |
386 { | |
387 if (!m_programCombo || m_programs.empty()) return; | |
388 | |
389 std::string currentProgram = m_plugin->getCurrentProgram(); | |
390 | |
391 for (size_t i = 0; i < m_programs.size(); ++i) { | |
392 if (m_programs[i] == currentProgram) { | |
393 m_programCombo->setCurrentIndex(i); | |
394 } | |
395 } | |
396 } | |
397 | |
398 |