src/ui/multiplyfactordialog.cpp

Wed, 18 Mar 2020 15:52:16 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 18 Mar 2020 15:52:16 +0200
changeset 83
b8bd338eb602
parent 81
62373840e33a
child 88
14e51640c189
permissions
-rw-r--r--

refactor, added splitter

#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