static void gimp_foreground_select_tool_motion (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpDisplay *display) { GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool); if (fg_select->mask) { GimpVector2 *last = &g_array_index (fg_select->stroke, GimpVector2, fg_select->stroke->len - 1); gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); fg_select->last_coords = *coords; if (last->x != (gint) coords->x || last->y != (gint) coords->y) { GimpVector2 point = gimp_vector2_new (coords->x, coords->y); g_array_append_val (fg_select->stroke, point); } gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } else { GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display); } }
static void gimp_foreground_select_tool_button_press (GimpTool *tool, const GimpCoords *coords, guint32 time, GdkModifierType state, GimpButtonPressType press_type, GimpDisplay *display) { GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool); GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); if ((fg_select->state == MATTING_STATE_PAINT_TRIMAP) || (fg_select->state == MATTING_STATE_PREVIEW_MASK)) { GimpVector2 point = gimp_vector2_new (coords->x, coords->y); gimp_draw_tool_pause (draw_tool); if (gimp_draw_tool_is_active (draw_tool) && draw_tool->display != display) gimp_draw_tool_stop (draw_tool); gimp_tool_control_activate (tool->control); fg_select->last_coords = *coords; g_return_if_fail (fg_select->stroke == NULL); fg_select->stroke = g_array_new (FALSE, FALSE, sizeof (GimpVector2)); g_array_append_val (fg_select->stroke, point); if (!gimp_draw_tool_is_active (draw_tool)) gimp_draw_tool_start (draw_tool, display); gimp_draw_tool_resume (draw_tool); } else if (fg_select->state == MATTING_STATE_FREE_SELECT) { GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state, press_type, display); } }