[gimp/gimp-2-8] Bug 750953 - The Curves dialog should present per channel lines...



commit f2405277820c09a131f3b90a7f0b0d9209643d31
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 15 00:11:13 2015 +0200

    Bug 750953 - The Curves dialog should present per channel lines...
    
    ...when opened by the "Edit these settings as Curves" button on the
    Levels dialog
    
    The code to configure the entire GUI correctly was not even called
    when initially creating the curves dialog (the color bars probably
    looked right just because of default values of their own).
    
    Factor out gimp_curves_tool_update_channel() which properly updates
    the GUI. Call it after the dialog has been created, and when the
    active channel changes.
    
    (cherry picked from commit 014cd08c5c15e0675c9af7b8724f358a13fb93d2)

 app/tools/gimpcurvestool.c |  142 +++++++++++++++++++++++---------------------
 1 files changed, 75 insertions(+), 67 deletions(-)
---
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index de565c5..f8c9a41 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -106,6 +106,7 @@ static void       gimp_curves_tool_export_setup   (GimpSettingsBox      *setting
                                                    GtkFileChooserDialog *dialog,
                                                    gboolean              export,
                                                    GimpCurvesTool       *tool);
+static void       gimp_curves_tool_update_channel (GimpCurvesTool       *tool);
 static void       gimp_curves_tool_config_notify  (GObject              *object,
                                                    GParamSpec           *pspec,
                                                    GimpCurvesTool       *tool);
@@ -533,9 +534,6 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
                 "border-width", RADIUS,
                 "subdivisions", 1,
                 NULL);
-  gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph),
-                             config->curve[config->channel],
-                             curves_get_channel_color (config->channel));
   gtk_container_add (GTK_CONTAINER (frame), tool->graph);
   gtk_widget_show (tool->graph);
 
@@ -587,6 +585,8 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
   gtk_widget_show (combo);
 
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
+
+  gimp_curves_tool_update_channel (tool);
 }
 
 static void
@@ -733,82 +733,90 @@ gimp_curves_tool_export_setup (GimpSettingsBox      *settings_box,
 }
 
 static void
-gimp_curves_tool_config_notify (GObject        *object,
-                                GParamSpec     *pspec,
-                                GimpCurvesTool *tool)
+gimp_curves_tool_update_channel (GimpCurvesTool *tool)
 {
-  GimpCurvesConfig *config = GIMP_CURVES_CONFIG (object);
-  GimpCurve        *curve  = config->curve[config->channel];
+  GimpCurvesConfig     *config = GIMP_CURVES_TOOL (tool)->config;
+  GimpCurve            *curve  = config->curve[config->channel];
+  GimpHistogramChannel  channel;
 
-  if (! tool->xrange)
-    return;
+  gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
+                                 config->channel);
 
-  if (! strcmp (pspec->name, "channel"))
+  switch (config->channel)
     {
-      GimpHistogramChannel channel;
+      guchar r[256];
+      guchar g[256];
+      guchar b[256];
 
-      gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
-                                     config->channel);
+    case GIMP_HISTOGRAM_VALUE:
+    case GIMP_HISTOGRAM_ALPHA:
+    case GIMP_HISTOGRAM_RGB:
+      gimp_curve_get_uchar (curve, sizeof (r), r);
 
-      switch (config->channel)
-        {
-          guchar r[256];
-          guchar g[256];
-          guchar b[256];
-
-        case GIMP_HISTOGRAM_VALUE:
-        case GIMP_HISTOGRAM_ALPHA:
-        case GIMP_HISTOGRAM_RGB:
-          gimp_curve_get_uchar (curve, sizeof (r), r);
-
-          gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
-                                      r, r, r);
-          break;
-
-        case GIMP_HISTOGRAM_RED:
-        case GIMP_HISTOGRAM_GREEN:
-        case GIMP_HISTOGRAM_BLUE:
-          gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_RED],
-                                sizeof (r), r);
-          gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_GREEN],
-                                sizeof (g), g);
-          gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_BLUE],
-                                sizeof (b), b);
-
-          gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
-                                      r, g, b);
-          break;
-        }
+      gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
+                                  r, r, r);
+      break;
+
+    case GIMP_HISTOGRAM_RED:
+    case GIMP_HISTOGRAM_GREEN:
+    case GIMP_HISTOGRAM_BLUE:
+      gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_RED],
+                            sizeof (r), r);
+      gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_GREEN],
+                            sizeof (g), g);
+      gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_BLUE],
+                            sizeof (b), b);
+
+      gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
+                                  r, g, b);
+      break;
+    }
 
-      gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->graph),
-                                       config->channel);
-      gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
-                                tool->picked_color[config->channel]);
+  gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->graph),
+                                   config->channel);
+  gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
+                            tool->picked_color[config->channel]);
 
-      gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->yrange),
-                                  config->channel);
+  gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->yrange),
+                              config->channel);
 
-      gimp_curve_view_remove_all_backgrounds (GIMP_CURVE_VIEW (tool->graph));
+  gimp_curve_view_remove_all_backgrounds (GIMP_CURVE_VIEW (tool->graph));
 
-      for (channel = GIMP_HISTOGRAM_VALUE;
-           channel <= GIMP_HISTOGRAM_ALPHA;
-           channel++)
+  for (channel = GIMP_HISTOGRAM_VALUE;
+       channel <= GIMP_HISTOGRAM_ALPHA;
+       channel++)
+    {
+      if (channel == config->channel)
+        {
+          gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), curve,
+                                     curves_get_channel_color (channel));
+        }
+      else
         {
-          if (channel == config->channel)
-            {
-              gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), curve,
-                                         curves_get_channel_color (channel));
-            }
-          else
-            {
-              gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
-                                              config->curve[channel],
-                                              curves_get_channel_color (channel));
-            }
+          gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
+                                          config->curve[channel],
+                                          curves_get_channel_color (channel));
         }
+    }
 
-      gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->curve_type),
-                                     curve->curve_type);
+  gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->curve_type),
+                                 curve->curve_type);
+}
+
+static void
+gimp_curves_tool_config_notify (GObject        *object,
+                                GParamSpec     *pspec,
+                                GimpCurvesTool *tool)
+{
+  GimpCurvesConfig *config = GIMP_CURVES_CONFIG (object);
+  GimpCurve        *curve  = config->curve[config->channel];
+
+  if (! tool->xrange)
+    return;
+
+  if (! strcmp (pspec->name, "channel"))
+    {
+      gimp_curves_tool_update_channel (GIMP_CURVES_TOOL (tool));
     }
   else if (! strcmp (pspec->name, "curve"))
     {


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