]> Shamusworld >> Repos - architektonas/blobdiff - src/arc.cpp
Lines respond to mouse movement, added Text rendering.
[architektonas] / src / arc.cpp
index d4d747b7df80d1a3a7dd7cb8c4e1010609e82b7a..6391eaecd0d813cfe14928996025081a9b28ae37 100644 (file)
@@ -168,6 +168,9 @@ Also: should put the snap logic into the Object base class (as a static method).
        if (snapToGrid)
                point = SnapPointToGrid(point);
 
+       if (snapPointIsValid)
+               point = snapPoint;
+
 /*
 State Management:
 We want the arc to go into OSSelected mode if we click on it but don't drag.
@@ -241,6 +244,13 @@ so let's do like this:
        SaveHitState();
        bool hovered = HitTest(point);
        needUpdate = HitStateChanged();
+
+       if (snapToGrid)
+               point = SnapPointToGrid(point);
+
+       if (snapPointIsValid)
+               point = snapPoint;
+
        objectWasDragged = (draggingCenter | draggingEdge | draggingRotate | draggingSpan);
 
        if (objectWasDragged)
@@ -324,14 +334,26 @@ point (to get the correct position).
                hitArc = true;
 #else
        if ((length * Painter::zoom) < 8.0)
+       {
                hitCenter = true;
+               snapPoint = position;
+               snapPointIsValid = true;
+       }
        else if (((fabs(length - radius) * Painter::zoom) < 2.0)
                && AngleInArcSpan(pointerAngle))
                hitArc = true;
        else if ((Vector::Magnitude(handle2, point) * Painter::zoom) < 8.0)
+       {
                hitRotate = true;
+               snapPoint = handle2;
+               snapPointIsValid = true;
+       }
        else if ((Vector::Magnitude(handle3, point) * Painter::zoom) < 8.0)
+       {
                hitSpan = true;
+               snapPoint = handle3;
+               snapPointIsValid = true;
+       }
 #endif
 
        return (hitCenter || hitArc || hitRotate || hitSpan ? true : false);
@@ -346,6 +368,7 @@ point (to get the correct position).
        QPointF p2(cos(end), sin(end));
        QRectF bounds(p1, p2);
 
+#if 0
        // Swap X/Y coordinates if they're backwards...
        if (bounds.left() > bounds.right())
        {
@@ -360,6 +383,9 @@ point (to get the correct position).
                bounds.setBottom(bounds.top());
                bounds.setTop(temp);
        }
+#else
+       bounds = bounds.normalized();
+#endif
 
        // If the end of the arc is before the beginning, add 360 degrees to it
        if (end < start)