Code

Fix bug #1511262: don't snap rect to itself
authordvlierop2 <dvlierop2@users.sourceforge.net>
Fri, 16 Mar 2007 21:26:53 +0000 (21:26 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Fri, 16 Mar 2007 21:26:53 +0000 (21:26 +0000)
src/object-edit.cpp
src/rect-context.cpp

index 2eabdd7bd480acd97a64789f9de6c635f38eb81d..5ca3469771ae463c2eeab558fe90a97bbda7f13d 100644 (file)
@@ -331,18 +331,18 @@ static NR::Point sp_rect_wh_get(SPItem *item)
     return NR::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed);
 }
 
-static NR::Point rect_snap_knot_position(NR::Point const &p)
+static NR::Point rect_snap_knot_position(SPRect *rect, NR::Point const &p)
 {
     SPDesktop const *desktop = inkscape_active_desktop();
     NR::Point s = sp_desktop_dt2root_xy_point(desktop, p);
     SnapManager const &m = desktop->namedview->snap_manager;
-    s = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, s, NULL).getPoint();
+    s = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, s, rect).getPoint();
     return sp_desktop_root2dt_xy_point(desktop, s);
 }
 
 static void sp_rect_wh_set_internal(SPRect *rect, NR::Point const &p, NR::Point const &origin, guint state)
 {
-    NR::Point const s = rect_snap_knot_position(p);
+    NR::Point const s = rect_snap_knot_position(rect, p);
 
     if (state & GDK_CONTROL_MASK) {
         // original width/height when drag started
@@ -420,7 +420,7 @@ static void sp_rect_xy_set(SPItem *item, NR::Point const &p, NR::Point const &or
     gdouble w_orig = opposite_x - origin[NR::X];
     gdouble h_orig = opposite_y - origin[NR::Y];
 
-    NR::Point const s = rect_snap_knot_position(p);
+    NR::Point const s = rect_snap_knot_position(rect, p);
 
     // mouse displacement since drag started
     gdouble minx = s[NR::X] - origin[NR::X];
index 8482cd0424432841731556f86218f4f275051f48..b6c3315384918635cfac39ade944a4493d7b04c6 100644 (file)
@@ -330,7 +330,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
             NR::Point motion_dt(desktop->w2d(motion_w));
             
             SnapManager const &m = desktop->namedview->snap_manager;
-            motion_dt = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, motion_dt, NULL).getPoint();   
+            motion_dt = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, motion_dt, rc->item).getPoint();
             
             sp_rect_drag(*rc, motion_dt, event->motion.state);