Code

Only in the selector tool we should snap in bbox mode (PointType = SNAPPOINT_BBOX)
[inkscape.git] / src / draw-context.cpp
index 75ded20f5a04a388aab181a92d8d9f56fdf49f7a..43e028aa5655032071f821e2c089a40e58b623e8 100644 (file)
@@ -209,30 +209,11 @@ sp_draw_context_set(SPEventContext *ec, const gchar *key, const gchar *value)
 gint
 sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event)
 {
-    //SPDrawContext *dc = SP_DRAW_CONTEXT(ec);
-    SPDesktop *desktop = ec->desktop;
-
     gint ret = FALSE;
 
     switch (event->type) {
         case GDK_KEY_PRESS:
             switch (get_group0_keyval (&event->key)) {
-                case GDK_Escape:
-                    sp_desktop_selection(desktop)->clear();
-                    ret = TRUE;
-                    break;
-                case GDK_Tab: // Tab - cycle selection forward
-                    if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
-                        sp_selection_item_next();
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_ISO_Left_Tab: // Shift Tab - cycle selection backward
-                    if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
-                        sp_selection_item_prev();
-                        ret = TRUE;
-                    }
-                    break;
                 case GDK_Up:
                 case GDK_Down:
                 case GDK_KP_Up:
@@ -301,14 +282,14 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection *sel)
         SPCurve *norm = sp_shape_get_curve(SP_SHAPE(item));
         sp_curve_transform(norm, sp_item_i2d_affine(dc->white_item));
         g_return_if_fail( norm != NULL );
-        dc->white_curves = sp_curve_split(norm);
+        dc->white_curves = g_slist_reverse(sp_curve_split(norm));
         sp_curve_unref(norm);
         /* Anchor list */
         for (GSList *l = dc->white_curves; l != NULL; l = l->next) {
             SPCurve *c;
             c = (SPCurve*)l->data;
             g_return_if_fail( c->end > 1 );
-            if ( c->bpath->code == NR_MOVETO_OPEN ) {
+            if ( SP_CURVE_BPATH(c)->code == NR_MOVETO_OPEN ) {
                 NArtBpath *s, *e;
                 SPDrawAnchor *a;
                 s = sp_curve_first_bpath(c);
@@ -373,7 +354,7 @@ 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::SNAP_POINT | Inkscape::Snapper::BBOX_POINT,
+        p = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE,
                               p, Inkscape::Snapper::ConstraintLine(best), NULL).getPoint();
     }
 }
@@ -386,9 +367,8 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guin
         return;
     }
 
-    /* FIXME: this should be doing bbox snap as well */
     SnapManager const &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
-    p = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, p, NULL).getPoint();
+    p = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p, NULL).getPoint();
 }
 
 static SPCurve *
@@ -530,6 +510,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
 
     SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
     SPDocument *doc = sp_desktop_document(desktop);
+    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
 
     if ( c && !sp_curve_empty(c) ) {
         /* We actually have something to write */
@@ -538,7 +519,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
         if (dc->white_item) {
             repr = SP_OBJECT_REPR(dc->white_item);
         } else {
-            repr = sp_repr_new("svg:path");
+            repr = xml_doc->createElement("svg:path");
             /* Set style */
             sp_desktop_apply_style_tool(desktop, repr, tool_name(dc), false);
         }
@@ -557,7 +538,8 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
             item->updateRepr();
         }
 
-        sp_document_done(doc);
+        sp_document_done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, 
+                         _("Draw path"));
     }
 
     sp_curve_unref(c);