Commit 201b11e2 authored by Michael Natterer's avatar Michael Natterer 😴

app: add separate opacity and mode API to GimpDrawableFilter

parent 265dfec5
......@@ -86,6 +86,7 @@ static void gimp_drawable_filter_sync_preview (GimpDrawableFilter *fi
gboolean old_enabled,
GimpAlignmentType old_alignment,
gdouble old_position);
static void gimp_drawable_filter_sync_opacity (GimpDrawableFilter *filter);
static void gimp_drawable_filter_sync_mode (GimpDrawableFilter *filter);
static void gimp_drawable_filter_sync_affect (GimpDrawableFilter *filter);
static void gimp_drawable_filter_sync_mask (GimpDrawableFilter *filter);
......@@ -297,17 +298,31 @@ gimp_drawable_filter_set_preview (GimpDrawableFilter *filter,
}
}
void
gimp_drawable_filter_set_opacity (GimpDrawableFilter *filter,
gdouble opacity)
{
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
if (opacity != filter->opacity)
{
filter->opacity = opacity;
gimp_drawable_filter_sync_opacity (filter);
if (gimp_drawable_filter_is_filtering (filter))
gimp_drawable_filter_update_drawable (filter, NULL);
}
}
void
gimp_drawable_filter_set_mode (GimpDrawableFilter *filter,
gdouble opacity,
GimpLayerModeEffects paint_mode)
{
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
if (opacity != filter->opacity ||
paint_mode != filter->paint_mode)
if (paint_mode != filter->paint_mode)
{
filter->opacity = opacity;
filter->paint_mode = paint_mode;
gimp_drawable_filter_sync_mode (filter);
......@@ -528,10 +543,15 @@ gimp_drawable_filter_sync_preview (GimpDrawableFilter *filter,
}
static void
gimp_drawable_filter_sync_mode (GimpDrawableFilter *filter)
gimp_drawable_filter_sync_opacity (GimpDrawableFilter *filter)
{
gimp_applicator_set_opacity (filter->applicator,
filter->opacity);
}
static void
gimp_drawable_filter_sync_mode (GimpDrawableFilter *filter)
{
gimp_applicator_set_mode (filter->applicator,
filter->paint_mode);
}
......@@ -647,6 +667,7 @@ gimp_drawable_filter_add_filter (GimpDrawableFilter *filter)
filter->preview_enabled,
filter->preview_alignment,
filter->preview_position);
gimp_drawable_filter_sync_opacity (filter);
gimp_drawable_filter_sync_mode (filter);
gimp_drawable_filter_sync_affect (filter);
gimp_drawable_filter_sync_gamma_hack (filter);
......
......@@ -61,8 +61,9 @@ void gimp_drawable_filter_set_preview (GimpDrawableFilter *filter,
gboolean enabled,
GimpAlignmentType alignment,
gdouble split_position);
void gimp_drawable_filter_set_opacity (GimpDrawableFilter *filter,
gdouble opacity);
void gimp_drawable_filter_set_mode (GimpDrawableFilter *filter,
gdouble opacity,
GimpLayerModeEffects paint_mode);
void gimp_drawable_filter_set_gamma_hack (GimpDrawableFilter *filter,
......
......@@ -608,6 +608,7 @@ gimp_blend_tool_options_notify (GimpTool *tool,
{
/* Sync any property changes on the config object that match the op */
GValue value = G_VALUE_INIT;
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (options), pspec->name, &value);
......@@ -626,11 +627,15 @@ gimp_blend_tool_options_notify (GimpTool *tool,
gimp_drawable_filter_apply (blend_tool->filter, NULL);
}
else if (blend_tool->filter &&
(! strcmp (pspec->name, "opacity") ||
! strcmp (pspec->name, "paint-mode")))
! strcmp (pspec->name, "opacity"))
{
gimp_drawable_filter_set_opacity (blend_tool->filter,
gimp_context_get_opacity (context));
}
else if (blend_tool->filter &&
! strcmp (pspec->name, "paint-mode"))
{
gimp_drawable_filter_set_mode (blend_tool->filter,
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context));
}
}
......@@ -1181,14 +1186,14 @@ gimp_blend_tool_create_filter (GimpBlendTool *blend_tool,
gimp_drawable_filter_set_region (blend_tool->filter,
GIMP_FILTER_REGION_DRAWABLE);
gimp_drawable_filter_set_opacity (blend_tool->filter,
gimp_context_get_opacity (context));
gimp_drawable_filter_set_mode (blend_tool->filter,
gimp_context_get_paint_mode (context));
g_signal_connect (blend_tool->filter, "flush",
G_CALLBACK (gimp_blend_tool_filter_flush),
blend_tool);
gimp_drawable_filter_set_mode (blend_tool->filter,
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context));
}
static void
......
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