[gimp/gtk3-port: 381/457] app: undeprecate GimpLevelsTool



commit 65a96886c154b61a3a7b143d79f519dc09b98a95
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 8 23:32:48 2018 +0200

    app: undeprecate GimpLevelsTool
    
    by using some semi-smart luminance magic to get a distinct color for
    the alpha curve.

 app/tools/gimpcurvestool.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index 8c3d05d..b54c506 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -912,21 +912,34 @@ curves_get_channel_color (GtkWidget            *widget,
     { 0.5, 0.5, 0.5, 1.0 }
   };
 
+  GdkRGBA rgba;
+
   if (channel == GIMP_HISTOGRAM_VALUE)
     return FALSE;
 
   if (channel == GIMP_HISTOGRAM_ALPHA)
     {
-      GtkStyle *style = gtk_widget_get_style (widget);
+      GtkStyleContext *style = gtk_widget_get_style_context (widget);
+      gdouble          lum;
+
+      gtk_style_context_get_color (style, gtk_style_context_get_state (style),
+                                   &rgba);
+
+      lum = GIMP_RGB_LUMINANCE (rgba.red, rgba.green, rgba.blue);
+
+      if (lum > 0.5)
+        {
+          gimp_rgba_set (color, lum - 0.3, lum - 0.3, lum - 0.3, 1.0);
+        }
+      else
+        {
+          gimp_rgba_set (color, lum + 0.3, lum + 0.3, lum + 0.3, 1.0);
+        }
 
-      gimp_rgba_set (color,
-                     style->text_aa[GTK_STATE_NORMAL].red / 65535.0,
-                     style->text_aa[GTK_STATE_NORMAL].green / 65535.0,
-                     style->text_aa[GTK_STATE_NORMAL].blue / 65535.0,
-                     1.0);
       return TRUE;
     }
 
   *color = channel_colors[channel];
+
   return TRUE;
 }


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