src/ui/canvas.cpp

changeset 166
8857351912d0
parent 165
f6eab2bd46c2
child 168
24590af32ad6
--- 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);
 	}
 }
 

mercurial