mirror of https://github.com/GNOME/gimp.git
app: GimpCurveView using GeglColor.
This commit is contained in:
parent
20b9f9bc06
commit
ae31cf0b18
|
@ -63,76 +63,75 @@
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static gboolean gimp_curves_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *display,
|
||||
GError **error);
|
||||
static void gimp_curves_tool_button_release (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpButtonReleaseType release_type,
|
||||
GimpDisplay *display);
|
||||
static gboolean gimp_curves_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display);
|
||||
static void gimp_curves_tool_oper_update (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display);
|
||||
static gboolean gimp_curves_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *display,
|
||||
GError **error);
|
||||
static void gimp_curves_tool_button_release (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpButtonReleaseType release_type,
|
||||
GimpDisplay *display);
|
||||
static gboolean gimp_curves_tool_key_press (GimpTool *tool,
|
||||
GdkEventKey *kevent,
|
||||
GimpDisplay *display);
|
||||
static void gimp_curves_tool_oper_update (GimpTool *tool,
|
||||
const GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display);
|
||||
|
||||
static gchar * gimp_curves_tool_get_operation (GimpFilterTool *filter_tool,
|
||||
static gchar * gimp_curves_tool_get_operation (GimpFilterTool *filter_tool,
|
||||
gchar **description);
|
||||
static void gimp_curves_tool_dialog (GimpFilterTool *filter_tool);
|
||||
static void gimp_curves_tool_reset (GimpFilterTool *filter_tool);
|
||||
static void gimp_curves_tool_config_notify (GimpFilterTool *filter_tool,
|
||||
GimpConfig *config,
|
||||
const GParamSpec *pspec);
|
||||
static gboolean gimp_curves_tool_settings_import (GimpFilterTool *filter_tool,
|
||||
GInputStream *input,
|
||||
GError **error);
|
||||
static gboolean gimp_curves_tool_settings_export (GimpFilterTool *filter_tool,
|
||||
GOutputStream *output,
|
||||
GError **error);
|
||||
static void gimp_curves_tool_color_picked (GimpFilterTool *filter_tool,
|
||||
gpointer identifier,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
const Babl *sample_format,
|
||||
const GimpRGB *color);
|
||||
static void gimp_curves_tool_dialog (GimpFilterTool *filter_tool);
|
||||
static void gimp_curves_tool_reset (GimpFilterTool *filter_tool);
|
||||
static void gimp_curves_tool_config_notify (GimpFilterTool *filter_tool,
|
||||
GimpConfig *config,
|
||||
const GParamSpec *pspec);
|
||||
static gboolean gimp_curves_tool_settings_import (GimpFilterTool *filter_tool,
|
||||
GInputStream *input,
|
||||
GError **error);
|
||||
static gboolean gimp_curves_tool_settings_export (GimpFilterTool *filter_tool,
|
||||
GOutputStream *output,
|
||||
GError **error);
|
||||
static void gimp_curves_tool_color_picked (GimpFilterTool *filter_tool,
|
||||
gpointer identifier,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
const Babl *sample_format,
|
||||
const GimpRGB *color);
|
||||
|
||||
static void gimp_curves_tool_export_setup (GimpSettingsBox *settings_box,
|
||||
GtkFileChooserDialog *dialog,
|
||||
gboolean export,
|
||||
GimpCurvesTool *tool);
|
||||
static void gimp_curves_tool_update_channel (GimpCurvesTool *tool);
|
||||
static void gimp_curves_tool_update_point (GimpCurvesTool *tool);
|
||||
static void gimp_curves_tool_export_setup (GimpSettingsBox *settings_box,
|
||||
GtkFileChooserDialog *dialog,
|
||||
gboolean export,
|
||||
GimpCurvesTool *tool);
|
||||
static void gimp_curves_tool_update_channel (GimpCurvesTool *tool);
|
||||
static void gimp_curves_tool_update_point (GimpCurvesTool *tool);
|
||||
|
||||
static void curves_curve_dirty_callback (GimpCurve *curve,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_curve_dirty_callback (GimpCurve *curve,
|
||||
GimpCurvesTool *tool);
|
||||
|
||||
static void curves_channel_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_channel_reset_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_channel_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_channel_reset_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
|
||||
static gboolean curves_menu_sensitivity (gint value,
|
||||
gpointer data);
|
||||
static gboolean curves_menu_sensitivity (gint value,
|
||||
gpointer data);
|
||||
|
||||
static void curves_graph_selection_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_graph_selection_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
|
||||
static void curves_point_coords_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_point_type_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_point_coords_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_point_type_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
|
||||
static void curves_curve_type_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
static void curves_curve_type_callback (GtkWidget *widget,
|
||||
GimpCurvesTool *tool);
|
||||
|
||||
static gboolean curves_get_channel_color (GtkWidget *widget,
|
||||
GimpHistogramChannel channel,
|
||||
GimpRGB *color);
|
||||
static GeglColor * curves_get_channel_color (GtkWidget *widget,
|
||||
GimpHistogramChannel channel);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpCurvesTool, gimp_curves_tool, GIMP_TYPE_FILTER_TOOL)
|
||||
|
@ -893,22 +892,17 @@ gimp_curves_tool_update_channel (GimpCurvesTool *tool)
|
|||
channel <= GIMP_HISTOGRAM_ALPHA;
|
||||
channel++)
|
||||
{
|
||||
GimpRGB curve_color;
|
||||
gboolean has_color;
|
||||
GeglColor *curve_color;
|
||||
|
||||
has_color = curves_get_channel_color (tool->graph, channel, &curve_color);
|
||||
curve_color = curves_get_channel_color (tool->graph, channel);
|
||||
|
||||
if (channel == config->channel)
|
||||
{
|
||||
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), curve,
|
||||
has_color ? &curve_color : NULL);
|
||||
}
|
||||
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), curve, curve_color);
|
||||
else
|
||||
{
|
||||
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
|
||||
config->curve[channel],
|
||||
has_color ? &curve_color : NULL);
|
||||
}
|
||||
gimp_curve_view_add_background (GIMP_CURVE_VIEW (tool->graph),
|
||||
config->curve[channel], curve_color);
|
||||
|
||||
g_clear_object (&curve_color);
|
||||
}
|
||||
|
||||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->curve_type),
|
||||
|
@ -1126,12 +1120,11 @@ curves_curve_type_callback (GtkWidget *widget,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static GeglColor *
|
||||
curves_get_channel_color (GtkWidget *widget,
|
||||
GimpHistogramChannel channel,
|
||||
GimpRGB *color)
|
||||
GimpHistogramChannel channel)
|
||||
{
|
||||
static const GimpRGB channel_colors[GIMP_HISTOGRAM_RGB] =
|
||||
static const gdouble channel_colors[GIMP_HISTOGRAM_RGB][4] =
|
||||
{
|
||||
{ 0.0, 0.0, 0.0, 1.0 },
|
||||
{ 1.0, 0.0, 0.0, 1.0 },
|
||||
|
@ -1140,34 +1133,36 @@ curves_get_channel_color (GtkWidget *widget,
|
|||
{ 0.5, 0.5, 0.5, 1.0 }
|
||||
};
|
||||
|
||||
GdkRGBA rgba;
|
||||
GeglColor *color;
|
||||
GdkRGBA rgba;
|
||||
|
||||
if (channel == GIMP_HISTOGRAM_VALUE)
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
color = gegl_color_new (NULL);
|
||||
if (channel == GIMP_HISTOGRAM_ALPHA)
|
||||
{
|
||||
GtkStyleContext *style = gtk_widget_get_style_context (widget);
|
||||
gdouble lum;
|
||||
gdouble rgb[4];
|
||||
|
||||
gtk_style_context_get_color (style, gtk_style_context_get_state (style),
|
||||
&rgba);
|
||||
|
||||
lum = GIMP_RGB_LUMINANCE (rgba.red, rgba.green, rgba.blue);
|
||||
|
||||
rgb[3] = 1.0;
|
||||
if (lum > 0.5)
|
||||
{
|
||||
gimp_rgba_set (color, lum - 0.3, lum - 0.3, lum - 0.3, 1.0);
|
||||
}
|
||||
rgb[0] = rgb[1] = rgb[2] = lum - 0.3;
|
||||
else
|
||||
{
|
||||
gimp_rgba_set (color, lum + 0.3, lum + 0.3, lum + 0.3, 1.0);
|
||||
}
|
||||
rgb[0] = rgb[1] = rgb[2] = lum + 0.3;
|
||||
|
||||
return TRUE;
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A"), rgb);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
*color = channel_colors[channel];
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A"), channel_colors[channel]);
|
||||
|
||||
return TRUE;
|
||||
return color;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcurve.h"
|
||||
#include "core/gimpcurve-map.h"
|
||||
|
@ -67,7 +69,7 @@ enum
|
|||
typedef struct
|
||||
{
|
||||
GimpCurve *curve;
|
||||
GimpRGB color;
|
||||
GeglColor *color;
|
||||
gboolean color_set;
|
||||
} BGCurve;
|
||||
|
||||
|
@ -609,11 +611,11 @@ gimp_curve_view_draw (GtkWidget *widget,
|
|||
|
||||
if (bg->color_set)
|
||||
{
|
||||
cairo_set_source_rgba (cr,
|
||||
bg->color.r,
|
||||
bg->color.g,
|
||||
bg->color.b,
|
||||
0.5);
|
||||
GeglColor *color = gegl_color_duplicate (bg->color);
|
||||
|
||||
gimp_color_set_alpha (color, 0.5);
|
||||
gimp_cairo_set_source_color (cr, color, view->gimp->config->color_management, FALSE, widget);
|
||||
g_object_unref (color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -630,7 +632,7 @@ gimp_curve_view_draw (GtkWidget *widget,
|
|||
|
||||
/* Draw the curve */
|
||||
if (view->curve_color)
|
||||
gimp_cairo_set_source_rgb (cr, view->curve_color);
|
||||
gimp_cairo_set_source_color (cr, view->curve_color, view->gimp->config->color_management, FALSE, widget);
|
||||
else
|
||||
gdk_cairo_set_source_rgba (cr, &fg_color);
|
||||
|
||||
|
@ -1278,7 +1280,7 @@ gimp_curve_view_new (void)
|
|||
void
|
||||
gimp_curve_view_set_curve (GimpCurveView *view,
|
||||
GimpCurve *curve,
|
||||
const GimpRGB *color)
|
||||
GeglColor *color)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CURVE_VIEW (view));
|
||||
g_return_if_fail (curve == NULL || GIMP_IS_CURVE (curve));
|
||||
|
@ -1310,11 +1312,9 @@ gimp_curve_view_set_curve (GimpCurveView *view,
|
|||
view);
|
||||
}
|
||||
|
||||
if (view->curve_color)
|
||||
g_free (view->curve_color);
|
||||
|
||||
g_clear_object (&view->curve_color);
|
||||
if (color)
|
||||
view->curve_color = g_memdup2 (color, sizeof (GimpRGB));
|
||||
view->curve_color = gegl_color_duplicate (color);
|
||||
else
|
||||
view->curve_color = NULL;
|
||||
|
||||
|
@ -1334,7 +1334,7 @@ gimp_curve_view_get_curve (GimpCurveView *view)
|
|||
void
|
||||
gimp_curve_view_add_background (GimpCurveView *view,
|
||||
GimpCurve *curve,
|
||||
const GimpRGB *color)
|
||||
GeglColor *color)
|
||||
{
|
||||
GList *list;
|
||||
BGCurve *bg;
|
||||
|
@ -1355,7 +1355,7 @@ gimp_curve_view_add_background (GimpCurveView *view,
|
|||
|
||||
if (color)
|
||||
{
|
||||
bg->color = *color;
|
||||
bg->color = gegl_color_duplicate (color);
|
||||
bg->color_set = TRUE;
|
||||
}
|
||||
|
||||
|
@ -1386,6 +1386,7 @@ gimp_curve_view_remove_background (GimpCurveView *view,
|
|||
g_signal_handlers_disconnect_by_func (bg->curve,
|
||||
gimp_curve_view_curve_dirty,
|
||||
view);
|
||||
g_clear_object (&bg->color);
|
||||
g_object_unref (bg->curve);
|
||||
|
||||
view->bg_curves = g_list_remove (view->bg_curves, bg);
|
||||
|
@ -1414,6 +1415,7 @@ gimp_curve_view_remove_all_backgrounds (GimpCurveView *view)
|
|||
g_signal_handlers_disconnect_by_func (bg->curve,
|
||||
gimp_curve_view_curve_dirty,
|
||||
view);
|
||||
g_clear_object (&bg->color);
|
||||
g_object_unref (bg->curve);
|
||||
|
||||
view->bg_curves = g_list_remove (view->bg_curves, bg);
|
||||
|
|
|
@ -39,7 +39,7 @@ struct _GimpCurveView
|
|||
Gimp *gimp; /* only needed for copy & paste */
|
||||
|
||||
GimpCurve *curve;
|
||||
GimpRGB *curve_color;
|
||||
GeglColor *curve_color;
|
||||
|
||||
GList *bg_curves;
|
||||
|
||||
|
@ -97,12 +97,12 @@ GtkWidget * gimp_curve_view_new (void);
|
|||
|
||||
void gimp_curve_view_set_curve (GimpCurveView *view,
|
||||
GimpCurve *curve,
|
||||
const GimpRGB *color);
|
||||
GeglColor *color);
|
||||
GimpCurve * gimp_curve_view_get_curve (GimpCurveView *view);
|
||||
|
||||
void gimp_curve_view_add_background (GimpCurveView *view,
|
||||
GimpCurve *curve,
|
||||
const GimpRGB *color);
|
||||
GeglColor *color);
|
||||
void gimp_curve_view_remove_background (GimpCurveView *view,
|
||||
GimpCurve *curve);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ struct
|
|||
const gchar *use_property;
|
||||
const gchar *curve_property;
|
||||
const gchar *label;
|
||||
const GimpRGB color;
|
||||
const gdouble color[4];
|
||||
}
|
||||
inputs[] =
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ inputs[] =
|
|||
{ "use-fade", "fade-curve", N_("Fade"), { 0.5, 0.5, 0.5, 0.0 } }
|
||||
};
|
||||
|
||||
#define INPUT_COLOR(i) (inputs[(i)].color.a ? &inputs[(i)].color : NULL)
|
||||
#define INPUT_COLOR(i) (inputs[(i)].color[3] ? &inputs[(i)].color : NULL)
|
||||
|
||||
|
||||
typedef struct _GimpDynamicsOutputEditorPrivate GimpDynamicsOutputEditorPrivate;
|
||||
|
@ -408,16 +408,18 @@ gimp_dynamics_output_editor_activate_input (GimpDynamicsOutputEditor *editor,
|
|||
{
|
||||
gboolean use_input;
|
||||
GimpCurve *input_curve;
|
||||
GeglColor *color = gegl_color_new (NULL);
|
||||
|
||||
g_object_get (private->output,
|
||||
inputs[i].use_property, &use_input,
|
||||
inputs[i].curve_property, &input_curve,
|
||||
NULL);
|
||||
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), INPUT_COLOR (i));
|
||||
if (input == i)
|
||||
{
|
||||
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (private->curve_view),
|
||||
input_curve, INPUT_COLOR (i));
|
||||
input_curve, color);
|
||||
private->active_curve = input_curve;
|
||||
|
||||
gimp_curve_view_set_x_axis_label (GIMP_CURVE_VIEW (private->curve_view),
|
||||
|
@ -426,10 +428,11 @@ gimp_dynamics_output_editor_activate_input (GimpDynamicsOutputEditor *editor,
|
|||
else if (use_input)
|
||||
{
|
||||
gimp_curve_view_add_background (GIMP_CURVE_VIEW (private->curve_view),
|
||||
input_curve, INPUT_COLOR (i));
|
||||
input_curve, color);
|
||||
}
|
||||
|
||||
g_object_unref (input_curve);
|
||||
g_object_unref (color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,8 +468,12 @@ gimp_dynamics_output_editor_notify_output (GimpDynamicsOutput *output,
|
|||
{
|
||||
if (use_input)
|
||||
{
|
||||
GeglColor *color = gegl_color_new (NULL);
|
||||
|
||||
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), INPUT_COLOR (i));
|
||||
gimp_curve_view_add_background (GIMP_CURVE_VIEW (private->curve_view),
|
||||
input_curve, INPUT_COLOR (i));
|
||||
input_curve, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue