From de27d953d1c13d2e7563b43c2d959b1b02aee9c3 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 12 May 2008 18:58:04 +0000 Subject: Add a centralized check (i.e. in the snapper mechanism) whether we've snapped or not, instead of leaving it up to the various tools. This should prevent these tools from moving to (0,0) if they bluntly use the value returned by the snapping mechanism without checking whether snapping has really occured. (bzr r5659) --- src/context-fns.cpp | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'src/context-fns.cpp') diff --git a/src/context-fns.cpp b/src/context-fns.cpp index 83048af40..61b6a2fc4 100644 --- a/src/context-fns.cpp +++ b/src/context-fns.cpp @@ -86,7 +86,7 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item, bool const control = state & GDK_CONTROL_MASK; SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop, item); + m.setup(NULL, item); Inkscape::SnappedPoint snappoint; if (control) { @@ -141,23 +141,27 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item, /* Choose the best snap and update points accordingly */ if (s[0].getDistance() < s[1].getDistance()) { - p[0] = s[0].getPoint(); - p[1] = 2 * center - s[0].getPoint(); - snappoint = s[0]; + if (s[0].getSnapped()) { + p[0] = s[0].getPoint(); + p[1] = 2 * center - s[0].getPoint(); + snappoint = s[0]; + } } else { - p[0] = 2 * center - s[1].getPoint(); - p[1] = s[1].getPoint(); - snappoint = s[1]; + if (s[1].getSnapped()) { + p[0] = 2 * center - s[1].getPoint(); + p[1] = s[1].getPoint(); + snappoint = s[1]; + } } - desktop->snapindicator->set_new_snappoint(snappoint); - } else { /* Our origin is the opposite corner. Snap the drag point along the constraint vector */ p[0] = center; snappoint = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, p[1], Inkscape::Snapper::ConstraintLine(p[1] - p[0])); - p[1] = snappoint.getPoint(); + if (snappoint.getSnapped()) { + p[1] = snappoint.getPoint(); + } } } else if (shift) { @@ -175,13 +179,17 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item, s[1] = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p[1]); if (s[0].getDistance() < s[1].getDistance()) { - p[0] = s[0].getPoint(); - p[1] = 2 * center - s[0].getPoint(); - snappoint = s[0]; + if (s[0].getSnapped()) { + p[0] = s[0].getPoint(); + p[1] = 2 * center - s[0].getPoint(); + snappoint = s[0]; + } } else { - p[0] = 2 * center - s[1].getPoint(); - p[1] = s[1].getPoint(); - snappoint = s[1]; + if (s[1].getSnapped()) { + p[0] = 2 * center - s[1].getPoint(); + p[1] = s[1].getPoint(); + snappoint = s[1]; + } } } else { @@ -189,12 +197,13 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item, /* There's no constraint on the corner point, so just snap it to anything */ p[0] = center; snappoint = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, pt); - p[1] = snappoint.getPoint(); + if (snappoint.getSnapped()) { + p[1] = snappoint.getPoint(); + } } if (snappoint.getSnapped()) { - // this does not work well enough yet. -// desktop->snapindicator->set_new_snappoint(snappoint); + desktop->snapindicator->set_new_snappoint(snappoint); } p[0] = sp_desktop_dt2root_xy_point(desktop, p[0]); -- cgit v1.2.3