void gimp_draw_tool_add_item (GimpDrawTool *draw_tool, GimpCanvasItem *item) { GimpCanvasGroup *group; g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_if_fail (GIMP_IS_CANVAS_ITEM (item)); if (! draw_tool->item) draw_tool->item = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); group = GIMP_CANVAS_GROUP (draw_tool->item); if (draw_tool->group_stack) group = draw_tool->group_stack->data; gimp_canvas_group_add_item (group, item); }
static void gimp_rectangle_select_tool_draw (GimpDrawTool *draw_tool) { GimpRectangleSelectTool *rect_sel_tool; GimpRectangleSelectToolPrivate *priv; GimpCanvasGroup *stroke_group = NULL; rect_sel_tool = GIMP_RECTANGLE_SELECT_TOOL (draw_tool); priv = GIMP_RECTANGLE_SELECT_TOOL_GET_PRIVATE (rect_sel_tool); if (priv->round_corners) { GimpCanvasItem *item; gint x1, y1, x2, y2; gdouble radius; gint square_size; g_object_get (rect_sel_tool, "x1", &x1, "y1", &y1, "x2", &x2, "y2", &y2, NULL); radius = MIN (priv->corner_radius, MIN ((x2 - x1) / 2.0, (y2 - y1) / 2.0)); square_size = (int) (radius * 2); stroke_group = GIMP_CANVAS_GROUP (gimp_draw_tool_add_stroke_group (draw_tool)); item = gimp_draw_tool_add_arc (draw_tool, FALSE, x1, y1, square_size, square_size, G_PI / 2.0, G_PI / 2.0); gimp_canvas_group_add_item (stroke_group, item); gimp_draw_tool_remove_item (draw_tool, item); item = gimp_draw_tool_add_arc (draw_tool, FALSE, x2 - square_size, y1, square_size, square_size, 0.0, G_PI / 2.0); gimp_canvas_group_add_item (stroke_group, item); gimp_draw_tool_remove_item (draw_tool, item); item = gimp_draw_tool_add_arc (draw_tool, FALSE, x2 - square_size, y2 - square_size, square_size, square_size, G_PI * 1.5, G_PI / 2.0); gimp_canvas_group_add_item (stroke_group, item); gimp_draw_tool_remove_item (draw_tool, item); item = gimp_draw_tool_add_arc (draw_tool, FALSE, x1, y2 - square_size, square_size, square_size, G_PI, G_PI / 2.0); gimp_canvas_group_add_item (stroke_group, item); gimp_draw_tool_remove_item (draw_tool, item); } gimp_rectangle_tool_draw (draw_tool, stroke_group); }