From: cilix42 Date: Thu, 12 Jun 2008 13:22:56 +0000 (+0000) Subject: Pen context can now wait for a specified number of clicks and finish the path afterwa... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=62e787393bfaf2abaefe7efc076c0c71e38d8c65;p=inkscape.git Pen context can now wait for a specified number of clicks and finish the path afterwards; together with the new polylines mode this will be used to pass paths as arguments to LPEs --- diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 49bf881a4..dd9688f02 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -42,7 +42,7 @@ #include "helper/units.h" #include "macros.h" #include "context-fns.h" - +#include "live_effects/effect.h" static void sp_pen_context_class_init(SPPenContextClass *klass); static void sp_pen_context_init(SPPenContext *pc); @@ -177,6 +177,12 @@ sp_pen_context_dispose(GObject *object) } G_OBJECT_CLASS(pen_parent_class)->dispose(object); + + pc->polylines_only = false; + if (pc->expecting_clicks_for_LPE > 0) { + // we received too few clicks to sanely set the parameter path so we remove the LPE from the item + //sp_lpe_item_remove_current_path_effect(SP_LPE_ITEM(pc->waiting_item), false); + } } /** @@ -378,7 +384,9 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const SPEventContext *event_context = SP_EVENT_CONTEXT(pc); gint ret = FALSE; - if (bevent.button == 1 && !event_context->space_panning) { + if (bevent.button == 1 && !event_context->space_panning + && pc->expecting_clicks_for_LPE != 1) { // when the last click for a waiting LPE occurs we want to finish the path + if (Inkscape::have_viable_layer(desktop, dc->_message_context) == false) { return TRUE; @@ -497,7 +505,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const default: break; } - } else if (bevent.button == 3) { + } else if (bevent.button == 3 || pc->expecting_clicks_for_LPE == 1) { // when the last click for a waiting LPE occurs we want to finish the path if (pc->npoints != 0) { spdc_pen_finish_segment(pc, event_dt, bevent.state); @@ -766,6 +774,22 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) dc->green_closed = FALSE; } + // TODO: can we be sure that the path was created correctly? + // TODO: should we offer an option to collect the clicks in a list? + if (pc->expecting_clicks_for_LPE > 0) { + --pc->expecting_clicks_for_LPE; + + if (pc->expecting_clicks_for_LPE == 0) { + pc->polylines_only = false; + + SPEventContext *ec = SP_EVENT_CONTEXT(pc); + Inkscape::Selection *selection = sp_desktop_selection (ec->desktop); + + //pc->waiting_LPE->acceptParamPath(SP_PATH(selection->singleItem())); + //selection->add(SP_OBJECT(pc->waiting_item)); + } + } + return ret; } @@ -1214,6 +1238,11 @@ spdc_pen_finish_segment(SPPenContext *const pc, NR::Point const /*p*/, guint con static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) { + if (pc->expecting_clicks_for_LPE > 1) { + // don't let the path be finished before we have collected the required number of mouse clicks + return; + } + pen_disable_events(pc); SPDesktop *const desktop = pc->desktop; diff --git a/src/pen-context.h b/src/pen-context.h index ddf1e76c4..49e77e389 100644 --- a/src/pen-context.h +++ b/src/pen-context.h @@ -40,6 +40,8 @@ struct SPPenContext : public SPDrawContext { bool polylines_only; + unsigned int expecting_clicks_for_LPE; // if positive, finish the path after this many clicks + SPCanvasItem *c0, *c1, *cl0, *cl1; unsigned int events_disabled : 1;