From 8cf801c8e010409eac9296a7b7b8e0c8f6814eb1 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 26 Jul 2010 01:08:44 +0200 Subject: [PATCH] app: allow to delete curve points Pressing Delete in the Curve view now deletes the selected point on the curve. --- app/core/gimpcurve.c | 28 ++++++++++++++++++++++++++++ app/core/gimpcurve.h | 2 ++ app/widgets/gimpcurveview.c | 4 ++++ 3 files changed, 34 insertions(+) diff --git a/app/core/gimpcurve.c b/app/core/gimpcurve.c index 0f3410c984..8c031f8939 100644 --- a/app/core/gimpcurve.c +++ b/app/core/gimpcurve.c @@ -797,6 +797,34 @@ gimp_curve_move_point (GimpCurve *curve, gimp_data_dirty (GIMP_DATA (curve)); } +void +gimp_curve_delete_point (GimpCurve *curve, + gint point) +{ + g_return_if_fail (GIMP_IS_CURVE (curve)); + g_return_if_fail (point >= 0 && point < curve->n_points); + + if (point == 0) + { + curve->points[0].x = 0.0; + curve->points[0].y = 0.0; + } + else if (point == curve->n_points - 1) + { + curve->points[curve->n_points - 1].x = 1.0; + curve->points[curve->n_points - 1].y = 1.0; + } + else + { + curve->points[point].x = -1.0; + curve->points[point].y = -1.0; + } + + g_object_notify (G_OBJECT (curve), "points"); + + gimp_data_dirty (GIMP_DATA (curve)); +} + void gimp_curve_get_point (GimpCurve *curve, gint point, diff --git a/app/core/gimpcurve.h b/app/core/gimpcurve.h index c945f55b91..2f0f423c39 100644 --- a/app/core/gimpcurve.h +++ b/app/core/gimpcurve.h @@ -79,6 +79,8 @@ void gimp_curve_set_point (GimpCurve *curve, void gimp_curve_move_point (GimpCurve *curve, gint point, gdouble y); +void gimp_curve_delete_point (GimpCurve *curve, + gint point); void gimp_curve_get_point (GimpCurve *curve, gint point, gdouble *x, diff --git a/app/widgets/gimpcurveview.c b/app/widgets/gimpcurveview.c index d2dfc2f0ba..3627b43a00 100644 --- a/app/widgets/gimpcurveview.c +++ b/app/widgets/gimpcurveview.c @@ -1014,6 +1014,10 @@ gimp_curve_view_key_press (GtkWidget *widget, } break; + case GDK_Delete: + gimp_curve_delete_point (curve, i); + break; + default: break; }