Mercurial > hg > svgui
comparison widgets/PropertyBox.cpp @ 33:651e4e868bcc
* Implement play mute, level and pan controls and a layer visibility control
* Handle swapping the buffers in AudioCallbackPlaySource more gracefully, so
that in many cases it can be done inaudibly. Still gets it wrong when
playing in a noncontiguous selection.
* Fix to SV file save for non-2d sparse models
* Fixes to LED button drawing and AudioDial mouse functionality
* Add progress bar for Ogg file import
* Reshuffle PropertyContainer and its subclasses so it can be a QObject
* Add layer dormancy (invisible layer permitted to free its cache space)
* Optimisations to SpectrogramLayer, removing locks when reading/writing
individual pixels in the cache (should be unnecessary there) -- there's
still an issue here as we need a lock when reading from the model in
case the model is replaced, and we don't currently have one
* Several munlock() calls to make it harder to exhaust real memory if
running in an RT mode with mlockall() active
author | Chris Cannam |
---|---|
date | Fri, 17 Feb 2006 18:04:26 +0000 |
parents | 37b110168acf |
children | c43f2c4f66f2 |
comparison
equal
deleted
inserted
replaced
32:c53b949ef142 | 33:651e4e868bcc |
---|---|
8 */ | 8 */ |
9 | 9 |
10 #include "PropertyBox.h" | 10 #include "PropertyBox.h" |
11 | 11 |
12 #include "base/PropertyContainer.h" | 12 #include "base/PropertyContainer.h" |
13 #include "base/PlayParameters.h" | |
14 #include "base/Layer.h" | |
13 | 15 |
14 #include "AudioDial.h" | 16 #include "AudioDial.h" |
17 #include "LEDButton.h" | |
15 | 18 |
16 #include <QGridLayout> | 19 #include <QGridLayout> |
17 #include <QHBoxLayout> | 20 #include <QHBoxLayout> |
21 #include <QVBoxLayout> | |
18 #include <QCheckBox> | 22 #include <QCheckBox> |
19 #include <QComboBox> | 23 #include <QComboBox> |
20 #include <QLabel> | 24 #include <QLabel> |
25 #include <QFrame> | |
21 | 26 |
22 #include <cassert> | 27 #include <cassert> |
23 #include <iostream> | 28 #include <iostream> |
24 | 29 |
25 //#define DEBUG_PROPERTY_BOX 1 | 30 //#define DEBUG_PROPERTY_BOX 1 |
30 #ifdef DEBUG_PROPERTY_BOX | 35 #ifdef DEBUG_PROPERTY_BOX |
31 std::cerr << "PropertyBox[" << this << "(\"" << | 36 std::cerr << "PropertyBox[" << this << "(\"" << |
32 container->getPropertyContainerName().toStdString() << "\")]::PropertyBox" << std::endl; | 37 container->getPropertyContainerName().toStdString() << "\")]::PropertyBox" << std::endl; |
33 #endif | 38 #endif |
34 | 39 |
40 QVBoxLayout *vbox = new QVBoxLayout; | |
41 setLayout(vbox); | |
42 | |
43 bool needViewPlayBox = false; | |
44 | |
45 if (container->getPlayParameters() || dynamic_cast<Layer *>(container)) { | |
46 needViewPlayBox = true; | |
47 } | |
48 | |
49 if (needViewPlayBox) { | |
50 #ifdef DEBUG_PROPERTY_BOX | |
51 std::cerr << "Adding view play box" << std::endl; | |
52 #endif | |
53 QFrame *frame = new QFrame; | |
54 frame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); | |
55 QHBoxLayout *hbox = new QHBoxLayout; | |
56 frame->setLayout(hbox); | |
57 vbox->addWidget(frame); | |
58 populateViewPlayBox(container, hbox); | |
59 hbox->insertStretch(-1, 10); | |
60 } | |
61 | |
62 m_mainWidget = new QWidget; | |
63 vbox->addWidget(m_mainWidget); | |
64 | |
65 vbox->insertStretch(-1, 10); | |
66 | |
35 m_layout = new QGridLayout; | 67 m_layout = new QGridLayout; |
36 setLayout(m_layout); | 68 m_mainWidget->setLayout(m_layout); |
37 | 69 |
38 PropertyContainer::PropertyList properties = container->getProperties(); | 70 PropertyContainer::PropertyList properties = container->getProperties(); |
39 | 71 |
40 blockSignals(true); | 72 blockSignals(true); |
41 | 73 |
55 } | 87 } |
56 | 88 |
57 PropertyBox::~PropertyBox() | 89 PropertyBox::~PropertyBox() |
58 { | 90 { |
59 #ifdef DEBUG_PROPERTY_BOX | 91 #ifdef DEBUG_PROPERTY_BOX |
60 std::cerr << "PropertyBox[" << this << "(\"" << m_container->getPropertyContainerName().toStdString() << "\")]::~PropertyBox" << std::endl; | 92 std::cerr << "PropertyBox[" << this << "]::~PropertyBox" << std::endl; |
61 #endif | 93 #endif |
94 } | |
95 | |
96 void | |
97 PropertyBox::populateViewPlayBox(PropertyContainer *container, QLayout *layout) | |
98 { | |
99 Layer *layer = dynamic_cast<Layer *>(container); | |
100 PlayParameters *params = container->getPlayParameters(); | |
101 if (!params && !layer) return; | |
102 | |
103 std::cerr << "PropertyBox::populateViewPlayBox: container " << container << " (name " << container->getPropertyContainerName().toStdString() << ") params " << params << std::endl; | |
104 | |
105 if (layer) { | |
106 LEDButton *showButton = new LEDButton(Qt::blue); | |
107 layout->addWidget(showButton); | |
108 connect(showButton, SIGNAL(stateChanged(bool)), | |
109 layer, SLOT(showLayer(bool))); | |
110 } | |
111 | |
112 if (params) { | |
113 LEDButton *playButton = new LEDButton(Qt::darkGreen); | |
114 layout->addWidget(playButton); | |
115 connect(playButton, SIGNAL(stateChanged(bool)), | |
116 params, SLOT(setPlayAudible(bool))); | |
117 } | |
62 } | 118 } |
63 | 119 |
64 void | 120 void |
65 PropertyBox::updatePropertyEditor(PropertyContainer::PropertyName name) | 121 PropertyBox::updatePropertyEditor(PropertyContainer::PropertyName name) |
66 { | 122 { |
90 if (inGroup) { | 146 if (inGroup) { |
91 if (m_groupLayouts.find(groupName) == m_groupLayouts.end()) { | 147 if (m_groupLayouts.find(groupName) == m_groupLayouts.end()) { |
92 #ifdef DEBUG_PROPERTY_BOX | 148 #ifdef DEBUG_PROPERTY_BOX |
93 std::cerr << "PropertyBox: adding label \"" << groupName.toStdString() << "\" and frame for group for \"" << name.toStdString() << "\"" << std::endl; | 149 std::cerr << "PropertyBox: adding label \"" << groupName.toStdString() << "\" and frame for group for \"" << name.toStdString() << "\"" << std::endl; |
94 #endif | 150 #endif |
95 m_layout->addWidget(new QLabel(groupName, this), row, 0); | 151 m_layout->addWidget(new QLabel(groupName, m_mainWidget), row, 0); |
96 QFrame *frame = new QFrame(this); | 152 QFrame *frame = new QFrame(m_mainWidget); |
97 m_layout->addWidget(frame, row, 1, 1, 2); | 153 m_layout->addWidget(frame, row, 1, 1, 2); |
98 m_groupLayouts[groupName] = new QHBoxLayout; | 154 m_groupLayouts[groupName] = new QHBoxLayout; |
99 m_groupLayouts[groupName]->setMargin(0); | 155 m_groupLayouts[groupName]->setMargin(0); |
100 frame->setLayout(m_groupLayouts[groupName]); | 156 frame->setLayout(m_groupLayouts[groupName]); |
101 } | 157 } |
102 } else { | 158 } else { |
103 #ifdef DEBUG_PROPERTY_BOX | 159 #ifdef DEBUG_PROPERTY_BOX |
104 std::cerr << "PropertyBox: adding label \"" << name.toStdString() << "\"" << std::endl; | 160 std::cerr << "PropertyBox: adding label \"" << name.toStdString() << "\"" << std::endl; |
105 #endif | 161 #endif |
106 m_layout->addWidget(new QLabel(name, this), row, 0); | 162 m_layout->addWidget(new QLabel(name, m_mainWidget), row, 0); |
107 } | 163 } |
108 } | 164 } |
109 | 165 |
110 switch (type) { | 166 switch (type) { |
111 | 167 |
164 m_groupLayouts[groupName]->addWidget(dial); | 220 m_groupLayouts[groupName]->addWidget(dial); |
165 } else { | 221 } else { |
166 dial->setFixedWidth(32); | 222 dial->setFixedWidth(32); |
167 dial->setFixedHeight(32); | 223 dial->setFixedHeight(32); |
168 m_layout->addWidget(dial, row, 1); | 224 m_layout->addWidget(dial, row, 1); |
169 QLabel *label = new QLabel(this); | 225 QLabel *label = new QLabel(m_mainWidget); |
170 connect(dial, SIGNAL(valueChanged(int)), | 226 connect(dial, SIGNAL(valueChanged(int)), |
171 label, SLOT(setNum(int))); | 227 label, SLOT(setNum(int))); |
172 label->setNum(value); | 228 label->setNum(value); |
173 m_layout->addWidget(label, row, 2); | 229 m_layout->addWidget(label, row, 2); |
174 } | 230 } |
244 PropertyBox::propertyControllerChanged(int value) | 300 PropertyBox::propertyControllerChanged(int value) |
245 { | 301 { |
246 QObject *obj = sender(); | 302 QObject *obj = sender(); |
247 QString name = obj->objectName(); | 303 QString name = obj->objectName(); |
248 | 304 |
249 // std::cerr << "PropertyBox::propertyControllerChanged(" << name.toStdString() | 305 std::cerr << "PropertyBox::propertyControllerChanged(" << name.toStdString() |
250 // << ", " << value << ")" << std::endl; | 306 << ", " << value << ")" << std::endl; |
251 | 307 |
252 PropertyContainer::PropertyType type = m_container->getPropertyType(name); | 308 PropertyContainer::PropertyType type = m_container->getPropertyType(name); |
253 | 309 |
254 if (type != PropertyContainer::InvalidProperty) { | 310 if (type != PropertyContainer::InvalidProperty) { |
255 m_container->setProperty(name, value); | 311 m_container->setProperty(name, value); |