static void gimp_blend_tool_create_filter (GimpBlendTool *blend_tool, GimpDrawable *drawable) { GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool); GimpContext *context = GIMP_CONTEXT (options); if (! blend_tool->graph) gimp_blend_tool_create_graph (blend_tool); blend_tool->filter = gimp_drawable_filter_new (drawable, C_("undo-type", "Blend"), blend_tool->graph, GIMP_STOCK_TOOL_BLEND); 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); }
static void gimp_blend_tool_options_notify (GimpTool *tool, GimpToolOptions *options, const GParamSpec *pspec) { GimpContext *context = GIMP_CONTEXT (options); GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool); if (! strcmp (pspec->name, "gradient")) { gimp_blend_tool_set_gradient (blend_tool, context->gradient); if (blend_tool->filter) gimp_drawable_filter_apply (blend_tool->filter, NULL); } else if (blend_tool->render_node && gegl_node_find_property (blend_tool->render_node, pspec->name)) { /* 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); gegl_node_set_property (blend_tool->render_node, pspec->name, &value); g_value_unset (&value); if (! strcmp (pspec->name, "gradient-type")) { if (gimp_blend_tool_is_shapeburst (blend_tool)) gimp_blend_tool_precalc_shapeburst (blend_tool); gimp_blend_tool_update_graph (blend_tool); } gimp_drawable_filter_apply (blend_tool->filter, NULL); } else if (blend_tool->filter && ! 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_paint_mode (context)); } }
void gimp_drawable_edit_fill (GimpDrawable *drawable, GimpFillOptions *options, const gchar *undo_desc) { GimpContext *context; gint x, y, width, height; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable))); g_return_if_fail (GIMP_IS_FILL_OPTIONS (options)); if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height)) { return; /* nothing to do, but the fill succeeded */ } context = GIMP_CONTEXT (options); if (gimp_layer_mode_is_alpha_only (gimp_context_get_paint_mode (context))) { if (! gimp_drawable_has_alpha (drawable) || ! (gimp_drawable_get_active_mask (drawable) & GIMP_COMPONENT_MASK_ALPHA)) { return; /* nothing to do, but the fill succeeded */ } } if (! undo_desc) undo_desc = gimp_fill_options_get_undo_desc (options); /* check if we can fill the drawable's buffer directly */ if (gimp_drawable_edit_can_fill_direct (drawable, options)) { gimp_drawable_edit_fill_direct (drawable, options, undo_desc); gimp_drawable_update (drawable, x, y, width, height); } else { GeglNode *operation; GimpDrawableFilter *filter; gdouble opacity; GimpLayerMode mode; GimpLayerMode composite_mode; opacity = gimp_context_get_opacity (context); mode = gimp_context_get_paint_mode (context); composite_mode = gimp_layer_mode_get_paint_composite_mode (mode); operation = gegl_node_new_child (NULL, "operation", "gimp:fill-source", "options", options, "drawable", drawable, "pattern-offset-x", -x, "pattern-offset-y", -y, NULL); filter = gimp_drawable_filter_new (drawable, undo_desc, operation, NULL); gimp_drawable_filter_set_opacity (filter, opacity); gimp_drawable_filter_set_mode (filter, mode, GIMP_LAYER_COLOR_SPACE_AUTO, GIMP_LAYER_COLOR_SPACE_AUTO, composite_mode); gimp_drawable_filter_apply (filter, NULL); gimp_drawable_filter_commit (filter, NULL, FALSE); g_object_unref (filter); g_object_unref (operation); } }