static void gimp_blend_tool_cursor_update (GimpTool *tool, const GimpCoords *coords, GdkModifierType state, GimpDisplay *display) { GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool); GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE; blend_tool->mouse_x = coords->x; blend_tool->mouse_y = coords->y; if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) || gimp_item_is_content_locked (GIMP_ITEM (drawable)) || ! gimp_item_is_visible (GIMP_ITEM (drawable))) { modifier = GIMP_CURSOR_MODIFIER_BAD; } else if (gimp_blend_tool_is_shapeburst (blend_tool)) { modifier = GIMP_CURSOR_MODIFIER_PLUS; } else if (gimp_blend_tool_get_point_under_cursor (blend_tool)) { modifier = GIMP_CURSOR_MODIFIER_MOVE; } gimp_tool_control_set_cursor_modifier (tool->control, modifier); GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display); }
static void gimp_blend_tool_start (GimpBlendTool *blend_tool, GimpDisplay *display) { GimpTool *tool = GIMP_TOOL (blend_tool); GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool); GimpContext *context = GIMP_CONTEXT (options); tool->display = display; tool->drawable = drawable; gimp_blend_tool_create_filter (blend_tool, drawable); /* Initially sync all of the properties */ gimp_gegl_config_sync_node (GIMP_OBJECT (options), blend_tool->render_node); /* Connect signal handlers for the gradient */ gimp_blend_tool_set_gradient (blend_tool, context->gradient); if (gimp_blend_tool_is_shapeburst (blend_tool)) gimp_blend_tool_precalc_shapeburst (blend_tool); if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool))) gimp_draw_tool_start (GIMP_DRAW_TOOL (blend_tool), display); }
static void gimp_blend_tool_button_press (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpButtonPressType press_type, GimpDisplay *display) { GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool); if (tool->display && display != tool->display) { gimp_tool_pop_status (tool, tool->display); gimp_blend_tool_halt (blend_tool); } blend_tool->grabbed_point = gimp_blend_tool_get_point_under_cursor (blend_tool); if (blend_tool->grabbed_point == POINT_NONE && ! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool))) { blend_tool->start_x = coords->x; blend_tool->start_y = coords->y; if (gimp_blend_tool_is_shapeburst (blend_tool)) { blend_tool->grabbed_point = POINT_FILL_MODE; } else { blend_tool->grabbed_point = POINT_INIT_MODE; } } else if ((state & GDK_MOD1_MASK) && gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool))) { blend_tool->grabbed_point = POINT_BOTH; } gimp_blend_tool_point_motion (blend_tool, state & gimp_get_constrain_behavior_mask ()); tool->display = display; gimp_blend_tool_update_items (blend_tool); if (blend_tool->grabbed_point != POINT_FILL_MODE && blend_tool->grabbed_point != POINT_INIT_MODE) { gimp_blend_tool_update_graph (blend_tool); gimp_drawable_filter_apply (blend_tool->filter, NULL); } gimp_tool_control_activate (tool->control); gimp_blend_tool_push_status (blend_tool, state, display); }
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)); } }
static void gimp_blend_tool_update_graph (GimpBlendTool *blend_tool) { GimpTool *tool = GIMP_TOOL (blend_tool); gint off_x, off_y; gimp_item_get_offset (GIMP_ITEM (tool->drawable), &off_x, &off_y); #if 0 if (gimp_blend_tool_is_shapeburst (blend_tool)) { gfloat start, end; gegl_buffer_get (blend_tool->dist_buffer, GEGL_RECTANGLE (blend_tool->start_x - off_x, blend_tool->start_y - off_y, 1, 1), 1.0, babl_format("Y float"), &start, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); gegl_buffer_get (blend_tool->dist_buffer, GEGL_RECTANGLE (blend_tool->end_x - off_x, blend_tool->end_y - off_y, 1, 1), 1.0, babl_format("Y float"), &end, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); if (start != end) { gegl_node_set (blend_tool->subtract_node, "value", (gdouble) start, NULL); gegl_node_set (blend_tool->divide_node, "value", (gdouble) (end - start), NULL); } } else #endif { gegl_node_set (blend_tool->render_node, "start_x", blend_tool->start_x - off_x, "start_y", blend_tool->start_y - off_y, "end_x", blend_tool->end_x - off_x, "end_y", blend_tool->end_y - off_y, NULL); } }
static void gimp_blend_tool_button_press (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpButtonPressType press_type, GimpDisplay *display) { GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool); GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); blend_tool->mouse_x = coords->x; blend_tool->mouse_y = coords->y; if (tool->display && display != tool->display) { gimp_tool_pop_status (tool, tool->display); gimp_blend_tool_halt_preview (blend_tool); } gimp_draw_tool_pause (draw_tool); blend_tool->grabbed_point = gimp_blend_tool_get_point_under_cursor (blend_tool); if (blend_tool->grabbed_point == POINT_NONE) { if (gimp_draw_tool_is_active (draw_tool)) { gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display); gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display); } if (gimp_blend_tool_is_shapeburst (blend_tool)) { blend_tool->grabbed_point = POINT_FILL_MODE; } else { blend_tool->grabbed_point = POINT_INIT_MODE; blend_tool->start_x = coords->x; blend_tool->start_y = coords->y; } } gimp_blend_tool_point_motion (blend_tool, state & gimp_get_constrain_behavior_mask ()); tool->display = display; gimp_draw_tool_resume (draw_tool); if (blend_tool->grabbed_point != POINT_FILL_MODE && blend_tool->grabbed_point != POINT_INIT_MODE) { gimp_blend_tool_update_preview_coords (blend_tool); gimp_image_map_apply (blend_tool->image_map, NULL); } gimp_tool_control_activate (tool->control); gimp_blend_tool_push_status (blend_tool, state, display); }