From 78dff132275043d3d96b753ddcd52a109e29d8d2 Mon Sep 17 00:00:00 2001 From: Roland Lutz Date: Mon, 7 Oct 2019 00:03:49 +0200 Subject: [PATCH] gschem: Make right-click in path mode work as expected --- gschem/include/prototype.h | 1 + gschem/src/o_path.c | 25 +++++++++++++++++++++++++ gschem/src/x_event.c | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h index 214771a15..6b9324131 100644 --- a/gschem/include/prototype.h +++ b/gschem/include/prototype.h @@ -266,6 +266,7 @@ void o_path_start(GschemToplevel *w_current, int x, int y); void o_path_continue (GschemToplevel *w_current, int w_x, int w_y); void o_path_motion (GschemToplevel *w_current, int w_x, int w_y); void o_path_end(GschemToplevel *w_current, int x, int y); +void o_path_end_path (GschemToplevel *w_current); void o_path_invalidate_rubber (GschemToplevel *w_current); void o_path_draw_rubber (GschemToplevel *w_current, EdaRenderer *renderer); void o_path_invalidate_rubber_grips (GschemToplevel *w_current); diff --git a/gschem/src/o_path.c b/gschem/src/o_path.c index 723b90d77..49a758787 100644 --- a/gschem/src/o_path.c +++ b/gschem/src/o_path.c @@ -527,6 +527,31 @@ o_path_end(GschemToplevel *w_current, int w_x, int w_y) } } +/*! \brief End the input of a path. + * + * Called on right-click. Confirms all path segments except for the + * current one. If there is only one path segment, cancels the path. + * + * \param [in] w_current The GschemToplevel object. + */ +void +o_path_end_path (GschemToplevel *w_current) +{ + PATH *p = w_current->temp_path; + PATH_SECTION *prev_section; + + if (p->num_sections < 2) { + o_path_invalidate_rubber (w_current); + i_action_stop (w_current); + return; + } + + prev_section = &p->sections[p->num_sections - 1]; + w_current->first_wx = prev_section->x3; + w_current->first_wy = prev_section->y3; + o_path_end (w_current, 0, 0); +} + /*! \brief Draw path creation preview. * \par Function Description * Draw a preview of the path currently being drawn, including a diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c index 1795e3236..c19512a79 100644 --- a/gschem/src/x_event.c +++ b/gschem/src/x_event.c @@ -297,7 +297,7 @@ x_event_button_pressed(GschemPageView *page_view, GdkEventButton *event, GschemT case (CIRCLEMODE) : o_circle_invalidate_rubber (w_current); break; case (LINEMODE) : o_line_invalidate_rubber (w_current); break; case (NETMODE) : o_net_reset (w_current); break; - case (PATHMODE) : o_path_invalidate_rubber (w_current); break; + case (PATHMODE) : o_path_end_path (w_current); break; case (PICTUREMODE): o_picture_invalidate_rubber (w_current); break; case (PINMODE) : o_pin_invalidate_rubber (w_current); break; -- 2.11.4.GIT