diff --git a/src/node-context.cpp b/src/node-context.cpp
index 1e01b1af9ac59e00602c3087623db0455cd4e89e..439848d5222c6604ad428e0bb3bf8f3daa21b400 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
node_context->rightalt = FALSE;
node_context->leftctrl = FALSE;
node_context->rightctrl = FALSE;
-
+
new (&node_context->sel_changed_connection) sigc::connection();
}
((SPEventContextClass *) parent_class)->setup(ec);
nc->sel_changed_connection.disconnect();
- nc->sel_changed_connection = SP_DT_SELECTION(ec->desktop)->connectChanged(sigc::bind(sigc::ptr_fun(&sp_node_context_selection_changed), (gpointer)nc));
+ nc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(sigc::bind(sigc::ptr_fun(&sp_node_context_selection_changed), (gpointer)nc));
- Inkscape::Selection *selection = SP_DT_SELECTION(ec->desktop);
+ Inkscape::Selection *selection = sp_desktop_selection(ec->desktop);
SPItem *item = selection->singleItem();
nc->nodepath = NULL;
nc->added_node = false;
+ nc->current_state = SP_NODE_CONTEXT_INACTIVE;
+
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 +243,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;
}
ec->shape_knot_holder = NULL;
}
- Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
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 +373,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<Path::cut_position> 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;
@@ -405,7 +408,7 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
gint ret = FALSE;
SPDesktop *desktop = event_context->desktop;
- Inkscape::Selection *selection = SP_DT_SELECTION (desktop);
+ Inkscape::Selection *selection = sp_desktop_selection (desktop);
SPNodeContext *nc = SP_NODE_CONTEXT(event_context);
@@ -445,6 +448,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 +461,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;
sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
{
SPDesktop *desktop = event_context->desktop;
- Inkscape::Selection *selection = SP_DT_SELECTION (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->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;
}
break;
&& ( 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 {
- 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 {
NR::Maybe<NR::Rect> 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);
if (nc->nodepath && nc->nodepath->selected)
sp_nodepath_deselect(nc->nodepath);
else
- SP_DT_SELECTION(desktop)->clear();
+ sp_desktop_selection(desktop)->clear();
}
}
ret = TRUE;
Inkscape::Rubberband::get()->stop();
+ desktop->updateNow();
nc->rb_escaped = false;
nc->drag = FALSE;
nc->hit = false;
+ nc->current_state = SP_NODE_CONTEXT_INACTIVE;
break;
}
break;
case GDK_Delete:
case GDK_KP_Delete:
case GDK_BackSpace:
- // with any modifiers
- sp_node_selected_delete();
+ if (MOD__CTRL_ONLY) {
+ sp_node_selected_delete();
+ } else {
+ if (nc->nodepath && nc->nodepath->selected) {
+ sp_node_delete_preserve(g_list_copy(nc->nodepath->selected));
+ }
+ }
ret = TRUE;
break;
case GDK_C:
ret = TRUE;
}
break;
- case GDK_Tab: // Tab - cycle selection forward
- if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
- sp_nodepath_select_next(nc->nodepath);
- ret = TRUE;
- }
- break;
- case GDK_ISO_Left_Tab: // Shift Tab - cycle selection backward
- if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
- sp_nodepath_select_prev(nc->nodepath);
- ret = TRUE;
- }
- break;
case GDK_Escape:
{
NR::Maybe<NR::Rect> 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) {
sp_nodepath_deselect(nc->nodepath);
} else {
- SP_DT_SELECTION(desktop)->clear();
+ sp_desktop_selection(desktop)->clear();
}
}
ret = TRUE;