diff --git a/src/node-context.cpp b/src/node-context.cpp
index 747fa65b3eb86155a32f7eeaf245e380ff3db604..ccdb6c79eec6331054034b16ba94c9774e16dd26 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
static SPEventContextClass *parent_class;
-static gchar *undo_label_1 = "dragcurve:1";
-static gchar *undo_label_2 = "dragcurve:2";
-static gchar *undo_label = undo_label_1;
-
GType
sp_node_context_get_type()
{
if (ec->shape_knot_holder)
repr = ec->shape_knot_holder->repr;
else
- repr = SP_OBJECT_REPR(item);
+ repr = SP_OBJECT_REPR(item);
if (repr) {
Inkscape::GC::anchor(repr);
sp_repr_add_listener(repr, &nodepath_repr_events, ec);
- sp_repr_synthesize_events(repr, &nodepath_repr_events, ec);
}
}
}
@@ -227,7 +222,9 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data)
if (nc->nodepath) {
old_repr = nc->nodepath->repr;
sp_nodepath_destroy(nc->nodepath);
+ nc->nodepath = NULL;
}
+
if (ec->shape_knot_holder) {
old_repr = ec->shape_knot_holder->repr;
sp_knot_holder_destroy(ec->shape_knot_holder);
@@ -256,11 +253,10 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data)
if (ec->shape_knot_holder)
repr = ec->shape_knot_holder->repr;
else
- repr = SP_OBJECT_REPR(item);
+ repr = SP_OBJECT_REPR(item);
if (repr) {
Inkscape::GC::anchor(repr);
sp_repr_add_listener(repr, &nodepath_repr_events, ec);
- sp_repr_synthesize_events(repr, &nodepath_repr_events, ec);
}
}
}
if (nc->nodepath) {
sp_nodepath_destroy(nc->nodepath);
+ nc->nodepath = NULL;
}
if (ec->shape_knot_holder) {
sp_knot_holder_destroy(ec->shape_knot_holder);
+ ec->shape_knot_holder = NULL;
}
Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
item = selection->singleItem();
- nc->nodepath = NULL;
- ec->shape_knot_holder = NULL;
if (item) {
nc->nodepath = sp_nodepath_new(desktop, item);
if (nc->nodepath) {
@@ -369,8 +365,8 @@ sp_node_context_show_modifier_tip(SPEventContext *event_context, GdkEvent *event
_("<b>Alt</b>: lock handle length; <b>Ctrl+Alt</b>: move along handles"));
}
-bool
-sp_node_context_is_over_stroke (SPNodeContext *nc, SPItem *item, NR::Point event_p, bool remember)
+bool
+sp_node_context_is_over_stroke (SPNodeContext *nc, SPItem *item, NR::Point event_p, bool remember)
{
SPDesktop *desktop = SP_EVENT_CONTEXT (nc)->desktop;
@@ -379,17 +375,17 @@ 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);
- NR::Maybe<Path::cut_position> position = get_nearest_position_on_Path(item, nc->curvepoint_doc);
- NR::Point nearest = get_point_on_Path(item, position.assume().piece, position.assume().t);
+ 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;
delta = desktop->d2w(delta);
- double stroke_tolerance =
- (SP_OBJECT_STYLE (item)->stroke.type != SP_PAINT_TYPE_NONE?
- desktop->current_zoom() *
- SP_OBJECT_STYLE (item)->stroke_width.computed *
- sp_item_i2d_affine (item).expansion() * 0.5
+ double stroke_tolerance =
+ (SP_OBJECT_STYLE (item)->stroke.type != SP_PAINT_TYPE_NONE?
+ desktop->current_zoom() *
+ SP_OBJECT_STYLE (item)->stroke_width.computed *
+ sp_item_i2d_affine (item).expansion() * 0.5
: 0.0)
+ (double) SP_EVENT_CONTEXT(nc)->tolerance;
@@ -424,12 +420,13 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
if (!nc->drag) {
// find out clicked item, disregarding groups, honoring Alt
- SPItem *item_clicked = sp_event_context_find_item (desktop,
+ SPItem *item_clicked = sp_event_context_find_item (desktop,
NR::Point(event->button.x, event->button.y),
(event->button.state & GDK_MOD1_MASK) && !(event->button.state & GDK_CONTROL_MASK), TRUE);
// find out if we're over the selected item, disregarding groups
- SPItem *item_over = sp_event_context_over_item (desktop, selection->singleItem(),
+ SPItem *item_over = sp_event_context_over_item (desktop, selection->singleItem(),
NR::Point(event->button.x, event->button.y));
+
bool over_stroke = false;
if (item_over && nc->nodepath) {
over_stroke = sp_node_context_is_over_stroke (nc, item_over, NR::Point(event->button.x, event->button.y), false);
@@ -440,7 +437,7 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
case GDK_BUTTON_RELEASE:
if (event->button.state & GDK_CONTROL_MASK && event->button.state & GDK_MOD1_MASK) {
//add a node
- sp_nodepath_add_node_near_point(item_over, nc->curvepoint_doc);
+ sp_nodepath_add_node_near_point(nc->nodepath, nc->curvepoint_doc);
} else {
if (nc->added_node) { // we just received double click, ignore release
nc->added_node = false;
@@ -448,20 +445,20 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
}
//select the segment
if (event->button.state & GDK_SHIFT_MASK) {
- sp_nodepath_select_segment_near_point(item_over, nc->curvepoint_doc, true);
+ sp_nodepath_select_segment_near_point(nc->nodepath, nc->curvepoint_doc, true);
} else {
- sp_nodepath_select_segment_near_point(item_over, nc->curvepoint_doc, false);
+ sp_nodepath_select_segment_near_point(nc->nodepath, nc->curvepoint_doc, false);
}
}
- break;
+ break;
case GDK_2BUTTON_PRESS:
//add a node
- sp_nodepath_add_node_near_point(item_over, nc->curvepoint_doc);
+ sp_nodepath_add_node_near_point(nc->nodepath, nc->curvepoint_doc);
nc->added_node = true;
break;
default:
break;
- }
+ }
} else if (event->button.state & GDK_SHIFT_MASK) {
selection->toggle(item_clicked);
} else {
@@ -483,7 +480,7 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
if (!nc->drag) {
// find out if we're over the selected item, disregarding groups
- SPItem *item_over = sp_event_context_over_item (desktop, selection->singleItem(),
+ SPItem *item_over = sp_event_context_over_item (desktop, selection->singleItem(),
NR::Point(event->button.x, event->button.y));
if (nc->nodepath && selection->single() && item_over) {
@@ -492,7 +489,7 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
bool over_stroke = sp_node_context_is_over_stroke (nc, item_over, NR::Point(event->button.x, event->button.y), true);
//only dragging curves
if (over_stroke) {
- sp_nodepath_select_segment_near_point(item_over, nc->curvepoint_doc, false);
+ sp_nodepath_select_segment_near_point(nc->nodepath, nc->curvepoint_doc, false);
ret = TRUE;
} else {
break;
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, undo_label);
- nc->curvepoint_event[NR::X] = (gint) event->motion.x;
+ 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 {
break;
}
- SPItem *item_over = sp_event_context_over_item (desktop, selection->singleItem(),
+ SPItem *item_over = sp_event_context_over_item (desktop, selection->singleItem(),
NR::Point(event->motion.x, event->motion.y));
bool over_stroke = false;
if (item_over && nc->nodepath) {
if (event->button.button == 1) {
NR::Maybe<NR::Rect> b = Inkscape::Rubberband::get()->getRectangle();
-
+
if (nc->hit && !event_context->within_tolerance) { //drag curve
- if (undo_label == undo_label_1)
- undo_label = undo_label_2;
- else
- undo_label = undo_label_1;
+ sp_nodepath_update_repr (nc->nodepath);
} 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);