define GIMP_COORDS_DEFAULT_VALUES, a struct initializer for GimpCoords.

2006-03-19  Michael Natterer  <mitch@gimp.org>

	* app/core/core-types.h: define GIMP_COORDS_DEFAULT_VALUES, a
	struct initializer for GimpCoords.

	* app/core/gimpimage-snap.c
	* app/paint/gimppaintcore-stroke.c
	* app/vectors/gimpbezierstroke.c
	* app/vectors/gimpvectors-compat.c
	* tools/pdbgen/pdb/paint_tools.pdb
	* tools/pdbgen/pdb/vectors.pdb: use it here.

	* app/pdb/paint_tools_cmds.c
	* app/pdb/vectors_cmds.c: regenerated.
This commit is contained in:
Michael Natterer
2006-03-19 13:39:10 +00:00
committed by Michael Natterer
parent 2770e17a4c
commit cc4badb87b
10 changed files with 88 additions and 125 deletions

View File

@ -1,3 +1,18 @@
2006-03-19 Michael Natterer <mitch@gimp.org>
* app/core/core-types.h: define GIMP_COORDS_DEFAULT_VALUES, a
struct initializer for GimpCoords.
* app/core/gimpimage-snap.c
* app/paint/gimppaintcore-stroke.c
* app/vectors/gimpbezierstroke.c
* app/vectors/gimpvectors-compat.c
* tools/pdbgen/pdb/paint_tools.pdb
* tools/pdbgen/pdb/vectors.pdb: use it here.
* app/pdb/paint_tools_cmds.c
* app/pdb/vectors_cmds.c: regenerated.
2006-03-19 DindinX <dindinx@gimp.org>
* libgimp/gimpzoompreview.c: untabbified.

View File

@ -46,6 +46,12 @@
#define GIMP_COORDS_MAX_WHEEL 1.0
#define GIMP_COORDS_DEFAULT_WHEEL 0.5
#define GIMP_COORDS_DEFAULT_VALUES { 0.0, 0.0, \
GIMP_COORDS_DEFAULT_PRESSURE, \
GIMP_COORDS_DEFAULT_TILT, \
GIMP_COORDS_DEFAULT_TILT, \
GIMP_COORDS_DEFAULT_WHEEL }
/* base classes */

View File

@ -535,12 +535,8 @@ gimp_image_snap_rectangle (GimpImage *gimage,
{
GimpVectors *vectors = gimp_image_get_active_vectors (gimage);
GimpStroke *stroke = NULL;
GimpCoords coords1 = { 0, 0,
GIMP_COORDS_DEFAULT_PRESSURE,
GIMP_COORDS_DEFAULT_TILT,
GIMP_COORDS_DEFAULT_TILT,
GIMP_COORDS_DEFAULT_WHEEL };
GimpCoords coords2 = coords1;
GimpCoords coords1 = GIMP_COORDS_DEFAULT_VALUES;
GimpCoords coords2 = GIMP_COORDS_DEFAULT_VALUES;
while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
{

View File

@ -34,6 +34,9 @@
#include "gimppaintoptions.h"
static const GimpCoords default_coords = GIMP_COORDS_DEFAULT_VALUES;
gboolean
gimp_paint_core_stroke (GimpPaintCore *core,
GimpDrawable *drawable,
@ -126,12 +129,9 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
/* we offset all coordinates by 0.5 to align the brush with the path */
coords[n_coords].x = (gdouble) (stroke_segs[0].x1 - off_x + 0.5);
coords[n_coords].y = (gdouble) (stroke_segs[0].y1 - off_y + 0.5);
coords[n_coords].pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coords[n_coords].xtilt = GIMP_COORDS_DEFAULT_TILT;
coords[n_coords].ytilt = GIMP_COORDS_DEFAULT_TILT;
coords[n_coords].wheel = GIMP_COORDS_DEFAULT_WHEEL;
coords[n_coords] = default_coords;
coords[n_coords].x = (gdouble) (stroke_segs[0].x1 - off_x + 0.5);
coords[n_coords].y = (gdouble) (stroke_segs[0].y1 - off_y + 0.5);
n_coords++;
@ -142,14 +142,9 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
stroke_segs[seg].y1 != -1 ||
stroke_segs[seg].y2 != -1)
{
coords[n_coords].x = (gdouble) (stroke_segs[seg].x1 -
off_x + 0.5);
coords[n_coords].y = (gdouble) (stroke_segs[seg].y1 -
off_y + 0.5);
coords[n_coords].pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coords[n_coords].xtilt = GIMP_COORDS_DEFAULT_TILT;
coords[n_coords].ytilt = GIMP_COORDS_DEFAULT_TILT;
coords[n_coords].wheel = GIMP_COORDS_DEFAULT_WHEEL;
coords[n_coords] = default_coords;
coords[n_coords].x = (gdouble) (stroke_segs[seg].x1 - off_x + 0.5);
coords[n_coords].y = (gdouble) (stroke_segs[seg].y1 - off_y + 0.5);
n_coords++;
seg++;
@ -190,12 +185,9 @@ gimp_paint_core_stroke_boundary (GimpPaintCore *core,
n_coords = 0;
seg++;
coords[n_coords].x = (gdouble) (stroke_segs[seg].x1 - off_x + 0.5);
coords[n_coords].y = (gdouble) (stroke_segs[seg].y1 - off_y + 0.5);
coords[n_coords].pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coords[n_coords].xtilt = GIMP_COORDS_DEFAULT_TILT;
coords[n_coords].ytilt = GIMP_COORDS_DEFAULT_TILT;
coords[n_coords].wheel = GIMP_COORDS_DEFAULT_WHEEL;
coords[n_coords] = default_coords;
coords[n_coords].x = (gdouble) (stroke_segs[seg].x1 - off_x + 0.5);
coords[n_coords].y = (gdouble) (stroke_segs[seg].y1 - off_y + 0.5);
n_coords++;
}

View File

@ -71,6 +71,8 @@ register_paint_tools_procs (Gimp *gimp)
procedural_db_register (gimp, &smudge_default_proc);
}
static const GimpCoords default_coords = GIMP_COORDS_DEFAULT_VALUES;
static gboolean
paint_tools_stroke (Gimp *gimp,
GimpContext *context,
@ -100,12 +102,9 @@ paint_tools_stroke (Gimp *gimp,
for (i = 0; i < n_strokes; i++)
{
coords[i].x = strokes[2 * i];
coords[i].y = strokes[2 * i + 1];
coords[i].pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coords[i].xtilt = GIMP_COORDS_DEFAULT_TILT;
coords[i].ytilt = GIMP_COORDS_DEFAULT_TILT;
coords[i].wheel = GIMP_COORDS_DEFAULT_WHEEL;
coords[i] = default_coords;
coords[i].x = strokes[2 * i];
coords[i].y = strokes[2 * i + 1];
}
retval = gimp_paint_core_stroke (core, drawable, options,

View File

@ -1434,14 +1434,10 @@ vectors_bezier_stroke_new_moveto_invoker (Gimp *gimp,
if (success)
{
GimpStroke *stroke;
GimpCoords coord0;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
stroke = gimp_bezier_stroke_new_moveto (&coord0);
gimp_vectors_stroke_add (vectors, stroke);
@ -1530,14 +1526,10 @@ vectors_bezier_stroke_lineto_invoker (Gimp *gimp,
if (stroke)
{
GimpCoords coord0;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
gimp_bezier_stroke_lineto (stroke, &coord0);
}
@ -1626,16 +1618,12 @@ vectors_bezier_stroke_conicto_invoker (Gimp *gimp,
if (stroke)
{
GimpCoords coord0, coord1;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
GimpCoords coord1 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
coord1 = coord0;
coord1.x = x1;
coord1.y = y1;
@ -1742,20 +1730,16 @@ vectors_bezier_stroke_cubicto_invoker (Gimp *gimp,
if (stroke)
{
GimpCoords coord0, coord1, coord2;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
GimpCoords coord1 = GIMP_COORDS_DEFAULT_VALUES;
GimpCoords coord2 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
coord1 = coord0;
coord1.x = x1;
coord1.y = y1;
coord2 = coord0;
coord2.x = x2;
coord2.y = y2;
@ -1865,14 +1849,10 @@ vectors_bezier_stroke_new_ellipse_invoker (Gimp *gimp,
if (success)
{
GimpStroke *stroke;
GimpCoords coord0;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
stroke = gimp_bezier_stroke_new_ellipse (&coord0, radius_x, radius_y, angle);
gimp_vectors_stroke_add (vectors, stroke);

View File

@ -1680,11 +1680,7 @@ arcto_ellipsesegment (gdouble radius_x,
GimpCoords *ellips)
{
gdouble phi_s, phi_e;
GimpCoords template = { 0, 0,
GIMP_COORDS_DEFAULT_PRESSURE,
GIMP_COORDS_DEFAULT_TILT,
GIMP_COORDS_DEFAULT_TILT,
GIMP_COORDS_DEFAULT_WHEEL };
GimpCoords template = GIMP_COORDS_DEFAULT_VALUES;
const gdouble circlemagic = 4.0 * (G_SQRT2 - 1.0) / 3.0;
gdouble y[4];
gdouble h0, h1;

View File

@ -42,6 +42,8 @@ enum
};
static const GimpCoords default_coords = GIMP_COORDS_DEFAULT_VALUES;
GimpVectors *
gimp_vectors_compat_new (GimpImage *gimage,
@ -73,12 +75,10 @@ gimp_vectors_compat_new (GimpImage *gimage,
for (i = 0; i < n_points; i++)
{
curr_coord->x = points[i].x;
curr_coord->y = points[i].y;
curr_coord->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
curr_coord->xtilt = GIMP_COORDS_DEFAULT_TILT;
curr_coord->ytilt = GIMP_COORDS_DEFAULT_TILT;
curr_coord->wheel = GIMP_COORDS_DEFAULT_WHEEL;
*curr_coord = default_coords;
curr_coord->x = points[i].x;
curr_coord->y = points[i].y;
/* copy the first anchor to be the first control point */
if (curr_coord == curr_stroke + 1)

View File

@ -790,6 +790,8 @@ sub ink {
"core/gimp.h" "core/gimpcontainer.h" "core/gimppaintinfo.h");
$extra{app}->{code} = <<'CODE';
static const GimpCoords default_coords = GIMP_COORDS_DEFAULT_VALUES;
static gboolean
paint_tools_stroke (Gimp *gimp,
GimpContext *context,
@ -819,12 +821,9 @@ paint_tools_stroke (Gimp *gimp,
for (i = 0; i < n_strokes; i++)
{
coords[i].x = strokes[2 * i];
coords[i].y = strokes[2 * i + 1];
coords[i].pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coords[i].xtilt = GIMP_COORDS_DEFAULT_TILT;
coords[i].ytilt = GIMP_COORDS_DEFAULT_TILT;
coords[i].wheel = GIMP_COORDS_DEFAULT_WHEEL;
coords[i] = default_coords;
coords[i].x = strokes[2 * i];
coords[i].y = strokes[2 * i + 1];
}
retval = gimp_paint_core_stroke (core, drawable, options,

View File

@ -659,14 +659,10 @@ HELP
code => <<"CODE"
{
GimpStroke *stroke;
GimpCoords coord0;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
stroke = gimp_bezier_stroke_new_moveto (&coord0);
gimp_vectors_stroke_add (vectors, stroke);
@ -703,14 +699,10 @@ HELP
if (stroke)
{
GimpCoords coord0;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
gimp_bezier_stroke_lineto (stroke, &coord0);
}
@ -756,16 +748,12 @@ HELP
if (stroke)
{
GimpCoords coord0, coord1;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
GimpCoords coord1 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
coord1 = coord0;
coord1.x = x1;
coord1.y = y1;
@ -815,20 +803,16 @@ HELP
if (stroke)
{
GimpCoords coord0, coord1, coord2;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
GimpCoords coord1 = GIMP_COORDS_DEFAULT_VALUES;
GimpCoords coord2 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
coord1 = coord0;
coord1.x = x1;
coord1.y = y1;
coord2 = coord0;
coord2.x = x2;
coord2.y = y2;
@ -877,14 +861,10 @@ HELP
code => <<"CODE"
{
GimpStroke *stroke;
GimpCoords coord0;
GimpCoords coord0 = GIMP_COORDS_DEFAULT_VALUES;
coord0.x = x0;
coord0.y = y0;
coord0.pressure = GIMP_COORDS_DEFAULT_PRESSURE;
coord0.xtilt = GIMP_COORDS_DEFAULT_TILT;
coord0.ytilt = GIMP_COORDS_DEFAULT_TILT;
coord0.wheel = GIMP_COORDS_DEFAULT_WHEEL;
coord0.x = x0;
coord0.y = y0;
stroke = gimp_bezier_stroke_new_ellipse (&coord0, radius_x, radius_y, angle);
gimp_vectors_stroke_add (vectors, stroke);