From 44804318ece44d0c7256381d1ec3dfd63ee2a43c Mon Sep 17 00:00:00 2001 From: cilix42 Date: Thu, 12 Jun 2008 13:22:37 +0000 Subject: [PATCH] New 'polylines only' mode in pen context; to be used later when LPEs are waiting for mouse input --- src/pen-context.cpp | 19 +++++++++++++++---- src/pen-context.h | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 7dc489540..e3ff835d5 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -145,6 +145,8 @@ sp_pen_context_init(SPPenContext *pc) pc->cl1 = NULL; pc->events_disabled = 0; + + pc->polylines_only = false; } /** @@ -473,10 +475,13 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const p = event_dt; spdc_endpoint_snap(pc, p, bevent.state); /* Snap node only if not hitting anchor. */ spdc_pen_set_subsequent_point(pc, p, true); + if (pc->polylines_only) { + spdc_pen_finish_segment(pc, p, bevent.state); + } } } - pc->state = SP_PEN_CONTEXT_CONTROL; + pc->state = pc->polylines_only ? SP_PEN_CONTEXT_POINT : SP_PEN_CONTEXT_CONTROL; ret = TRUE; break; case SP_PEN_CONTEXT_CONTROL: @@ -624,7 +629,11 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) // snap the handle spdc_endpoint_snap_handle(pc, p, mevent.state); - spdc_pen_set_ctrl(pc, p, mevent.state); + if (!pc->polylines_only) { + spdc_pen_set_ctrl(pc, p, mevent.state); + } else { + spdc_pen_set_ctrl(pc, pc->p[1], mevent.state); + } gobble_motion_events(GDK_BUTTON1_MASK); ret = TRUE; break; @@ -717,8 +726,10 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) switch (pc->state) { case SP_PEN_CONTEXT_POINT: case SP_PEN_CONTEXT_CONTROL: - spdc_endpoint_snap(pc, p, revent.state); - spdc_pen_finish_segment(pc, p, revent.state); + if (!pc->polylines_only) { + spdc_endpoint_snap(pc, p, revent.state); + spdc_pen_finish_segment(pc, p, revent.state); + } break; case SP_PEN_CONTEXT_CLOSE: spdc_endpoint_snap(pc, p, revent.state); diff --git a/src/pen-context.h b/src/pen-context.h index e149391a9..29938e923 100644 --- a/src/pen-context.h +++ b/src/pen-context.h @@ -39,6 +39,8 @@ struct SPPenContext : public SPDrawContext { unsigned int state : 2; unsigned int onlycurves : 1; + bool polylines_only; + SPCanvasItem *c0, *c1, *cl0, *cl1; unsigned int events_disabled : 1; -- 2.30.2