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@64
|
157 QPushButton *pluginButton = new QPushButton(QIcon(":icons/faders.png"), "");
|
Chris@64
|
158 pluginButton->setFixedWidth(24);
|
Chris@64
|
159 pluginButton->setFixedHeight(24);
|
Chris@63
|
160 layout->addWidget(pluginButton);
|
Chris@63
|
161 connect(pluginButton, SIGNAL(clicked()),
|
Chris@63
|
162 this, SLOT(editPlugin()));
|
Chris@63
|
163 }
|
Chris@63
|
164
|
Chris@34
|
165 AudioDial *gainDial = new AudioDial;
|
Chris@34
|
166 layout->addWidget(gainDial);
|
Chris@34
|
167 gainDial->setMeterColor(Qt::darkRed);
|
Chris@34
|
168 gainDial->setMinimum(-50);
|
Chris@34
|
169 gainDial->setMaximum(50);
|
Chris@34
|
170 gainDial->setPageStep(1);
|
Chris@34
|
171 gainDial->setFixedWidth(24);
|
Chris@34
|
172 gainDial->setFixedHeight(24);
|
Chris@34
|
173 gainDial->setNotchesVisible(false);
|
Chris@57
|
174 gainDial->setToolTip(tr("Playback Level"));
|
Chris@34
|
175 gainDial->setDefaultValue(0);
|
Chris@34
|
176 connect(gainDial, SIGNAL(valueChanged(int)),
|
Chris@34
|
177 this, SLOT(playGainDialChanged(int)));
|
Chris@34
|
178 connect(params, SIGNAL(playGainChanged(float)),
|
Chris@34
|
179 this, SLOT(playGainChanged(float)));
|
Chris@34
|
180 connect(this, SIGNAL(changePlayGain(float)),
|
Chris@34
|
181 params, SLOT(setPlayGain(float)));
|
Chris@34
|
182 connect(this, SIGNAL(changePlayGainDial(int)),
|
Chris@34
|
183 gainDial, SLOT(setValue(int)));
|
Chris@34
|
184 layout->setAlignment(gainDial, Qt::AlignVCenter);
|
Chris@34
|
185
|
Chris@34
|
186 AudioDial *panDial = new AudioDial;
|
Chris@34
|
187 layout->addWidget(panDial);
|
Chris@34
|
188 panDial->setMeterColor(Qt::darkGreen);
|
Chris@34
|
189 panDial->setMinimum(-50);
|
Chris@34
|
190 panDial->setMaximum(50);
|
Chris@34
|
191 panDial->setPageStep(1);
|
Chris@34
|
192 panDial->setFixedWidth(24);
|
Chris@34
|
193 panDial->setFixedHeight(24);
|
Chris@34
|
194 panDial->setNotchesVisible(false);
|
Chris@57
|
195 panDial->setToolTip(tr("Playback Pan / Balance"));
|
Chris@34
|
196 panDial->setDefaultValue(0);
|
Chris@34
|
197 connect(panDial, SIGNAL(valueChanged(int)),
|
Chris@34
|
198 this, SLOT(playPanDialChanged(int)));
|
Chris@34
|
199 connect(params, SIGNAL(playPanChanged(float)),
|
Chris@34
|
200 this, SLOT(playPanChanged(float)));
|
Chris@34
|
201 connect(this, SIGNAL(changePlayPan(float)),
|
Chris@34
|
202 params, SLOT(setPlayPan(float)));
|
Chris@34
|
203 connect(this, SIGNAL(changePlayPanDial(int)),
|
Chris@34
|
204 panDial, SLOT(setValue(int)));
|
Chris@34
|
205 layout->setAlignment(panDial, Qt::AlignVCenter);
|
Chris@34
|
206
|
Chris@34
|
207 } else {
|
Chris@34
|
208
|
Chris@34
|
209 layout->insertStretch(-1, 10);
|
Chris@33
|
210 }
|
Chris@33
|
211 }
|
Chris@33
|
212
|
Chris@33
|
213 void
|
Chris@0
|
214 PropertyBox::updatePropertyEditor(PropertyContainer::PropertyName name)
|
Chris@0
|
215 {
|
Chris@0
|
216 PropertyContainer::PropertyType type = m_container->getPropertyType(name);
|
Chris@0
|
217 int row = m_layout->rowCount();
|
Chris@0
|
218
|
Chris@0
|
219 int min = 0, max = 0, value = 0;
|
Chris@0
|
220 value = m_container->getPropertyRangeAndValue(name, &min, &max);
|
Chris@0
|
221
|
Chris@0
|
222 bool have = (m_propertyControllers.find(name) !=
|
Chris@0
|
223 m_propertyControllers.end());
|
Chris@0
|
224
|
Chris@0
|
225 QString groupName = m_container->getPropertyGroupName(name);
|
Chris@0
|
226
|
Chris@0
|
227 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
228 std::cerr << "PropertyBox[" << this
|
Chris@0
|
229 << "(\"" << m_container->getPropertyContainerName().toStdString()
|
Chris@0
|
230 << "\")]";
|
Chris@0
|
231 std::cerr << "::updatePropertyEditor(\"" << name.toStdString() << "\"):";
|
Chris@0
|
232 std::cerr << " value " << value << ", have " << have << ", group \""
|
Chris@0
|
233 << groupName.toStdString() << "\"" << std::endl;
|
Chris@0
|
234 #endif
|
Chris@0
|
235
|
Chris@0
|
236 bool inGroup = (groupName != QString());
|
Chris@0
|
237
|
Chris@0
|
238 if (!have) {
|
Chris@0
|
239 if (inGroup) {
|
Chris@0
|
240 if (m_groupLayouts.find(groupName) == m_groupLayouts.end()) {
|
Chris@0
|
241 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
242 std::cerr << "PropertyBox: adding label \"" << groupName.toStdString() << "\" and frame for group for \"" << name.toStdString() << "\"" << std::endl;
|
Chris@0
|
243 #endif
|
Chris@33
|
244 m_layout->addWidget(new QLabel(groupName, m_mainWidget), row, 0);
|
Chris@33
|
245 QFrame *frame = new QFrame(m_mainWidget);
|
Chris@0
|
246 m_layout->addWidget(frame, row, 1, 1, 2);
|
Chris@0
|
247 m_groupLayouts[groupName] = new QHBoxLayout;
|
Chris@0
|
248 m_groupLayouts[groupName]->setMargin(0);
|
Chris@0
|
249 frame->setLayout(m_groupLayouts[groupName]);
|
Chris@0
|
250 }
|
Chris@0
|
251 } else {
|
Chris@0
|
252 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
253 std::cerr << "PropertyBox: adding label \"" << name.toStdString() << "\"" << std::endl;
|
Chris@0
|
254 #endif
|
Chris@33
|
255 m_layout->addWidget(new QLabel(name, m_mainWidget), row, 0);
|
Chris@0
|
256 }
|
Chris@0
|
257 }
|
Chris@0
|
258
|
Chris@0
|
259 switch (type) {
|
Chris@0
|
260
|
Chris@0
|
261 case PropertyContainer::ToggleProperty:
|
Chris@0
|
262 {
|
Chris@0
|
263 QCheckBox *cb;
|
Chris@0
|
264
|
Chris@0
|
265 if (have) {
|
Chris@0
|
266 cb = dynamic_cast<QCheckBox *>(m_propertyControllers[name]);
|
Chris@0
|
267 assert(cb);
|
Chris@0
|
268 } else {
|
Chris@0
|
269 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
270 std::cerr << "PropertyBox: creating new checkbox" << std::endl;
|
Chris@0
|
271 #endif
|
Chris@0
|
272 cb = new QCheckBox();
|
Chris@0
|
273 cb->setObjectName(name);
|
Chris@0
|
274 connect(cb, SIGNAL(stateChanged(int)),
|
Chris@0
|
275 this, SLOT(propertyControllerChanged(int)));
|
Chris@0
|
276 if (inGroup) {
|
Chris@0
|
277 cb->setToolTip(name);
|
Chris@0
|
278 m_groupLayouts[groupName]->addWidget(cb);
|
Chris@0
|
279 } else {
|
Chris@0
|
280 m_layout->addWidget(cb, row, 1, 1, 2);
|
Chris@0
|
281 }
|
Chris@0
|
282 m_propertyControllers[name] = cb;
|
Chris@0
|
283 }
|
Chris@0
|
284
|
Chris@55
|
285 if (cb->isChecked() != (value > 0)) {
|
Chris@55
|
286 cb->blockSignals(true);
|
Chris@55
|
287 cb->setChecked(value > 0);
|
Chris@55
|
288 cb->blockSignals(false);
|
Chris@55
|
289 }
|
Chris@0
|
290 break;
|
Chris@0
|
291 }
|
Chris@0
|
292
|
Chris@0
|
293 case PropertyContainer::RangeProperty:
|
Chris@0
|
294 {
|
Chris@0
|
295 AudioDial *dial;
|
Chris@0
|
296
|
Chris@0
|
297 if (have) {
|
Chris@0
|
298 dial = dynamic_cast<AudioDial *>(m_propertyControllers[name]);
|
Chris@0
|
299 assert(dial);
|
Chris@0
|
300 } else {
|
Chris@0
|
301 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
302 std::cerr << "PropertyBox: creating new dial" << std::endl;
|
Chris@0
|
303 #endif
|
Chris@0
|
304 dial = new AudioDial();
|
Chris@0
|
305 dial->setObjectName(name);
|
Chris@0
|
306 dial->setMinimum(min);
|
Chris@0
|
307 dial->setMaximum(max);
|
Chris@0
|
308 dial->setPageStep(1);
|
Chris@34
|
309 dial->setNotchesVisible((max - min) <= 12);
|
Chris@34
|
310 dial->setDefaultValue(value);
|
Chris@0
|
311 connect(dial, SIGNAL(valueChanged(int)),
|
Chris@0
|
312 this, SLOT(propertyControllerChanged(int)));
|
Chris@0
|
313
|
Chris@0
|
314 if (inGroup) {
|
Chris@0
|
315 dial->setFixedWidth(24);
|
Chris@0
|
316 dial->setFixedHeight(24);
|
Chris@0
|
317 dial->setToolTip(name);
|
Chris@0
|
318 m_groupLayouts[groupName]->addWidget(dial);
|
Chris@0
|
319 } else {
|
Chris@0
|
320 dial->setFixedWidth(32);
|
Chris@0
|
321 dial->setFixedHeight(32);
|
Chris@0
|
322 m_layout->addWidget(dial, row, 1);
|
Chris@33
|
323 QLabel *label = new QLabel(m_mainWidget);
|
Chris@0
|
324 connect(dial, SIGNAL(valueChanged(int)),
|
Chris@0
|
325 label, SLOT(setNum(int)));
|
Chris@0
|
326 label->setNum(value);
|
Chris@0
|
327 m_layout->addWidget(label, row, 2);
|
Chris@0
|
328 }
|
Chris@0
|
329
|
Chris@0
|
330 m_propertyControllers[name] = dial;
|
Chris@0
|
331 }
|
Chris@0
|
332
|
Chris@55
|
333 if (dial->value() != value) {
|
Chris@55
|
334 dial->blockSignals(true);
|
Chris@55
|
335 dial->setValue(value);
|
Chris@55
|
336 dial->blockSignals(false);
|
Chris@55
|
337 }
|
Chris@0
|
338 break;
|
Chris@0
|
339 }
|
Chris@0
|
340
|
Chris@0
|
341 case PropertyContainer::ValueProperty:
|
Chris@0
|
342 {
|
Chris@0
|
343 QComboBox *cb;
|
Chris@0
|
344
|
Chris@0
|
345 if (have) {
|
Chris@0
|
346 cb = dynamic_cast<QComboBox *>(m_propertyControllers[name]);
|
Chris@0
|
347 assert(cb);
|
Chris@0
|
348 } else {
|
Chris@0
|
349 #ifdef DEBUG_PROPERTY_BOX
|
Chris@0
|
350 std::cerr << "PropertyBox: creating new combobox" << std::endl;
|
Chris@0
|
351 #endif
|
Chris@0
|
352
|
Chris@0
|
353 cb = new QComboBox();
|
Chris@0
|
354 cb->setObjectName(name);
|
Chris@0
|
355 for (int i = min; i <= max; ++i) {
|
Chris@0
|
356 cb->addItem(m_container->getPropertyValueLabel(name, i));
|
Chris@0
|
357 }
|
Chris@0
|
358 connect(cb, SIGNAL(activated(int)),
|
Chris@0
|
359 this, SLOT(propertyControllerChanged(int)));
|
Chris@0
|
360 if (inGroup) {
|
Chris@0
|
361 cb->setToolTip(name);
|
Chris@0
|
362 m_groupLayouts[groupName]->addWidget(cb);
|
Chris@0
|
363 } else {
|
Chris@0
|
364 m_layout->addWidget(cb, row, 1, 1, 2);
|
Chris@0
|
365 }
|
Chris@0
|
366 m_propertyControllers[name] = cb;
|
Chris@0
|
367 }
|
Chris@0
|
368
|
Chris@55
|
369 if (cb->currentIndex() != value) {
|
Chris@55
|
370 cb->blockSignals(true);
|
Chris@55
|
371 cb->setCurrentIndex(value);
|
Chris@55
|
372 cb->blockSignals(false);
|
Chris@55
|
373 }
|
Chris@0
|
374
|
Chris@0
|
375 #ifdef Q_WS_MAC
|
Chris@0
|
376 // Crashes on startup without this, for some reason
|
Chris@0
|
377 cb->setMinimumSize(QSize(10, 10));
|
Chris@0
|
378 #endif
|
Chris@0
|
379
|
Chris@0
|
380 break;
|
Chris@0
|
381 }
|
Chris@0
|
382
|
Chris@0
|
383 default:
|
Chris@0
|
384 break;
|
Chris@0
|
385 }
|
Chris@0
|
386 }
|
Chris@0
|
387
|
Chris@0
|
388 void
|
Chris@0
|
389 PropertyBox::propertyContainerPropertyChanged(PropertyContainer *pc)
|
Chris@0
|
390 {
|
Chris@0
|
391 if (pc != m_container) return;
|
Chris@0
|
392
|
Chris@55
|
393 #ifdef DEBUG_PROPERTY_BOX
|
Chris@55
|
394 std::cerr << "PropertyBox::propertyContainerPropertyChanged" << std::endl;
|
Chris@55
|
395 #endif
|
Chris@55
|
396
|
Chris@0
|
397 PropertyContainer::PropertyList properties = m_container->getProperties();
|
Chris@0
|
398 size_t i;
|
Chris@0
|
399
|
Chris@0
|
400 blockSignals(true);
|
Chris@0
|
401
|
Chris@0
|
402 for (i = 0; i < properties.size(); ++i) {
|
Chris@0
|
403 updatePropertyEditor(properties[i]);
|
Chris@0
|
404 }
|
Chris@0
|
405
|
Chris@0
|
406 blockSignals(false);
|
Chris@0
|
407 }
|
Chris@0
|
408
|
Chris@0
|
409 void
|
Chris@0
|
410 PropertyBox::propertyControllerChanged(int value)
|
Chris@0
|
411 {
|
Chris@0
|
412 QObject *obj = sender();
|
Chris@0
|
413 QString name = obj->objectName();
|
Chris@0
|
414
|
Chris@34
|
415 #ifdef DEBUG_PROPERTY_BOX
|
Chris@33
|
416 std::cerr << "PropertyBox::propertyControllerChanged(" << name.toStdString()
|
Chris@33
|
417 << ", " << value << ")" << std::endl;
|
Chris@34
|
418 #endif
|
Chris@0
|
419
|
Chris@0
|
420 PropertyContainer::PropertyType type = m_container->getPropertyType(name);
|
Chris@0
|
421
|
Chris@0
|
422 if (type != PropertyContainer::InvalidProperty) {
|
Chris@55
|
423 m_container->setPropertyWithCommand(name, value);
|
Chris@0
|
424 }
|
Chris@0
|
425
|
Chris@0
|
426 if (type == PropertyContainer::RangeProperty) {
|
Chris@0
|
427 AudioDial *dial = dynamic_cast<AudioDial *>(m_propertyControllers[name]);
|
Chris@0
|
428 if (dial) {
|
Chris@0
|
429 dial->setToolTip(QString("%1: %2").arg(name).arg(value));
|
Chris@0
|
430 //!!! unfortunately this doesn't update an already-visible tooltip
|
Chris@0
|
431 }
|
Chris@0
|
432 }
|
Chris@0
|
433 }
|
Chris@0
|
434
|
Chris@34
|
435 void
|
Chris@34
|
436 PropertyBox::playGainChanged(float gain)
|
Chris@34
|
437 {
|
Chris@34
|
438 int dialValue = lrint(log10(gain) * 20.0);
|
Chris@34
|
439 if (dialValue < -50) dialValue = -50;
|
Chris@34
|
440 if (dialValue > 50) dialValue = 50;
|
Chris@34
|
441 emit changePlayGainDial(dialValue);
|
Chris@34
|
442 }
|
Chris@34
|
443
|
Chris@34
|
444 void
|
Chris@34
|
445 PropertyBox::playGainDialChanged(int dialValue)
|
Chris@34
|
446 {
|
Chris@34
|
447 float gain = pow(10, float(dialValue) / 20.0);
|
Chris@34
|
448 emit changePlayGain(gain);
|
Chris@34
|
449 }
|
Chris@34
|
450
|
Chris@34
|
451 void
|
Chris@34
|
452 PropertyBox::playPanChanged(float pan)
|
Chris@34
|
453 {
|
Chris@34
|
454 int dialValue = lrint(pan * 50.0);
|
Chris@34
|
455 if (dialValue < -50) dialValue = -50;
|
Chris@34
|
456 if (dialValue > 50) dialValue = 50;
|
Chris@34
|
457 emit changePlayPanDial(dialValue);
|
Chris@34
|
458 }
|
Chris@34
|
459
|
Chris@34
|
460 void
|
Chris@34
|
461 PropertyBox::playPanDialChanged(int dialValue)
|
Chris@34
|
462 {
|
Chris@34
|
463 float pan = float(dialValue) / 50.0;
|
Chris@34
|
464 if (pan < -1.0) pan = -1.0;
|
Chris@34
|
465 if (pan > 1.0) pan = 1.0;
|
Chris@34
|
466 emit changePlayPan(pan);
|
Chris@34
|
467 }
|
Chris@0
|
468
|
Chris@63
|
469 void
|
Chris@63
|
470 PropertyBox::editPlugin()
|
Chris@63
|
471 {
|
Chris@63
|
472 //!!! should probably just emit and let something else do this
|
Chris@63
|
473
|
Chris@63
|
474 PlayParameters *params = m_container->getPlayParameters();
|
Chris@63
|
475 if (!params) return;
|
Chris@63
|
476
|
Chris@63
|
477 QString pluginId = params->getPlayPluginId();
|
Chris@63
|
478 QString configurationXml = params->getPlayPluginConfiguration();
|
Chris@63
|
479
|
Chris@63
|
480 RealTimePluginFactory *factory =
|
Chris@63
|
481 RealTimePluginFactory::instanceFor(pluginId);
|
Chris@63
|
482 if (!factory) return;
|
Chris@63
|
483
|
Chris@63
|
484 RealTimePluginInstance *instance =
|
Chris@63
|
485 factory->instantiatePlugin(pluginId, 0, 0, 48000, 1024, 1);
|
Chris@63
|
486 if (!instance) return;
|
Chris@63
|
487
|
Chris@63
|
488 instance->setParametersFromXml(configurationXml);
|
Chris@63
|
489
|
Chris@63
|
490 PluginParameterDialog *dialog = new PluginParameterDialog(instance);
|
Chris@64
|
491 connect(dialog, SIGNAL(pluginConfigurationChanged(QString)),
|
Chris@64
|
492 this, SLOT(pluginConfigurationChanged(QString)));
|
Chris@64
|
493
|
Chris@63
|
494 if (dialog->exec() == QDialog::Accepted) {
|
Chris@63
|
495 params->setPlayPluginConfiguration(instance->toXmlString());
|
Chris@64
|
496 } else {
|
Chris@64
|
497 // restore in case we mucked about with the configuration
|
Chris@64
|
498 // as a consequence of signals from the dialog
|
Chris@64
|
499 params->setPlayPluginConfiguration(configurationXml);
|
Chris@63
|
500 }
|
Chris@63
|
501
|
Chris@63
|
502 delete dialog;
|
Chris@63
|
503 delete instance;
|
Chris@63
|
504 }
|
Chris@63
|
505
|
Chris@64
|
506 void
|
Chris@64
|
507 PropertyBox::pluginConfigurationChanged(QString configurationXml)
|
Chris@64
|
508 {
|
Chris@64
|
509 PlayParameters *params = m_container->getPlayParameters();
|
Chris@64
|
510 if (!params) return;
|
Chris@64
|
511
|
Chris@64
|
512 params->setPlayPluginConfiguration(configurationXml);
|
Chris@64
|
513 }
|
Chris@64
|
514
|
Chris@64
|
515
|
Chris@64
|
516
|
Chris@0
|
517 #ifdef INCLUDE_MOCFILES
|
Chris@0
|
518 #include "PropertyBox.moc.cpp"
|
Chris@0
|
519 #endif
|
Chris@0
|
520
|