X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fpen-context.cpp;h=3267912752bb8378c1b0895e6f8d40173d8103a9;hb=f0e5ef1c60ad148623253dc3cc5d53014724094a;hp=6344cff2877f3dd56c561350dee0a922ff12364b;hpb=f951374eef04129c6a0d213e7ab4d9ed2095ca69;p=inkscape.git diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 6344cff28..326791275 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -48,6 +48,7 @@ static void sp_pen_context_setup(SPEventContext *ec); static void sp_pen_context_finish(SPEventContext *ec); static void sp_pen_context_set(SPEventContext *ec, gchar const *key, gchar const *val); static gint sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event); +static gint sp_pen_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); static void spdc_pen_set_initial_point(SPPenContext *pc, NR::Point const p); static void spdc_pen_set_subsequent_point(SPPenContext *pc, NR::Point const p, bool statusbar); @@ -59,10 +60,12 @@ static void spdc_pen_finish(SPPenContext *pc, gboolean closed); static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const &bevent); static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent); static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent); -static gint pen_handle_2button_press(SPPenContext *const pc); +static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent); static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event); static void spdc_reset_colors(SPPenContext *pc); +static void pen_disable_events(SPPenContext *const pc); +static void pen_enable_events(SPPenContext *const pc); static NR::Point pen_drag_origin_w(0, 0); static bool pen_within_tolerance = false; @@ -112,6 +115,7 @@ sp_pen_context_class_init(SPPenContextClass *klass) event_context_class->finish = sp_pen_context_finish; event_context_class->set = sp_pen_context_set; event_context_class->root_handler = sp_pen_context_root_handler; + event_context_class->item_handler = sp_pen_context_item_handler; } /** @@ -135,6 +139,8 @@ sp_pen_context_init(SPPenContext *pc) pc->c1 = NULL; pc->cl0 = NULL; pc->cl1 = NULL; + + pc->events_disabled = 0; } /** @@ -182,13 +188,13 @@ sp_pen_context_setup(SPEventContext *ec) } /* Pen indicators */ - pc->c0 = sp_canvas_item_new(SP_DT_CONTROLS(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRL, "shape", SP_CTRL_SHAPE_CIRCLE, + pc->c0 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRL, "shape", SP_CTRL_SHAPE_CIRCLE, "size", 4.0, "filled", 0, "fill_color", 0xff00007f, "stroked", 1, "stroke_color", 0x0000ff7f, NULL); - pc->c1 = sp_canvas_item_new(SP_DT_CONTROLS(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRL, "shape", SP_CTRL_SHAPE_CIRCLE, + pc->c1 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRL, "shape", SP_CTRL_SHAPE_CIRCLE, "size", 4.0, "filled", 0, "fill_color", 0xff00007f, "stroked", 1, "stroke_color", 0x0000ff7f, NULL); - pc->cl0 = sp_canvas_item_new(SP_DT_CONTROLS(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL); + pc->cl0 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL); sp_ctrlline_set_rgba32(SP_CTRLLINE(pc->cl0), 0x0000007f); - pc->cl1 = sp_canvas_item_new(SP_DT_CONTROLS(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL); + pc->cl1 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL); sp_ctrlline_set_rgba32(SP_CTRLLINE(pc->cl1), 0x0000007f); sp_canvas_item_hide(pc->c0); @@ -205,13 +211,32 @@ sp_pen_context_setup(SPEventContext *ec) } } +static void +pen_cancel (SPPenContext *const pc) +{ + pc->state = SP_PEN_CONTEXT_STOP; + spdc_reset_colors(pc); + sp_canvas_item_hide(pc->c0); + sp_canvas_item_hide(pc->c1); + sp_canvas_item_hide(pc->cl0); + sp_canvas_item_hide(pc->cl1); + pc->_message_context->clear(); + pc->_message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled")); + + sp_canvas_end_forced_full_redraws(pc->desktop->canvas); +} + /** * Finalization callback. */ static void sp_pen_context_finish(SPEventContext *ec) { - spdc_pen_finish(SP_PEN_CONTEXT(ec), FALSE); + SPPenContext *pc = SP_PEN_CONTEXT(ec); + + if (pc->npoints != 0) { + pen_cancel (pc); + } if (((SPEventContextClass *) pen_parent_class)->finish) { ((SPEventContextClass *) pen_parent_class)->finish(ec); @@ -261,6 +286,29 @@ spdc_endpoint_snap_handle(SPPenContext const *const pc, NR::Point &p, guint cons spdc_endpoint_snap_free(pc, p, state); } +static gint +sp_pen_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event) +{ + SPPenContext *const pc = SP_PEN_CONTEXT(ec); + + gint ret = FALSE; + + switch (event->type) { + case GDK_BUTTON_PRESS: + ret = pen_handle_button_press(pc, event->button); + break; + default: + break; + } + + if (!ret) { + if (((SPEventContextClass *) pen_parent_class)->item_handler) + ret = ((SPEventContextClass *) pen_parent_class)->item_handler(ec, item, event); + } + + return ret; +} + /** * Callback to handle all pen events. */ @@ -285,7 +333,7 @@ sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event) break; case GDK_2BUTTON_PRESS: - ret = pen_handle_2button_press(pc); + ret = pen_handle_2button_press(pc, event->button); break; case GDK_KEY_PRESS: @@ -312,24 +360,30 @@ sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event) */ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const &bevent) { - gint ret = FALSE; - if (bevent.button == 1) { + if (pc->events_disabled) { + // skip event processing if events are disabled + return FALSE; + } + + SPDrawContext * const dc = SP_DRAW_CONTEXT(pc); + SPDesktop * const desktop = SP_EVENT_CONTEXT_DESKTOP(dc); + NR::Point const event_w(bevent.x, bevent.y); + NR::Point const event_dt(desktop->w2d(event_w)); + SPEventContext *event_context = SP_EVENT_CONTEXT(pc); - SPDrawContext * const dc = SP_DRAW_CONTEXT(pc); - SPDesktop * const desktop = SP_EVENT_CONTEXT_DESKTOP(dc); + gint ret = FALSE; + if (bevent.button == 1 && !event_context->space_panning) { if (Inkscape::have_viable_layer(desktop, dc->_message_context) == false) { return TRUE; } - NR::Point const event_w(bevent.x, bevent.y); pen_drag_origin_w = event_w; pen_within_tolerance = true; /* Test whether we hit any anchor. */ SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); - NR::Point const event_dt(desktop->w2d(event_w)); switch (pc->mode) { case SP_PEN_CONTEXT_MODE_CLICK: /* In click mode we add point on release */ @@ -367,7 +421,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const // This is the first click of a new curve; deselect item so that // this curve is not combined with it (unless it is drawn from its // anchor, which is handled by the sibling branch above) - Inkscape::Selection * const selection = SP_DT_SELECTION(desktop); + Inkscape::Selection * const selection = sp_desktop_selection(desktop); if (!(bevent.state & GDK_SHIFT_MASK)) { selection->clear(); @@ -430,7 +484,16 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const } } else if (bevent.button == 3) { if (pc->npoints != 0) { - spdc_pen_finish(pc, FALSE); + + spdc_pen_finish_segment(pc, event_dt, bevent.state); + if (pc->green_closed) { + // finishing at the start anchor, close curve + spdc_pen_finish(pc, TRUE); + } else { + // finishing at some other anchor, finish curve but not close + spdc_pen_finish(pc, FALSE); + } + ret = TRUE; } } @@ -446,8 +509,15 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) { gint ret = FALSE; - if (mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) { - // allow middle-button scrolling + SPEventContext *event_context = SP_EVENT_CONTEXT(pc); + + if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) { + // allow scrolling + return FALSE; + } + + if (pc->events_disabled) { + // skip motion events if pen events are disabled return FALSE; } @@ -545,6 +615,7 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) spdc_endpoint_snap_handle(pc, p, mevent.state); spdc_pen_set_ctrl(pc, p, mevent.state); + gobble_motion_events(GDK_BUTTON1_MASK); ret = TRUE; break; case SP_PEN_CONTEXT_STOP: @@ -566,8 +637,14 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) { + if (pc->events_disabled) { + // skip event processing if events are disabled + return FALSE; + } + gint ret = FALSE; - if ( revent.button == 1 ) { + SPEventContext *event_context = SP_EVENT_CONTEXT(pc); + if ( revent.button == 1 && !event_context->space_panning) { SPDrawContext *dc = SP_DRAW_CONTEXT (pc); @@ -672,16 +749,67 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) } static gint -pen_handle_2button_press(SPPenContext *const pc) +pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent) { gint ret = FALSE; - if (pc->npoints != 0) { + if (pc->npoints != 0 && bevent.button != 2) { spdc_pen_finish(pc, FALSE); ret = TRUE; } return ret; } +void +pen_redraw_all (SPPenContext *const pc) +{ + // green + if (pc->green_bpaths) { + // remove old piecewise green canvasitems + while (pc->green_bpaths) { + gtk_object_destroy(GTK_OBJECT(pc->green_bpaths->data)); + pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data); + } + // one canvas bpath for all of green_curve + SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), pc->green_curve); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO); + + pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape); + } + + if (pc->green_anchor) + SP_CTRL(pc->green_anchor->ctrl)->moveto(pc->green_anchor->dp); + + sp_curve_reset(pc->red_curve); + sp_curve_moveto(pc->red_curve, pc->p[0]); + sp_curve_curveto(pc->red_curve, pc->p[1], pc->p[2], pc->p[3]); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); + + // handles + if (pc->p[0] != pc->p[1]) { + SP_CTRL(pc->c1)->moveto(pc->p[1]); + sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl1), pc->p[0], pc->p[1]); + sp_canvas_item_show (pc->c1); + sp_canvas_item_show (pc->cl1); + } else { + sp_canvas_item_hide (pc->c1); + sp_canvas_item_hide (pc->cl1); + } + + NArtBpath *const bpath = sp_curve_last_bpath(pc->green_curve); + if (bpath) { + if (bpath->code == NR_CURVETO && NR::Point(bpath->x2, bpath->y2) != pc->p[0]) { + SP_CTRL(pc->c0)->moveto(NR::Point(bpath->x2, bpath->y2)); + sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl0), NR::Point(bpath->x2, bpath->y2), pc->p[0]); + sp_canvas_item_show (pc->c0); + sp_canvas_item_show (pc->cl0); + } else { + sp_canvas_item_hide (pc->c0); + sp_canvas_item_hide (pc->cl0); + } + } +} + void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y) { @@ -697,44 +825,17 @@ pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y) } bpath->x3 += x; bpath->y3 += y; - if (pc->green_bpaths && pc->green_bpaths->data) { - // remove old piecewise green canvasitems - while (pc->green_bpaths) { - gtk_object_destroy(GTK_OBJECT(pc->green_bpaths->data)); - pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data); - } - // one canvas bpath for all of green_curve - SPCanvasItem *cshape = sp_canvas_bpath_new(SP_DT_SKETCH(pc->desktop), pc->green_curve); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO); - - pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape); - } } else { // start anchor too if (pc->green_anchor) { pc->green_anchor->dp += NR::Point(x, y); - SP_CTRL(pc->green_anchor->ctrl)->moveto(pc->green_anchor->dp); } } // red pc->p[0] += NR::Point(x, y); pc->p[1] += NR::Point(x, y); - sp_curve_reset(pc->red_curve); - sp_curve_moveto(pc->red_curve, pc->p[0]); - sp_curve_curveto(pc->red_curve, pc->p[1], pc->p[2], pc->p[3]); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); - - // handles - if (pc->p[0] != pc->p[1]) { - SP_CTRL(pc->c1)->moveto(pc->p[1]); - sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl1), pc->p[0], pc->p[1]); - } - if (bpath && bpath->code == NR_CURVETO && NR::Point(bpath->x2, bpath->y2) != pc->p[0]) { - SP_CTRL(pc->c0)->moveto(NR::Point(bpath->x2, bpath->y2)); - sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl0), NR::Point(bpath->x2, bpath->y2), pc->p[0]); - } + pen_redraw_all(pc); } void @@ -743,6 +844,35 @@ pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y) pen_lastpoint_move (pc, x / pc->desktop->current_zoom(), y / pc->desktop->current_zoom()); } +void +pen_lastpoint_tocurve (SPPenContext *const pc) +{ + if (pc->npoints != 5) + return; + + // red + NArtBpath *const bpath = sp_curve_last_bpath(pc->green_curve); + if (bpath && bpath->code == NR_CURVETO) { + pc->p[1] = pc->p[0] + (NR::Point(bpath->x3, bpath->y3) - NR::Point(bpath->x2, bpath->y2)); + } else { + pc->p[1] = pc->p[0] + (pc->p[3] - pc->p[0])*(1/3); + } + + pen_redraw_all(pc); +} + +void +pen_lastpoint_toline (SPPenContext *const pc) +{ + if (pc->npoints != 5) + return; + + pc->p[1] = pc->p[0]; + + pen_redraw_all(pc); +} + + static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) { @@ -812,6 +942,21 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) } break; + case GDK_U: + case GDK_u: + if (MOD__SHIFT_ONLY) { + pen_lastpoint_tocurve(pc); + ret = TRUE; + } + break; + case GDK_L: + case GDK_l: + if (MOD__SHIFT_ONLY) { + pen_lastpoint_toline(pc); + ret = TRUE; + } + break; + case GDK_Return: case GDK_KP_Enter: if (pc->npoints != 0) { @@ -822,12 +967,7 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) case GDK_Escape: if (pc->npoints != 0) { // if drawing, cancel, otherwise pass it up for deselecting - pc->state = SP_PEN_CONTEXT_STOP; - spdc_reset_colors(pc); - sp_canvas_item_hide(pc->c0); - sp_canvas_item_hide(pc->c1); - sp_canvas_item_hide(pc->cl0); - sp_canvas_item_hide(pc->cl1); + pen_cancel (pc); ret = TRUE; } break; @@ -835,12 +975,7 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) case GDK_Z: if (MOD__CTRL_ONLY && pc->npoints != 0) { // if drawing, cancel, otherwise pass it up for undo - pc->state = SP_PEN_CONTEXT_STOP; - spdc_reset_colors(pc); - sp_canvas_item_hide(pc->c0); - sp_canvas_item_hide(pc->c1); - sp_canvas_item_hide(pc->cl0); - sp_canvas_item_hide(pc->cl1); + pen_cancel (pc); ret = TRUE; } break; @@ -848,13 +983,7 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) case GDK_Delete: case GDK_KP_Delete: if (sp_curve_is_empty(pc->green_curve)) { - /* Same as cancel */ - pc->state = SP_PEN_CONTEXT_STOP; - spdc_reset_colors(pc); - sp_canvas_item_hide(pc->c0); - sp_canvas_item_hide(pc->c1); - sp_canvas_item_hide(pc->cl0); - sp_canvas_item_hide(pc->cl1); + pen_cancel (pc); ret = TRUE; } else { /* Reset red curve */ @@ -873,7 +1002,11 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) break; } pc->p[0] = p[e - 2].c(3); - pc->p[1] = p[e - 1].c(1); + if (p[e - 1].code == NR_CURVETO) { + pc->p[1] = p[e - 1].c(1); + } else { + pc->p[1] = pc->p[0]; + } NR::Point const pt(( pc->npoints < 4 ? p[e - 1].c(3) : pc->p[3] )); @@ -928,6 +1061,8 @@ spdc_pen_set_initial_point(SPPenContext *const pc, NR::Point const p) pc->p[1] = p; pc->npoints = 2; sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL); + + sp_canvas_force_full_redraw_after_interruptions(pc->desktop->canvas, 5); } static void @@ -952,6 +1087,7 @@ spdc_pen_set_subsequent_point(SPPenContext *const pc, NR::Point const p, bool st sp_curve_lineto(pc->red_curve, p); is_curve = false; } + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); if (statusbar) { @@ -962,7 +1098,7 @@ spdc_pen_set_subsequent_point(SPPenContext *const pc, NR::Point const p, bool st double angle = atan2(rel[NR::Y], rel[NR::X]) * 180 / M_PI; if (prefs_get_int_attribute("options.compassangledisplay", "value", 0) != 0) angle = angle_to_compass (angle); - pc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter to finish the path"), is_curve? "Curve segment" : "Line segment", angle, dist->str); + pc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("%s: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter to finish the path"), is_curve? "Curve segment" : "Line segment", angle, dist->str); g_string_free(dist, FALSE); } } @@ -987,7 +1123,7 @@ spdc_pen_set_ctrl(SPPenContext *const pc, NR::Point const p, guint const state) double angle = atan2(rel[NR::Y], rel[NR::X]) * 180 / M_PI; if (prefs_get_int_attribute("options.compassangledisplay", "value", 0) != 0) angle = angle_to_compass (angle); - pc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("Curve handle: angle %3.2f°, length %s; with Ctrl to snap angle"), angle, dist->str); + pc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Curve handle: angle %3.2f°, length %s; with Ctrl to snap angle"), angle, dist->str); g_string_free(dist, FALSE); } else if ( pc->npoints == 5 ) { @@ -1017,7 +1153,7 @@ spdc_pen_set_ctrl(SPPenContext *const pc, NR::Point const p, guint const state) double angle = atan2(rel[NR::Y], rel[NR::X]) * 180 / M_PI; if (prefs_get_int_attribute("options.compassangledisplay", "value", 0) != 0) angle = angle_to_compass (angle); - pc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s: angle %3.2f°, length %s; with Ctrl to snap angle, with Shift to move this handle only"), is_symm? "Curve handle, symmetric" : "Curve handle", angle, dist->str); + pc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("%s: angle %3.2f°, length %s; with Ctrl to snap angle, with Shift to move this handle only"), is_symm? "Curve handle, symmetric" : "Curve handle", angle, dist->str); g_string_free(dist, FALSE); } else { @@ -1026,13 +1162,13 @@ spdc_pen_set_ctrl(SPPenContext *const pc, NR::Point const p, guint const state) } static void -spdc_pen_finish_segment(SPPenContext *const pc, NR::Point const p, guint const state) +spdc_pen_finish_segment(SPPenContext *const pc, NR::Point const /*p*/, guint const /*state*/) { if (!sp_curve_empty(pc->red_curve)) { sp_curve_append_continuous(pc->green_curve, pc->red_curve, 0.0625); SPCurve *curve = sp_curve_copy(pc->red_curve); /// \todo fixme: - SPCanvasItem *cshape = sp_canvas_bpath_new(SP_DT_SKETCH(pc->desktop), curve); + SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), curve); sp_curve_unref(curve); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); @@ -1049,9 +1185,11 @@ spdc_pen_finish_segment(SPPenContext *const pc, NR::Point const p, guint const s static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) { + pen_disable_events(pc); + SPDesktop *const desktop = pc->desktop; pc->_message_context->clear(); - desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Finishing pen")); + desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Drawing finished")); sp_curve_reset(pc->red_curve); spdc_concat_colors_and_flush(pc, closed); @@ -1069,8 +1207,24 @@ spdc_pen_finish(SPPenContext *const pc, gboolean const closed) if (pc->green_anchor) { pc->green_anchor = sp_draw_anchor_destroy(pc->green_anchor); } + + + sp_canvas_end_forced_full_redraws(pc->desktop->canvas); + + pen_enable_events(pc); } +static void +pen_disable_events(SPPenContext *const pc) { + pc->events_disabled++; +} + +static void +pen_enable_events(SPPenContext *const pc) { + g_return_if_fail(pc->events_disabled != 0); + + pc->events_disabled--; +} /* Local Variables: