Fix for obtaining values from editor.

This commit is contained in:
Andrzej Kapolka 2014-02-03 14:35:29 -08:00
parent 449cf1fbd3
commit 7dfb83b6cc
3 changed files with 14 additions and 15 deletions

View file

@ -81,6 +81,9 @@ MetavoxelEditor::MetavoxelEditor() :
QVBoxLayout* valueLayout = new QVBoxLayout();
_value->setLayout(valueLayout);
valueLayout->addWidget(_valueArea = new QScrollArea());
_valueArea->setWidgetResizable(true);
updateAttributes();
connect(Application::getInstance(), SIGNAL(renderingInWorldInterface()), SLOT(render()));
@ -146,19 +149,14 @@ void MetavoxelEditor::updateValueEditor() {
}
_value->setVisible(true);
if (!_value->layout()->isEmpty()) {
QLayoutItem* item = _value->layout()->takeAt(0);
delete item->widget();
delete item;
if (_valueArea->widget()) {
delete _valueArea->widget();
}
AttributePointer attribute = AttributeRegistry::getInstance()->getAttribute(selected);
QWidget* editor = attribute->createEditor();
if (editor) {
QScrollArea* area = new QScrollArea();
area->setWidgetResizable(true);
area->setWidget(editor);
_value->layout()->addWidget(area);
_valueArea->setWidget(editor);
}
}
@ -372,11 +370,8 @@ void MetavoxelEditor::applyValue(const glm::vec3& minimum, const glm::vec3& maxi
}
QVariant MetavoxelEditor::getValue() const {
if (_value->layout()->isEmpty()) {
return QVariant();
}
QWidget* editor = _value->layout()->itemAt(0)->widget();
return editor->metaObject()->userProperty().read(editor);
QWidget* editor = _valueArea->widget();
return editor ? editor->metaObject()->userProperty().read(editor) : QVariant();
}
ProgramObject MetavoxelEditor::_gridProgram;

View file

@ -17,6 +17,7 @@ class QComboBox;
class QDoubleSpinBox;
class QGroupBox;
class QListWidget;
class QScrollArea;
/// Allows editing metavoxels.
class MetavoxelEditor : public QDialog {
@ -52,6 +53,7 @@ private:
QDoubleSpinBox* _gridSpacing;
QDoubleSpinBox* _gridPosition;
QGroupBox* _value;
QScrollArea* _valueArea;
enum State { HOVERING_STATE, DRAGGING_STATE, RAISING_STATE };

View file

@ -157,8 +157,10 @@ QWidget* QRgbAttribute::createEditor(QWidget* parent) const {
}
QRgbEditor::QRgbEditor(QWidget* parent) : QWidget(parent) {
setLayout(new QVBoxLayout());
layout()->addWidget(_button = new QPushButton());
QVBoxLayout* layout = new QVBoxLayout();
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
layout->addWidget(_button = new QPushButton());
connect(_button, SIGNAL(clicked()), SLOT(selectColor()));
}