diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 1df6d72c4e..c97832d791 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -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; diff --git a/interface/src/ui/MetavoxelEditor.h b/interface/src/ui/MetavoxelEditor.h index 6fe5b26398..9024837757 100644 --- a/interface/src/ui/MetavoxelEditor.h +++ b/interface/src/ui/MetavoxelEditor.h @@ -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 }; diff --git a/libraries/metavoxels/src/AttributeRegistry.cpp b/libraries/metavoxels/src/AttributeRegistry.cpp index 9a18ecc8b9..c6cad2bbaf 100644 --- a/libraries/metavoxels/src/AttributeRegistry.cpp +++ b/libraries/metavoxels/src/AttributeRegistry.cpp @@ -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())); }