Code

Implement snapping in shape-tools during initial-drawing
authordvlierop2 <dvlierop2@users.sourceforge.net>
Sun, 18 Mar 2007 09:12:01 +0000 (09:12 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Sun, 18 Mar 2007 09:12:01 +0000 (09:12 +0000)
src/arc-context.cpp
src/spiral-context.cpp
src/star-context.cpp

index c682677a69c1c001d39bc423cd9ec79da2dae4cc..1071d6f5d9133ec0fc49eb92af66410dc7e9b623 100644 (file)
@@ -263,8 +263,9 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent
                 dragging = true;
                 ac->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
 
-                SnapManager const &m = desktop->namedview->snap_manager;
-                ac->center = m.freeSnap(Inkscape::Snapper::SNAP_POINT, ac->center, ac->item).getPoint();
+                SnapManager const &m = desktop->namedview->snap_manager;                
+                ac->center = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, ac->center, ac->item).getPoint();
+                
                 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                     GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
                                     GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK,
@@ -286,7 +287,12 @@ static gint sp_arc_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 const motion_dt(desktop->w2d(motion_w));
+                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, ac->item).getPoint();
+            
+                
                 sp_arc_drag(ac, motion_dt, event->motion.state);
                 ret = TRUE;
             }
index 2e4214f066308759ed214b89a44e9c85b3d2a2e1..ef3e3470b75790b0726aee6497d984705be899ee 100644 (file)
@@ -264,7 +264,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
 
                 SnapManager const &m = desktop->namedview->snap_manager;
-                sc->center = m.freeSnap(Inkscape::Snapper::SNAP_POINT, sc->center, sc->item).getPoint();
+                sc->center = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, sc->center, sc->item).getPoint();
 
                 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                     ( GDK_KEY_PRESS_MASK |
@@ -289,7 +289,11 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 event_context->within_tolerance = false;
 
                 NR::Point const motion_w(event->motion.x, event->motion.y);
-                NR::Point const motion_dt(event_context->desktop->w2d(motion_w));
+                NR::Point motion_dt(event_context->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, sc->item).getPoint();
+            
                 sp_spiral_drag(sc, motion_dt, event->motion.state);
                 ret = TRUE;
             }
index 03954e939924d439d3984ee9cc05e6c27528d6e3..611866acf17da167c1c0267c9b950fc683d36516 100644 (file)
@@ -276,7 +276,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
             sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
 
             SnapManager const &m = desktop->namedview->snap_manager;
-            sc->center = m.freeSnap(Inkscape::Snapper::SNAP_POINT, sc->center, sc->item).getPoint();
+            sc->center = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, sc->center, sc->item).getPoint();
 
             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                 GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@@ -299,7 +299,11 @@ 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 const motion_dt(event_context->desktop->w2d(motion_w));
+            NR::Point motion_dt(event_context->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, sc->item).getPoint();
+            
             sp_star_drag (sc, motion_dt, event->motion.state);
             ret = TRUE;
         }