gimp r24838 - in trunk: . app/tools app/widgets



Author: mitch
Date: Sat Feb  9 10:56:25 2008
New Revision: 24838
URL: http://svn.gnome.org/viewvc/gimp?rev=24838&view=rev

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

	* app/widgets/gimpcurveview.[ch]: port the "xpos" API
	to [0.0..1.0] doubles too.

	* app/tools/gimpcurvestool.[ch]: rename "col_value" member to
	"picked_color" and use gdouble instead of gint. Also use GimpCurve
	API to map the values instead of accessing the curve directly.
	Fixes setting curve anchor points by color picking.



Modified:
   trunk/ChangeLog
   trunk/app/tools/gimpcurvestool.c
   trunk/app/tools/gimpcurvestool.h
   trunk/app/widgets/gimpcurveview.c
   trunk/app/widgets/gimpcurveview.h

Modified: trunk/app/tools/gimpcurvestool.c
==============================================================================
--- trunk/app/tools/gimpcurvestool.c	(original)
+++ trunk/app/tools/gimpcurvestool.c	Sat Feb  9 10:56:25 2008
@@ -178,8 +178,8 @@
 
   tool->lut = gimp_lut_new ();
 
-  for (i = 0; i < G_N_ELEMENTS (tool->col_value); i++)
-    tool->col_value[i] = -1;
+  for (i = 0; i < G_N_ELEMENTS (tool->picked_color); i++)
+    tool->picked_color[i] = -1.0;
 
   im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
   im_tool->apply_data = tool->lut;
@@ -248,19 +248,16 @@
   if (state & GDK_SHIFT_MASK)
     {
       GimpCurve *curve = config->curve[config->channel];
+      gdouble    value = c_tool->picked_color[config->channel];
       gint       closest;
 
-      closest =
-        gimp_curve_get_closest_point (curve,
-                                      c_tool->col_value[config->channel]);
+      closest = gimp_curve_get_closest_point (curve, value);
 
       gimp_curve_view_set_selected (GIMP_CURVE_VIEW (c_tool->graph),
                                     closest);
 
-      gimp_curve_set_point (curve,
-                            closest,
-                            c_tool->col_value[config->channel],
-                            curve->curve[c_tool->col_value[config->channel]]);
+      gimp_curve_set_point (curve, closest,
+                            value, gimp_curve_map (curve, value));
     }
   else if (state & GDK_CONTROL_MASK)
     {
@@ -269,19 +266,16 @@
       for (i = 0; i < 5; i++)
         {
           GimpCurve *curve = config->curve[i];
+          gdouble    value = c_tool->picked_color[i];
           gint       closest;
 
-          closest =
-            gimp_curve_get_closest_point (curve,
-                                          c_tool->col_value[i]);
+          closest = gimp_curve_get_closest_point (curve, value);
 
           gimp_curve_view_set_selected (GIMP_CURVE_VIEW (c_tool->graph),
                                         closest);
 
-          gimp_curve_set_point (curve,
-                                closest,
-                                c_tool->col_value[i],
-                                curve->curve[c_tool->col_value[i]]);
+          gimp_curve_set_point (curve, closest,
+                                value, gimp_curve_map (curve, value));
         }
     }
 
@@ -341,26 +335,21 @@
 {
   GimpCurvesTool *tool = GIMP_CURVES_TOOL (color_tool);
   GimpDrawable   *drawable;
-  guchar          r, g, b, a;
 
   drawable = GIMP_IMAGE_MAP_TOOL (tool)->drawable;
 
-  gimp_rgba_get_uchar (color, &r, &g, &b, &a);
-
-  tool->col_value[GIMP_HISTOGRAM_RED]   = r;
-  tool->col_value[GIMP_HISTOGRAM_GREEN] = g;
-  tool->col_value[GIMP_HISTOGRAM_BLUE]  = b;
+  tool->picked_color[GIMP_HISTOGRAM_RED]   = color->r;
+  tool->picked_color[GIMP_HISTOGRAM_GREEN] = color->g;
+  tool->picked_color[GIMP_HISTOGRAM_BLUE]  = color->b;
 
   if (gimp_drawable_has_alpha (drawable))
-    tool->col_value[GIMP_HISTOGRAM_ALPHA] = a;
-
-  if (gimp_drawable_is_indexed (drawable))
-    tool->col_value[GIMP_HISTOGRAM_ALPHA] = color_index;
+    tool->picked_color[GIMP_HISTOGRAM_ALPHA] = color->a;
 
-  tool->col_value[GIMP_HISTOGRAM_VALUE] = MAX (MAX (r, g), b);
+  tool->picked_color[GIMP_HISTOGRAM_VALUE] = MAX (MAX (color->r, color->g),
+                                                  color->b);
 
   gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
-                            tool->col_value[tool->config->channel]);
+                            tool->picked_color[tool->config->channel]);
 }
 
 static GeglNode *
@@ -669,7 +658,7 @@
       gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->graph),
                                        config->channel);
       gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
-                                tool->col_value[config->channel]);
+                                tool->picked_color[config->channel]);
 
       gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->yrange),
                                   config->channel);

Modified: trunk/app/tools/gimpcurvestool.h
==============================================================================
--- trunk/app/tools/gimpcurvestool.h	(original)
+++ trunk/app/tools/gimpcurvestool.h	Sat Feb  9 10:56:25 2008
@@ -41,7 +41,7 @@
   GimpLut              *lut;
 
   /* dialog */
-  gint                  col_value[5];
+  gdouble               picked_color[5];
 
   GtkWidget            *channel_menu;
   GtkWidget            *xrange;

Modified: trunk/app/widgets/gimpcurveview.c
==============================================================================
--- trunk/app/widgets/gimpcurveview.c	(original)
+++ trunk/app/widgets/gimpcurveview.c	Sat Feb  9 10:56:25 2008
@@ -125,7 +125,7 @@
   view->last_x      = 0.0;
   view->last_y      = 0.0;
   view->cursor_type = -1;
-  view->xpos        = -1;
+  view->xpos        = -1.0;
   view->cursor_x    = -1;
   view->cursor_y    = -1;
 
@@ -410,7 +410,7 @@
        }
     }
 
-  if (view->xpos >= 0)
+  if (view->xpos >= 0.0)
     {
       gint  layout_x;
       gint  layout_y;
@@ -420,15 +420,15 @@
 
       /* draw the color line */
       cairo_move_to (cr,
-                     border + ROUND ((gdouble) width * view->xpos / 256.0),
+                     border + ROUND ((gdouble) width * view->xpos),
                      border);
       cairo_line_to (cr,
-                     border + ROUND ((gdouble) width * view->xpos / 256.0),
+                     border + ROUND ((gdouble) width * view->xpos),
                      border + height - 1);
       cairo_stroke (cr);
 
       /* and xpos indicator */
-      g_snprintf (buf, sizeof (buf), "x:%d", view->xpos);
+      g_snprintf (buf, sizeof (buf), "x:%d", (gint) (view->xpos * 255.999));
 
       if (! view->xpos_layout)
         view->xpos_layout = gtk_widget_create_pango_layout (widget, NULL);
@@ -436,13 +436,13 @@
       pango_layout_set_text (view->xpos_layout, buf, -1);
       pango_layout_get_pixel_size (view->xpos_layout, &layout_x, &layout_y);
 
-      if (view->xpos < 127)
+      if (view->xpos < 0.5)
         layout_x = border;
       else
         layout_x = -(layout_x + border);
 
       cairo_move_to (cr,
-                     border + (gdouble) width * view->xpos / 256.0 + layout_x,
+                     border + (gdouble) width * view->xpos + layout_x,
                      border + height - border - layout_y);
       pango_cairo_show_layout (cr, view->xpos_layout);
       cairo_fill (cr);
@@ -864,7 +864,7 @@
 
 void
 gimp_curve_view_set_xpos (GimpCurveView *view,
-                          gint           x)
+                          gdouble        x)
 {
   g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
 

Modified: trunk/app/widgets/gimpcurveview.h
==============================================================================
--- trunk/app/widgets/gimpcurveview.h	(original)
+++ trunk/app/widgets/gimpcurveview.h	Sat Feb  9 10:56:25 2008
@@ -52,7 +52,7 @@
 
   GdkCursorType      cursor_type;
 
-  gint               xpos;
+  gdouble            xpos;
   PangoLayout       *xpos_layout;
 
   gint               cursor_x;
@@ -78,7 +78,7 @@
 void        gimp_curve_view_set_selected (GimpCurveView *view,
                                           gint           selected);
 void        gimp_curve_view_set_xpos     (GimpCurveView *view,
-                                          gint           x);
+                                          gdouble        x);
 
 
 #endif /* __GIMP_CURVE_VIEW_H__ */



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