From: dvlierop2 Date: Fri, 16 May 2008 21:53:27 +0000 (+0000) Subject: Fix a regression in the snapper, caused by me. Sorry! X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6a69102a7dd02614f36aa17fb2f1ecd6cdb09d8a;p=inkscape.git Fix a regression in the snapper, caused by me. Sorry! --- diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 6169d000f..b06b5fb86 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -265,7 +265,7 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, ac->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, ac->center); + 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 | @@ -292,7 +292,7 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, ac->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); sp_arc_drag(ac, motion_dt, event->motion.state); diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index a7cead93e..c1af593d4 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -317,7 +317,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven dragging = true; /* */ - NR::Point const button_dt(desktop->w2d(button_w)); + NR::Point button_dt(desktop->w2d(button_w)); bc->drag_origin = button_dt; bc->drag_ptB = button_dt; bc->drag_ptC = button_dt; @@ -332,7 +332,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven /* Snap center */ SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, bc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt); bc->center = button_dt; sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), @@ -364,7 +364,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, bc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK; @@ -397,7 +397,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven bc->drag_ptB_proj.normalize(); bc->drag_ptC_proj = cur_persp->tmat.preimage (motion_dt, bc->drag_ptB_proj[Proj::X], Proj::X); } - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC); } sp_box3d_drag(*bc, event->motion.state); diff --git a/src/connector-context.cpp b/src/connector-context.cpp index e33b11e64..028467b44 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -532,7 +532,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const // as there's no other points to go off. SnapManager &m = cc->desktop->namedview->snap_manager; m.setup(cc->desktop); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p); } spcc_connector_set_initial_point(cc, p); diff --git a/src/context-fns.cpp b/src/context-fns.cpp index 2ae4c3901..28725c64f 100644 --- a/src/context-fns.cpp +++ b/src/context-fns.cpp @@ -197,11 +197,8 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item, /* There's no constraint on the corner point, so just snap it to anything */ p[0] = center; p[1] = pt; - //std::cout << "pt = " << pt << std::endl; snappoint = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, pt); - //std::cout << "snappoint.getPoint() = " << snappoint.getPoint() << std::endl; if (snappoint.getSnapped()) { - //std::cout << "we snapped here ..." << std::endl; p[1] = snappoint.getPoint(); } } @@ -213,8 +210,6 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item, p[0] = sp_desktop_dt2root_xy_point(desktop, p[0]); p[1] = sp_desktop_dt2root_xy_point(desktop, p[1]); - //std::cout << "after: p[0] vs. p[1] = " << p[0] << " | " << p[1] << std::endl; - return NR::Rect(NR::Point(MIN(p[0][NR::X], p[1][NR::X]), MIN(p[0][NR::Y], p[1][NR::Y])), NR::Point(MAX(p[0][NR::X], p[1][NR::X]), MAX(p[0][NR::Y], p[1][NR::Y]))); } diff --git a/src/draw-context.cpp b/src/draw-context.cpp index f4d7a8569..9a2c1215c 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -356,7 +356,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, N /* Snap it along best vector */ SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager; m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL); - m.constrainedSnap( Inkscape::Snapper::SNAPPOINT_NODE, p, Inkscape::Snapper::ConstraintLine(best)); + m.constrainedSnapReturnByRef( Inkscape::Snapper::SNAPPOINT_NODE, p, Inkscape::Snapper::ConstraintLine(best)); } } @@ -370,7 +370,7 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guin SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager; m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p); } static SPCurve * diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index e4cdd707f..01964b8e7 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -533,7 +533,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) break; case GDK_BUTTON_PRESS: if ( event->button.button == 1 && !event_context->space_panning ) { - NR::Point const button_w(event->button.x, event->button.y); + NR::Point button_w(event->button.x, event->button.y); // save drag origin event_context->xp = (gint) button_w[NR::X]; @@ -542,7 +542,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) dragging = true; - NR::Point const button_dt = desktop->w2d(button_w); + NR::Point button_dt = desktop->w2d(button_w); if (event->button.state & GDK_SHIFT_MASK) { Inkscape::Rubberband::get()->start(desktop, button_dt); } else { @@ -554,7 +554,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) /* Snap center to nearest magnetic point */ SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt); rc->origin = button_dt; } diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 0abf84a1f..65b256b34 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -224,7 +224,7 @@ static NR::Point snap_knot_position(SPItem *item, NR::Point const &p) NR::Point s = p * i2d; SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, s); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, s); return s * i2d.inverse(); } diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 87cbb8d12..6af9f7956 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -248,7 +248,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new path")); SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p); } else if (selection->singleItem() && SP_IS_PATH(selection->singleItem())) { desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Appending to selected path")); } @@ -325,7 +325,7 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev } else if ((mevent.state & GDK_SHIFT_MASK) == 0) { SnapManager &m = dt->namedview->snap_manager; m.setup(dt, NULL); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p); } if ( pc->npoints != 0 ) { // buttonpress may have happened before we entered draw context! spdc_add_freehand_point(pc, p, mevent.state); diff --git a/src/rect-context.cpp b/src/rect-context.cpp index b8047b201..3ecd89113 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -302,11 +302,6 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent /* Position center */ NR::Point const button_dt(desktop->w2d(button_w)); - - /* Snap center */ - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop, rc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt); rc->center = button_dt; sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), @@ -315,6 +310,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK ), NULL, event->button.time); + ret = TRUE; } break; @@ -336,11 +332,11 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent event->motion.y); NR::Point motion_dt(desktop->w2d(motion_w)); - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop, rc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); + //SnapManager &m = desktop->namedview->snap_manager; + //m.setup(desktop, rc->item); + //m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); - sp_rect_drag(*rc, motion_dt, event->motion.state); + sp_rect_drag(*rc, motion_dt, event->motion.state); // this will also handle the snapping gobble_motion_events(GDK_BUTTON1_MASK); ret = TRUE; } @@ -500,6 +496,11 @@ 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/seltrans.cpp b/src/seltrans.cpp index 432b1e670..94baf12d7 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1261,7 +1261,7 @@ gboolean Inkscape::SelTrans::centerRequest(NR::Point &pt, guint state) { SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); - m.freeSnap(Snapper::SNAPPOINT_NODE, pt); + m.freeSnapReturnByRef(Snapper::SNAPPOINT_NODE, pt); if (state & GDK_CONTROL_MASK) { if ( fabs(_point[NR::X] - pt[NR::X]) > fabs(_point[NR::Y] - pt[NR::Y]) ) { @@ -1369,7 +1369,7 @@ void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state) ** FIXME: this will snap to more than just the grid, nowadays. */ - m.freeSnap(Snapper::SNAPPOINT_NODE, dxy); + m.freeSnapReturnByRef(Snapper::SNAPPOINT_NODE, dxy); } else if (!shift) { @@ -1434,14 +1434,14 @@ void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state) } } - if (control) { - /* Ensure that the horizontal and vertical constraint has been applied */ - if (fabs(dxy[NR::X]) > fabs(dxy[NR::Y])) { - dxy[NR::Y] = 0; - } else { - dxy[NR::X] = 0; - } - } + //if (control) { + // /* Ensure that the horizontal and vertical constraint has been applied */ + // if (fabs(dxy[NR::X]) > fabs(dxy[NR::Y])) { + // dxy[NR::Y] = 0; + // } else { + // dxy[NR::X] = 0; + // } + //} NR::Matrix const move((NR::translate(dxy))); NR::Point const norm(0, 0); diff --git a/src/snap.cpp b/src/snap.cpp index bc81bdf3a..46d043ec1 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -179,7 +179,7 @@ bool SnapManager::getSnapModeGuide() const * \return Snapped point. */ -void SnapManager::freeSnapVoid(Inkscape::Snapper::PointType point_type, +void SnapManager::freeSnapReturnByRef(Inkscape::Snapper::PointType point_type, NR::Point &p, bool first_point, NR::Maybe const &bbox_to_snap) const @@ -244,7 +244,7 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType point_ * \return Snapped point. */ -void SnapManager::constrainedSnapVoid(Inkscape::Snapper::PointType point_type, +void SnapManager::constrainedSnapReturnByRef(Inkscape::Snapper::PointType point_type, NR::Point &p, Inkscape::Snapper::ConstraintLine const &constraint, bool first_point, diff --git a/src/snap.h b/src/snap.h index 900f548ce..4c5e57b73 100644 --- a/src/snap.h +++ b/src/snap.h @@ -50,9 +50,9 @@ public: void setup(SPDesktop const *desktop_for_snapindicator = NULL, SPItem const *item_to_ignore = NULL, std::vector *unselected_nodes = NULL); void setup(SPDesktop const *desktop_for_snapindicator, std::vector &items_to_ignore, std::vector *unselected_nodes = NULL); - // freeSnapVoid() is preferred over freeSnap(), because it only returns a - // point, by overwriting p, if snapping has occured; otherwise p is untouched - void freeSnapVoid(Inkscape::Snapper::PointType point_type, + // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a + // point if snapping has occured (by overwriting p); otherwise p is untouched + void freeSnapReturnByRef(Inkscape::Snapper::PointType point_type, NR::Point &p, bool first_point = true, NR::Maybe const &bbox_to_snap = NR::Nothing()) const; @@ -62,9 +62,9 @@ public: bool first_point = true, NR::Maybe const &bbox_to_snap = NR::Nothing()) const; - // constrainedSnapVoid() is preferred over constrainedSnap(), because it only returns a + // constrainedSnapReturnByRef() is preferred over constrainedSnap(), because it only returns a // point, by overwriting p, if snapping has occured; otherwise p is untouched - void constrainedSnapVoid(Inkscape::Snapper::PointType point_type, + void constrainedSnapReturnByRef(Inkscape::Snapper::PointType point_type, NR::Point &p, Inkscape::Snapper::ConstraintLine const &constraint, bool first_point = true, diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 57c06e4a3..31ec40d50 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -267,7 +267,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, sc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, sc->center); sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), ( GDK_KEY_PRESS_MASK | @@ -296,7 +296,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, sc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); sp_spiral_drag(sc, motion_dt, event->motion.state); gobble_motion_events(GDK_BUTTON1_MASK); @@ -440,7 +440,7 @@ sp_spiral_drag(SPSpiralContext *sc, NR::Point p, guint state) NR::Point p1 = sp_desktop_dt2root_xy_point(desktop, p); SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, sc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p1); SPSpiral *spiral = SP_SPIRAL(sc->item); diff --git a/src/star-context.cpp b/src/star-context.cpp index afdb14a0c..b6b3c340e 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -282,7 +282,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, sc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center); + 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 | @@ -309,7 +309,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, sc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt); sp_star_drag (sc, motion_dt, event->motion.state); @@ -455,7 +455,7 @@ static void sp_star_drag(SPStarContext *sc, NR::Point p, guint state) /* Snap corner point with no constraints */ SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, sc->item); - m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1); + m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p1); SPStar *star = SP_STAR(sc->item);