From: johanengelen Date: Tue, 4 Mar 2008 21:04:14 +0000 (+0000) Subject: snapindicator in freehand X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c4881b995ec2e38dd06ef1e7e5da4f0440f9164f;p=inkscape.git snapindicator in freehand --- diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 649f13572..64cfb76f7 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -40,6 +40,7 @@ #include "snap.h" #include "sp-path.h" #include "sp-namedview.h" +#include "display/snap-indicator.h" static void sp_draw_context_class_init(SPDrawContextClass *klass); static void sp_draw_context_init(SPDrawContext *dc); @@ -354,8 +355,12 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, N /* Snap it along best vector */ SnapManager const &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager; - p = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, - p, Inkscape::Snapper::ConstraintLine(best), NULL).getPoint(); + Inkscape::SnappedPoint const s = m.constrainedSnap( Inkscape::Snapper::SNAPPOINT_NODE, + p, Inkscape::Snapper::ConstraintLine(best), NULL ); + p = s.getPoint(); + if (s.getDistance() < NR_HUGE) { + SP_EVENT_CONTEXT_DESKTOP(ec)->snapindicator->set_new_snappoint(p.to_2geom()); + } } } @@ -368,7 +373,11 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guin } SnapManager const &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager; - p = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p, NULL).getPoint(); + Inkscape::SnappedPoint const s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p, NULL); + p = s.getPoint(); + if (s.getDistance() < NR_HUGE) { + SP_EVENT_CONTEXT_DESKTOP(ec)->snapindicator->set_new_snappoint(p.to_2geom()); + } } static SPCurve * diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 1088e19ed..d27d363f9 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -32,6 +32,7 @@ #include "pixmaps/cursor-pencil.xpm" #include "display/bezier-utils.h" #include "display/canvas-bpath.h" +#include "display/snap-indicator.h" #include #include "libnr/in-svg-plane.h" #include "libnr/n-art-bpath.h" @@ -274,6 +275,8 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev gint ret = FALSE; SPDesktop *const dt = pc->desktop; + dt->snapindicator->remove_snappoint(); + SPEventContext *event_context = SP_EVENT_CONTEXT(pc); if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) { // allow scrolling @@ -322,7 +325,11 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev p = anchor->dp; } else if ((mevent.state & GDK_SHIFT_MASK) == 0) { SnapManager const &m = dt->namedview->snap_manager; - p = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p, NULL).getPoint(); + Inkscape::SnappedPoint const s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p, NULL); + p = s.getPoint(); + if (s.getDistance() < NR_HUGE) { + dt->snapindicator->set_new_snappoint(p.to_2geom()); + } } if ( pc->npoints != 0 ) { // buttonpress may have happened before we entered draw context! spdc_add_freehand_point(pc, p, mevent.state);