X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnode-context.cpp;h=6ad2254ce4e5f3a950d6b2452a9ed448186fca74;hb=ac248d5f76a334cd01269ef995c00dba1ba28ed8;hp=67511ea30e83c3e0a4f4445e3c9da1fdc5084608;hpb=a331544754adf287970dc26ff3571f992a0d5227;p=inkscape.git diff --git a/src/node-context.cpp b/src/node-context.cpp index 67511ea30..6ad2254ce 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -26,9 +26,11 @@ #include "desktop-handles.h" #include "selection.h" #include "pixmaps/cursor-node.xpm" +#include "pixmaps/cursor-node.pixbuf" #include "message-context.h" #include "node-context.h" #include "pixmaps/cursor-node-d.xpm" +#include "pixmaps/cursor-node-d.pixbuf" #include "prefs-utils.h" #include "xml/node-event-vector.h" #include "style.h" @@ -98,6 +100,11 @@ sp_node_context_init(SPNodeContext *node_context) SPEventContext *event_context = SP_EVENT_CONTEXT(node_context); event_context->cursor_shape = cursor_node_xpm; + event_context->cursor_pixbuf = gdk_pixbuf_new_from_inline( + -1, + cursor_node_pixbuf, + FALSE, + NULL); event_context->hot_x = 1; event_context->hot_y = 1; @@ -174,7 +181,7 @@ sp_node_context_setup(SPEventContext *ec) nc->added_node = false; if (item) { - nc->nodepath = sp_nodepath_new(ec->desktop, item); + nc->nodepath = sp_nodepath_new(ec->desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0)); if ( nc->nodepath) { //point pack to parent in case nodepath is deleted nc->nodepath->nodeContext = nc; @@ -241,7 +248,7 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data) nc->nodepath = NULL; ec->shape_knot_holder = NULL; if (item) { - nc->nodepath = sp_nodepath_new(desktop, item); + nc->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0)); if (nc->nodepath) { nc->nodepath->nodeContext = nc; } @@ -292,7 +299,7 @@ sp_nodepath_update_from_item(SPNodeContext *nc, SPItem *item) item = selection->singleItem(); if (item) { - nc->nodepath = sp_nodepath_new(desktop, item); + nc->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0)); if (nc->nodepath) { nc->nodepath->nodeContext = nc; } @@ -371,6 +378,7 @@ sp_node_context_is_over_stroke (SPNodeContext *nc, SPItem *item, NR::Point event nc->curvepoint_doc *= sp_item_dt2i_affine(item); nc->curvepoint_doc *= sp_item_i2doc_affine(item); + sp_nodepath_ensure_livarot_path(nc->nodepath); NR::Maybe position = get_nearest_position_on_Path(nc->nodepath->livarot_path, nc->curvepoint_doc); NR::Point nearest = get_point_on_Path(nc->nodepath->livarot_path, position.assume().piece, position.assume().t); NR::Point delta = nearest - nc->curvepoint_doc; @@ -445,6 +453,7 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve } else { sp_nodepath_select_segment_near_point(nc->nodepath, nc->curvepoint_doc, false); } + desktop->updateNow(); } break; case GDK_2BUTTON_PRESS: @@ -457,8 +466,10 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve } } else if (event->button.state & GDK_SHIFT_MASK) { selection->toggle(item_clicked); + desktop->updateNow(); } else { selection->set(item_clicked); + desktop->updateNow(); } ret = TRUE; @@ -517,6 +528,11 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) SPDesktop *desktop = event_context->desktop; Inkscape::Selection *selection = sp_desktop_selection (desktop); + // fixme: nc->nodepath can potentially become NULL after retrieving nc. + // A general method for handling this possibility should be created. + // For now, the number of checks for a NULL nc->nodepath have been + // increased, both here and in the called sp_nodepath_* functions. + SPNodeContext *nc = SP_NODE_CONTEXT(event_context); double const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); // read every time, to make prefs changes really live @@ -538,6 +554,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) event->button.y); NR::Point const button_dt(desktop->w2d(button_w)); Inkscape::Rubberband::get()->start(desktop, button_dt); + desktop->updateNow(); ret = TRUE; } break; @@ -549,6 +566,13 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) { break; // do not drag if we're within tolerance from origin } + + // The path went away while dragging; throw away any further motion + // events until the mouse pointer is released. + if (nc->hit && (nc->nodepath == NULL)) { + break; + } + // Once the user has moved farther than tolerance from the original location // (indicating they intend to move the object, not click), then always process the // motion notify coordinates as given (no snapping back to origin) @@ -584,12 +608,22 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (nc->cursor_drag && !over_stroke) { event_context->cursor_shape = cursor_node_xpm; + event_context->cursor_pixbuf = gdk_pixbuf_new_from_inline( + -1, + cursor_node_pixbuf, + FALSE, + NULL); event_context->hot_x = 1; event_context->hot_y = 1; sp_event_context_update_cursor(event_context); nc->cursor_drag = false; } else if (!nc->cursor_drag && over_stroke) { event_context->cursor_shape = cursor_node_d_xpm; + event_context->cursor_pixbuf = gdk_pixbuf_new_from_inline( + -1, + cursor_node_d_pixbuf, + FALSE, + NULL); event_context->hot_x = 1; event_context->hot_y = 1; sp_event_context_update_cursor(event_context); @@ -604,7 +638,9 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) NR::Maybe b = Inkscape::Rubberband::get()->getRectangle(); if (nc->hit && !event_context->within_tolerance) { //drag curve - sp_nodepath_update_repr (nc->nodepath); + if (nc->nodepath) { + sp_nodepath_update_repr (nc->nodepath, _("Drag curve")); + } } else if (b != NR::Nothing() && !event_context->within_tolerance) { // drag to select if (nc->nodepath) { sp_nodepath_select_rect(nc->nodepath, b.assume(), event->button.state & GDK_SHIFT_MASK); @@ -619,6 +655,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) } ret = TRUE; Inkscape::Rubberband::get()->stop(); + desktop->updateNow(); nc->rb_escaped = false; nc->drag = FALSE; nc->hit = false;