Chris@58
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@59
|
4 Sonic Visualiser
|
Chris@59
|
5 An audio file viewer and annotation editor.
|
Chris@59
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@59
|
7 This file copyright 2006 Chris Cannam.
|
Chris@0
|
8
|
Chris@59
|
9 This program is free software; you can redistribute it and/or
|
Chris@59
|
10 modify it under the terms of the GNU General Public License as
|
Chris@59
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@59
|
12 License, or (at your option) any later version. See the file
|
Chris@59
|
13 COPYING included with this distribution for more information.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@0
|
16 #include "PropertyBox.h"
|
Chris@63
|
17 #include "PluginParameterDialog.h"
|
Chris@0
|
18
|
Chris@0
|
19 #include "base/PropertyContainer.h"
|
Chris@33
|
20 #include "base/PlayParameters.h"
|
Chris@33
|
21 #include "base/Layer.h"
|
Chris@0
|
22
|
Chris@63
|
23 #include "plugin/RealTimePluginFactory.h"
|
Chris@63
|
24 #include "plugin/RealTimePluginInstance.h"
|
Chris@63
|
25
|
Chris@0
|
26 #include "AudioDial.h"
|
Chris@33
|
27 #include "LEDButton.h"
|
Chris@0
|
28
|
Chris@0
|
29 #include <QGridLayout>
|
Chris@0
|
30 #include <QHBoxLayout>
|
Chris@33
|
31 #include <QVBoxLayout>
|
Chris@0
|
32 #include <QCheckBox>
|
Chris@0
|
33 #include <QComboBox>
|
Chris@63
|
34 #include <QPushButton>
|
Chris@0
|
35 #include <QLabel>
|
Chris@33
|
36 #include <QFrame>
|
Chris@0
|
37
|
Chris@0
|
38 #include <cassert>
|
Chris@0
|
39 #include <iostream>
|
Martin@46
|
40 #include <cmath>
|
Chris@0
|
41
|
Chris@0
|
42 //#define DEBUG_PROPERTY_BOX 1
|
Chris@0
|
43
|
Chris@0
|
44 PropertyBox::PropertyBox(PropertyContainer *container) :
|
Chris@0
|
45 m_container(container)
|
Chris@0
|
46 {
|
Chris@0
|
47 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
48 std::cerr << "PropertyBox[" << this << "(\"" <<
|
Chris@0
|
49 container->getPropertyContainerName().toStdString() << "\")]::PropertyBox" << std::endl;
|
Chris@0
|
50 #endif
|
Chris@0
|
51
|
Chris@34
|
52 m_mainBox = new QVBoxLayout;
|
Chris@34
|
53 setLayout(m_mainBox);
|
Chris@33
|
54
|
Chris@34
|
55 m_mainWidget = new QWidget;
|
Chris@34
|
56 m_mainBox->addWidget(m_mainWidget);
|
Chris@34
|
57 m_mainBox->insertStretch(1, 10);
|
Chris@33
|
58
|
Chris@34
|
59 m_viewPlayFrame = 0;
|
Chris@34
|
60 populateViewPlayFrame();
|
Chris@33
|
61
|
Chris@0
|
62 m_layout = new QGridLayout;
|
Chris@34
|
63 m_layout->setMargin(0);
|
Chris@33
|
64 m_mainWidget->setLayout(m_layout);
|
Chris@0
|
65
|
Chris@34
|
66 PropertyContainer::PropertyList properties = m_container->getProperties();
|
Chris@0
|
67
|
Chris@0
|
68 blockSignals(true);
|
Chris@0
|
69
|
Chris@0
|
70 size_t i;
|
Chris@0
|
71
|
Chris@0
|
72 for (i = 0; i < properties.size(); ++i) {
|
Chris@0
|
73 updatePropertyEditor(properties[i]);
|
Chris@0
|
74 }
|
Chris@0
|
75
|
Chris@0
|
76 blockSignals(false);
|
Chris@0
|
77
|
Chris@0
|
78 m_layout->setRowStretch(m_layout->rowCount(), 10);
|
Chris@0
|
79
|
Chris@0
|
80 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
81 std::cerr << "PropertyBox[" << this << "]::PropertyBox returning" << std::endl;
|
Chris@0
|
82 #endif
|
Chris@0
|
83 }
|
Chris@0
|
84
|
Chris@0
|
85 PropertyBox::~PropertyBox()
|
Chris@0
|
86 {
|
Chris@0
|
87 #ifdef DEBUG_PROPERTY_BOX
|
Chris@33
|
88 std::cerr << "PropertyBox[" << this << "]::~PropertyBox" << std::endl;
|
Chris@0
|
89 #endif
|
Chris@0
|
90 }
|
Chris@0
|
91
|
Chris@0
|
92 void
|
Chris@34
|
93 PropertyBox::populateViewPlayFrame()
|
Chris@33
|
94 {
|
Chris@36
|
95 #ifdef DEBUG_PROPERTY_BOX
|
Chris@34
|
96 std::cerr << "PropertyBox(" << m_container << ")::populateViewPlayFrame" << std::endl;
|
Chris@36
|
97 #endif
|
Chris@34
|
98
|
Chris@34
|
99 if (m_viewPlayFrame) {
|
Chris@34
|
100 delete m_viewPlayFrame;
|
Chris@34
|
101 m_viewPlayFrame = 0;
|
Chris@34
|
102 }
|
Chris@34
|
103
|
Chris@34
|
104 if (!m_container) return;
|
Chris@34
|
105
|
Chris@34
|
106 Layer *layer = dynamic_cast<Layer *>(m_container);
|
Chris@34
|
107 if (layer) {
|
Chris@34
|
108 connect(layer, SIGNAL(modelReplaced()),
|
Chris@34
|
109 this, SLOT(populateViewPlayFrame()));
|
Chris@34
|
110 }
|
Chris@34
|
111
|
Chris@34
|
112 PlayParameters *params = m_container->getPlayParameters();
|
Chris@33
|
113 if (!params && !layer) return;
|
Chris@33
|
114
|
Chris@34
|
115 m_viewPlayFrame = new QFrame;
|
Chris@34
|
116 m_viewPlayFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@34
|
117 m_mainBox->addWidget(m_viewPlayFrame);
|
Chris@34
|
118
|
Chris@34
|
119 QHBoxLayout *layout = new QHBoxLayout;
|
Chris@34
|
120 m_viewPlayFrame->setLayout(layout);
|
Chris@34
|
121
|
Chris@34
|
122 layout->setMargin(layout->margin() / 2);
|
Chris@34
|
123
|
Chris@36
|
124 #ifdef DEBUG_PROPERTY_BOX
|
Chris@34
|
125 std::cerr << "PropertyBox::populateViewPlayFrame: container " << m_container << " (name " << m_container->getPropertyContainerName().toStdString() << ") params " << params << std::endl;
|
Chris@36
|
126 #endif
|
Chris@36
|
127
|
Chris@33
|
128 if (layer) {
|
Chris@34
|
129 QLabel *showLabel = new QLabel(tr("Show"));
|
Chris@34
|
130 layout->addWidget(showLabel);
|
Chris@34
|
131 layout->setAlignment(showLabel, Qt::AlignVCenter);
|
Chris@34
|
132
|
Chris@33
|
133 LEDButton *showButton = new LEDButton(Qt::blue);
|
Chris@33
|
134 layout->addWidget(showButton);
|
Chris@47
|
135 connect(showButton, SIGNAL(stateChanged(bool)),
|
Chris@47
|
136 this, SIGNAL(showLayer(bool)));
|
Chris@34
|
137 layout->setAlignment(showButton, Qt::AlignVCenter);
|
Chris@33
|
138 }
|
Chris@33
|
139
|
Chris@33
|
140 if (params) {
|
Chris@34
|
141
|
Chris@34
|
142 QLabel *playLabel = new QLabel(tr("Play"));
|
Chris@34
|
143 layout->addWidget(playLabel);
|
Chris@34
|
144 layout->setAlignment(playLabel, Qt::AlignVCenter);
|
Chris@34
|
145
|
Chris@33
|
146 LEDButton *playButton = new LEDButton(Qt::darkGreen);
|
Chris@33
|
147 layout->addWidget(playButton);
|
Chris@33
|
148 connect(playButton, SIGNAL(stateChanged(bool)),
|
Chris@33
|
149 params, SLOT(setPlayAudible(bool)));
|
Chris@34
|
150 connect(params, SIGNAL(playAudibleChanged(bool)),
|
Chris@34
|
151 playButton, SLOT(setState(bool)));
|
Chris@34
|
152 layout->setAlignment(playButton, Qt::AlignVCenter);
|
Chris@34
|
153
|
Chris@34
|
154 layout->insertStretch(-1, 10);
|
Chris@34
|
155
|
Chris@63
|
156 if (params->getPlayPluginId() != "") {
|
Chris@63
|
157 QPushButton *pluginButton = new QPushButton("E");
|
Chris@63
|
158 layout->addWidget(pluginButton);
|
Chris@63
|
159 connect(pluginButton, SIGNAL(clicked()),
|
Chris@63
|
160 this, SLOT(editPlugin()));
|
Chris@63
|
161 }
|
Chris@63
|
162
|
Chris@34
|
163 AudioDial *gainDial = new AudioDial;
|
Chris@34
|
164 layout->addWidget(gainDial);
|
Chris@34
|
165 gainDial->setMeterColor(Qt::darkRed);
|
Chris@34
|
166 gainDial->setMinimum(-50);
|
Chris@34
|
167 gainDial->setMaximum(50);
|
Chris@34
|
168 gainDial->setPageStep(1);
|
Chris@34
|
169 gainDial->setFixedWidth(24);
|
Chris@34
|
170 gainDial->setFixedHeight(24);
|
Chris@34
|
171 gainDial->setNotchesVisible(false);
|
Chris@57
|
172 gainDial->setToolTip(tr("Playback Level"));
|
Chris@34
|
173 gainDial->setDefaultValue(0);
|
Chris@34
|
174 connect(gainDial, SIGNAL(valueChanged(int)),
|
Chris@34
|
175 this, SLOT(playGainDialChanged(int)));
|
Chris@34
|
176 connect(params, SIGNAL(playGainChanged(float)),
|
Chris@34
|
177 this, SLOT(playGainChanged(float)));
|
Chris@34
|
178 connect(this, SIGNAL(changePlayGain(float)),
|
Chris@34
|
179 params, SLOT(setPlayGain(float)));
|
Chris@34
|
180 connect(this, SIGNAL(changePlayGainDial(int)),
|
Chris@34
|
181 gainDial, SLOT(setValue(int)));
|
Chris@34
|
182 layout->setAlignment(gainDial, Qt::AlignVCenter);
|
Chris@34
|
183
|
Chris@34
|
184 AudioDial *panDial = new AudioDial;
|
Chris@34
|
185 layout->addWidget(panDial);
|
Chris@34
|
186 panDial->setMeterColor(Qt::darkGreen);
|
Chris@34
|
187 panDial->setMinimum(-50);
|
Chris@34
|
188 panDial->setMaximum(50);
|
Chris@34
|
189 panDial->setPageStep(1);
|
Chris@34
|
190 panDial->setFixedWidth(24);
|
Chris@34
|
191 panDial->setFixedHeight(24);
|
Chris@34
|
192 panDial->setNotchesVisible(false);
|
Chris@57
|
193 panDial->setToolTip(tr("Playback Pan / Balance"));
|
Chris@34
|
194 panDial->setDefaultValue(0);
|
Chris@34
|
195 connect(panDial, SIGNAL(valueChanged(int)),
|
Chris@34
|
196 this, SLOT(playPanDialChanged(int)));
|
Chris@34
|
197 connect(params, SIGNAL(playPanChanged(float)),
|
Chris@34
|
198 this, SLOT(playPanChanged(float)));
|
Chris@34
|
199 connect(this, SIGNAL(changePlayPan(float)),
|
Chris@34
|
200 params, SLOT(setPlayPan(float)));
|
Chris@34
|
201 connect(this, SIGNAL(changePlayPanDial(int)),
|
Chris@34
|
202 panDial, SLOT(setValue(int)));
|
Chris@34
|
203 layout->setAlignment(panDial, Qt::AlignVCenter);
|
Chris@34
|
204
|
Chris@34
|
205 } else {
|
Chris@34
|
206
|
Chris@34
|
207 layout->insertStretch(-1, 10);
|
Chris@33
|
208 }
|
Chris@33
|
209 }
|
Chris@33
|
210
|
Chris@33
|
211 void
|
Chris@0
|
212 PropertyBox::updatePropertyEditor(PropertyContainer::PropertyName name)
|
Chris@0
|
213 {
|
Chris@0
|
214 PropertyContainer::PropertyType type = m_container->getPropertyType(name);
|
Chris@0
|
215 int row = m_layout->rowCount();
|
Chris@0
|
216
|
Chris@0
|
217 int min = 0, max = 0, value = 0;
|
Chris@0
|
218 value = m_container->getPropertyRangeAndValue(name, &min, &max);
|
Chris@0
|
219
|
Chris@0
|
220 bool have = (m_propertyControllers.find(name) !=
|
Chris@0
|
221 m_propertyControllers.end());
|
Chris@0
|
222
|
Chris@0
|
223 QString groupName = m_container->getPropertyGroupName(name);
|
Chris@0
|
224
|
Chris@0
|
225 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
226 std::cerr << "PropertyBox[" << this
|
Chris@0
|
227 << "(\"" << m_container->getPropertyContainerName().toStdString()
|
Chris@0
|
228 << "\")]";
|
Chris@0
|
229 std::cerr << "::updatePropertyEditor(\"" << name.toStdString() << "\"):";
|
Chris@0
|
230 std::cerr << " value " << value << ", have " << have << ", group \""
|
Chris@0
|
231 << groupName.toStdString() << "\"" << std::endl;
|
Chris@0
|
232 #endif
|
Chris@0
|
233
|
Chris@0
|
234 bool inGroup = (groupName != QString());
|
Chris@0
|
235
|
Chris@0
|
236 if (!have) {
|
Chris@0
|
237 if (inGroup) {
|
Chris@0
|
238 if (m_groupLayouts.find(groupName) == m_groupLayouts.end()) {
|
Chris@0
|
239 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
240 std::cerr << "PropertyBox: adding label \"" << groupName.toStdString() << "\" and frame for group for \"" << name.toStdString() << "\"" << std::endl;
|
Chris@0
|
241 #endif
|
Chris@33
|
242 m_layout->addWidget(new QLabel(groupName, m_mainWidget), row, 0);
|
Chris@33
|
243 QFrame *frame = new QFrame(m_mainWidget);
|
Chris@0
|
244 m_layout->addWidget(frame, row, 1, 1, 2);
|
Chris@0
|
245 m_groupLayouts[groupName] = new QHBoxLayout;
|
Chris@0
|
246 m_groupLayouts[groupName]->setMargin(0);
|
Chris@0
|
247 frame->setLayout(m_groupLayouts[groupName]);
|
Chris@0
|
248 }
|
Chris@0
|
249 } else {
|
Chris@0
|
250 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
251 std::cerr << "PropertyBox: adding label \"" << name.toStdString() << "\"" << std::endl;
|
Chris@0
|
252 #endif
|
Chris@33
|
253 m_layout->addWidget(new QLabel(name, m_mainWidget), row, 0);
|
Chris@0
|
254 }
|
Chris@0
|
255 }
|
Chris@0
|
256
|
Chris@0
|
257 switch (type) {
|
Chris@0
|
258
|
Chris@0
|
259 case PropertyContainer::ToggleProperty:
|
Chris@0
|
260 {
|
Chris@0
|
261 QCheckBox *cb;
|
Chris@0
|
262
|
Chris@0
|
263 if (have) {
|
Chris@0
|
264 cb = dynamic_cast<QCheckBox *>(m_propertyControllers[name]);
|
Chris@0
|
265 assert(cb);
|
Chris@0
|
266 } else {
|
Chris@0
|
267 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
268 std::cerr << "PropertyBox: creating new checkbox" << std::endl;
|
Chris@0
|
269 #endif
|
Chris@0
|
270 cb = new QCheckBox();
|
Chris@0
|
271 cb->setObjectName(name);
|
Chris@0
|
272 connect(cb, SIGNAL(stateChanged(int)),
|
Chris@0
|
273 this, SLOT(propertyControllerChanged(int)));
|
Chris@0
|
274 if (inGroup) {
|
Chris@0
|
275 cb->setToolTip(name);
|
Chris@0
|
276 m_groupLayouts[groupName]->addWidget(cb);
|
Chris@0
|
277 } else {
|
Chris@0
|
278 m_layout->addWidget(cb, row, 1, 1, 2);
|
Chris@0
|
279 }
|
Chris@0
|
280 m_propertyControllers[name] = cb;
|
Chris@0
|
281 }
|
Chris@0
|
282
|
Chris@55
|
283 if (cb->isChecked() != (value > 0)) {
|
Chris@55
|
284 cb->blockSignals(true);
|
Chris@55
|
285 cb->setChecked(value > 0);
|
Chris@55
|
286 cb->blockSignals(false);
|
Chris@55
|
287 }
|
Chris@0
|
288 break;
|
Chris@0
|
289 }
|
Chris@0
|
290
|
Chris@0
|
291 case PropertyContainer::RangeProperty:
|
Chris@0
|
292 {
|
Chris@0
|
293 AudioDial *dial;
|
Chris@0
|
294
|
Chris@0
|
295 if (have) {
|
Chris@0
|
296 dial = dynamic_cast<AudioDial *>(m_propertyControllers[name]);
|
Chris@0
|
297 assert(dial);
|
Chris@0
|
298 } else {
|
Chris@0
|
299 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
300 std::cerr << "PropertyBox: creating new dial" << std::endl;
|
Chris@0
|
301 #endif
|
Chris@0
|
302 dial = new AudioDial();
|
Chris@0
|
303 dial->setObjectName(name);
|
Chris@0
|
304 dial->setMinimum(min);
|
Chris@0
|
305 dial->setMaximum(max);
|
Chris@0
|
306 dial->setPageStep(1);
|
Chris@34
|
307 dial->setNotchesVisible((max - min) <= 12);
|
Chris@34
|
308 dial->setDefaultValue(value);
|
Chris@0
|
309 connect(dial, SIGNAL(valueChanged(int)),
|
Chris@0
|
310 this, SLOT(propertyControllerChanged(int)));
|
Chris@0
|
311
|
Chris@0
|
312 if (inGroup) {
|
Chris@0
|
313 dial->setFixedWidth(24);
|
Chris@0
|
314 dial->setFixedHeight(24);
|
Chris@0
|
315 dial->setToolTip(name);
|
Chris@0
|
316 m_groupLayouts[groupName]->addWidget(dial);
|
Chris@0
|
317 } else {
|
Chris@0
|
318 dial->setFixedWidth(32);
|
Chris@0
|
319 dial->setFixedHeight(32);
|
Chris@0
|
320 m_layout->addWidget(dial, row, 1);
|
Chris@33
|
321 QLabel *label = new QLabel(m_mainWidget);
|
Chris@0
|
322 connect(dial, SIGNAL(valueChanged(int)),
|
Chris@0
|
323 label, SLOT(setNum(int)));
|
Chris@0
|
324 label->setNum(value);
|
Chris@0
|
325 m_layout->addWidget(label, row, 2);
|
Chris@0
|
326 }
|
Chris@0
|
327
|
Chris@0
|
328 m_propertyControllers[name] = dial;
|
Chris@0
|
329 }
|
Chris@0
|
330
|
Chris@55
|
331 if (dial->value() != value) {
|
Chris@55
|
332 dial->blockSignals(true);
|
Chris@55
|
333 dial->setValue(value);
|
Chris@55
|
334 dial->blockSignals(false);
|
Chris@55
|
335 }
|
Chris@0
|
336 break;
|
Chris@0
|
337 }
|
Chris@0
|
338
|
Chris@0
|
339 case PropertyContainer::ValueProperty:
|
Chris@0
|
340 {
|
Chris@0
|
341 QComboBox *cb;
|
Chris@0
|
342
|
Chris@0
|
343 if (have) {
|
Chris@0
|
344 cb = dynamic_cast<QComboBox *>(m_propertyControllers[name]);
|
Chris@0
|
345 assert(cb);
|
Chris@0
|
346 } else {
|
Chris@0
|
347 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
348 std::cerr << "PropertyBox: creating new combobox" << std::endl;
|
Chris@0
|
349 #endif
|
Chris@0
|
350
|
Chris@0
|
351 cb = new QComboBox();
|
Chris@0
|
352 cb->setObjectName(name);
|
Chris@0
|
353 for (int i = min; i <= max; ++i) {
|
Chris@0
|
354 cb->addItem(m_container->getPropertyValueLabel(name, i));
|
Chris@0
|
355 }
|
Chris@0
|
356 connect(cb, SIGNAL(activated(int)),
|
Chris@0
|
357 this, SLOT(propertyControllerChanged(int)));
|
Chris@0
|
358 if (inGroup) {
|
Chris@0
|
359 cb->setToolTip(name);
|
Chris@0
|
360 m_groupLayouts[groupName]->addWidget(cb);
|
Chris@0
|
361 } else {
|
Chris@0
|
362 m_layout->addWidget(cb, row, 1, 1, 2);
|
Chris@0
|
363 }
|
Chris@0
|
364 m_propertyControllers[name] = cb;
|
Chris@0
|
365 }
|
Chris@0
|
366
|
Chris@55
|
367 if (cb->currentIndex() != value) {
|
Chris@55
|
368 cb->blockSignals(true);
|
Chris@55
|
369 cb->setCurrentIndex(value);
|
Chris@55
|
370 cb->blockSignals(false);
|
Chris@55
|
371 }
|
Chris@0
|
372
|
Chris@0
|
373 #ifdef Q_WS_MAC
|
Chris@0
|
374 // Crashes on startup without this, for some reason
|
Chris@0
|
375 cb->setMinimumSize(QSize(10, 10));
|
Chris@0
|
376 #endif
|
Chris@0
|
377
|
Chris@0
|
378 break;
|
Chris@0
|
379 }
|
Chris@0
|
380
|
Chris@0
|
381 default:
|
Chris@0
|
382 break;
|
Chris@0
|
383 }
|
Chris@0
|
384 }
|
Chris@0
|
385
|
Chris@0
|
386 void
|
Chris@0
|
387 PropertyBox::propertyContainerPropertyChanged(PropertyContainer *pc)
|
Chris@0
|
388 {
|
Chris@0
|
389 if (pc != m_container) return;
|
Chris@0
|
390
|
Chris@55
|
391 #ifdef DEBUG_PROPERTY_BOX
|
Chris@55
|
392 std::cerr << "PropertyBox::propertyContainerPropertyChanged" << std::endl;
|
Chris@55
|
393 #endif
|
Chris@55
|
394
|
Chris@0
|
395 PropertyContainer::PropertyList properties = m_container->getProperties();
|
Chris@0
|
396 size_t i;
|
Chris@0
|
397
|
Chris@0
|
398 blockSignals(true);
|
Chris@0
|
399
|
Chris@0
|
400 for (i = 0; i < properties.size(); ++i) {
|
Chris@0
|
401 updatePropertyEditor(properties[i]);
|
Chris@0
|
402 }
|
Chris@0
|
403
|
Chris@0
|
404 blockSignals(false);
|
Chris@0
|
405 }
|
Chris@0
|
406
|
Chris@0
|
407 void
|
Chris@0
|
408 PropertyBox::propertyControllerChanged(int value)
|
Chris@0
|
409 {
|
Chris@0
|
410 QObject *obj = sender();
|
Chris@0
|
411 QString name = obj->objectName();
|
Chris@0
|
412
|
Chris@34
|
413 #ifdef DEBUG_PROPERTY_BOX
|
Chris@33
|
414 std::cerr << "PropertyBox::propertyControllerChanged(" << name.toStdString()
|
Chris@33
|
415 << ", " << value << ")" << std::endl;
|
Chris@34
|
416 #endif
|
Chris@0
|
417
|
Chris@0
|
418 PropertyContainer::PropertyType type = m_container->getPropertyType(name);
|
Chris@0
|
419
|
Chris@0
|
420 if (type != PropertyContainer::InvalidProperty) {
|
Chris@55
|
421 m_container->setPropertyWithCommand(name, value);
|
Chris@0
|
422 }
|
Chris@0
|
423
|
Chris@0
|
424 if (type == PropertyContainer::RangeProperty) {
|
Chris@0
|
425 AudioDial *dial = dynamic_cast<AudioDial *>(m_propertyControllers[name]);
|
Chris@0
|
426 if (dial) {
|
Chris@0
|
427 dial->setToolTip(QString("%1: %2").arg(name).arg(value));
|
Chris@0
|
428 //!!! unfortunately this doesn't update an already-visible tooltip
|
Chris@0
|
429 }
|
Chris@0
|
430 }
|
Chris@0
|
431 }
|
Chris@0
|
432
|
Chris@34
|
433 void
|
Chris@34
|
434 PropertyBox::playGainChanged(float gain)
|
Chris@34
|
435 {
|
Chris@34
|
436 int dialValue = lrint(log10(gain) * 20.0);
|
Chris@34
|
437 if (dialValue < -50) dialValue = -50;
|
Chris@34
|
438 if (dialValue > 50) dialValue = 50;
|
Chris@34
|
439 emit changePlayGainDial(dialValue);
|
Chris@34
|
440 }
|
Chris@34
|
441
|
Chris@34
|
442 void
|
Chris@34
|
443 PropertyBox::playGainDialChanged(int dialValue)
|
Chris@34
|
444 {
|
Chris@34
|
445 float gain = pow(10, float(dialValue) / 20.0);
|
Chris@34
|
446 emit changePlayGain(gain);
|
Chris@34
|
447 }
|
Chris@34
|
448
|
Chris@34
|
449 void
|
Chris@34
|
450 PropertyBox::playPanChanged(float pan)
|
Chris@34
|
451 {
|
Chris@34
|
452 int dialValue = lrint(pan * 50.0);
|
Chris@34
|
453 if (dialValue < -50) dialValue = -50;
|
Chris@34
|
454 if (dialValue > 50) dialValue = 50;
|
Chris@34
|
455 emit changePlayPanDial(dialValue);
|
Chris@34
|
456 }
|
Chris@34
|
457
|
Chris@34
|
458 void
|
Chris@34
|
459 PropertyBox::playPanDialChanged(int dialValue)
|
Chris@34
|
460 {
|
Chris@34
|
461 float pan = float(dialValue) / 50.0;
|
Chris@34
|
462 if (pan < -1.0) pan = -1.0;
|
Chris@34
|
463 if (pan > 1.0) pan = 1.0;
|
Chris@34
|
464 emit changePlayPan(pan);
|
Chris@34
|
465 }
|
Chris@0
|
466
|
Chris@63
|
467 void
|
Chris@63
|
468 PropertyBox::editPlugin()
|
Chris@63
|
469 {
|
Chris@63
|
470 //!!! should probably just emit and let something else do this
|
Chris@63
|
471
|
Chris@63
|
472 PlayParameters *params = m_container->getPlayParameters();
|
Chris@63
|
473 if (!params) return;
|
Chris@63
|
474
|
Chris@63
|
475 QString pluginId = params->getPlayPluginId();
|
Chris@63
|
476 QString configurationXml = params->getPlayPluginConfiguration();
|
Chris@63
|
477
|
Chris@63
|
478 RealTimePluginFactory *factory =
|
Chris@63
|
479 RealTimePluginFactory::instanceFor(pluginId);
|
Chris@63
|
480 if (!factory) return;
|
Chris@63
|
481
|
Chris@63
|
482 RealTimePluginInstance *instance =
|
Chris@63
|
483 factory->instantiatePlugin(pluginId, 0, 0, 48000, 1024, 1);
|
Chris@63
|
484 if (!instance) return;
|
Chris@63
|
485
|
Chris@63
|
486 instance->setParametersFromXml(configurationXml);
|
Chris@63
|
487
|
Chris@63
|
488 PluginParameterDialog *dialog = new PluginParameterDialog(instance);
|
Chris@63
|
489 if (dialog->exec() == QDialog::Accepted) {
|
Chris@63
|
490 params->setPlayPluginConfiguration(instance->toXmlString());
|
Chris@63
|
491 }
|
Chris@63
|
492
|
Chris@63
|
493 delete dialog;
|
Chris@63
|
494 delete instance;
|
Chris@63
|
495 }
|
Chris@63
|
496
|
Chris@0
|
497 #ifdef INCLUDE_MOCFILES
|
Chris@0
|
498 #include "PropertyBox.moc.cpp"
|
Chris@0
|
499 #endif
|
Chris@0
|
500
|