From 76e1015affb07da45fb04e3f7a5a6d9d7c5a272c Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Feb 2010 23:18:29 +0100 Subject: 1) Making snapping behaviour for paraxial lines (in the pen tool) similar to other tools 2) Always apply the constraint when asking for a constrained snap 3) Show snap indicator when applying a constraint (bzr r9105) --- src/snap.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 1033b0a2c..53832994f 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -357,9 +357,14 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint // First project the mouse pointer onto the constraint Geom::Point pp = constraint.projection(p.getPoint()); + Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, Geom::L2(pp - p.getPoint()), 0, false, false); + if (!someSnapperMightSnap()) { - // The constraint should always be enforce, so we return pp here instead of p - return Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false); + // The constraint should always be enforced, so we return pp here instead of p + if (_snapindicator) { + _desktop->snapindicator->set_new_snaptarget(no_snap); + } + return no_snap; } // Then try to snap the projected point @@ -371,7 +376,17 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint (*i)->constrainedSnap(sc, candidate, bbox_to_snap, constraint, &_items_to_ignore); } - return findBestSnap(candidate, sc, true); + Inkscape::SnappedPoint result = findBestSnap(candidate, sc, true); + + if (result.getSnapped()) { + return result; + } + + // The constraint should always be enforced, so we return pp here instead of p + if (_snapindicator) { + _desktop->snapindicator->set_new_snaptarget(no_snap); + } + return no_snap; } /** -- cgit v1.2.3