# HG changeset patch # User Teemu Piippo # Date 1584479609 -7200 # Node ID 62373840e33abbe05c0e04abf07fa398e112da76 # Parent 7643817568994fe9e14acac8fb9e8ce30afa6977 object editor widgets start to form up diff -r 764381756899 -r 62373840e33a CMakeLists.txt --- a/CMakeLists.txt Wed Mar 11 19:05:34 2020 +0200 +++ b/CMakeLists.txt Tue Mar 17 23:13:29 2020 +0200 @@ -54,7 +54,12 @@ src/settingseditor/settingseditor.cpp src/types/boundingbox.cpp src/ui/canvas.cpp + src/ui/multiplyfactordialog.cpp + src/ui/objecteditor.cpp + src/ui/polygonobjecteditor.cpp src/widgets/colorbutton.cpp + src/widgets/doublespinbox.cpp + src/widgets/vec3editor.cpp ) set (LDFORGE_HEADERS src/basics.h @@ -96,13 +101,20 @@ src/settingseditor/settingseditor.h src/types/boundingbox.h src/ui/canvas.h + src/ui/multiplyfactordialog.h + src/ui/objecteditor.h + src/ui/polygonobjecteditor.h src/widgets/colorbutton.h + src/widgets/doublespinbox.h + src/widgets/vec3editor.h ) set (LDFORGE_FORMS src/document.ui src/mainwindow.ui src/settingseditor/librarieseditor.ui src/settingseditor/settingseditor.ui + src/ui/multiplyfactordialog.ui + src/widgets/vec3editor.ui ) set(LDFORGE_LOCALES diff -r 764381756899 -r 62373840e33a locale/fi.ts --- a/locale/fi.ts Wed Mar 11 19:05:34 2020 +0200 +++ b/locale/fi.ts Tue Mar 17 23:13:29 2020 +0200 @@ -136,77 +136,105 @@ Näkymä - + Quit Lopeta - + Open… Avaa... - + Ctrl+O Ctrl+O - + New Uusi - + Ctrl+N Ctrl+N - + Preferences… Asetukset... - + Normal colours Perusvärit - + BFC color coding BFC-värikoodaus - + Random colours Satunnaiset värit - + + Pick scene colours + + + + Open model Avaa malli - + LDraw models (*.ldr *.dat) LDraw-mallit (*.ldr *.dat) - + Problem loading references Ongelma viitteiden lataamisessa - + Problem opening file Ongelma tiedoston avaamisessa - + Could not open %1: %2 Ei voitu avata %1: %2 + MultiplyFactorDialog + + + Multiply with a scalar + + + + + Factor: + + + + + Invert + + + + + Preview + + + + QObject @@ -328,4 +356,32 @@ Näppäinyhdistelmät + + Vec3Editor + + + Form + + + + + x = + + + + + y = + + + + + z = + + + + + × + + + diff -r 764381756899 -r 62373840e33a locale/sv.ts --- a/locale/sv.ts Wed Mar 11 19:05:34 2020 +0200 +++ b/locale/sv.ts Tue Mar 17 23:13:29 2020 +0200 @@ -224,6 +224,29 @@ Random colours Slumpmässiga färger + + Pick scene colours + + + + + MultiplyFactorDialog + + Multiply with a scalar + + + + Factor: + + + + Invert + + + + Preview + + PartRenderer @@ -335,6 +358,29 @@ + Vec3Editor + + Form + + + + x = + + + + y = + + + + z = + + + + × + + + + gl::Compiler Vertex shader: diff -r 764381756899 -r 62373840e33a src/basics.h --- a/src/basics.h Wed Mar 11 19:05:34 2020 +0200 +++ b/src/basics.h Tue Mar 17 23:13:29 2020 +0200 @@ -129,6 +129,17 @@ return static_cast(x); } +/** +* @brief casts floating point values to qreal, converting non-floating point values causes an error +* @param[in] x floating point value to cast +* @returns qreal +*/ +template +auto toQreal(T x) -> std::enable_if_t, qreal> +{ + return static_cast(x); +} + template inline QPoint toQPoint(const glm::vec& vec) { diff -r 764381756899 -r 62373840e33a src/document.cpp --- a/src/document.cpp Wed Mar 11 19:05:34 2020 +0200 +++ b/src/document.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -31,13 +31,15 @@ documents{documents}, colorTable{colorTable}, renderer{new Canvas{model, documents, colorTable, this}}, - ui{*new Ui::Document} + ui{*new Ui::Document}, + objectEditor{model, ldraw::NULL_ID, this} { this->ui.setupUi(this); this->ui.listView->setModel(model); - QVBoxLayout* layout = new QVBoxLayout; - layout->addWidget(this->renderer); - this->ui.viewportFrame->setLayout(layout); + this->ui.viewportFrame->setLayout(new QVBoxLayout{this->ui.listView}); + this->ui.viewportFrame->layout()->addWidget(this->renderer); + this->ui.objectEditorFrame->setLayout(new QVBoxLayout{this->ui.objectEditorFrame}); + this->ui.objectEditorFrame->layout()->addWidget(&this->objectEditor); this->setMouseTracking(true); connect(this->ui.splitter, &QSplitter::splitterMoved, this, &Document::splitterChanged); connect(this->renderer, &Canvas::newStatusText, this, &Document::newStatusText); @@ -53,7 +55,9 @@ selection.select(index, index); } } + QSignalBlocker blocker{this}; selectionModel->select(selection, QItemSelectionModel::ClearAndSelect); + this->selectionChanged(newSelection); }); connect(this->ui.listView->selectionModel(), &QItemSelectionModel::selectionChanged, [&](const QItemSelection& selected, const QItemSelection& deselected) @@ -64,6 +68,7 @@ return fn::map>(selection.indexes(), resolveIndex); }; this->renderer->handleSelectionChange(resolve(selected), resolve(deselected)); + this->selectionChanged(resolve(this->ui.listView->selectionModel()->selection())); }); } @@ -86,3 +91,15 @@ { this->renderer->setRenderPreferences(newPreferences); } + +void Document::selectionChanged(const QSet& newSelection) +{ + if (newSelection.size() == 1) + { + this->objectEditor.setObjectId(*newSelection.begin()); + } + else + { + this->objectEditor.setObjectId(ldraw::NULL_ID); + } +} diff -r 764381756899 -r 62373840e33a src/document.h --- a/src/document.h Wed Mar 11 19:05:34 2020 +0200 +++ b/src/document.h Tue Mar 17 23:13:29 2020 +0200 @@ -20,6 +20,7 @@ #include #include #include "ui/canvas.h" +#include "ui/objecteditor.h" namespace Ui { @@ -45,9 +46,11 @@ void newStatusText(const QString& newStatusText); void splitterChanged(); private: + void selectionChanged(const QSet& newSelection); Model* model; DocumentManager* const documents; const ldraw::ColorTable& colorTable; Canvas* renderer; Ui::Document& ui; + ObjectEditor objectEditor; }; diff -r 764381756899 -r 62373840e33a src/document.ui --- a/src/document.ui Wed Mar 11 19:05:34 2020 +0200 +++ b/src/document.ui Tue Mar 17 23:13:29 2020 +0200 @@ -19,6 +19,14 @@ Qt::Horizontal + + + QFrame::StyledPanel + + + QFrame::Raised + + true @@ -30,7 +38,7 @@ QAbstractItemView::SelectRows - + QFrame::StyledPanel diff -r 764381756899 -r 62373840e33a src/linetypes/conditionaledge.cpp --- a/src/linetypes/conditionaledge.cpp Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/conditionaledge.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -54,3 +54,21 @@ utility::vertexToStringParens(controlPoint_1), utility::vertexToStringParens(controlPoint_2)); } + +int ldraw::ConditionalEdge::numPoints() const +{ + return 4; +} + +const glm::vec3& ldraw::ConditionalEdge::getPoint(int index) const +{ + switch(index) + { + case 3: + return this->controlPoint_1; + case 4: + return this->controlPoint_2; + default: + return ldraw::Edge::getPoint(index); + } +} diff -r 764381756899 -r 62373840e33a src/linetypes/conditionaledge.h --- a/src/linetypes/conditionaledge.h Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/conditionaledge.h Tue Mar 17 23:13:29 2020 +0200 @@ -22,6 +22,8 @@ Property property, const QVariant& value) override; QString textRepresentation() const override; + int numPoints() const override; + const glm::vec3& getPoint(int index) const override; glm::vec3 controlPoint_1 = {}; glm::vec3 controlPoint_2 = {}; }; diff -r 764381756899 -r 62373840e33a src/linetypes/edge.cpp --- a/src/linetypes/edge.cpp Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/edge.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -56,3 +56,21 @@ Q_UNUSED(context) polygons.push_back(gl::edgeLine(this->point_1, this->point_2, this->colorIndex, this->id)); } + +int ldraw::Edge::numPoints() const +{ + return 2; +} + +const glm::vec3& ldraw::Edge::getPoint(int index) const +{ + switch (index) + { + case 0: + return this->point_1; + case 1: + return this->point_2; + default: + return ldraw::ColoredObject::getPoint(index); + } +} diff -r 764381756899 -r 62373840e33a src/linetypes/edge.h --- a/src/linetypes/edge.h Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/edge.h Tue Mar 17 23:13:29 2020 +0200 @@ -20,6 +20,8 @@ const QVariant& value) override; QString textRepresentation() const override; void getPolygons(std::vector& polygons, GetPolygonsContext* context) const override; + int numPoints() const override; + const glm::vec3& getPoint(int index) const override; glm::vec3 point_1 = {}; glm::vec3 point_2 = {}; }; diff -r 764381756899 -r 62373840e33a src/linetypes/object.cpp --- a/src/linetypes/object.cpp Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/object.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -58,6 +58,11 @@ Q_UNUSED(context) } +const glm::vec3& ldraw::Object::getPoint(int index) const +{ + throw BadPointIndex{}; +} + ldraw::ColoredObject::ColoredObject(const Color color_index) : colorIndex{color_index} { diff -r 764381756899 -r 62373840e33a src/linetypes/object.h --- a/src/linetypes/object.h Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/object.h Tue Mar 17 23:13:29 2020 +0200 @@ -81,6 +81,9 @@ PropertyNotHandled, InvalidValue }; + class BadPointIndex : public std::exception + { + }; Object(); Object(const Object&) = delete; virtual ~Object(); @@ -95,6 +98,8 @@ virtual QFont textRepresentationFont() const; virtual void getPolygons(std::vector& polygons, GetPolygonsContext* context) const; virtual void invert() {} + virtual int numPoints() const { return 0; } + virtual const glm::vec3& getPoint(int index) const; }; class ldraw::ColoredObject : public Object diff -r 764381756899 -r 62373840e33a src/linetypes/quadrilateral.cpp --- a/src/linetypes/quadrilateral.cpp Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/quadrilateral.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -87,3 +87,20 @@ // -> 2 1 0 3 std::swap(this->points[0], this->points[2]); } + +int ldraw::Quadrilateral::numPoints() const +{ + return 4; +} + +const glm::vec3& ldraw::Quadrilateral::getPoint(int index) const +{ + if (index >= 0 and index < 4) + { + return points[index]; + } + else + { + return ldraw::ColoredObject::getPoint(index); + } +} diff -r 764381756899 -r 62373840e33a src/linetypes/quadrilateral.h --- a/src/linetypes/quadrilateral.h Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/quadrilateral.h Tue Mar 17 23:13:29 2020 +0200 @@ -22,5 +22,7 @@ QString textRepresentation() const override; void getPolygons(std::vector& polygons, GetPolygonsContext* context) const override; void invert() override; + int numPoints() const override; + const glm::vec3& getPoint(int index) const override; glm::vec3 points[4] = {{}}; }; diff -r 764381756899 -r 62373840e33a src/linetypes/subfilereference.cpp --- a/src/linetypes/subfilereference.cpp Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/subfilereference.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -81,7 +81,7 @@ glm::vec3 ldraw::SubfileReference::position() const { - return {this->transformation[3][0], this->transformation[3][1], this->transformation[3][2]}; + return this->transformation[3]; } void ldraw::SubfileReference::invert() diff -r 764381756899 -r 62373840e33a src/linetypes/triangle.cpp --- a/src/linetypes/triangle.cpp Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/triangle.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -83,3 +83,20 @@ // -> 1 0 2 std::swap(this->points[0], this->points[1]); } + +int ldraw::Triangle::numPoints() const +{ + return 3; +} + +const glm::vec3& ldraw::Triangle::getPoint(int index) const +{ + if (index >= 0 and index < 3) + { + return this->points[index]; + } + else + { + return ldraw::ColoredObject::getPoint(index); + } +} diff -r 764381756899 -r 62373840e33a src/linetypes/triangle.h --- a/src/linetypes/triangle.h Wed Mar 11 19:05:34 2020 +0200 +++ b/src/linetypes/triangle.h Tue Mar 17 23:13:29 2020 +0200 @@ -22,6 +22,8 @@ QString textRepresentation() const override; void getPolygons(std::vector& polygons, GetPolygonsContext* context) const override; void invert() override; + int numPoints() const override; + const glm::vec3& getPoint(int index) const override; glm::vec3 points[3] = {{}}; }; diff -r 764381756899 -r 62373840e33a src/main.h --- a/src/main.h Wed Mar 11 19:05:34 2020 +0200 +++ b/src/main.h Tue Mar 17 23:13:29 2020 +0200 @@ -74,13 +74,14 @@ using conditionaledgeid_t = Id; using subfileid_t = Id; - constexpr struct + constexpr struct NullId { template constexpr operator Id() const { return Id{0}; } + static constexpr decltype(ldraw::id_t::value) value = 0; } NULL_ID = {}; template diff -r 764381756899 -r 62373840e33a src/model.h --- a/src/model.h Wed Mar 11 19:05:34 2020 +0200 +++ b/src/model.h Tue Mar 17 23:13:29 2020 +0200 @@ -135,5 +135,12 @@ { *index_out = index; } - return static_cast(this->objectAt(index)); + if (index.isValid()) + { + return static_cast(this->objectAt(index)); + } + else + { + return nullptr; + } } diff -r 764381756899 -r 62373840e33a src/ui/multiplyfactordialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/multiplyfactordialog.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,39 @@ +#include "multiplyfactordialog.h" +#include "ui_multiplyfactordialog.h" + +MultiplyFactorDialog::MultiplyFactorDialog(const glm::vec3& baseVector, QWidget* parent) : + QDialog{parent}, + baseVector{baseVector}, + preview{baseVector, parent, Vec3Editor::NoMultiplyButton} +{ + ui = std::make_unique(); + ui->setupUi(this); + this->preview.setEnabled(false); + this->ui->previewGroupBox->setLayout(new QVBoxLayout{parent}); + this->ui->previewGroupBox->layout()->addWidget(&this->preview); + connect(this->ui->invert, &QCheckBox::clicked, this, &MultiplyFactorDialog::updatePreview); + connect(this->ui->factor, qOverload(&DoubleSpinBox::valueChanged), this, &MultiplyFactorDialog::updatePreview); +} + +MultiplyFactorDialog::~MultiplyFactorDialog() +{ +} + +glm::vec3 MultiplyFactorDialog::value() const +{ + glm::vec3 result = baseVector; + if (this->ui->invert->isChecked()) + { + result /= this->ui->factor->value(); + } + else + { + result *= this->ui->factor->value(); + } + return result; +} + +void MultiplyFactorDialog::updatePreview() +{ + this->preview.setValue(this->value()); +} diff -r 764381756899 -r 62373840e33a src/ui/multiplyfactordialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/multiplyfactordialog.h Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,23 @@ +#pragma once +#include +#include "../main.h" +#include "../widgets/vec3editor.h" + +namespace Ui +{ + class MultiplyFactorDialog; +} + +class MultiplyFactorDialog : public QDialog +{ + Q_OBJECT +public: + explicit MultiplyFactorDialog(const glm::vec3& baseVector = glm::vec3{}, QWidget *parent = nullptr); + ~MultiplyFactorDialog(); + glm::vec3 value() const; +private: + Q_SLOT void updatePreview(); + std::unique_ptr ui; + const glm::vec3 baseVector; + Vec3Editor preview; +}; diff -r 764381756899 -r 62373840e33a src/ui/multiplyfactordialog.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/multiplyfactordialog.ui Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,103 @@ + + + MultiplyFactorDialog + + + + 0 + 0 + 436 + 128 + + + + Multiply with a scalar + + + + + + + + + + Factor: + + + + + + + + + + Invert + + + + + + + + + Preview + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + DoubleSpinBox + QDoubleSpinBox +
widgets/doublespinbox.h
+
+
+ + + + buttonBox + accepted() + MultiplyFactorDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + MultiplyFactorDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff -r 764381756899 -r 62373840e33a src/ui/objecteditor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/objecteditor.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,32 @@ +#include +#include "objecteditor.h" + +ObjectEditor::ObjectEditor(Model* model, const ldraw::id_t id, QWidget *parent) : + QWidget{parent}, + model{model} +{ + this->setObjectId(id); + this->setLayout(new QVBoxLayout{this}); +} + +void ObjectEditor::setObjectId(const ldraw::id_t id) +{ + this->objectId = id; + const ldraw::Object* object = this->model->get(id); + if (object != nullptr and object->numPoints() > 0) + { + if (not this->polygonEditor.has_value()) + { + this->polygonEditor.emplace(this->model, id); + this->layout()->addWidget(&*this->polygonEditor); + } + else + { + this->polygonEditor->setObjectId(id); + } + } + else + { + this->polygonEditor.reset(); + } +} diff -r 764381756899 -r 62373840e33a src/ui/objecteditor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/objecteditor.h Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,17 @@ +#pragma once +#include +#include "../main.h" +#include "../model.h" +#include "polygonobjecteditor.h" + +class ObjectEditor : public QWidget +{ + Q_OBJECT +public: + explicit ObjectEditor(Model* model, ldraw::id_t id = ldraw::NULL_ID, QWidget* parent = nullptr); + void setObjectId(ldraw::id_t id); +private: + Model* const model; + ldraw::id_t objectId = ldraw::NULL_ID; + std::optional polygonEditor; +}; diff -r 764381756899 -r 62373840e33a src/ui/polygonobjecteditor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/polygonobjecteditor.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,48 @@ +#include +#include "model.h" +#include "widgets/vec3editor.h" +#include "polygonobjecteditor.h" + +PolygonObjectEditor::PolygonObjectEditor(Model* model, ldraw::id_t id, QWidget* parent) : + QWidget{parent}, + model{model}, + storedObjectId{ldraw::NULL_ID.value} +{ + this->setLayout(new QVBoxLayout{this}); + this->setObjectId(id); +} + +// destructor needed for std::unique_ptr +PolygonObjectEditor::~PolygonObjectEditor() +{ +} + +ldraw::id_t PolygonObjectEditor::objectId() const +{ + return this->storedObjectId; +} + +void PolygonObjectEditor::setObjectId(ldraw::id_t id) +{ + this->storedObjectId = id; + this->updateNumRows(); +} + +void PolygonObjectEditor::updateNumRows() +{ + const ldraw::Object* object = model->get(this->storedObjectId); + const int number = object->numPoints(); + if (static_cast(this->vec3Editors.size()) > number) + { + this->vec3Editors.resize(number); + } + else + { + while (static_cast(this->vec3Editors.size()) < number) + { + const glm::vec3& value = object->getPoint(this->vec3Editors.size()); + this->vec3Editors.emplace_back(std::make_unique(value, this)); + this->layout()->addWidget(this->vec3Editors.back().get()); + } + } +} diff -r 764381756899 -r 62373840e33a src/ui/polygonobjecteditor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/polygonobjecteditor.h Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,19 @@ +#pragma once +#include +#include "main.h" + +class Model; + +class PolygonObjectEditor : public QWidget +{ +public: + PolygonObjectEditor(Model* model, ldraw::id_t id, QWidget* parent = nullptr); + ~PolygonObjectEditor(); + ldraw::id_t objectId() const; + void setObjectId(ldraw::id_t id); +private: + void updateNumRows(); + Model* model; + ldraw::id_t storedObjectId; + std::vector> vec3Editors; +}; diff -r 764381756899 -r 62373840e33a src/widgets/vec3editor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/widgets/vec3editor.cpp Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,60 @@ +#include +#include +#include +#include "vec3editor.h" +#include "ui_vec3editor.h" +#include "../ui/multiplyfactordialog.h" + +Vec3Editor::Vec3Editor(const glm::vec3& value, QWidget *parent, QFlags flags) : + QWidget{parent}, + ui{new Ui::Vec3Editor} +{ + this->ui->setupUi(this); + this->setValue(value); + if (flags.testFlag(NoMultiplyButton)) + { + this->ui->multiply->setVisible(false); + } + else + { + connect(this->ui->multiply, &QPushButton::clicked, this, &Vec3Editor::multiplyPressed); + } +} + +Vec3Editor::~Vec3Editor() +{ +} + +glm::vec3 Vec3Editor::value() const +{ + auto get = [](DoubleSpinBox* spinbox){ return toFloat(spinbox->value()); }; + return {get(this->ui->x), get(this->ui->y), get(this->ui->z)}; +} + +void Vec3Editor::setValue(const glm::vec3& value) +{ + auto set = [](DoubleSpinBox* spinbox, float value) + { + QSignalBlocker blocker{spinbox}; + spinbox->setValue(toQreal(value)); + }; + set(this->ui->x, value.x); + set(this->ui->y, value.y); + set(this->ui->z, value.z); + Q_EMIT this->valueChanged(value); +} + +std::array Vec3Editor::spinboxes() +{ + return {this->ui->x, this->ui->y, this->ui->z}; +} + +void Vec3Editor::multiplyPressed() +{ + MultiplyFactorDialog dialog{this->value(), this}; + const int dialogResult = dialog.exec(); + if (dialogResult == QDialog::Accepted) + { + this->setValue(dialog.value()); + } +} diff -r 764381756899 -r 62373840e33a src/widgets/vec3editor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/widgets/vec3editor.h Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,30 @@ +#pragma once +#include +#include "main.h" + +namespace Ui +{ + class Vec3Editor; +} + +class Vec3Editor : public QWidget +{ + Q_OBJECT +public: + enum Flag + { + NoMultiplyButton = 0x1 + }; + explicit Vec3Editor(const glm::vec3& value = {}, QWidget* parent = nullptr, QFlags flags = 0); + ~Vec3Editor(); + glm::vec3 value() const; + void setValue(const glm::vec3& value); +Q_SIGNALS: + void valueChanged(const glm::vec3& value); +private: + std::array spinboxes(); + Q_SLOT void multiplyPressed(); + std::unique_ptr ui; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QFlags) diff -r 764381756899 -r 62373840e33a src/widgets/vec3editor.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/widgets/vec3editor.ui Tue Mar 17 23:13:29 2020 +0200 @@ -0,0 +1,83 @@ + + + Vec3Editor + + + + 0 + 0 + 613 + 46 + + + + Form + + + + + + x = + + + 4 + + + -1000000.000000000000000 + + + 1000000.000000000000000 + + + + + + + y = + + + 4 + + + -1000000.000000000000000 + + + 1000000.000000000000000 + + + + + + + z = + + + 4 + + + -1000000.000000000000000 + + + 1000000.000000000000000 + + + + + + + × + + + + + + + + DoubleSpinBox + QDoubleSpinBox +
widgets/doublespinbox.h
+
+
+ + +