src/ui/canvas.h

changeset 108
94c92c923713
parent 107
02f142b399b1
child 109
40a1cf2f38f5
--- a/src/ui/canvas.h	Sat Jul 24 01:50:38 2021 +0300
+++ b/src/ui/canvas.h	Sun Jul 25 13:49:37 2021 +0300
@@ -1,4 +1,6 @@
 #pragma once
+#include <QBrush>
+#include <QPen>
 #include "gl/partrenderer.h"
 #include "gl/gridprogram.h"
 #include "gl/axesprogram.h"
@@ -8,14 +10,27 @@
 	Q_OBJECT
 public:
 	struct MouseClickInfo;
+	struct MouseMoveInfo;
 	enum PreviewLayerName : std::int8_t
 	{
 		DrawToolPreview
 	};
 	struct PreviewLayer
 	{
-		QVector<geom::NPolygon> polygons;
-		QColor color{64, 255, 128};
+		struct Point
+		{
+			glm::vec3 location;
+			QBrush brush = {};
+			QPen pen = {};
+		};
+		struct Polygon
+		{
+			geom::NPolygon geometry;
+			QBrush brush = {};
+			QPen pen = {};
+		};
+		QVector<Point> points;
+		QVector<Polygon> polygons;
 	};
 	static constexpr int NUM_PREVIEW_LAYERS = 1;
 
@@ -40,6 +55,7 @@
 	void newStatusText(const QString& newStatusText);
 	void selectionChanged(const QSet<ldraw::id_t>& newSelection);
 	void mouseClick(const MouseClickInfo& info);
+	void mouseMove(const MouseMoveInfo& info);
 private:
 	void updateGridMatrix();
 	glm::vec3 cameraVector() const;
@@ -59,3 +75,9 @@
 	std::optional<glm::vec3> worldPosition;
 	Canvas* invoker;
 };
+
+struct Canvas::MouseMoveInfo
+{
+	std::optional<glm::vec3> worldPosition;
+	Canvas* invoker;
+};

mercurial