[gimp] app: allow to delete curve points



commit 8cf801c8e010409eac9296a7b7b8e0c8f6814eb1
Author: Sven Neumann <sven gimp org>
Date:   Mon Jul 26 01:08:44 2010 +0200

    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(+), 0 deletions(-)
---
diff --git a/app/core/gimpcurve.c b/app/core/gimpcurve.c
index 0f3410c..8c031f8 100644
--- a/app/core/gimpcurve.c
+++ b/app/core/gimpcurve.c
@@ -798,6 +798,34 @@ gimp_curve_move_point (GimpCurve *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,
                       gdouble   *x,
diff --git a/app/core/gimpcurve.h b/app/core/gimpcurve.h
index c945f55..2f0f423 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 d2dfc2f..3627b43 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;
         }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]