src/widgets/vec3editor.cpp

changeset 252
da4876bfd822
parent 251
94b0a30a1886
child 253
8b994c917f69
--- a/src/widgets/vec3editor.cpp	Wed Jun 22 20:10:57 2022 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-#include <QDialog>
-#include <QCheckBox>
-#include <QSignalBlocker>
-#include "vec3editor.h"
-#include "ui_vec3editor.h"
-#include "../ui/multiplyfactordialog.h"
-
-Vec3Editor::Vec3Editor(const glm::vec3& value, QWidget *parent, QFlags<Flag> 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);
-	}
-	for (QDoubleSpinBox* spinbox : this->spinboxes())
-	{
-		connect(spinbox, qOverload<double>(&QDoubleSpinBox::valueChanged), [&](double)
-		{
-			Q_EMIT this->valueChanged(this->value());
-		});
-	}
-}
-
-Vec3Editor::~Vec3Editor()
-{
-}
-
-glm::vec3 Vec3Editor::value() const
-{
-	auto get = [](DoubleSpinBox* spinbox){ return float_cast(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(qreal_cast(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<DoubleSpinBox*, 3> 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());
-	}
-}

mercurial