diff 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
line wrap: on
line diff
--- a/widgets/PropertyBox.cpp	Wed Feb 15 17:58:35 2006 +0000
+++ b/widgets/PropertyBox.cpp	Fri Feb 17 18:04:26 2006 +0000
@@ -10,14 +10,19 @@
 #include "PropertyBox.h"
 
 #include "base/PropertyContainer.h"
+#include "base/PlayParameters.h"
+#include "base/Layer.h"
 
 #include "AudioDial.h"
+#include "LEDButton.h"
 
 #include <QGridLayout>
 #include <QHBoxLayout>
+#include <QVBoxLayout>
 #include <QCheckBox>
 #include <QComboBox>
 #include <QLabel>
+#include <QFrame>
 
 #include <cassert>
 #include <iostream>
@@ -32,8 +37,35 @@
 	container->getPropertyContainerName().toStdString() << "\")]::PropertyBox" << std::endl;
 #endif
 
+    QVBoxLayout *vbox = new QVBoxLayout;
+    setLayout(vbox);
+
+    bool needViewPlayBox = false;
+
+    if (container->getPlayParameters() || dynamic_cast<Layer *>(container)) {
+	needViewPlayBox = true;
+    }
+
+    if (needViewPlayBox) {
+#ifdef DEBUG_PROPERTY_BOX
+	std::cerr << "Adding view play box" << std::endl;
+#endif
+	QFrame *frame = new QFrame;
+	frame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
+	QHBoxLayout *hbox = new QHBoxLayout;
+	frame->setLayout(hbox);
+	vbox->addWidget(frame);
+	populateViewPlayBox(container, hbox);
+	hbox->insertStretch(-1, 10);
+    }
+
+    m_mainWidget = new QWidget;
+    vbox->addWidget(m_mainWidget);
+
+    vbox->insertStretch(-1, 10);
+
     m_layout = new QGridLayout;
-    setLayout(m_layout);
+    m_mainWidget->setLayout(m_layout);
 
     PropertyContainer::PropertyList properties = container->getProperties();
 
@@ -57,11 +89,35 @@
 PropertyBox::~PropertyBox()
 {
 #ifdef DEBUG_PROPERTY_BOX
-    std::cerr << "PropertyBox[" << this << "(\"" << m_container->getPropertyContainerName().toStdString() << "\")]::~PropertyBox" << std::endl;
+    std::cerr << "PropertyBox[" << this << "]::~PropertyBox" << std::endl;
 #endif
 }
 
 void
+PropertyBox::populateViewPlayBox(PropertyContainer *container, QLayout *layout)
+{
+    Layer *layer = dynamic_cast<Layer *>(container);
+    PlayParameters *params = container->getPlayParameters();
+    if (!params && !layer) return;
+
+    std::cerr << "PropertyBox::populateViewPlayBox: container " << container << " (name " << container->getPropertyContainerName().toStdString() << ") params " << params << std::endl;
+    
+    if (layer) {
+	LEDButton *showButton = new LEDButton(Qt::blue);
+	layout->addWidget(showButton);
+	connect(showButton, SIGNAL(stateChanged(bool)),
+		layer, SLOT(showLayer(bool)));
+    }
+    
+    if (params) {
+	LEDButton *playButton = new LEDButton(Qt::darkGreen);
+	layout->addWidget(playButton);
+	connect(playButton, SIGNAL(stateChanged(bool)),
+		params, SLOT(setPlayAudible(bool)));
+    }
+}
+
+void
 PropertyBox::updatePropertyEditor(PropertyContainer::PropertyName name)
 {
     PropertyContainer::PropertyType type = m_container->getPropertyType(name);
@@ -92,8 +148,8 @@
 #ifdef DEBUG_PROPERTY_BOX
 		std::cerr << "PropertyBox: adding label \"" << groupName.toStdString() << "\" and frame for group for \"" << name.toStdString() << "\"" << std::endl;
 #endif
-		m_layout->addWidget(new QLabel(groupName, this), row, 0);
-		QFrame *frame = new QFrame(this);
+		m_layout->addWidget(new QLabel(groupName, m_mainWidget), row, 0);
+		QFrame *frame = new QFrame(m_mainWidget);
 		m_layout->addWidget(frame, row, 1, 1, 2);
 		m_groupLayouts[groupName] = new QHBoxLayout;
 		m_groupLayouts[groupName]->setMargin(0);
@@ -103,7 +159,7 @@
 #ifdef DEBUG_PROPERTY_BOX 
 	    std::cerr << "PropertyBox: adding label \"" << name.toStdString() << "\"" << std::endl;
 #endif
-	    m_layout->addWidget(new QLabel(name, this), row, 0);
+	    m_layout->addWidget(new QLabel(name, m_mainWidget), row, 0);
 	}
     }
 
@@ -166,7 +222,7 @@
 		dial->setFixedWidth(32);
 		dial->setFixedHeight(32);
 		m_layout->addWidget(dial, row, 1);
-		QLabel *label = new QLabel(this);
+		QLabel *label = new QLabel(m_mainWidget);
 		connect(dial, SIGNAL(valueChanged(int)),
 			label, SLOT(setNum(int)));
 		label->setNum(value);
@@ -246,8 +302,8 @@
     QObject *obj = sender();
     QString name = obj->objectName();
 
-//    std::cerr << "PropertyBox::propertyControllerChanged(" << name.toStdString()
-//	      << ", " << value << ")" << std::endl;
+    std::cerr << "PropertyBox::propertyControllerChanged(" << name.toStdString()
+	      << ", " << value << ")" << std::endl;
     
     PropertyContainer::PropertyType type = m_container->getPropertyType(name);