[gimp] app: fix Curves tool numeric-entry range/precision for > 8-bpc images



commit be719f9070a1143855e7da97bdd75e6313f62543
Author: Ell <ell_se yahoo com>
Date:   Fri Apr 19 11:09:51 2019 -0400

    app: fix Curves tool numeric-entry range/precision for > 8-bpc images
    
    In the Curves tool, when the image precision is greater than 8-bpc,
    use a 0.00-100.00 range for the point-coordinate spin-buttons,
    instead of a 0-255 range.

 app/tools/gimpcurvestool.c | 42 ++++++++++++++++++++++++++++++------------
 app/tools/gimpcurvestool.h |  1 +
 2 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index 47eecc3808..3b3b82b6c2 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -224,15 +224,29 @@ gimp_curves_tool_initialize (GimpTool     *tool,
 
   if (gimp_drawable_get_component_type (drawable) == GIMP_COMPONENT_TYPE_U8)
     {
-      gimp_curve_view_set_range_x (GIMP_CURVE_VIEW (c_tool->graph), 0, 255);
-      gimp_curve_view_set_range_y (GIMP_CURVE_VIEW (c_tool->graph), 0, 255);
+      c_tool->scale = 255.0;
+
+      gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c_tool->point_input),  0);
+      gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c_tool->point_output), 0);
     }
   else
     {
-      gimp_curve_view_set_range_x (GIMP_CURVE_VIEW (c_tool->graph), 0, 100);
-      gimp_curve_view_set_range_y (GIMP_CURVE_VIEW (c_tool->graph), 0, 100);
+      c_tool->scale = 100.0;
+
+      gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c_tool->point_input),  2);
+      gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c_tool->point_output), 2);
     }
 
+  gimp_curve_view_set_range_x (GIMP_CURVE_VIEW (c_tool->graph),
+                               0, c_tool->scale);
+  gimp_curve_view_set_range_y (GIMP_CURVE_VIEW (c_tool->graph),
+                               0, c_tool->scale);
+
+  gtk_spin_button_set_range (GTK_SPIN_BUTTON (c_tool->point_input),
+                             0, c_tool->scale);
+  gtk_spin_button_set_range (GTK_SPIN_BUTTON (c_tool->point_output),
+                             0, c_tool->scale);
+
   for (channel = GIMP_HISTOGRAM_VALUE;
        channel <= GIMP_HISTOGRAM_ALPHA;
        channel++)
@@ -242,6 +256,8 @@ gimp_curves_tool_initialize (GimpTool     *tool,
                         tool);
     }
 
+  gimp_curves_tool_update_point (c_tool);
+
   /*  always pick colors  */
   gimp_filter_tool_enable_color_picking (filter_tool, NULL, FALSE);
 
@@ -590,6 +606,7 @@ gimp_curves_tool_dialog (GimpFilterTool *filter_tool)
 
   gtk_widget_show (grid);
 
+  /*  The point properties box  */
   tool->point_box = hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
   gtk_box_pack_start (GTK_BOX (frame_vbox), hbox, FALSE, FALSE, 0);
   gtk_widget_show (tool->point_box);
@@ -598,7 +615,7 @@ gimp_curves_tool_dialog (GimpFilterTool *filter_tool)
   gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
   gtk_widget_show (label);
 
-  tool->point_input = gimp_spin_button_new_with_range (0.0, 255.0, 1.0);
+  tool->point_input = gimp_spin_button_new (NULL, 1.0, 0);
   gtk_box_pack_start (GTK_BOX (hbox), tool->point_input, FALSE, FALSE, 0);
   gtk_widget_show (tool->point_input);
 
@@ -612,7 +629,7 @@ gimp_curves_tool_dialog (GimpFilterTool *filter_tool)
   gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
   gtk_widget_show (label);
 
-  tool->point_output = gimp_spin_button_new_with_range (0.0, 255.0, 1.0);
+  tool->point_output = gimp_spin_button_new (NULL, 1.0, 0);
   gtk_box_pack_start (GTK_BOX (hbox), tool->point_output, FALSE, FALSE, 0);
   gtk_widget_show (tool->point_output);
 
@@ -645,6 +662,7 @@ gimp_curves_tool_dialog (GimpFilterTool *filter_tool)
   gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
   gtk_widget_show (label);
 
+  /*  The curve-type combo  */
   tool->curve_type = combo = gimp_enum_combo_box_new (GIMP_TYPE_CURVE_TYPE);
   gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (combo),
                                        "gimp-curve");
@@ -951,10 +969,10 @@ gimp_curves_tool_update_point (GimpCurvesTool *tool)
 
       gimp_curve_get_point (curve, point, &x, &y);
 
-      x   *= 255.0;
-      y   *= 255.0;
-      min *= 255.0;
-      max *= 255.0;
+      x   *= tool->scale;
+      y   *= tool->scale;
+      min *= tool->scale;
+      max *= tool->scale;
 
       g_signal_handlers_block_by_func (tool->point_input,
                                        curves_point_coords_callback,
@@ -1087,8 +1105,8 @@ curves_point_coords_callback (GtkWidget      *widget,
       x = gtk_spin_button_get_value (GTK_SPIN_BUTTON (tool->point_input));
       y = gtk_spin_button_get_value (GTK_SPIN_BUTTON (tool->point_output));
 
-      x /= 255.0;
-      y /= 255.0;
+      x /= tool->scale;
+      y /= tool->scale;
 
       gimp_curve_set_point (curve, point, x, y);
     }
diff --git a/app/tools/gimpcurvestool.h b/app/tools/gimpcurvestool.h
index e80f776cb7..8d3ba8b577 100644
--- a/app/tools/gimpcurvestool.h
+++ b/app/tools/gimpcurvestool.h
@@ -37,6 +37,7 @@ struct _GimpCurvesTool
   GimpFilterTool  parent_instance;
 
   /* dialog */
+  gdouble           scale;
   gdouble           picked_color[5];
 
   GtkWidget        *channel_menu;


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