+#else
+ DrawGlyphPoly(p, glyph, poly);
+#endif
+ }
+}
+
+
+/*
+So, to make it draw the point the pointer is pointing at, we need to do something. Either patch the GlyphPoints to handle it, or insert the point into the GlyphPoints and delete it if the user changes tools. Either way, need
+to change the color of the line(s) drawn to the point to signal to the user
+that it isn't finalized until they click the button.
+*/
+void EditWindow::DrawGlyphPoly(Painter & p, GlyphPoints & glyph, uint16_t poly)
+{
+ // Sanity check
+ if (glyph.GetNumPoints(poly) < 3)
+ return;
+
+ IPoint p1 = glyph.GetPrevPoint(poly, 0);
+ IPoint p2 = glyph.GetPoint(poly, 0);
+
+ // Inject the new poly point into the current polygon
+ if ((tool == TOOLAddPoly) && (poly == (glyph.GetNumPolys() - 1)))
+ {
+ p1 = IPoint(addPoint.x, addPoint.y, addPointOnCurve);
+ }
+
+ for(int i=0; i<glyph.GetNumPoints(poly); i++)
+ {
+ IPoint p3 = glyph.GetNextPoint(poly, i);
+
+ if ((tool == TOOLAddPoly) && (poly == (glyph.GetNumPolys() - 1))
+ && (i == (glyph.GetNumPoints(poly) - 1)))
+ {
+ p3 = IPoint(addPoint.x, addPoint.y, addPointOnCurve);
+ p.SetPen(QPen(Qt::green, 1.0, Qt::SolidLine));
+ DrawGlyphSegment(p, p1, p2, p3);
+ p1 = p2;
+ p2 = p3;
+ p3 = glyph.GetNextPoint(poly, i);
+ }
+
+ DrawGlyphSegment(p, p1, p2, p3);
+
+ p1 = p2;
+ p2 = p3;
+ }
+}
+
+
+//
+// Draw a glyph segment given 3 points
+//
+void EditWindow::DrawGlyphSegment(Painter & p, IPoint p1, IPoint p2, IPoint p3)
+{
+ if (p2.onCurve)
+ {
+ // Skip drawing if the middle point is on curve and the last is off
+ if (p3.onCurve)
+ p.DrawLine(p2, p3);
+ }
+ else
+ {
+ // The middle point is off curve, and so we need to draw a Bezier curve.
+ // Also, depending on whether or not the previous or follow points are
+ // off curve, we need to draw to the midpoints if so.
+ IPoint mid12 = IPoint((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
+ IPoint mid23 = IPoint((p2.x + p3.x) / 2, (p2.y + p3.y) / 2);
+ p.DrawBezier((p1.onCurve ? p1 : mid12), p2, (p3.onCurve ? p3 : mid23));