From c92071fd28ca41ff96983340ebfd32c91d363420 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 20 Jun 2023 01:54:56 +0000 Subject: [PATCH] tools: Close iscissors curve on pressing Enter This better aligns the tool with the path tool, which also closes on Enter if it is not already a connected path. --- app/tools/gimpiscissorstool.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c index e641f7127fc..cb75f14230f 100644 --- a/app/tools/gimpiscissorstool.c +++ b/app/tools/gimpiscissorstool.c @@ -1115,6 +1115,33 @@ gimp_iscissors_tool_key_press (GimpTool *tool, gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display); return TRUE; } + else if (g_queue_get_length (iscissors->curve->segments) > 1) + { + /* Create a closed curve if there are at least three points + and we haven't connected it yet */ + ISegment *first = g_queue_peek_head (iscissors->curve->segments); + ISegment *last = g_queue_peek_tail (iscissors->curve->segments); + + if (first && last && first != last) + { + ISegment *segment; + + gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); + gimp_iscissors_tool_push_undo (iscissors); + + segment = icurve_append_segment (iscissors->curve, + last->x2, last->y2, + first->x1, first->y1); + + icurve_close (iscissors->curve); + calculate_segment (iscissors, segment); + iscissors_convert (iscissors, display); + + gimp_iscissors_tool_free_redo (iscissors); + gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); + } + return TRUE; + } return FALSE; case GDK_KEY_Escape: -- GitLab