gimp r24857 - in trunk: . app/core app/gegl app/widgets



Author: mitch
Date: Mon Feb 11 10:22:59 2008
New Revision: 24857
URL: http://svn.gnome.org/viewvc/gimp?rev=24857&view=rev

Log:
2008-02-11  Michael Natterer  <mitch gimp org>

	* app/core/gimpcurve.[ch]: add gimp_curve_get_point().

	* app/gegl/gimpcurvesconfig.c
	* app/widgets/gimpcurveview.c: use it instead of accessing the
	points array directly.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpcurve.c
   trunk/app/core/gimpcurve.h
   trunk/app/gegl/gimpcurvesconfig.c
   trunk/app/widgets/gimpcurveview.c

Modified: trunk/app/core/gimpcurve.c
==============================================================================
--- trunk/app/core/gimpcurve.c	(original)
+++ trunk/app/core/gimpcurve.c	Mon Feb 11 10:22:59 2008
@@ -476,6 +476,21 @@
 }
 
 void
+gimp_curve_get_point (GimpCurve *curve,
+                      gint       point,
+                      gdouble   *x,
+                      gdouble   *y)
+{
+  g_return_if_fail (GIMP_IS_CURVE (curve));
+
+  if (curve->curve_type == GIMP_CURVE_FREE)
+    return;
+
+  if (x) *x = curve->points[point].x;
+  if (y) *y = curve->points[point].y;
+}
+
+void
 gimp_curve_set_curve (GimpCurve *curve,
                       gdouble    x,
                       gdouble    y)

Modified: trunk/app/core/gimpcurve.h
==============================================================================
--- trunk/app/core/gimpcurve.h	(original)
+++ trunk/app/core/gimpcurve.h	Mon Feb 11 10:22:59 2008
@@ -67,6 +67,7 @@
 
 gint            gimp_curve_get_closest_point (GimpCurve     *curve,
                                               gdouble        x);
+
 void            gimp_curve_set_point         (GimpCurve     *curve,
                                               gint           point,
                                               gdouble        x,
@@ -74,6 +75,10 @@
 void            gimp_curve_move_point        (GimpCurve     *curve,
                                               gint           point,
                                               gdouble        y);
+void            gimp_curve_get_point         (GimpCurve     *curve,
+                                              gint           point,
+                                              gdouble       *x,
+                                              gdouble       *y);
 
 void            gimp_curve_set_curve         (GimpCurve     *curve,
                                               gdouble        x,

Modified: trunk/app/gegl/gimpcurvesconfig.c
==============================================================================
--- trunk/app/gegl/gimpcurvesconfig.c	(original)
+++ trunk/app/gegl/gimpcurvesconfig.c	Mon Feb 11 10:22:59 2008
@@ -417,9 +417,15 @@
         }
 
       for (j = 0; j < GIMP_CURVE_NUM_POINTS; j++)
-        fprintf (file, "%d %d ",
-                 (gint) (curve->points[j].x * 255.999),
-                 (gint) (curve->points[j].y * 255.999));
+        {
+          gdouble x, y;
+
+          gimp_curve_get_point (curve, j, &x, &y);
+
+          fprintf (file, "%d %d ",
+                   (gint) (x * 255.999),
+                   (gint) (y * 255.999));
+        }
 
       fprintf (file, "\n");
     }

Modified: trunk/app/widgets/gimpcurveview.c
==============================================================================
--- trunk/app/widgets/gimpcurveview.c	(original)
+++ trunk/app/widgets/gimpcurveview.c	Mon Feb 11 10:22:59 2008
@@ -315,12 +315,13 @@
 {
   gdouble x, y;
 
-  x =       view->curve->points[i].x;
-  y = 1.0 - view->curve->points[i].y;
+  gimp_curve_get_point (view->curve, i, &x, &y);
 
   if (x < 0.0)
     return;
 
+  y = 1.0 - y;
+
 #define RADIUS 3
 
   cairo_move_to (cr,
@@ -553,19 +554,31 @@
       /*  determine the leftmost and rightmost points  */
       view->leftmost = -1.0;
       for (i = closest_point - 1; i >= 0; i--)
-        if (curve->points[i].x >= 0.0)
-          {
-            view->leftmost = curve->points[i].x;
-            break;
-          }
+        {
+          gdouble point_x;
+
+          gimp_curve_get_point (curve, i, &point_x, NULL);
+
+          if (point_x >= 0.0)
+            {
+              view->leftmost = point_x;
+              break;
+            }
+        }
 
       view->rightmost = 2.0;
       for (i = closest_point + 1; i < GIMP_CURVE_NUM_POINTS; i++)
-        if (curve->points[i].x >= 0.0)
-          {
-            view->rightmost = curve->points[i].x;
-            break;
-          }
+        {
+          gdouble point_x;
+
+          gimp_curve_get_point (curve, i, &point_x, NULL);
+
+          if (point_x >= 0.0)
+            {
+              view->rightmost = point_x;
+              break;
+            }
+        }
 
       gimp_curve_view_set_selected (view, closest_point);
 
@@ -632,10 +645,14 @@
 
   switch (gimp_curve_get_curve_type (curve))
     {
+      gdouble point_x;
+
     case GIMP_CURVE_SMOOTH:
       if (! view->grabbed) /*  If no point is grabbed...  */
         {
-          if (curve->points[closest_point].x >= 0.0)
+          gimp_curve_get_point (curve, closest_point, &x, NULL);
+
+          if (point_x >= 0.0)
             new_cursor = GDK_FLEUR;
           else
             new_cursor = GDK_TCROSS;
@@ -651,7 +668,10 @@
           if (x > view->leftmost && x < view->rightmost)
             {
               closest_point = ((gint) (x * 255.999) + 8) / 16;
-              if (curve->points[closest_point].x < 0.0)
+
+              gimp_curve_get_point (curve, closest_point, &point_x, NULL);
+
+              if (point_x < 0.0)
                 gimp_curve_view_set_selected (view, closest_point);
 
               gimp_curve_set_point (curve, view->selected, x, 1.0 - y);
@@ -737,19 +757,23 @@
   GimpCurveView *view   = GIMP_CURVE_VIEW (widget);
   GimpCurve     *curve  = view->curve;
   gint           i      = view->selected;
-  gdouble        y      = curve->points[i].y;
+  gdouble        x, y;
   gboolean       retval = FALSE;
 
   if (view->grabbed || ! curve ||
       gimp_curve_get_curve_type (curve) == GIMP_CURVE_FREE)
     return FALSE;
 
+  gimp_curve_get_point (curve, i, NULL, &y);
+
   switch (kevent->keyval)
     {
     case GDK_Left:
       for (i = i - 1; i >= 0 && ! retval; i--)
         {
-          if (curve->points[i].x >= 0.0)
+          gimp_curve_get_point (curve, i, &x, NULL);
+
+          if (x >= 0.0)
             {
               gimp_curve_view_set_selected (view, i);
 
@@ -761,7 +785,9 @@
     case GDK_Right:
       for (i = i + 1; i < GIMP_CURVE_NUM_POINTS && ! retval; i++)
         {
-          if (curve->points[i].x >= 0.0)
+          gimp_curve_get_point (curve, i, &x, NULL);
+
+          if (x >= 0.0)
             {
               gimp_curve_view_set_selected (view, i);
 



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