From 77558e04c19e0774bc2194f029f30112e73fe47d Mon Sep 17 00:00:00 2001 From: dvlierop2 Date: Fri, 13 Mar 2009 22:00:28 +0000 Subject: [PATCH] Fix bug #333762: snapping a guide while dragging/rotating, it always ends up being just a little bit off (started occuring after the recent guide handling improvements) --- src/desktop-events.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 8f5b53246..f77f3de35 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -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; -- 2.30.2