Commit ec196a8a authored by Michael Natterer's avatar Michael Natterer 😴

app: allow to set a color for GimpCurveView's primary curve

and redo how the curves tool sets its curves in order to support this
without code duplication. Also change the color of the yellow curve in
the dynamics output editor to orange because yellow is hardly visible.
parent b5a706b3
......@@ -125,6 +125,15 @@ 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 */
......@@ -531,7 +540,8 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
"subdivisions", 1,
NULL);
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph),
config->curve[config->channel]);
config->curve[config->channel],
&channel_colors[config->channel]);
gtk_container_add (GTK_CONTAINER (frame), tool->graph);
gtk_widget_show (tool->graph);
......@@ -740,9 +750,7 @@ gimp_curves_tool_config_notify (GObject *object,
if (! strcmp (pspec->name, "channel"))
{
GimpRGB red;
GimpRGB green;
GimpRGB blue;
GimpHistogramChannel channel;
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
config->channel);
......@@ -787,45 +795,23 @@ gimp_curves_tool_config_notify (GObject *object,
gimp_curve_view_remove_all_backgrounds (GIMP_CURVE_VIEW (tool->graph));
gimp_rgb_set (&red, 1.0, 0.0, 0.0);
gimp_rgb_set (&green, 0.0, 1.0, 0.0);
gimp_rgb_set (&blue, 0.0, 0.0, 1.0);
switch (config->channel)
for (channel = GIMP_HISTOGRAM_VALUE;
channel <= GIMP_HISTOGRAM_ALPHA;
channel++)
{
case GIMP_HISTOGRAM_RED:
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
config->curve[GIMP_HISTOGRAM_GREEN],
&green);
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
config->curve[GIMP_HISTOGRAM_BLUE],
&blue);
break;
case GIMP_HISTOGRAM_GREEN:
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
config->curve[GIMP_HISTOGRAM_RED],
&red);
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
config->curve[GIMP_HISTOGRAM_BLUE],
&blue);
break;
case GIMP_HISTOGRAM_BLUE:
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
config->curve[GIMP_HISTOGRAM_RED],
&red);
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
config->curve[GIMP_HISTOGRAM_GREEN],
&green);
break;
default:
break;
if (channel == config->channel)
{
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), curve,
&channel_colors[channel]);
}
else
{
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
config->curve[channel],
&channel_colors[channel]);
}
}
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), curve);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->curve_type),
curve->curve_type);
}
......
......@@ -24,6 +24,7 @@
#include "libgimpconfig/gimpconfig.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
......@@ -242,7 +243,7 @@ gimp_curve_view_dispose (GObject *object)
{
GimpCurveView *view = GIMP_CURVE_VIEW (object);
gimp_curve_view_set_curve (view, NULL);
gimp_curve_view_set_curve (view, NULL, NULL);
if (view->bg_curves)
gimp_curve_view_remove_all_backgrounds (view);
......@@ -513,7 +514,10 @@ gimp_curve_view_expose (GtkWidget *widget,
}
/* Draw the curve */
gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
if (view->curve_color)
gimp_cairo_set_source_rgb (cr, view->curve_color);
else
gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]);
gimp_curve_view_draw_curve (view, cr, view->curve,
width, height, border);
......@@ -1088,7 +1092,8 @@ gimp_curve_view_curve_dirty (GimpCurve *curve,
void
gimp_curve_view_set_curve (GimpCurveView *view,
GimpCurve *curve)
GimpCurve *curve,
const GimpRGB *color)
{
g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
g_return_if_fail (curve == NULL || GIMP_IS_CURVE (curve));
......@@ -1114,6 +1119,14 @@ gimp_curve_view_set_curve (GimpCurveView *view,
view);
}
if (view->curve_color)
g_free (view->curve_color);
if (color)
view->curve_color = g_memdup (color, sizeof (GimpRGB));
else
view->curve_color = NULL;
gtk_widget_queue_draw (GTK_WIDGET (view));
}
......
......@@ -39,6 +39,7 @@ struct _GimpCurveView
Gimp *gimp; /* only needed for copy & paste */
GimpCurve *curve;
GimpRGB *curve_color;
GList *bg_curves;
......@@ -84,7 +85,8 @@ GType gimp_curve_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_curve_view_new (void);
void gimp_curve_view_set_curve (GimpCurveView *view,
GimpCurve *curve);
GimpCurve *curve,
const GimpRGB *color);
GimpCurve * gimp_curve_view_get_curve (GimpCurveView *view);
void gimp_curve_view_add_background (GimpCurveView *view,
......
......@@ -448,7 +448,7 @@ gimp_device_info_editor_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (frame), view);
gtk_widget_show (view);
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (view), curve);
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (view), curve, NULL);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_set_spacing (GTK_BOX (hbox), 6);
......
......@@ -68,7 +68,7 @@ inputs[] =
{ "use-pressure", "pressure-curve", N_("Pressure"), { 1.0, 0.0, 0.0, 1.0 } },
{ "use-velocity", "velocity-curve", N_("Velocity"), { 0.0, 1.0, 0.0, 1.0 } },
{ "use-direction", "direction-curve", N_("Direction"), { 0.0, 0.0, 1.0, 1.0 } },
{ "use-tilt", "tilt-curve", N_("Tilt"), { 1.0, 1.0, 0.0, 1.0 } },
{ "use-tilt", "tilt-curve", N_("Tilt"), { 1.0, 0.5, 0.0, 1.0 } },
{ "use-wheel", "wheel-curve", N_("Wheel"), { 1.0, 0.0, 1.0, 1.0 } },
{ "use-random", "random-curve", N_("Random"), { 0.0, 1.0, 1.0, 1.0 } },
{ "use-fade", "fade-curve", N_("Fade"), { 0.2, 0.2, 0.2, 1.0 } }
......@@ -394,7 +394,7 @@ gimp_dynamics_output_editor_activate_input (GimpDynamicsOutputEditor *editor,
GimpDynamicsOutputEditorPrivate *private = GET_PRIVATE (editor);
gint i;
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (private->curve_view), NULL);
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (private->curve_view), NULL, NULL);
gimp_curve_view_remove_all_backgrounds (GIMP_CURVE_VIEW (private->curve_view));
for (i = 0; i < G_N_ELEMENTS (inputs); i++)
......@@ -410,7 +410,7 @@ gimp_dynamics_output_editor_activate_input (GimpDynamicsOutputEditor *editor,
if (input == i)
{
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (private->curve_view),
input_curve);
input_curve, &inputs[i].color);
private->active_curve = input_curve;
}
else if (use_input)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment