Commit 47571782 authored by Simon Budig's avatar Simon Budig Committed by Simon Budig

Intruduce casting macro GIMP_ANCHOR.

2003-08-26  Simon Budig  <simon@gimp.org>

	* app/vectors/gimpanchor.h: Intruduce casting macro GIMP_ANCHOR.

	* app/tools/gimpvectortool.c
	* app/vectors/gimpstroke.c
	* app/vectors/gimpbezierstroke.c
	* app/vectors/gimpvectors-compat.c: Use it for code readibility.
parent 3b30a0b8
2003-08-26 Simon Budig <simon@gimp.org>
* app/vectors/gimpanchor.h: Intruduce casting macro GIMP_ANCHOR.
* app/tools/gimpvectortool.c
* app/vectors/gimpstroke.c
* app/vectors/gimpbezierstroke.c
* app/vectors/gimpvectors-compat.c: Use it for code readibility.
2003-08-26 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdockbook.c: added gimp_dockbook_help_func()
......@@ -618,22 +618,22 @@ gimp_vector_tool_on_handle (GimpTool *tool,
while (anchor_list)
{
dx = coords->x - ((GimpAnchor *) anchor_list->data)->position.x;
dy = coords->y - ((GimpAnchor *) anchor_list->data)->position.y;
dx = coords->x - GIMP_ANCHOR (anchor_list->data)->position.x;
dy = coords->y - GIMP_ANCHOR (anchor_list->data)->position.y;
if (mindist < 0 || mindist > dx * dx + dy * dy)
{
mindist = dx * dx + dy * dy;
anchor = (GimpAnchor *) anchor_list->data;
anchor = GIMP_ANCHOR (anchor_list->data);
if (ret_stroke)
*ret_stroke = stroke;
}
if ((pref_mindist < 0 || pref_mindist > dx * dx + dy * dy) &&
((GimpAnchor *) anchor_list->data)->type == preferred)
GIMP_ANCHOR (anchor_list->data)->type == preferred)
{
pref_mindist = dx * dx + dy * dy;
pref_anchor = (GimpAnchor *) anchor_list->data;
pref_anchor = GIMP_ANCHOR (anchor_list->data);
pref_stroke = stroke;
}
......@@ -964,7 +964,7 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
for (list = draw_anchors; list; list = g_list_next (list))
{
cur_anchor = (GimpAnchor *) list->data;
cur_anchor = GIMP_ANCHOR (list->data);
if (cur_anchor->type == GIMP_ANCHOR_ANCHOR)
{
......@@ -988,7 +988,7 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
for (list = draw_anchors; list; list = g_list_next (list))
{
cur_anchor = (GimpAnchor *) list->data;
cur_anchor = GIMP_ANCHOR (list->data);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
......
......@@ -22,6 +22,7 @@
#ifndef __GIMP_ANCHOR_H__
#define __GIMP_ANCHOR_H__
#define GIMP_ANCHOR(anchor) ((GimpAnchor *) (anchor))
struct _GimpAnchor
{
......
......@@ -277,7 +277,7 @@ gimp_bezier_stroke_anchor_delete (GimpStroke *stroke,
{
g_return_if_fail (list != NULL);
list2 = g_list_next (list);
gimp_anchor_free ((GimpAnchor *) list->data);
gimp_anchor_free (GIMP_ANCHOR (list->data));
stroke->anchors = g_list_delete_link (stroke->anchors, list);
list = list2;
}
......@@ -354,7 +354,7 @@ gimp_bezier_stroke_anchor_insert (GimpStroke *stroke,
for (i=0; i <= 3; i++)
{
beziercoords[i] = ((GimpAnchor *) list->data)->position;
beziercoords[i] = GIMP_ANCHOR (list->data)->position;
list = g_list_next (list);
if (!list)
list = stroke->anchors;
......@@ -415,7 +415,7 @@ gimp_bezier_stroke_anchor_insert (GimpStroke *stroke,
}
else
{
((GimpAnchor *) list->data)->position = subdivided[i];
GIMP_ANCHOR (list->data)->position = subdivided[i];
}
list = g_list_next (list);
......@@ -426,7 +426,7 @@ gimp_bezier_stroke_anchor_insert (GimpStroke *stroke,
stroke->anchors = g_list_first (stroke->anchors);
return ((GimpAnchor *) segment_start->data);
return GIMP_ANCHOR (segment_start->data);
}
......@@ -479,7 +479,7 @@ gimp_bezier_stroke_point_move_relative (GimpStroke *stroke,
for (i=0; i <= 1; i++)
{
gimp_stroke_anchor_move_relative (stroke, ((GimpAnchor *) list->data),
gimp_stroke_anchor_move_relative (stroke, GIMP_ANCHOR (list->data),
&(offsetcoords[i]), feature);
list = g_list_next (list);
if (!list)
......@@ -511,7 +511,7 @@ gimp_bezier_stroke_point_move_absolute (GimpStroke *stroke,
for (i=0; i <= 3; i++)
{
beziercoords[i] = ((GimpAnchor *) list->data)->position;
beziercoords[i] = GIMP_ANCHOR (list->data)->position;
list = g_list_next (list);
if (!list)
list = stroke->anchors;
......@@ -555,7 +555,7 @@ gimp_bezier_stroke_nearest_point_get (const GimpStroke *stroke,
min_dist = -1;
for (anchorlist = stroke->anchors;
anchorlist && ((GimpAnchor *) anchorlist->data)->type != GIMP_ANCHOR_ANCHOR;
anchorlist && GIMP_ANCHOR (anchorlist->data)->type != GIMP_ANCHOR_ANCHOR;
anchorlist = g_list_next (anchorlist));
segment_start = anchorlist->data;
......@@ -596,12 +596,12 @@ gimp_bezier_stroke_nearest_point_get (const GimpStroke *stroke,
while (count < 3)
{
segmentcoords[count] = ((GimpAnchor *) anchorlist->data)->position;
segmentcoords[count] = GIMP_ANCHOR (anchorlist->data)->position;
count++;
}
anchorlist = g_list_next (anchorlist);
if (anchorlist)
segmentcoords[3] = ((GimpAnchor *) anchorlist->data)->position;
segmentcoords[3] = GIMP_ANCHOR (anchorlist->data)->position;
dist = gimp_bezier_stroke_segment_nearest_point_get (segmentcoords,
coord, precision,
......@@ -795,12 +795,12 @@ gimp_bezier_stroke_is_extendable (GimpStroke *stroke,
if (listneighbor && neighbor->type == GIMP_ANCHOR_CONTROL)
{
if (listneighbor->prev &&
((GimpAnchor *) listneighbor->prev->data)->type == GIMP_ANCHOR_ANCHOR)
GIMP_ANCHOR (listneighbor->prev->data)->type == GIMP_ANCHOR_ANCHOR)
{
listneighbor = listneighbor->prev;
}
else if (listneighbor->next &&
((GimpAnchor *) listneighbor->next->data)->type == GIMP_ANCHOR_ANCHOR)
GIMP_ANCHOR (listneighbor->next->data)->type == GIMP_ANCHOR_ANCHOR)
{
listneighbor = listneighbor->next;
}
......@@ -917,12 +917,12 @@ gimp_bezier_stroke_extend (GimpStroke *stroke,
if (listneighbor && neighbor->type == GIMP_ANCHOR_CONTROL)
{
if (listneighbor->prev &&
((GimpAnchor *) listneighbor->prev->data)->type == GIMP_ANCHOR_ANCHOR)
GIMP_ANCHOR (listneighbor->prev->data)->type == GIMP_ANCHOR_ANCHOR)
{
listneighbor = listneighbor->prev;
}
else if (listneighbor->next &&
((GimpAnchor *) listneighbor->next->data)->type == GIMP_ANCHOR_ANCHOR)
GIMP_ANCHOR (listneighbor->next->data)->type == GIMP_ANCHOR_ANCHOR)
{
listneighbor = listneighbor->next;
}
......@@ -965,7 +965,7 @@ gimp_bezier_stroke_extend (GimpStroke *stroke,
if (loose_end == 1)
{
while (listneighbor &&
((GimpAnchor *) listneighbor->data)->type == GIMP_ANCHOR_CONTROL)
GIMP_ANCHOR (listneighbor->data)->type == GIMP_ANCHOR_CONTROL)
{
control_count++;
listneighbor = listneighbor->prev;
......@@ -974,7 +974,7 @@ gimp_bezier_stroke_extend (GimpStroke *stroke,
else
{
while (listneighbor &&
((GimpAnchor *) listneighbor->data)->type == GIMP_ANCHOR_CONTROL)
GIMP_ANCHOR (listneighbor->data)->type == GIMP_ANCHOR_CONTROL)
{
control_count++;
listneighbor = listneighbor->next;
......@@ -1077,17 +1077,16 @@ gimp_bezier_stroke_anchor_move_relative (GimpStroke *stroke,
{
if (g_list_previous (anchor_list))
{
coord2 = ((GimpAnchor *) g_list_previous (anchor_list)->data)->position;
coord2 = GIMP_ANCHOR (g_list_previous (anchor_list)->data)->position;
gimp_bezier_coords_add (&coord2, &delta, &coord1);
((GimpAnchor *) g_list_previous (anchor_list)->data)->position =
coord1;
GIMP_ANCHOR (g_list_previous (anchor_list)->data)->position = coord1;
}
if (g_list_next (anchor_list))
{
coord2 = ((GimpAnchor *) g_list_next (anchor_list)->data)->position;
coord2 = GIMP_ANCHOR (g_list_next (anchor_list)->data)->position;
gimp_bezier_coords_add (&coord2, &delta, &coord1);
((GimpAnchor *) g_list_next (anchor_list)->data)->position = coord1;
GIMP_ANCHOR (g_list_next (anchor_list)->data)->position = coord1;
}
}
else
......@@ -1099,7 +1098,7 @@ gimp_bezier_stroke_anchor_move_relative (GimpStroke *stroke,
/* search for opposite control point. Sigh. */
neighbour = g_list_previous (anchor_list);
if (neighbour &&
((GimpAnchor *) neighbour->data)->type == GIMP_ANCHOR_ANCHOR)
GIMP_ANCHOR (neighbour->data)->type == GIMP_ANCHOR_ANCHOR)
{
opposite = g_list_previous (neighbour);
}
......@@ -1107,19 +1106,19 @@ gimp_bezier_stroke_anchor_move_relative (GimpStroke *stroke,
{
neighbour = g_list_next (anchor_list);
if (neighbour &&
((GimpAnchor *) neighbour->data)->type == GIMP_ANCHOR_ANCHOR)
GIMP_ANCHOR (neighbour->data)->type == GIMP_ANCHOR_ANCHOR)
{
opposite = g_list_next (neighbour);
}
}
if (opposite &&
((GimpAnchor *) opposite->data)->type == GIMP_ANCHOR_CONTROL)
GIMP_ANCHOR (opposite->data)->type == GIMP_ANCHOR_CONTROL)
{
gimp_bezier_coords_difference (&(((GimpAnchor *) neighbour->data)->position),
gimp_bezier_coords_difference (&(GIMP_ANCHOR (neighbour->data)->position),
&(anchor->position), &delta);
gimp_bezier_coords_add (&(((GimpAnchor *) neighbour->data)->position),
gimp_bezier_coords_add (&(GIMP_ANCHOR (neighbour->data)->position),
&delta, &coord1);
((GimpAnchor *) opposite->data)->position = coord1;
GIMP_ANCHOR (opposite->data)->position = coord1;
}
}
}
......@@ -1156,21 +1155,21 @@ gimp_bezier_stroke_anchor_convert (GimpStroke *stroke,
if (anchor->type == GIMP_ANCHOR_ANCHOR)
{
if (g_list_previous (anchor_list))
((GimpAnchor *) g_list_previous (anchor_list)->data)->position =
GIMP_ANCHOR (g_list_previous (anchor_list)->data)->position =
anchor->position;
if (g_list_next (anchor_list))
((GimpAnchor *) g_list_next (anchor_list)->data)->position =
GIMP_ANCHOR (g_list_next (anchor_list)->data)->position =
anchor->position;
}
else
{
if (g_list_previous (anchor_list) &&
((GimpAnchor *) g_list_previous (anchor_list)->data)->type == GIMP_ANCHOR_ANCHOR)
anchor->position = ((GimpAnchor *) g_list_previous (anchor_list)->data)->position;
GIMP_ANCHOR (g_list_previous (anchor_list)->data)->type == GIMP_ANCHOR_ANCHOR)
anchor->position = GIMP_ANCHOR (g_list_previous (anchor_list)->data)->position;
if (g_list_next (anchor_list) &&
((GimpAnchor *) g_list_next (anchor_list)->data)->type == GIMP_ANCHOR_ANCHOR)
anchor->position = ((GimpAnchor *) g_list_next (anchor_list)->data)->position;
GIMP_ANCHOR (g_list_next (anchor_list)->data)->type == GIMP_ANCHOR_ANCHOR)
anchor->position = GIMP_ANCHOR (g_list_next (anchor_list)->data)->position;
}
break;
......@@ -1207,7 +1206,7 @@ gimp_bezier_stroke_interpolate (const GimpStroke *stroke,
count = 0;
for (anchorlist = stroke->anchors;
anchorlist && ((GimpAnchor *) anchorlist->data)->type != GIMP_ANCHOR_ANCHOR;
anchorlist && GIMP_ANCHOR (anchorlist->data)->type != GIMP_ANCHOR_ANCHOR;
anchorlist = g_list_next (anchorlist));
for ( ; anchorlist; anchorlist = g_list_next (anchorlist))
......@@ -1232,12 +1231,12 @@ gimp_bezier_stroke_interpolate (const GimpStroke *stroke,
while (count < 3)
{
segmentcoords[count] = ((GimpAnchor *) anchorlist->data)->position;
segmentcoords[count] = GIMP_ANCHOR (anchorlist->data)->position;
count++;
}
anchorlist = g_list_next (anchorlist);
if (anchorlist)
segmentcoords[3] = ((GimpAnchor *) anchorlist->data)->position;
segmentcoords[3] = GIMP_ANCHOR (anchorlist->data)->position;
gimp_bezier_coords_subdivide (segmentcoords, precision, &ret_coords);
need_endpoint = TRUE;
......
......@@ -247,7 +247,7 @@ gimp_stroke_finalize (GObject *object)
stroke = GIMP_STROKE (object);
for (list = stroke->anchors; list; list = list->next)
gimp_anchor_free ((GimpAnchor *) list->data);
gimp_anchor_free (GIMP_ANCHOR (list->data));
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -326,13 +326,13 @@ gimp_stroke_real_anchor_get (const GimpStroke *stroke,
for (list = anchors; list; list = g_list_next (list))
{
dx = coord->x - ((GimpAnchor *) list->data)->position.x;
dy = coord->y - ((GimpAnchor *) list->data)->position.y;
dx = coord->x - GIMP_ANCHOR (list->data)->position.x;
dy = coord->y - GIMP_ANCHOR (list->data)->position.y;
if (mindist < 0 || mindist > dx * dx + dy * dy)
{
mindist = dx * dx + dy * dy;
anchor = (GimpAnchor *) list->data;
anchor = GIMP_ANCHOR (list->data);
}
}
......@@ -342,13 +342,13 @@ gimp_stroke_real_anchor_get (const GimpStroke *stroke,
for (list = anchors; list; list = g_list_next (list))
{
dx = coord->x - ((GimpAnchor *) list->data)->position.x;
dy = coord->y - ((GimpAnchor *) list->data)->position.y;
dx = coord->x - GIMP_ANCHOR (list->data)->position.x;
dy = coord->y - GIMP_ANCHOR (list->data)->position.y;
if (mindist < 0 || mindist > dx * dx + dy * dy)
{
mindist = dx * dx + dy * dy;
anchor = (GimpAnchor *) list->data;
anchor = GIMP_ANCHOR (list->data);
}
}
......@@ -387,7 +387,7 @@ gimp_stroke_real_anchor_get_next (const GimpStroke *stroke,
}
if (list)
return (GimpAnchor *) list->data;
return GIMP_ANCHOR (list->data);
return NULL;
}
......@@ -416,7 +416,7 @@ gimp_stroke_real_anchor_select (GimpStroke *stroke,
{
while (list)
{
((GimpAnchor *) list->data)->selected = FALSE;
GIMP_ANCHOR (list->data)->selected = FALSE;
list = g_list_next (list);
}
}
......@@ -424,7 +424,7 @@ gimp_stroke_real_anchor_select (GimpStroke *stroke,
list = g_list_find (stroke->anchors, anchor);
if (list)
((GimpAnchor *) list->data)->selected = TRUE;
GIMP_ANCHOR (list->data)->selected = TRUE;
}
......@@ -784,7 +784,7 @@ gimp_stroke_real_duplicate (const GimpStroke *stroke)
for (list = new_stroke->anchors; list; list = g_list_next (list))
{
list->data = gimp_anchor_duplicate ((GimpAnchor *) list->data);
list->data = gimp_anchor_duplicate (GIMP_ANCHOR (list->data));
}
return new_stroke;
......@@ -1057,7 +1057,7 @@ gimp_stroke_real_get_draw_anchors (const GimpStroke *stroke)
for (list = stroke->anchors; list; list = g_list_next (list))
{
if (((GimpAnchor *) list->data)->type == GIMP_ANCHOR_ANCHOR)
if (GIMP_ANCHOR (list->data)->type == GIMP_ANCHOR_ANCHOR)
ret_list = g_list_prepend (ret_list, list->data);
}
......
......@@ -208,7 +208,7 @@ gimp_vectors_compat_get_points (GimpVectors *vectors,
/* write the skipped control point */
if (! anchors->next && stroke->closed)
{
anchor = (GimpAnchor *) stroke->anchors->data;
anchor = GIMP_ANCHOR (stroke->anchors->data);
points[i].type = GIMP_VECTORS_COMPAT_CONTROL;
points[i].x = anchor->position.x;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment