]> git.tokkee.org Git - inkscape.git/commitdiff

Code

robustize remembering the dragged segment - store node number, not pointer; fixes...
authorbuliabyak <buliabyak@users.sourceforge.net>
Fri, 5 Jan 2007 13:46:30 +0000 (13:46 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Fri, 5 Jan 2007 13:46:30 +0000 (13:46 +0000)
src/node-context.cpp
src/node-context.h
src/nodepath.cpp
src/nodepath.h

index 2b30d067b66449620c84e5ba5baaaf83e0c8f410..a4a51f676a6636f55596882cfbb356ef803dd37c 100644 (file)
@@ -134,6 +134,7 @@ sp_node_context_dispose(GObject *object)
     }
 
     if (nc->nodepath) {
+        nc->grab_node = -1;
         sp_nodepath_destroy(nc->nodepath);
         nc->nodepath = NULL;
     }
@@ -164,6 +165,7 @@ sp_node_context_setup(SPEventContext *ec)
     Inkscape::Selection *selection = sp_desktop_selection(ec->desktop);
     SPItem *item = selection->singleItem();
 
+    nc->grab_node = -1;
     nc->nodepath = NULL;
     ec->shape_knot_holder = NULL;
 
@@ -223,6 +225,7 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data)
 
     if (nc->nodepath) {
         old_repr = nc->nodepath->repr;
+        nc->grab_node = -1;
         sp_nodepath_destroy(nc->nodepath);
         nc->nodepath = NULL;
     }
@@ -240,6 +243,7 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data)
     SPItem *item = selection->singleItem();
 
     SPDesktop *desktop = selection->desktop();
+    nc->grab_node = -1;
     nc->nodepath = NULL;
     ec->shape_knot_holder = NULL;
     if (item) {
@@ -281,6 +285,7 @@ sp_nodepath_update_from_item(SPNodeContext *nc, SPItem *item)
     g_assert(desktop);
 
     if (nc->nodepath) {
+        nc->grab_node = -1;
         sp_nodepath_destroy(nc->nodepath);
         nc->nodepath = NULL;
     }
@@ -395,7 +400,7 @@ sp_node_context_is_over_stroke (SPNodeContext *nc, SPItem *item, NR::Point event
         nc->curvepoint_event[NR::Y] = (gint) event_p [NR::Y];
         nc->hit = true;
         nc->grab_t = position.assume().t;
-        nc->grab_node = sp_nodepath_get_node_by_index(position.assume().piece);
+        nc->grab_node = position.assume().piece;
     }
 
     return close;
@@ -588,6 +593,9 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 switch (nc->current_state) {
                     case SP_NODE_CONTEXT_NODE_DRAGGING:
                         {
+                            if (nc->grab_node == -1) // don't know which segment to drag
+                                break;
+
                             // We round off the extra precision in the motion coordinates provided
                             // by some input devices (like tablets). As we'll store the coordinates
                             // as integers in curvepoint_event we need to do this rounding before
index d5067a66a751dbbdeddff6448ef34ec97682f20a..fae95cf433ee33a133c213eadcc87f53757911be 100644 (file)
@@ -51,7 +51,7 @@ struct SPNodeContext {
        Inkscape::MessageContext *_node_message_context;
 
        double grab_t;
-       Inkscape::NodePath::Node * grab_node;
+       int grab_node; // number of node grabbed by sp_node_context_is_over_stroke
        bool hit;
        NR::Point curvepoint_event; // int coords from event
        NR::Point curvepoint_doc; // same, in doc coords
index e58a8b31da3056c9494ff62163559b3d6bc2f186..8371c8241825d00a153c1305b2de858b44c75a0a 100644 (file)
@@ -1608,8 +1608,10 @@ sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p)
  * cf. app/vectors/gimpbezierstroke.c, gimp_bezier_stroke_point_move_relative()
  */
 void
-sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta)
+sp_nodepath_curve_drag(int node, double t, NR::Point delta)
 {
+    Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(node);
+
     //fixme: e and e->p can be NULL, so check for those before proceeding
     g_return_if_fail(e != NULL);
     g_return_if_fail(&e->p != NULL);
index 0216af730952a00c19527a35e89ffdacda4acf07..b675863d50d24d9903c0978fd454b8f23d44e3ab 100644 (file)
@@ -263,7 +263,7 @@ void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, NR::Dim2 axi
 void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis);
 void sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p, bool toggle);
 void sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p);
-void sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta);
+void sp_nodepath_curve_drag(int node, double t, NR::Point delta);
 Inkscape::NodePath::Node * sp_nodepath_get_node_by_index(int index);
 /* possibly private functions */