use GimpDrawTool API, not GimpCanvas one. Some cleanup.

2006-06-05  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimprectangletool.c (gimp_rectangle_tool_draw): use
	GimpDrawTool API, not GimpCanvas one. Some cleanup.
This commit is contained in:
Michael Natterer 2006-06-05 20:48:58 +00:00 committed by Michael Natterer
parent fa4427f83a
commit 5e30f2f1d6
2 changed files with 46 additions and 37 deletions

View File

@ -1,3 +1,8 @@
2006-06-05 Michael Natterer <mitch@gimp.org>
* app/tools/gimprectangletool.c (gimp_rectangle_tool_draw): use
GimpDrawTool API, not GimpCanvas one. Some cleanup.
2006-06-05 Sven Neumann <sven@gimp.org>
* tools/pdbgen/pdb/selection.pdb: fixed documentation of

View File

@ -1665,23 +1665,24 @@ gimp_rectangle_tool_cursor_update (GimpTool *tool,
void
gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
{
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->display->shell);
GimpCanvas *canvas = GIMP_CANVAS (shell->canvas);
GimpTool *tool;
GimpRectangleToolPrivate *private;
GimpRectangleOptions *options;
gint x1, x2, y1, y2;
guint function;
GimpRectangleGuide guide;
g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool));
g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (draw_tool));
tool = GIMP_TOOL (draw_tool);
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (draw_tool);
options = GIMP_RECTANGLE_OPTIONS (tool->tool_info->tool_options);
g_object_get (GIMP_RECTANGLE_TOOL (tool), "function", &function, NULL);
if (function == RECT_INACTIVE)
return;
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
x1 = private->x1;
x2 = private->x2;
y1 = private->y1;
@ -1689,6 +1690,7 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
gimp_draw_tool_draw_rectangle (draw_tool, FALSE,
x1, y1, x2 - x1, y2 - y1, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x1, y1, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_NORTH_WEST, FALSE);
@ -1702,48 +1704,50 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
x2, y2, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_SOUTH_EAST, FALSE);
options = GIMP_RECTANGLE_OPTIONS (tool->tool_info->tool_options);
g_object_get (options, "guide", &guide, NULL);
switch (guide)
{
case GIMP_RECTANGLE_GUIDE_NONE:
break;
case GIMP_RECTANGLE_GUIDE_CENTER_LINES:
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, (y1 + y2) / 2,
x2 - 1, (y1 + y2) / 2);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
(x1 + x2) / 2, y1 + 1,
(x1 + x2) / 2, y2 - 1);
gimp_draw_tool_draw_line (draw_tool,
x1, (y1 + y2) / 2,
x2, (y1 + y2) / 2, FALSE);
gimp_draw_tool_draw_line (draw_tool,
(x1 + x2) / 2, y1,
(x1 + x2) / 2, y2, FALSE);
break;
case GIMP_RECTANGLE_GUIDE_THIRDS:
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, (2 * y1 + y2) / 3,
x2 - 1, (2 * y1 + y2) / 3);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, (y1 + 2 * y2) / 3,
x2 - 1, (y1 + 2 * y2) / 3);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
(2 * x1 + x2) / 3, y1 + 1,
(2 * x1 + x2) / 3, y2 - 1);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
(x1 + 2 * x2) / 3, y1 + 1,
(x1 + 2 * x2) / 3, y2 - 1);
gimp_draw_tool_draw_line (draw_tool,
x1, (2 * y1 + y2) / 3,
x2, (2 * y1 + y2) / 3, FALSE);
gimp_draw_tool_draw_line (draw_tool,
x1, (y1 + 2 * y2) / 3,
x2, (y1 + 2 * y2) / 3, FALSE);
gimp_draw_tool_draw_line (draw_tool,
(2 * x1 + x2) / 3, y1,
(2 * x1 + x2) / 3, y2, FALSE);
gimp_draw_tool_draw_line (draw_tool,
(x1 + 2 * x2) / 3, y1,
(x1 + 2 * x2) / 3, y2, FALSE);
break;
case GIMP_RECTANGLE_GUIDE_GOLDEN:
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, (2 * y1 + (1 + sqrt(5)) * y2) / (3 + sqrt(5)),
x2 - 1, (2 * y1 + (1 + sqrt(5)) * y2) / (3 + sqrt(5)));
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, ((1 + sqrt(5)) * y1 + 2 * y2) / (3 + sqrt(5)),
x2 - 1, ((1 + sqrt(5)) * y1 + 2 * y2) / (3 + sqrt(5)));
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
(2 * x1 + (1 + sqrt(5)) * x2) / (3 + sqrt(5)), y1 + 1,
(2 * x1 + (1 + sqrt(5)) * x2) / (3 + sqrt(5)), y2 - 1);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
((1 + sqrt(5)) * x1 + 2 * x2) / (3 + sqrt(5)), y1 + 1,
((1 + sqrt(5)) * x1 + 2 * x2) / (3 + sqrt(5)), y2 - 1);
gimp_draw_tool_draw_line (draw_tool,
x1, (2 * y1 + (1 + sqrt(5)) * y2) / (3 + sqrt(5)),
x2, (2 * y1 + (1 + sqrt(5)) * y2) / (3 + sqrt(5)), FALSE);
gimp_draw_tool_draw_line (draw_tool,
x1, ((1 + sqrt(5)) * y1 + 2 * y2) / (3 + sqrt(5)),
x2, ((1 + sqrt(5)) * y1 + 2 * y2) / (3 + sqrt(5)), FALSE);
gimp_draw_tool_draw_line (draw_tool,
(2 * x1 + (1 + sqrt(5)) * x2) / (3 + sqrt(5)), y1,
(2 * x1 + (1 + sqrt(5)) * x2) / (3 + sqrt(5)), y2, FALSE);
gimp_draw_tool_draw_line (draw_tool,
((1 + sqrt(5)) * x1 + 2 * x2) / (3 + sqrt(5)), y1,
((1 + sqrt(5)) * x1 + 2 * x2) / (3 + sqrt(5)), y2, FALSE);
break;
}
}