X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fpencil-context.cpp;h=d86b83c01b72f0344c5b35dd32eec2049611ecac;hb=ad4b3133547bb79aa1362ab40512d31267868c82;hp=380c68c6b6981210a2eddbeabd26138bfc8cb989;hpb=124aed58b23bd24292c6e2175522db06a196e39e;p=inkscape.git diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 380c68c6b..d86b83c01 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -29,7 +29,6 @@ #include "prefs-utils.h" #include "snap.h" #include "pixmaps/cursor-pencil.xpm" -#include "pixmaps/cursor-pencil.pixbuf" #include "display/bezier-utils.h" #include "display/canvas-bpath.h" #include @@ -110,11 +109,6 @@ sp_pencil_context_init(SPPencilContext *pc) SPEventContext *event_context = SP_EVENT_CONTEXT(pc); event_context->cursor_shape = cursor_pencil_xpm; - event_context->cursor_pixbuf = gdk_pixbuf_new_from_inline( - -1, - cursor_pencil_pixbuf, - FALSE, - NULL); event_context->hot_x = 4; event_context->hot_y = 4; @@ -408,12 +402,42 @@ pencil_handle_button_release(SPPencilContext *const pc, GdkEventButton const &re pc->grab = NULL; } - pc->grab = NULL; ret = TRUE; } return ret; } +static void +pencil_cancel (SPPencilContext *const pc) +{ + if (pc->grab) { + /* Release grab now */ + sp_canvas_item_ungrab(pc->grab, 0); + pc->grab = NULL; + } + + pc->is_drawing = false; + + pc->state = SP_PENCIL_CONTEXT_IDLE; + + sp_curve_reset(pc->red_curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL); + 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); + } + sp_curve_reset(pc->green_curve); + if (pc->green_anchor) { + pc->green_anchor = sp_draw_anchor_destroy(pc->green_anchor); + } + + pc->_message_context->clear(); + pc->_message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled")); + + sp_canvas_end_forced_full_redraws(pc->desktop->canvas); +} + + static gint pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint const state) { @@ -428,6 +452,25 @@ pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint con ret = TRUE; } break; + case GDK_Escape: + if (pc->npoints != 0) { + // if drawing, cancel, otherwise pass it up for deselecting + if (pc->is_drawing) { + pencil_cancel (pc); + ret = TRUE; + } + } + break; + case GDK_z: + case GDK_Z: + if (mod_ctrl_only(state) && pc->npoints != 0) { + // if drawing, cancel, otherwise pass it up for undo + if (pc->is_drawing) { + pencil_cancel (pc); + ret = TRUE; + } + } + break; default: break; }