Rename Vec3Editor to VectorInput

Wed, 22 Jun 2022 21:46:38 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Wed, 22 Jun 2022 21:46:38 +0300
changeset 254
b7b29cb82360
parent 253
8b994c917f69
child 255
5188f8a74a5c

Rename Vec3Editor to VectorInput

widgets/designerplugins.cpp file | annotate | diff | comparison | revisions
widgets/multiplyfactordialog.cpp file | annotate | diff | comparison | revisions
widgets/multiplyfactordialog.h file | annotate | diff | comparison | revisions
widgets/vec3editor.cpp file | annotate | diff | comparison | revisions
widgets/vec3editor.h file | annotate | diff | comparison | revisions
--- a/widgets/designerplugins.cpp	Wed Jun 22 21:42:10 2022 +0300
+++ b/widgets/designerplugins.cpp	Wed Jun 22 21:46:38 2022 +0300
@@ -16,7 +16,7 @@
 
 QString Vec3EditorPlugin::name() const
 {
-	return "Vec3Editor";
+	return "VectorInput";
 }
 
 QString Vec3EditorPlugin::group() const
@@ -51,7 +51,7 @@
 
 QWidget* Vec3EditorPlugin::createWidget(QWidget* parent)
 {
-	return new Vec3Editor{{0, 0, 0}, parent};
+	return new VectorInput{{0, 0, 0}, parent};
 }
 
 QString MatrixEditorPlugin::name() const
--- a/widgets/multiplyfactordialog.cpp	Wed Jun 22 21:42:10 2022 +0300
+++ b/widgets/multiplyfactordialog.cpp	Wed Jun 22 21:46:38 2022 +0300
@@ -4,7 +4,7 @@
 MultiplyFactorDialog::MultiplyFactorDialog(const glm::vec3& baseVector, QWidget* parent) :
 	QDialog{parent},
 	baseVector{baseVector},
-	preview{baseVector, parent, Vec3Editor::NoMultiplyButton}
+	preview{baseVector, parent, VectorInput::NoMultiplyButton}
 {
 	ui = std::make_unique<Ui::MultiplyFactorDialog>();
 	ui->setupUi(this);
--- a/widgets/multiplyfactordialog.h	Wed Jun 22 21:42:10 2022 +0300
+++ b/widgets/multiplyfactordialog.h	Wed Jun 22 21:46:38 2022 +0300
@@ -18,5 +18,5 @@
 	Q_SLOT void updatePreview();
 	std::unique_ptr<Ui::MultiplyFactorDialog> ui;
 	const glm::vec3 baseVector;
-	Vec3Editor preview;
+	VectorInput preview;
 };
--- a/widgets/vec3editor.cpp	Wed Jun 22 21:42:10 2022 +0300
+++ b/widgets/vec3editor.cpp	Wed Jun 22 21:46:38 2022 +0300
@@ -2,66 +2,64 @@
 #include <QCheckBox>
 #include <QSignalBlocker>
 #include "vec3editor.h"
-#include "ui_vec3editor.h"
 #include "multiplyfactordialog.h"
 
-Vec3Editor::Vec3Editor(const glm::vec3& value, QWidget *parent, QFlags<Flag> flags) :
-	QWidget{parent},
-	ui{new Ui::Vec3Editor}
+VectorInput::VectorInput(const glm::vec3& value, QWidget* parent, QFlags<VectorInput::Flag> flags) :
+	VectorInput{parent, flags}
 {
-	this->ui->setupUi(this);
 	this->setValue(value);
-	if (flags.testFlag(NoMultiplyButton))
-	{
-		this->ui->multiply->setVisible(false);
+}
+
+VectorInput::VectorInput(QWidget *parent, QFlags<Flag> flags) :
+	QWidget{parent}
+{
+	
+	this->ui.setupUi(this);
+	if (flags.testFlag(NoMultiplyButton)) {
+		this->ui.multiply->setVisible(false);
 	}
-	else
-	{
-		connect(this->ui->multiply, &QPushButton::clicked, this, &Vec3Editor::multiplyPressed);
+	else {
+		connect(this->ui.multiply, &QPushButton::clicked, this, &VectorInput::multiplyPressed);
 	}
-	for (QDoubleSpinBox* spinbox : this->spinboxes())
-	{
-		connect(spinbox, qOverload<double>(&QDoubleSpinBox::valueChanged), [&](double)
-		{
+	for (QDoubleSpinBox* spinbox : this->spinboxes()) {
+		connect(spinbox, qOverload<double>(&QDoubleSpinBox::valueChanged), [&](double){
 			Q_EMIT this->valueChanged(this->value());
 		});
 	}
 }
 
-Vec3Editor::~Vec3Editor()
+VectorInput::~VectorInput()
 {
 }
 
-glm::vec3 Vec3Editor::value() const
+glm::vec3 VectorInput::value() const
 {
 	auto get = [](DoubleSpinBox* spinbox){ return static_cast<float>(spinbox->value()); };
-	return {get(this->ui->x), get(this->ui->y), get(this->ui->z)};
+	return {get(this->ui.x), get(this->ui.y), get(this->ui.z)};
 }
 
-void Vec3Editor::setValue(const glm::vec3& value)
+void VectorInput::setValue(const glm::vec3& value)
 {
-	auto set = [](DoubleSpinBox* spinbox, float value)
-	{
+	auto set = [](DoubleSpinBox* spinbox, float value){
 		QSignalBlocker blocker{spinbox};
 		spinbox->setValue(static_cast<qreal>(value));
 	};
-	set(this->ui->x, value.x);
-	set(this->ui->y, value.y);
-	set(this->ui->z, value.z);
+	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()
+std::array<DoubleSpinBox*, 3> VectorInput::spinboxes()
 {
-	return {this->ui->x, this->ui->y, this->ui->z};
+	return {this->ui.x, this->ui.y, this->ui.z};
 }
 
-void Vec3Editor::multiplyPressed()
+void VectorInput::multiplyPressed()
 {
 	MultiplyFactorDialog dialog{this->value(), this};
 	const int dialogResult = dialog.exec();
-	if (dialogResult == QDialog::Accepted)
-	{
+	if (dialogResult == QDialog::Accepted) {
 		this->setValue(dialog.value());
 	}
 }
--- a/widgets/vec3editor.h	Wed Jun 22 21:42:10 2022 +0300
+++ b/widgets/vec3editor.h	Wed Jun 22 21:46:38 2022 +0300
@@ -1,22 +1,20 @@
 #pragma once
 #include <QWidget>
 #include <glm/glm.hpp>
+#include "ui_vec3editor.h"
 
-namespace Ui
-{
-	class Vec3Editor;
-}
-
-class Vec3Editor : public QWidget
+class VectorInput : public QWidget
 {
 	Q_OBJECT
+	Ui_Vec3Editor ui;
 public:
 	enum Flag
 	{
 		NoMultiplyButton = 0x1
 	};
-	explicit Vec3Editor(const glm::vec3& value, QWidget* parent = nullptr, QFlags<Flag> flags = {});
-	~Vec3Editor();
+	explicit VectorInput(const glm::vec3& value, QWidget* parent = nullptr, QFlags<Flag> flags = {});
+	explicit VectorInput(QWidget* parent = nullptr, QFlags<Flag> flags = {});
+	~VectorInput();
 	glm::vec3 value() const;
 	void setValue(const glm::vec3& value);
 Q_SIGNALS:
@@ -24,7 +22,6 @@
 private:
 	std::array<class DoubleSpinBox*, 3> spinboxes();
 	Q_SLOT void multiplyPressed();
-	std::unique_ptr<Ui::Vec3Editor> ui;
 };
 
-Q_DECLARE_OPERATORS_FOR_FLAGS(QFlags<Vec3Editor::Flag>)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFlags<VectorInput::Flag>)

mercurial