From: johncoswell Date: Sun, 5 Nov 2006 18:41:15 +0000 (+0000) Subject: When canvas cannot update quickly, ensure that nodes being dragged will stay selected. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8d4b1581c73e19144848d97cba638611108efe66;p=inkscape.git When canvas cannot update quickly, ensure that nodes being dragged will stay selected. --- diff --git a/src/node-context.cpp b/src/node-context.cpp index 774e0813e..e6ea78c62 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -105,7 +105,7 @@ sp_node_context_init(SPNodeContext *node_context) node_context->rightalt = FALSE; node_context->leftctrl = FALSE; node_context->rightctrl = FALSE; - + new (&node_context->sel_changed_connection) sigc::connection(); } @@ -173,6 +173,8 @@ sp_node_context_setup(SPEventContext *ec) nc->added_node = false; + nc->current_state = SP_NODE_CONTEXT_INACTIVE; + if (item) { nc->nodepath = sp_nodepath_new(ec->desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0)); if ( nc->nodepath) { @@ -547,6 +549,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); + nc->current_state = SP_NODE_CONTEXT_INACTIVE; desktop->updateNow(); ret = TRUE; } @@ -559,34 +562,51 @@ 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) event_context->within_tolerance = false; - if (nc->nodepath && nc->hit) { - NR::Point const delta_w(event->motion.x - nc->curvepoint_event[NR::X], - event->motion.y - nc->curvepoint_event[NR::Y]); - NR::Point const delta_dt(desktop->w2d(delta_w)); - sp_nodepath_curve_drag (nc->grab_node, nc->grab_t, delta_dt); - nc->curvepoint_event[NR::X] = (gint) event->motion.x; - nc->curvepoint_event[NR::Y] = (gint) event->motion.y; - gobble_motion_events(GDK_BUTTON1_MASK); - } else { - if (Inkscape::Rubberband::get()->is_started()) { - NR::Point const motion_w(event->motion.x, - event->motion.y); - NR::Point const motion_dt(desktop->w2d(motion_w)); - Inkscape::Rubberband::get()->move(motion_dt); + // Once we determine what the user is doing (dragging either a node or the + // selection rubberband), make sure we continue to perform that operation + // until the mouse pointer is lifted. + if (nc->current_state == SP_NODE_CONTEXT_INACTIVE) { + if (nc->nodepath && nc->hit) { + nc->current_state = SP_NODE_CONTEXT_NODE_DRAGGING; + } else { + nc->current_state = SP_NODE_CONTEXT_RUBBERBAND_DRAGGING; } } + + switch (nc->current_state) { + case SP_NODE_CONTEXT_NODE_DRAGGING: + { + NR::Point const delta_w(event->motion.x - nc->curvepoint_event[NR::X], + event->motion.y - nc->curvepoint_event[NR::Y]); + NR::Point const delta_dt(desktop->w2d(delta_w)); + sp_nodepath_curve_drag (nc->grab_node, nc->grab_t, delta_dt); + nc->curvepoint_event[NR::X] = (gint) event->motion.x; + nc->curvepoint_event[NR::Y] = (gint) event->motion.y; + gobble_motion_events(GDK_BUTTON1_MASK); + break; + } + case SP_NODE_CONTEXT_RUBBERBAND_DRAGGING: + if (Inkscape::Rubberband::get()->is_started()) { + NR::Point const motion_w(event->motion.x, + event->motion.y); + NR::Point const motion_dt(desktop->w2d(motion_w)); + Inkscape::Rubberband::get()->move(motion_dt); + } + break; + } + nc->drag = TRUE; ret = TRUE; } else { @@ -644,6 +664,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) nc->rb_escaped = false; nc->drag = FALSE; nc->hit = false; + nc->current_state = SP_NODE_CONTEXT_INACTIVE; break; } break; @@ -808,6 +829,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) NR::Maybe const b = Inkscape::Rubberband::get()->getRectangle(); if (b != NR::Nothing()) { Inkscape::Rubberband::get()->stop(); + nc->current_state = SP_NODE_CONTEXT_INACTIVE; nc->rb_escaped = true; } else { if (nc->nodepath && nc->nodepath->selected) { diff --git a/src/node-context.h b/src/node-context.h index a9b4beb07..d5067a66a 100644 --- a/src/node-context.h +++ b/src/node-context.h @@ -24,6 +24,10 @@ namespace Inkscape { class Selection; } #define SP_IS_NODE_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_NODE_CONTEXT)) #define SP_IS_NODE_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_NODE_CONTEXT)) +enum { SP_NODE_CONTEXT_INACTIVE, + SP_NODE_CONTEXT_NODE_DRAGGING, + SP_NODE_CONTEXT_RUBBERBAND_DRAGGING }; + class SPNodeContext; class SPNodeContextClass; @@ -54,6 +58,8 @@ struct SPNodeContext { bool cursor_drag; bool added_node; + + unsigned int current_state; }; struct SPNodeContextClass {