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_update_item_hilight (GimpBlendTool *blend_tool) { GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (blend_tool); if (gimp_draw_tool_is_active (draw_tool)) { GimpBlendToolPoint hilight_point; gboolean start_visible, end_visible; /* Calculate handle visibility */ if (blend_tool->grabbed_point) { start_visible = FALSE; end_visible = FALSE; } else { gdouble dist; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->start_x, blend_tool->start_y); start_visible = dist < FULL_HANDLE_THRESHOLD_SQ; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->end_x, blend_tool->end_y); end_visible = dist < FULL_HANDLE_THRESHOLD_SQ; } gimp_canvas_item_set_visible (blend_tool->start_handle_circle, start_visible); gimp_canvas_item_set_visible (blend_tool->end_handle_circle, end_visible); /* Update hilights */ if (blend_tool->grabbed_point) hilight_point = blend_tool->grabbed_point; else hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool); gimp_canvas_item_set_highlight (blend_tool->start_handle_circle, hilight_point == POINT_START); gimp_canvas_item_set_highlight (blend_tool->start_handle_cross, hilight_point == POINT_START); gimp_canvas_item_set_highlight (blend_tool->end_handle_circle, hilight_point == POINT_END); gimp_canvas_item_set_highlight (blend_tool->end_handle_cross, hilight_point == POINT_END); } }
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_draw (GimpDrawTool *draw_tool) { GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (draw_tool); GimpCanvasItem *start_handle_cross, *end_handle_cross; gimp_draw_tool_add_line (draw_tool, blend_tool->start_x, blend_tool->start_y, blend_tool->end_x, blend_tool->end_y); start_handle_cross = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CROSS, blend_tool->start_x, blend_tool->start_y, HANDLE_CROSS_DIAMETER, HANDLE_CROSS_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); end_handle_cross = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CROSS, blend_tool->end_x, blend_tool->end_y, HANDLE_CROSS_DIAMETER, HANDLE_CROSS_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); GimpBlendToolPoint hilight_point; gboolean start_visible, end_visible; /* Calculate handle visibility */ if (blend_tool->grabbed_point) { start_visible = FALSE; end_visible = FALSE; } else { gdouble dist; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->start_x, blend_tool->start_y); start_visible = dist < FULL_HANDLE_THRESHOLD_SQ; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->end_x, blend_tool->end_y); end_visible = dist < FULL_HANDLE_THRESHOLD_SQ; } /* Update hilights */ if (blend_tool->grabbed_point) hilight_point = blend_tool->grabbed_point; else hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool); if (start_visible) { GimpCanvasItem *start_handle_circle; start_handle_circle = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CIRCLE, blend_tool->start_x, blend_tool->start_y, HANDLE_DIAMETER, HANDLE_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); gimp_canvas_item_set_highlight (start_handle_circle, hilight_point == POINT_START); } if (end_visible) { GimpCanvasItem *end_handle_circle; end_handle_circle = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CIRCLE, blend_tool->end_x, blend_tool->end_y, HANDLE_DIAMETER, HANDLE_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); gimp_canvas_item_set_highlight (end_handle_circle, hilight_point == POINT_END); } gimp_canvas_item_set_highlight (start_handle_cross, hilight_point == POINT_START); gimp_canvas_item_set_highlight (end_handle_cross, hilight_point == POINT_END); }
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); }
static void gimp_blend_tool_update_item_hilight (GimpBlendTool *blend_tool) { GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (blend_tool); if (gimp_draw_tool_is_active (draw_tool)) { GimpBlendToolPoint hilight_point; gboolean start_visible, end_visible; gint start_diameter, end_diameter; /* Calculate handle visibility */ if (blend_tool->grabbed_point) { start_visible = FALSE; end_visible = FALSE; } else { gdouble dist; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->start_x, blend_tool->start_y); start_diameter = calc_handle_diameter (dist); start_visible = start_diameter > 2; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->end_x, blend_tool->end_y); end_diameter = calc_handle_diameter (dist); end_visible = end_diameter > 2; } gimp_canvas_item_set_visible (blend_tool->start_handle_circle, start_visible); gimp_canvas_item_set_visible (blend_tool->end_handle_circle, end_visible); /* Update hilights */ if (blend_tool->grabbed_point) hilight_point = blend_tool->grabbed_point; else hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool); if (start_visible) { gimp_canvas_item_begin_change (blend_tool->start_handle_circle); g_object_set (blend_tool->start_handle_circle, "width", start_diameter, "height", start_diameter, NULL); gimp_canvas_item_end_change (blend_tool->start_handle_circle); } if (end_visible) { gimp_canvas_item_begin_change (blend_tool->end_handle_circle); g_object_set (blend_tool->end_handle_circle, "width", end_diameter, "height", end_diameter, NULL); gimp_canvas_item_end_change (blend_tool->end_handle_circle); } gimp_canvas_item_set_highlight (blend_tool->start_handle_circle, hilight_point == POINT_START); gimp_canvas_item_set_highlight (blend_tool->start_handle_cross, hilight_point == POINT_START); gimp_canvas_item_set_highlight (blend_tool->end_handle_circle, hilight_point == POINT_END); gimp_canvas_item_set_highlight (blend_tool->end_handle_cross, hilight_point == POINT_END); } }