src/ui/objecteditor.cpp

Sat, 05 Mar 2022 13:59:54 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 05 Mar 2022 13:59:54 +0200
changeset 166
8857351912d0
parent 152
03f8e6d42e13
child 177
f69d53c053df
permissions
-rw-r--r--

Fix rendering of cursor coordinates on bright background

#include <QVBoxLayout>
#include "objecteditor.h"
#include "document.h"

ObjectEditor::ObjectEditor(Document* document, const ldraw::id_t id) :
	QWidget{document},
	document{document}
{
	this->setObjectId(id);
	this->setLayout(new QVBoxLayout{this});
}

void ObjectEditor::setObjectId(const ldraw::id_t id)
{
	this->objectId = id;
	const ldraw::Object* object = this->document->getModel().get(id);
	if (object != nullptr and object->numPoints() > 0)
	{
		if (not this->polygonEditor.has_value())
		{
			this->polygonEditor.emplace(this->document, id);
			this->layout()->addWidget(&*this->polygonEditor);
		}
		else
		{
			this->polygonEditor->setObjectId(id);
		}
	}
	else
	{
		this->polygonEditor.reset();
	}
}

mercurial