diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-03-04 21:04:14 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-03-04 21:04:14 +0000 |
| commit | 42725bf2904fae94d41ba8074b6783c64b71fc43 (patch) | |
| tree | 193e6e4f6528b95f7711cd43e73d96af4a9db709 /src | |
| parent | snapindicator for gradient knots (diff) | |
| download | inkscape-42725bf2904fae94d41ba8074b6783c64b71fc43.tar.gz inkscape-42725bf2904fae94d41ba8074b6783c64b71fc43.zip | |
snapindicator in freehand
(bzr r4959)
Diffstat (limited to 'src')
| -rw-r--r-- | src/draw-context.cpp | 15 | ||||
| -rw-r--r-- | src/pencil-context.cpp | 9 |
2 files changed, 20 insertions, 4 deletions
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 <glibmm/i18n.h> #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); |
