Code

Fix bug #333762: snapping a guide while dragging/rotating, it always ends up being...
authordvlierop2 <dvlierop2@users.sourceforge.net>
Fri, 13 Mar 2009 22:00:28 +0000 (22:00 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Fri, 13 Mar 2009 22:00:28 +0000 (22:00 +0000)
src/desktop-events.cpp

index 8f5b53246a1169979e9f612e487ecd81d2c616f7..f77f3de354c42f9719150951d9ed977567f5b32e 100644 (file)
@@ -271,7 +271,14 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
                 double tol = 40.0;
                 Geom::Point const event_w(event->button.x, event->button.y);
                 Geom::Point const event_dt(desktop->w2d(event_w));
-                drag_origin = event_dt;
+
+                // Due to the tolerance allowed when grabbing a guide, event_dt will generally
+                // be close to the guide but not just exactly on it. The drag origin calculated
+                // here must be exactly on the guide line though, otherwise
+                // small errors will occur once we snap, see
+                // https://bugs.launchpad.net/inkscape/+bug/333762
+                drag_origin = Geom::projection(event_dt, Geom::Line(guide->point_on_line, guide->angle()));
+
                 if (Geom::L2(guide->point_on_line - event_dt) < tol) {
                     // the click was on the guide 'anchor'
                     drag_type = (event->button.state & GDK_SHIFT_MASK) ? SP_DRAG_MOVE_ORIGIN : SP_DRAG_TRANSLATE;