[gimp] Bug 737008 - Curve color always black
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 737008 - Curve color always black
- Date: Sun, 21 Sep 2014 10:32:40 +0000 (UTC)
commit 90c967a39fc20203274f1f8a1948de3d537bf113
Author: Michael Natterer <mitch gimp org>
Date: Sun Sep 21 12:29:35 2014 +0200
Bug 737008 - Curve color always black
Don't hardcode "black" for the "Value" curve in GimpCurvesTool.
Instead, pass a NULL color to GimpCurveView, which is then interpreted
as the theme's text color (the curve's background is the theme's text
background color). We still hardcode pure red, green and blue for the
other curves.
app/tools/gimpcurvestool.c | 35 +++++++++++++++++++++++------------
app/widgets/gimpcurveview.c | 30 +++++++++++++++++++++++-------
2 files changed, 46 insertions(+), 19 deletions(-)
---
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index fecdf8b..c301439 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -118,20 +118,13 @@ static gboolean curves_menu_sensitivity (gint value,
static void curves_curve_type_callback (GtkWidget *widget,
GimpCurvesTool *tool);
+static const GimpRGB * curves_get_channel_color (GimpHistogramChannel channel);
+
G_DEFINE_TYPE (GimpCurvesTool, gimp_curves_tool, GIMP_TYPE_IMAGE_MAP_TOOL)
#define parent_class gimp_curves_tool_parent_class
-static GimpRGB channel_colors[GIMP_HISTOGRAM_RGB] =
-{
- { 0.0, 0.0, 0.0, 1.0 },
- { 1.0, 0.0, 0.0, 1.0 },
- { 0.0, 1.0, 0.0, 1.0 },
- { 0.0, 0.0, 1.0, 1.0 },
- { 0.5, 0.5, 0.5, 1.0 }
-};
-
/* public functions */
@@ -502,7 +495,7 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
NULL);
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph),
config->curve[config->channel],
- &channel_colors[config->channel]);
+ curves_get_channel_color (config->channel));
gtk_container_add (GTK_CONTAINER (frame), tool->graph);
gtk_widget_show (tool->graph);
@@ -721,13 +714,13 @@ gimp_curves_tool_config_notify (GObject *object,
if (channel == config->channel)
{
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), curve,
- &channel_colors[channel]);
+ curves_get_channel_color (channel));
}
else
{
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
config->curve[channel],
- &channel_colors[channel]);
+ curves_get_channel_color (channel));
}
}
@@ -806,3 +799,21 @@ curves_curve_type_callback (GtkWidget *widget,
gimp_curve_set_curve_type (config->curve[config->channel], curve_type);
}
}
+
+static const GimpRGB *
+curves_get_channel_color (GimpHistogramChannel channel)
+{
+ static const GimpRGB channel_colors[GIMP_HISTOGRAM_RGB] =
+ {
+ { 0.0, 0.0, 0.0, 1.0 },
+ { 1.0, 0.0, 0.0, 1.0 },
+ { 0.0, 1.0, 0.0, 1.0 },
+ { 0.0, 0.0, 1.0, 1.0 },
+ { 0.5, 0.5, 0.5, 1.0 }
+ };
+
+ if (channel == GIMP_HISTOGRAM_VALUE)
+ return NULL;
+
+ return &channel_colors[channel];
+}
diff --git a/app/widgets/gimpcurveview.c b/app/widgets/gimpcurveview.c
index b0e5c21..7b7ef47 100644
--- a/app/widgets/gimpcurveview.c
+++ b/app/widgets/gimpcurveview.c
@@ -63,6 +63,7 @@ typedef struct
{
GimpCurve *curve;
GimpRGB color;
+ gboolean color_set;
} BGCurve;
@@ -586,11 +587,22 @@ gimp_curve_view_expose (GtkWidget *widget,
{
BGCurve *bg = list->data;
- cairo_set_source_rgba (cr,
- bg->color.r,
- bg->color.g,
- bg->color.b,
- 0.5);
+ if (bg->color_set)
+ {
+ cairo_set_source_rgba (cr,
+ bg->color.r,
+ bg->color.g,
+ bg->color.b,
+ 0.5);
+ }
+ else
+ {
+ cairo_set_source_rgba (cr,
+ style->text[GTK_STATE_NORMAL].red / 65535.0,
+ style->text[GTK_STATE_NORMAL].green / 65535.0,
+ style->text[GTK_STATE_NORMAL].blue / 65535.0,
+ 0.5);
+ }
gimp_curve_view_draw_curve (view, cr, bg->curve,
width, height, border);
@@ -1255,7 +1267,6 @@ gimp_curve_view_add_background (GimpCurveView *view,
g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
g_return_if_fail (GIMP_IS_CURVE (curve));
- g_return_if_fail (color != NULL);
for (list = view->bg_curves; list; list = g_list_next (list))
{
@@ -1267,7 +1278,12 @@ gimp_curve_view_add_background (GimpCurveView *view,
bg = g_slice_new0 (BGCurve);
bg->curve = g_object_ref (curve);
- bg->color = *color;
+
+ if (color)
+ {
+ bg->color = *color;
+ bg->color_set = TRUE;
+ }
g_signal_connect (bg->curve, "dirty",
G_CALLBACK (gimp_curve_view_curve_dirty),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]