Fix rendering of cursor coordinates on bright background

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 165
f6eab2bd46c2
child 167
c1ff4f107569

Fix rendering of cursor coordinates on bright background

src/ui/canvas.cpp file | annotate | diff | comparison | revisions
src/ui/canvas.h file | annotate | diff | comparison | revisions
--- a/src/ui/canvas.cpp	Sat Mar 05 13:55:12 2022 +0200
+++ b/src/ui/canvas.cpp	Sat Mar 05 13:59:54 2022 +0200
@@ -152,11 +152,10 @@
 		{
 			QPainter painter{this};
 			painter.setRenderHint(QPainter::Antialiasing);
-			painter.setPen(Qt::black);
+			painter.setPen(this->isDark ? Qt::white : Qt::black);
 			painter.setBrush(Qt::green);
 			const QPointF pos = this->modelToScreenCoordinates(*this->worldPosition);
 			painter.drawEllipse(pos, 5, 5);
-			painter.setPen(Qt::white);
 			painter.drawText(pos + QPointF{5, 5}, vectorToString(*this->worldPosition));
 		}
 		{
@@ -340,10 +339,10 @@
 
 void Canvas::updateCanvasRenderPreferences()
 {
+	this->isDark = luma(this->renderPreferences.backgroundColor) < 0.25;
 	if (this->gridProgram.has_value())
 	{
-		const bool isDark = luma(this->renderPreferences.backgroundColor) < 0.25;
-		this->gridProgram->setGridColor(isDark ? Qt::white : Qt::black);
+		this->gridProgram->setGridColor(this->isDark ? Qt::white : Qt::black);
 	}
 }
 
--- a/src/ui/canvas.h	Sat Mar 05 13:55:12 2022 +0200
+++ b/src/ui/canvas.h	Sat Mar 05 13:59:54 2022 +0200
@@ -52,6 +52,7 @@
 	glm::mat4 gridMatrix;
 	geom::Plane gridPlane;
 	int totalMouseMove = 0;
+	bool isDark = true;
 	QSet<ldraw::id_t> selection;
 	OverpaintCallback overpaintCallback = nullptr;
 };

mercurial