src/layers/edittools.cpp

changeset 311
fab454611f9b
parent 310
5d6639a9607f
child 312
2637134bc37c
--- a/src/layers/edittools.cpp	Fri Jul 01 13:41:46 2022 +0300
+++ b/src/layers/edittools.cpp	Fri Jul 01 16:45:40 2022 +0300
@@ -50,6 +50,15 @@
 void EditTools::setEditMode(EditingMode newMode)
 {
 	this->mode = newMode;
+	switch (this->mode) {
+	case SelectMode:
+		Q_EMIT this->suggestCursor(Qt::ArrowCursor);
+		break;
+	case DrawMode:
+	case CircleMode:
+		Q_EMIT this->suggestCursor(Qt::CrossCursor);
+		break;
+	}
 }
 
 void EditTools::setGridMatrix(const glm::mat4& newGridMatrix)
@@ -214,18 +223,20 @@
 void EditTools::overpaint(QPainter* painter)
 {
 	painter->save();
-	const Pens& pens = (this->renderer->isDark() ? darkPens : brightPens);
-	this->renderPreview(painter, &pens);
-	QFont font;
-	font.setBold(true);
-	if (this->worldPosition.has_value())
-	{
-		painter->setRenderHint(QPainter::Antialiasing);
-		painter->setPen(pens.pointPen);
-		painter->setBrush(pens.greenPolygonBrush);
-		const QPointF pos = this->renderer->modelToScreenCoordinates(*this->worldPosition);
-		painter->drawEllipse(pos, 5, 5);
-		drawBorderedText(painter, pos + QPointF{5, 5}, font, vectorToString(*this->worldPosition));
+	if (this->usePolygon()) {
+		const Pens& pens = (this->renderer->isDark() ? darkPens : brightPens);
+		this->renderPreview(painter, &pens);
+		QFont font;
+		font.setBold(true);
+		if (this->usePolygon() and this->worldPosition.has_value())
+		{
+			painter->setRenderHint(QPainter::Antialiasing);
+			painter->setPen(pens.pointPen);
+			painter->setBrush(pens.greenPolygonBrush);
+			const QPointF pos = this->renderer->modelToScreenCoordinates(*this->worldPosition);
+			painter->drawEllipse(pos, 5, 5);
+			drawBorderedText(painter, pos + QPointF{5, 5}, font, vectorToString(*this->worldPosition));
+		}
 	}
 	painter->restore();
 }
@@ -462,6 +473,18 @@
 	return result;
 }
 
+bool EditTools::usePolygon() const
+{
+	switch (this->mode) {
+	case SelectMode:
+		return false;
+	case DrawMode:
+	case CircleMode:
+		return true;
+	}
+	return {};
+}
+
 void EditTools::closeShape()
 {
 	for (const ModelAction& action : this->modelActions()) {

mercurial