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



commit 168fa1509197e93a3dc826b927fa9f605ab62ced
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.
    
    (cherry picked from commit be719f9070a1143855e7da97bdd75e6313f62543)

 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 65c686962f..a56c0f412a 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);
 
@@ -594,6 +610,7 @@ gimp_curves_tool_dialog (GimpFilterTool *filter_tool)
 
   gtk_widget_show (table);
 
+  /*  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);
@@ -602,7 +619,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);
 
@@ -616,7 +633,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);
 
@@ -649,6 +666,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");
@@ -955,10 +973,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,
@@ -1091,8 +1109,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]