From: Diederik van Lierop Date: Mon, 8 Mar 2010 21:06:42 +0000 (+0100) Subject: Don't snap to points which are off-screen X-Git-Url: https://git.tokkee.org/?p=inkscape.git;a=commitdiff_plain;h=9af0d2591bcbc964f2704842dfb2d9a23203c4cd Don't snap to points which are off-screen --- diff --git a/src/snap.cpp b/src/snap.cpp index 0df58080e..352683623 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -281,7 +281,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c // Find the best snap for this grid, including intersections of the grid-lines bool old_val = _snapindicator; _snapindicator = false; - Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false); + Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, false, true); _snapindicator = old_val; if (s.getSnapped() && (s.getSnapDistance() < nearest_distance)) { // use getSnapDistance() instead of getWeightedDistance() here because the pointer's position @@ -898,13 +898,15 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(std::vector::const_iterator i = sp_list.begin(); i != sp_list.end(); i++) { - // first find out if this snapped point is within snapping range // std::cout << "sp = " << (*i).getPoint() << " | source = " << (*i).getSource() << " | target = " << (*i).getTarget(); - if ((*i).getSnapDistance() <= (*i).getTolerance()) { - // if it's the first point, or if it is closer than the best snapped point so far - if (i == sp_list.begin() || bestSnappedPoint.isOtherSnapBetter(*i, false)) { - // then prefer this point over the previous one - bestSnappedPoint = *i; + bool onScreen = _desktop->get_display_area().contains((*i).getPoint()); + if (onScreen || allowOffScreen) { // Only snap to points which are not off the screen + if ((*i).getSnapDistance() <= (*i).getTolerance()) { // Only snap to points within snapping range + // if it's the first point, or if it is closer than the best snapped point so far + if (i == sp_list.begin() || bestSnappedPoint.isOtherSnapBetter(*i, false)) { + // then prefer this point over the previous one + bestSnappedPoint = *i; + } } } // std::cout << std::endl; diff --git a/src/snap.h b/src/snap.h index 24f62ec6f..8a5688bea 100644 --- a/src/snap.h +++ b/src/snap.h @@ -170,7 +170,7 @@ public: bool getSnapIndicator() const {return _snapindicator;} - Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, SnappedConstraints const &sc, bool constrained, bool noCurves = false) const; + Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, SnappedConstraints const &sc, bool constrained, bool noCurves = false, bool allowOffScreen = false) const; protected: SPNamedView const *_named_view;