From 5349b935f0a455adc0edcccc448b31af0ed421f9 Mon Sep 17 00:00:00 2001 From: dvlierop2 Date: Tue, 20 May 2008 19:21:01 +0000 Subject: [PATCH] Improve snapping behaviour when creating new shapes --- src/arc-context.cpp | 10 +++++----- src/rect-context.cpp | 10 +++++----- src/spiral-context.cpp | 2 +- src/star-context.cpp | 23 ++++++++++------------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 45b67a7dc..e3dc7161c 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -262,6 +262,11 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent dragging = true; ac->center = Inkscape::setup_for_drag_start(desktop, event_context, event); + + /* Snap center */ + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop, NULL); //null, because we don't have an item yet + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, ac->center); sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -425,11 +430,6 @@ static void sp_arc_drag(SPArcContext *ac, NR::Point pt, guint state) ac->item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); - - /* Snap center */ - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop, ac->item); - m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, ac->center); } bool ctrl_save = false; diff --git a/src/rect-context.cpp b/src/rect-context.cpp index d1e5fe381..f53a39948 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -304,6 +304,11 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent NR::Point const button_dt(desktop->w2d(button_w)); rc->center = button_dt; + /* Snap center */ + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop, NULL); //null, because we don't have an item yet + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, rc->center); + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), ( GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -491,11 +496,6 @@ static void sp_rect_drag(SPRectContext &rc, NR::Point const pt, guint state) rc.item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); - - /* Snap center */ - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop, rc.item); - m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, rc.center); } NR::Rect const r = Inkscape::snap_rectangular_box(desktop, rc.item, pt, rc.center, state); diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 31ec40d50..e86859369 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -266,7 +266,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event); SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop, sc->item); + m.setup(desktop, NULL); //null, because we don't have an item yet m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, sc->center); sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), diff --git a/src/star-context.cpp b/src/star-context.cpp index b6b3c340e..1b3b1e7b0 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -279,10 +279,11 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent dragging = TRUE; sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event); - + + /* Snap center */ SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop, sc->item); - m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, sc->center); + m.setup(desktop, NULL); //null, because we don't have an item yet + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, sc->center); sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -305,11 +306,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent event_context->within_tolerance = false; NR::Point const motion_w(event->motion.x, event->motion.y); - NR::Point motion_dt(event_context->desktop->w2d(motion_w)); - - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop, sc->item); - m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); + NR::Point motion_dt(desktop->w2d(motion_w)); sp_star_drag (sc, motion_dt, event->motion.state); @@ -449,14 +446,14 @@ static void sp_star_drag(SPStarContext *sc, NR::Point p, guint state) sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); } - NR::Point const p0 = sp_desktop_dt2root_xy_point(desktop, sc->center); - NR::Point p1 = sp_desktop_dt2root_xy_point(desktop, p); - /* Snap corner point with no constraints */ SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, sc->item); - m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p1); - + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p); + + NR::Point const p0 = sp_desktop_dt2root_xy_point(desktop, sc->center); + NR::Point p1 = sp_desktop_dt2root_xy_point(desktop, p); + SPStar *star = SP_STAR(sc->item); double const sides = (gdouble) sc->magnitude; -- 2.30.2