src/ui/multiplyfactordialog.cpp

Tue, 17 Mar 2020 23:13:29 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 17 Mar 2020 23:13:29 +0200
changeset 81
62373840e33a
child 88
14e51640c189
permissions
-rw-r--r--

object editor widgets start to form up

#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::MultiplyFactorDialog>();
	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<double>(&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());
}

mercurial