Guide creation/deletion/query is now available as PDB procedures. Not yet

* app/gimage.h app/gimpimage.c app/gimpimage.h
	app/internal_procs.c app/layer.c app/xcf.c:
	Guide creation/deletion/query is now available as
	PDB procedures.  Not yet directly exported to libgimp,
	and needs to be moved into gimage_cmds.c, but it
	works.
This commit is contained in:
Adam D. Moss 1998-08-31 17:31:19 +00:00
parent 1f325983b7
commit b164ee7947
24 changed files with 5166 additions and 16 deletions

View File

@ -1,3 +1,12 @@
Mon Aug 31 18:15:16 BST 1998 Adam D. Moss <adam@gimp.org>
* app/gimage.h app/gimpimage.c app/gimpimage.h
app/internal_procs.c app/layer.c app/xcf.c:
Guide creation/deletion/query is now available as
PDB procedures. Not yet directly exported to libgimp,
and needs to be moved into gimage_cmds.c, but it
works.
Mon Aug 31 11:35:00 CST 1998 Seth Burgess <sjburges@gimp.org>
* app/gimage.c
* app/gimpimage.c: Applied Zach's fix for layer merge opacity. I

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gimpimageP.h"
#include "drawable.h"
@ -31,6 +32,16 @@
#include "layer_pvt.h"
#include "drawable_pvt.h" /* ick ick. */
/* Exported functions */
static Argument* gimp_image_add_hguide_invoker (Argument*);
static Argument* gimp_image_add_vguide_invoker (Argument*);
static Argument* gimp_image_delete_guide_invoker (Argument*);/*fixme:refcount*/
static Argument* gimp_image_findnext_guide_invoker (Argument*);
static Argument* gimp_image_get_guide_orientation_invoker (Argument*);
static Argument* gimp_image_get_guide_position_invoker (Argument*);
/* Local function declarations */
static void gimp_image_free_projection (GimpImage *);
static void gimp_image_allocate_shadow (GimpImage *, int, int, int);
@ -71,6 +82,8 @@ int valid_combinations[][MAX_CHANNELS + 1] =
{ -1, -1, COMBINE_INDEXED_A_INDEXED_A, -1, -1 },
};
guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
/*
* Static variables
@ -230,8 +243,7 @@ gimp_image_new (int width, int height, int base_type)
case INDEXED:
/* always allocate 256 colors for the colormap */
gimage->num_cols = 0;
gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE);
memset (gimage->cmap, 0, COLORMAP_SIZE);
gimage->cmap = (unsigned char *) g_malloc0 (COLORMAP_SIZE);
break;
default:
break;
@ -776,6 +788,624 @@ gimp_image_transform_color (GimpImage *gimage, GimpDrawable *drawable,
}
}
/* The gimp_image_add_hguide procedure definition */
ProcArg gimp_image_add_hguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"yposition",
"The guide's y-offset from top of image"
}
};
ProcArg gimp_image_add_hguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_hguide_proc =
{
"gimp_image_add_hguide",
"Add a horizontal Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the y-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_hguide_args,
/* Output arguments */
1,
gimp_image_add_hguide_out_args,
/* Exec method */
{ { gimp_image_add_hguide_invoker } },
};
static Argument *
gimp_image_add_hguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_hguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_hguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_add_vguide procedure definition */
ProcArg gimp_image_add_vguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"xposition",
"The guide's x-offset from left of image"
}
};
ProcArg gimp_image_add_vguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_vguide_proc =
{
"gimp_image_add_vguide",
"Add a vertical Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the x-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_vguide_args,
/* Output arguments */
1,
gimp_image_add_vguide_out_args,
/* Exec method */
{ { gimp_image_add_vguide_invoker } },
};
static Argument *
gimp_image_add_vguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_vguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_vguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_delete_guide procedure definition */
ProcArg gimp_image_delete_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of the Guide to be removed"
}
};
ProcRecord gimp_image_delete_guide_proc =
{
"gimp_image_delete_guide",
"Deletes a Guide from an image",
"This procedure takes an image and a guide_id as input and removes the specified Guide from the specified image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_delete_guide_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { gimp_image_delete_guide_invoker } },
};
static Argument *
gimp_image_delete_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
success = FALSE;
guides = gimage->guides;
while (guides)
{
if (((Guide*)guides->data)->guide_ID == guide_id)
{
GList *tmp_next;
/* printf("Gotcha at %p\n", ((Guide*)guides->data)); */
success = TRUE;
tmp_next = g_list_next(guides);
gimp_image_remove_guide (gimage, ((Guide*)guides->data));
guides = tmp_next;
}
else
{
guides = g_list_next(guides);
}
}
}
return_args = procedural_db_return_args (&gimp_image_delete_guide_proc,
success);
return return_args;
}
/* The gimp_image_findnext_guide procedure definition */
ProcArg gimp_image_findnext_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of current Guide (0 if first invocation)"
}
};
ProcArg gimp_image_findnext_guide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The next guide's guide_id"
}
};
ProcRecord gimp_image_findnext_guide_proc =
{
"gimp_image_findnext_guide",
"Find next Guide on an image",
"This procedure takes an image and a guide_id as input and finds the guide_id of the successor of the given guide_id in the image's Guide list. If the supplied guide_id is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide_id as an argument or the image has no guides.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_findnext_guide_args,
/* Output arguments */
1,
gimp_image_findnext_guide_out_args,
/* Exec method */
{ { gimp_image_findnext_guide_invoker } },
};
static Argument *
gimp_image_findnext_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
rtn_guide_id = 0;
if (guides == NULL) /* No guides */
{
rtn_guide_id = 0;
}
else
{
if (guide_id == 0) /* init - Return first guide_ID in list */
{
while (guides != NULL &&
((Guide*)guides->data)->position < 0)
guides = g_list_next(guides);
if (guides)
rtn_guide_id = ((Guide*)guides->data)->guide_ID;
}
else
{
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
/*printf("Gotcha at %p: %d, %d, %d\n",
((Guide*)guides->data),
((Guide*)guides->data)->position,
((Guide*)guides->data)->orientation,
((Guide*)guides->data)->guide_ID
);*/
success = TRUE;
if (g_list_next(guides) == NULL)
{
rtn_guide_id = 0;
}
else
{
GList* tmplist;
tmplist = g_list_next(guides);
rtn_guide_id = ((Guide*)tmplist->data)->guide_ID;
goto got_it;
}
}
guides = g_list_next(guides);
}
}
}
}
got_it:
return_args = procedural_db_return_args (&gimp_image_findnext_guide_proc,
success);
if (success)
return_args[1].value.pdb_int = rtn_guide_id;
return return_args;
}
/* The gimp_image_get_guide_orientation procedure definition */
ProcArg gimp_image_get_guide_orientation_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_orientation_out_args[] =
{
{ PDB_INT32,
"orientation",
"The guide's orientation - vert=0, horiz=1"
}
};
ProcRecord gimp_image_get_guide_orientation_proc =
{
"gimp_image_get_guide_orientation",
"Get orientation of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the orientations of the guide, where 0=vertical and 1=horizontal.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_orientation_args,
/* Output arguments */
1,
gimp_image_get_guide_orientation_out_args,
/* Exec method */
{ { gimp_image_get_guide_orientation_invoker } },
};
static Argument *
gimp_image_get_guide_orientation_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_orientation;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
switch (((Guide*)guides->data)->orientation)
{
case VERTICAL_GUIDE: rtn_orientation = 0; break;
case HORIZONTAL_GUIDE: rtn_orientation = 1; break;
default:
{
rtn_orientation = 0;
g_warning("Guide has bad orientation.");
break;
}
}
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_orientation_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_orientation;
return return_args;
}
/* The gimp_image_get_guide_position procedure definition */
ProcArg gimp_image_get_guide_position_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_position_out_args[] =
{
{ PDB_INT32,
"position",
"The guide's position relative to top or left of image"
}
};
ProcRecord gimp_image_get_guide_position_proc =
{
"gimp_image_get_guide_position",
"Get position of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the position of the guide relative to the top or left of the image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_position_args,
/* Output arguments */
1,
gimp_image_get_guide_position_out_args,
/* Exec method */
{ { gimp_image_get_guide_position_invoker } },
};
static Argument *
gimp_image_get_guide_position_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_position;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
rtn_position = ((Guide*)guides->data)->position;
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_position_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_position;
return return_args;
}
Guide*
gimp_image_add_hguide (GimpImage *gimage)
{
@ -784,6 +1414,7 @@ gimp_image_add_hguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = HORIZONTAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);
@ -799,6 +1430,7 @@ gimp_image_add_vguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = VERTICAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);

View File

@ -1,6 +1,7 @@
#ifndef __GIMPIMAGE_H__
#define __GIMPIMAGE_H__
#include "procedural_db.h"
#include "gimpimageF.h"
#include "boundary.h"
@ -81,6 +82,7 @@ struct _Guide
int ref_count;
int position;
int orientation;
guint32 guide_ID;
};
@ -197,5 +199,12 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* Exported for PDB */
extern ProcRecord gimp_image_add_hguide_proc;
extern ProcRecord gimp_image_add_vguide_proc;
extern ProcRecord gimp_image_delete_guide_proc;
extern ProcRecord gimp_image_findnext_guide_proc;
extern ProcRecord gimp_image_get_guide_orientation_proc;
extern ProcRecord gimp_image_get_guide_position_proc;
#endif

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gimpimageP.h"
#include "drawable.h"
@ -31,6 +32,16 @@
#include "layer_pvt.h"
#include "drawable_pvt.h" /* ick ick. */
/* Exported functions */
static Argument* gimp_image_add_hguide_invoker (Argument*);
static Argument* gimp_image_add_vguide_invoker (Argument*);
static Argument* gimp_image_delete_guide_invoker (Argument*);/*fixme:refcount*/
static Argument* gimp_image_findnext_guide_invoker (Argument*);
static Argument* gimp_image_get_guide_orientation_invoker (Argument*);
static Argument* gimp_image_get_guide_position_invoker (Argument*);
/* Local function declarations */
static void gimp_image_free_projection (GimpImage *);
static void gimp_image_allocate_shadow (GimpImage *, int, int, int);
@ -71,6 +82,8 @@ int valid_combinations[][MAX_CHANNELS + 1] =
{ -1, -1, COMBINE_INDEXED_A_INDEXED_A, -1, -1 },
};
guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
/*
* Static variables
@ -230,8 +243,7 @@ gimp_image_new (int width, int height, int base_type)
case INDEXED:
/* always allocate 256 colors for the colormap */
gimage->num_cols = 0;
gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE);
memset (gimage->cmap, 0, COLORMAP_SIZE);
gimage->cmap = (unsigned char *) g_malloc0 (COLORMAP_SIZE);
break;
default:
break;
@ -776,6 +788,624 @@ gimp_image_transform_color (GimpImage *gimage, GimpDrawable *drawable,
}
}
/* The gimp_image_add_hguide procedure definition */
ProcArg gimp_image_add_hguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"yposition",
"The guide's y-offset from top of image"
}
};
ProcArg gimp_image_add_hguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_hguide_proc =
{
"gimp_image_add_hguide",
"Add a horizontal Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the y-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_hguide_args,
/* Output arguments */
1,
gimp_image_add_hguide_out_args,
/* Exec method */
{ { gimp_image_add_hguide_invoker } },
};
static Argument *
gimp_image_add_hguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_hguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_hguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_add_vguide procedure definition */
ProcArg gimp_image_add_vguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"xposition",
"The guide's x-offset from left of image"
}
};
ProcArg gimp_image_add_vguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_vguide_proc =
{
"gimp_image_add_vguide",
"Add a vertical Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the x-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_vguide_args,
/* Output arguments */
1,
gimp_image_add_vguide_out_args,
/* Exec method */
{ { gimp_image_add_vguide_invoker } },
};
static Argument *
gimp_image_add_vguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_vguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_vguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_delete_guide procedure definition */
ProcArg gimp_image_delete_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of the Guide to be removed"
}
};
ProcRecord gimp_image_delete_guide_proc =
{
"gimp_image_delete_guide",
"Deletes a Guide from an image",
"This procedure takes an image and a guide_id as input and removes the specified Guide from the specified image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_delete_guide_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { gimp_image_delete_guide_invoker } },
};
static Argument *
gimp_image_delete_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
success = FALSE;
guides = gimage->guides;
while (guides)
{
if (((Guide*)guides->data)->guide_ID == guide_id)
{
GList *tmp_next;
/* printf("Gotcha at %p\n", ((Guide*)guides->data)); */
success = TRUE;
tmp_next = g_list_next(guides);
gimp_image_remove_guide (gimage, ((Guide*)guides->data));
guides = tmp_next;
}
else
{
guides = g_list_next(guides);
}
}
}
return_args = procedural_db_return_args (&gimp_image_delete_guide_proc,
success);
return return_args;
}
/* The gimp_image_findnext_guide procedure definition */
ProcArg gimp_image_findnext_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of current Guide (0 if first invocation)"
}
};
ProcArg gimp_image_findnext_guide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The next guide's guide_id"
}
};
ProcRecord gimp_image_findnext_guide_proc =
{
"gimp_image_findnext_guide",
"Find next Guide on an image",
"This procedure takes an image and a guide_id as input and finds the guide_id of the successor of the given guide_id in the image's Guide list. If the supplied guide_id is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide_id as an argument or the image has no guides.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_findnext_guide_args,
/* Output arguments */
1,
gimp_image_findnext_guide_out_args,
/* Exec method */
{ { gimp_image_findnext_guide_invoker } },
};
static Argument *
gimp_image_findnext_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
rtn_guide_id = 0;
if (guides == NULL) /* No guides */
{
rtn_guide_id = 0;
}
else
{
if (guide_id == 0) /* init - Return first guide_ID in list */
{
while (guides != NULL &&
((Guide*)guides->data)->position < 0)
guides = g_list_next(guides);
if (guides)
rtn_guide_id = ((Guide*)guides->data)->guide_ID;
}
else
{
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
/*printf("Gotcha at %p: %d, %d, %d\n",
((Guide*)guides->data),
((Guide*)guides->data)->position,
((Guide*)guides->data)->orientation,
((Guide*)guides->data)->guide_ID
);*/
success = TRUE;
if (g_list_next(guides) == NULL)
{
rtn_guide_id = 0;
}
else
{
GList* tmplist;
tmplist = g_list_next(guides);
rtn_guide_id = ((Guide*)tmplist->data)->guide_ID;
goto got_it;
}
}
guides = g_list_next(guides);
}
}
}
}
got_it:
return_args = procedural_db_return_args (&gimp_image_findnext_guide_proc,
success);
if (success)
return_args[1].value.pdb_int = rtn_guide_id;
return return_args;
}
/* The gimp_image_get_guide_orientation procedure definition */
ProcArg gimp_image_get_guide_orientation_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_orientation_out_args[] =
{
{ PDB_INT32,
"orientation",
"The guide's orientation - vert=0, horiz=1"
}
};
ProcRecord gimp_image_get_guide_orientation_proc =
{
"gimp_image_get_guide_orientation",
"Get orientation of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the orientations of the guide, where 0=vertical and 1=horizontal.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_orientation_args,
/* Output arguments */
1,
gimp_image_get_guide_orientation_out_args,
/* Exec method */
{ { gimp_image_get_guide_orientation_invoker } },
};
static Argument *
gimp_image_get_guide_orientation_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_orientation;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
switch (((Guide*)guides->data)->orientation)
{
case VERTICAL_GUIDE: rtn_orientation = 0; break;
case HORIZONTAL_GUIDE: rtn_orientation = 1; break;
default:
{
rtn_orientation = 0;
g_warning("Guide has bad orientation.");
break;
}
}
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_orientation_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_orientation;
return return_args;
}
/* The gimp_image_get_guide_position procedure definition */
ProcArg gimp_image_get_guide_position_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_position_out_args[] =
{
{ PDB_INT32,
"position",
"The guide's position relative to top or left of image"
}
};
ProcRecord gimp_image_get_guide_position_proc =
{
"gimp_image_get_guide_position",
"Get position of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the position of the guide relative to the top or left of the image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_position_args,
/* Output arguments */
1,
gimp_image_get_guide_position_out_args,
/* Exec method */
{ { gimp_image_get_guide_position_invoker } },
};
static Argument *
gimp_image_get_guide_position_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_position;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
rtn_position = ((Guide*)guides->data)->position;
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_position_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_position;
return return_args;
}
Guide*
gimp_image_add_hguide (GimpImage *gimage)
{
@ -784,6 +1414,7 @@ gimp_image_add_hguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = HORIZONTAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);
@ -799,6 +1430,7 @@ gimp_image_add_vguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = VERTICAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);

View File

@ -1,6 +1,7 @@
#ifndef __GIMPIMAGE_H__
#define __GIMPIMAGE_H__
#include "procedural_db.h"
#include "gimpimageF.h"
#include "boundary.h"
@ -81,6 +82,7 @@ struct _Guide
int ref_count;
int position;
int orientation;
guint32 guide_ID;
};
@ -197,5 +199,12 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* Exported for PDB */
extern ProcRecord gimp_image_add_hguide_proc;
extern ProcRecord gimp_image_add_vguide_proc;
extern ProcRecord gimp_image_delete_guide_proc;
extern ProcRecord gimp_image_findnext_guide_proc;
extern ProcRecord gimp_image_get_guide_orientation_proc;
extern ProcRecord gimp_image_get_guide_position_proc;
#endif

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gimpimageP.h"
#include "drawable.h"
@ -31,6 +32,16 @@
#include "layer_pvt.h"
#include "drawable_pvt.h" /* ick ick. */
/* Exported functions */
static Argument* gimp_image_add_hguide_invoker (Argument*);
static Argument* gimp_image_add_vguide_invoker (Argument*);
static Argument* gimp_image_delete_guide_invoker (Argument*);/*fixme:refcount*/
static Argument* gimp_image_findnext_guide_invoker (Argument*);
static Argument* gimp_image_get_guide_orientation_invoker (Argument*);
static Argument* gimp_image_get_guide_position_invoker (Argument*);
/* Local function declarations */
static void gimp_image_free_projection (GimpImage *);
static void gimp_image_allocate_shadow (GimpImage *, int, int, int);
@ -71,6 +82,8 @@ int valid_combinations[][MAX_CHANNELS + 1] =
{ -1, -1, COMBINE_INDEXED_A_INDEXED_A, -1, -1 },
};
guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
/*
* Static variables
@ -230,8 +243,7 @@ gimp_image_new (int width, int height, int base_type)
case INDEXED:
/* always allocate 256 colors for the colormap */
gimage->num_cols = 0;
gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE);
memset (gimage->cmap, 0, COLORMAP_SIZE);
gimage->cmap = (unsigned char *) g_malloc0 (COLORMAP_SIZE);
break;
default:
break;
@ -776,6 +788,624 @@ gimp_image_transform_color (GimpImage *gimage, GimpDrawable *drawable,
}
}
/* The gimp_image_add_hguide procedure definition */
ProcArg gimp_image_add_hguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"yposition",
"The guide's y-offset from top of image"
}
};
ProcArg gimp_image_add_hguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_hguide_proc =
{
"gimp_image_add_hguide",
"Add a horizontal Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the y-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_hguide_args,
/* Output arguments */
1,
gimp_image_add_hguide_out_args,
/* Exec method */
{ { gimp_image_add_hguide_invoker } },
};
static Argument *
gimp_image_add_hguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_hguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_hguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_add_vguide procedure definition */
ProcArg gimp_image_add_vguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"xposition",
"The guide's x-offset from left of image"
}
};
ProcArg gimp_image_add_vguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_vguide_proc =
{
"gimp_image_add_vguide",
"Add a vertical Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the x-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_vguide_args,
/* Output arguments */
1,
gimp_image_add_vguide_out_args,
/* Exec method */
{ { gimp_image_add_vguide_invoker } },
};
static Argument *
gimp_image_add_vguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_vguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_vguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_delete_guide procedure definition */
ProcArg gimp_image_delete_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of the Guide to be removed"
}
};
ProcRecord gimp_image_delete_guide_proc =
{
"gimp_image_delete_guide",
"Deletes a Guide from an image",
"This procedure takes an image and a guide_id as input and removes the specified Guide from the specified image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_delete_guide_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { gimp_image_delete_guide_invoker } },
};
static Argument *
gimp_image_delete_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
success = FALSE;
guides = gimage->guides;
while (guides)
{
if (((Guide*)guides->data)->guide_ID == guide_id)
{
GList *tmp_next;
/* printf("Gotcha at %p\n", ((Guide*)guides->data)); */
success = TRUE;
tmp_next = g_list_next(guides);
gimp_image_remove_guide (gimage, ((Guide*)guides->data));
guides = tmp_next;
}
else
{
guides = g_list_next(guides);
}
}
}
return_args = procedural_db_return_args (&gimp_image_delete_guide_proc,
success);
return return_args;
}
/* The gimp_image_findnext_guide procedure definition */
ProcArg gimp_image_findnext_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of current Guide (0 if first invocation)"
}
};
ProcArg gimp_image_findnext_guide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The next guide's guide_id"
}
};
ProcRecord gimp_image_findnext_guide_proc =
{
"gimp_image_findnext_guide",
"Find next Guide on an image",
"This procedure takes an image and a guide_id as input and finds the guide_id of the successor of the given guide_id in the image's Guide list. If the supplied guide_id is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide_id as an argument or the image has no guides.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_findnext_guide_args,
/* Output arguments */
1,
gimp_image_findnext_guide_out_args,
/* Exec method */
{ { gimp_image_findnext_guide_invoker } },
};
static Argument *
gimp_image_findnext_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
rtn_guide_id = 0;
if (guides == NULL) /* No guides */
{
rtn_guide_id = 0;
}
else
{
if (guide_id == 0) /* init - Return first guide_ID in list */
{
while (guides != NULL &&
((Guide*)guides->data)->position < 0)
guides = g_list_next(guides);
if (guides)
rtn_guide_id = ((Guide*)guides->data)->guide_ID;
}
else
{
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
/*printf("Gotcha at %p: %d, %d, %d\n",
((Guide*)guides->data),
((Guide*)guides->data)->position,
((Guide*)guides->data)->orientation,
((Guide*)guides->data)->guide_ID
);*/
success = TRUE;
if (g_list_next(guides) == NULL)
{
rtn_guide_id = 0;
}
else
{
GList* tmplist;
tmplist = g_list_next(guides);
rtn_guide_id = ((Guide*)tmplist->data)->guide_ID;
goto got_it;
}
}
guides = g_list_next(guides);
}
}
}
}
got_it:
return_args = procedural_db_return_args (&gimp_image_findnext_guide_proc,
success);
if (success)
return_args[1].value.pdb_int = rtn_guide_id;
return return_args;
}
/* The gimp_image_get_guide_orientation procedure definition */
ProcArg gimp_image_get_guide_orientation_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_orientation_out_args[] =
{
{ PDB_INT32,
"orientation",
"The guide's orientation - vert=0, horiz=1"
}
};
ProcRecord gimp_image_get_guide_orientation_proc =
{
"gimp_image_get_guide_orientation",
"Get orientation of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the orientations of the guide, where 0=vertical and 1=horizontal.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_orientation_args,
/* Output arguments */
1,
gimp_image_get_guide_orientation_out_args,
/* Exec method */
{ { gimp_image_get_guide_orientation_invoker } },
};
static Argument *
gimp_image_get_guide_orientation_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_orientation;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
switch (((Guide*)guides->data)->orientation)
{
case VERTICAL_GUIDE: rtn_orientation = 0; break;
case HORIZONTAL_GUIDE: rtn_orientation = 1; break;
default:
{
rtn_orientation = 0;
g_warning("Guide has bad orientation.");
break;
}
}
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_orientation_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_orientation;
return return_args;
}
/* The gimp_image_get_guide_position procedure definition */
ProcArg gimp_image_get_guide_position_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_position_out_args[] =
{
{ PDB_INT32,
"position",
"The guide's position relative to top or left of image"
}
};
ProcRecord gimp_image_get_guide_position_proc =
{
"gimp_image_get_guide_position",
"Get position of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the position of the guide relative to the top or left of the image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_position_args,
/* Output arguments */
1,
gimp_image_get_guide_position_out_args,
/* Exec method */
{ { gimp_image_get_guide_position_invoker } },
};
static Argument *
gimp_image_get_guide_position_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_position;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
rtn_position = ((Guide*)guides->data)->position;
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_position_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_position;
return return_args;
}
Guide*
gimp_image_add_hguide (GimpImage *gimage)
{
@ -784,6 +1414,7 @@ gimp_image_add_hguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = HORIZONTAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);
@ -799,6 +1430,7 @@ gimp_image_add_vguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = VERTICAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);

View File

@ -1,6 +1,7 @@
#ifndef __GIMPIMAGE_H__
#define __GIMPIMAGE_H__
#include "procedural_db.h"
#include "gimpimageF.h"
#include "boundary.h"
@ -81,6 +82,7 @@ struct _Guide
int ref_count;
int position;
int orientation;
guint32 guide_ID;
};
@ -197,5 +199,12 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* Exported for PDB */
extern ProcRecord gimp_image_add_hguide_proc;
extern ProcRecord gimp_image_add_vguide_proc;
extern ProcRecord gimp_image_delete_guide_proc;
extern ProcRecord gimp_image_findnext_guide_proc;
extern ProcRecord gimp_image_get_guide_orientation_proc;
extern ProcRecord gimp_image_get_guide_position_proc;
#endif

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gimpimageP.h"
#include "drawable.h"
@ -31,6 +32,16 @@
#include "layer_pvt.h"
#include "drawable_pvt.h" /* ick ick. */
/* Exported functions */
static Argument* gimp_image_add_hguide_invoker (Argument*);
static Argument* gimp_image_add_vguide_invoker (Argument*);
static Argument* gimp_image_delete_guide_invoker (Argument*);/*fixme:refcount*/
static Argument* gimp_image_findnext_guide_invoker (Argument*);
static Argument* gimp_image_get_guide_orientation_invoker (Argument*);
static Argument* gimp_image_get_guide_position_invoker (Argument*);
/* Local function declarations */
static void gimp_image_free_projection (GimpImage *);
static void gimp_image_allocate_shadow (GimpImage *, int, int, int);
@ -71,6 +82,8 @@ int valid_combinations[][MAX_CHANNELS + 1] =
{ -1, -1, COMBINE_INDEXED_A_INDEXED_A, -1, -1 },
};
guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
/*
* Static variables
@ -230,8 +243,7 @@ gimp_image_new (int width, int height, int base_type)
case INDEXED:
/* always allocate 256 colors for the colormap */
gimage->num_cols = 0;
gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE);
memset (gimage->cmap, 0, COLORMAP_SIZE);
gimage->cmap = (unsigned char *) g_malloc0 (COLORMAP_SIZE);
break;
default:
break;
@ -776,6 +788,624 @@ gimp_image_transform_color (GimpImage *gimage, GimpDrawable *drawable,
}
}
/* The gimp_image_add_hguide procedure definition */
ProcArg gimp_image_add_hguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"yposition",
"The guide's y-offset from top of image"
}
};
ProcArg gimp_image_add_hguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_hguide_proc =
{
"gimp_image_add_hguide",
"Add a horizontal Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the y-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_hguide_args,
/* Output arguments */
1,
gimp_image_add_hguide_out_args,
/* Exec method */
{ { gimp_image_add_hguide_invoker } },
};
static Argument *
gimp_image_add_hguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_hguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_hguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_add_vguide procedure definition */
ProcArg gimp_image_add_vguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"xposition",
"The guide's x-offset from left of image"
}
};
ProcArg gimp_image_add_vguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_vguide_proc =
{
"gimp_image_add_vguide",
"Add a vertical Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the x-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_vguide_args,
/* Output arguments */
1,
gimp_image_add_vguide_out_args,
/* Exec method */
{ { gimp_image_add_vguide_invoker } },
};
static Argument *
gimp_image_add_vguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_vguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_vguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_delete_guide procedure definition */
ProcArg gimp_image_delete_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of the Guide to be removed"
}
};
ProcRecord gimp_image_delete_guide_proc =
{
"gimp_image_delete_guide",
"Deletes a Guide from an image",
"This procedure takes an image and a guide_id as input and removes the specified Guide from the specified image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_delete_guide_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { gimp_image_delete_guide_invoker } },
};
static Argument *
gimp_image_delete_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
success = FALSE;
guides = gimage->guides;
while (guides)
{
if (((Guide*)guides->data)->guide_ID == guide_id)
{
GList *tmp_next;
/* printf("Gotcha at %p\n", ((Guide*)guides->data)); */
success = TRUE;
tmp_next = g_list_next(guides);
gimp_image_remove_guide (gimage, ((Guide*)guides->data));
guides = tmp_next;
}
else
{
guides = g_list_next(guides);
}
}
}
return_args = procedural_db_return_args (&gimp_image_delete_guide_proc,
success);
return return_args;
}
/* The gimp_image_findnext_guide procedure definition */
ProcArg gimp_image_findnext_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of current Guide (0 if first invocation)"
}
};
ProcArg gimp_image_findnext_guide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The next guide's guide_id"
}
};
ProcRecord gimp_image_findnext_guide_proc =
{
"gimp_image_findnext_guide",
"Find next Guide on an image",
"This procedure takes an image and a guide_id as input and finds the guide_id of the successor of the given guide_id in the image's Guide list. If the supplied guide_id is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide_id as an argument or the image has no guides.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_findnext_guide_args,
/* Output arguments */
1,
gimp_image_findnext_guide_out_args,
/* Exec method */
{ { gimp_image_findnext_guide_invoker } },
};
static Argument *
gimp_image_findnext_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
rtn_guide_id = 0;
if (guides == NULL) /* No guides */
{
rtn_guide_id = 0;
}
else
{
if (guide_id == 0) /* init - Return first guide_ID in list */
{
while (guides != NULL &&
((Guide*)guides->data)->position < 0)
guides = g_list_next(guides);
if (guides)
rtn_guide_id = ((Guide*)guides->data)->guide_ID;
}
else
{
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
/*printf("Gotcha at %p: %d, %d, %d\n",
((Guide*)guides->data),
((Guide*)guides->data)->position,
((Guide*)guides->data)->orientation,
((Guide*)guides->data)->guide_ID
);*/
success = TRUE;
if (g_list_next(guides) == NULL)
{
rtn_guide_id = 0;
}
else
{
GList* tmplist;
tmplist = g_list_next(guides);
rtn_guide_id = ((Guide*)tmplist->data)->guide_ID;
goto got_it;
}
}
guides = g_list_next(guides);
}
}
}
}
got_it:
return_args = procedural_db_return_args (&gimp_image_findnext_guide_proc,
success);
if (success)
return_args[1].value.pdb_int = rtn_guide_id;
return return_args;
}
/* The gimp_image_get_guide_orientation procedure definition */
ProcArg gimp_image_get_guide_orientation_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_orientation_out_args[] =
{
{ PDB_INT32,
"orientation",
"The guide's orientation - vert=0, horiz=1"
}
};
ProcRecord gimp_image_get_guide_orientation_proc =
{
"gimp_image_get_guide_orientation",
"Get orientation of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the orientations of the guide, where 0=vertical and 1=horizontal.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_orientation_args,
/* Output arguments */
1,
gimp_image_get_guide_orientation_out_args,
/* Exec method */
{ { gimp_image_get_guide_orientation_invoker } },
};
static Argument *
gimp_image_get_guide_orientation_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_orientation;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
switch (((Guide*)guides->data)->orientation)
{
case VERTICAL_GUIDE: rtn_orientation = 0; break;
case HORIZONTAL_GUIDE: rtn_orientation = 1; break;
default:
{
rtn_orientation = 0;
g_warning("Guide has bad orientation.");
break;
}
}
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_orientation_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_orientation;
return return_args;
}
/* The gimp_image_get_guide_position procedure definition */
ProcArg gimp_image_get_guide_position_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_position_out_args[] =
{
{ PDB_INT32,
"position",
"The guide's position relative to top or left of image"
}
};
ProcRecord gimp_image_get_guide_position_proc =
{
"gimp_image_get_guide_position",
"Get position of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the position of the guide relative to the top or left of the image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_position_args,
/* Output arguments */
1,
gimp_image_get_guide_position_out_args,
/* Exec method */
{ { gimp_image_get_guide_position_invoker } },
};
static Argument *
gimp_image_get_guide_position_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_position;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
rtn_position = ((Guide*)guides->data)->position;
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_position_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_position;
return return_args;
}
Guide*
gimp_image_add_hguide (GimpImage *gimage)
{
@ -784,6 +1414,7 @@ gimp_image_add_hguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = HORIZONTAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);
@ -799,6 +1430,7 @@ gimp_image_add_vguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = VERTICAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);

View File

@ -1,6 +1,7 @@
#ifndef __GIMPIMAGE_H__
#define __GIMPIMAGE_H__
#include "procedural_db.h"
#include "gimpimageF.h"
#include "boundary.h"
@ -81,6 +82,7 @@ struct _Guide
int ref_count;
int position;
int orientation;
guint32 guide_ID;
};
@ -197,5 +199,12 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* Exported for PDB */
extern ProcRecord gimp_image_add_hguide_proc;
extern ProcRecord gimp_image_add_vguide_proc;
extern ProcRecord gimp_image_delete_guide_proc;
extern ProcRecord gimp_image_findnext_guide_proc;
extern ProcRecord gimp_image_get_guide_orientation_proc;
extern ProcRecord gimp_image_get_guide_position_proc;
#endif

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gimpimageP.h"
#include "drawable.h"
@ -31,6 +32,16 @@
#include "layer_pvt.h"
#include "drawable_pvt.h" /* ick ick. */
/* Exported functions */
static Argument* gimp_image_add_hguide_invoker (Argument*);
static Argument* gimp_image_add_vguide_invoker (Argument*);
static Argument* gimp_image_delete_guide_invoker (Argument*);/*fixme:refcount*/
static Argument* gimp_image_findnext_guide_invoker (Argument*);
static Argument* gimp_image_get_guide_orientation_invoker (Argument*);
static Argument* gimp_image_get_guide_position_invoker (Argument*);
/* Local function declarations */
static void gimp_image_free_projection (GimpImage *);
static void gimp_image_allocate_shadow (GimpImage *, int, int, int);
@ -71,6 +82,8 @@ int valid_combinations[][MAX_CHANNELS + 1] =
{ -1, -1, COMBINE_INDEXED_A_INDEXED_A, -1, -1 },
};
guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
/*
* Static variables
@ -230,8 +243,7 @@ gimp_image_new (int width, int height, int base_type)
case INDEXED:
/* always allocate 256 colors for the colormap */
gimage->num_cols = 0;
gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE);
memset (gimage->cmap, 0, COLORMAP_SIZE);
gimage->cmap = (unsigned char *) g_malloc0 (COLORMAP_SIZE);
break;
default:
break;
@ -776,6 +788,624 @@ gimp_image_transform_color (GimpImage *gimage, GimpDrawable *drawable,
}
}
/* The gimp_image_add_hguide procedure definition */
ProcArg gimp_image_add_hguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"yposition",
"The guide's y-offset from top of image"
}
};
ProcArg gimp_image_add_hguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_hguide_proc =
{
"gimp_image_add_hguide",
"Add a horizontal Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the y-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_hguide_args,
/* Output arguments */
1,
gimp_image_add_hguide_out_args,
/* Exec method */
{ { gimp_image_add_hguide_invoker } },
};
static Argument *
gimp_image_add_hguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_hguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_hguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_add_vguide procedure definition */
ProcArg gimp_image_add_vguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"xposition",
"The guide's x-offset from left of image"
}
};
ProcArg gimp_image_add_vguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_vguide_proc =
{
"gimp_image_add_vguide",
"Add a vertical Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the x-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_vguide_args,
/* Output arguments */
1,
gimp_image_add_vguide_out_args,
/* Exec method */
{ { gimp_image_add_vguide_invoker } },
};
static Argument *
gimp_image_add_vguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_vguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_vguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_delete_guide procedure definition */
ProcArg gimp_image_delete_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of the Guide to be removed"
}
};
ProcRecord gimp_image_delete_guide_proc =
{
"gimp_image_delete_guide",
"Deletes a Guide from an image",
"This procedure takes an image and a guide_id as input and removes the specified Guide from the specified image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_delete_guide_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { gimp_image_delete_guide_invoker } },
};
static Argument *
gimp_image_delete_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
success = FALSE;
guides = gimage->guides;
while (guides)
{
if (((Guide*)guides->data)->guide_ID == guide_id)
{
GList *tmp_next;
/* printf("Gotcha at %p\n", ((Guide*)guides->data)); */
success = TRUE;
tmp_next = g_list_next(guides);
gimp_image_remove_guide (gimage, ((Guide*)guides->data));
guides = tmp_next;
}
else
{
guides = g_list_next(guides);
}
}
}
return_args = procedural_db_return_args (&gimp_image_delete_guide_proc,
success);
return return_args;
}
/* The gimp_image_findnext_guide procedure definition */
ProcArg gimp_image_findnext_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of current Guide (0 if first invocation)"
}
};
ProcArg gimp_image_findnext_guide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The next guide's guide_id"
}
};
ProcRecord gimp_image_findnext_guide_proc =
{
"gimp_image_findnext_guide",
"Find next Guide on an image",
"This procedure takes an image and a guide_id as input and finds the guide_id of the successor of the given guide_id in the image's Guide list. If the supplied guide_id is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide_id as an argument or the image has no guides.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_findnext_guide_args,
/* Output arguments */
1,
gimp_image_findnext_guide_out_args,
/* Exec method */
{ { gimp_image_findnext_guide_invoker } },
};
static Argument *
gimp_image_findnext_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
rtn_guide_id = 0;
if (guides == NULL) /* No guides */
{
rtn_guide_id = 0;
}
else
{
if (guide_id == 0) /* init - Return first guide_ID in list */
{
while (guides != NULL &&
((Guide*)guides->data)->position < 0)
guides = g_list_next(guides);
if (guides)
rtn_guide_id = ((Guide*)guides->data)->guide_ID;
}
else
{
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
/*printf("Gotcha at %p: %d, %d, %d\n",
((Guide*)guides->data),
((Guide*)guides->data)->position,
((Guide*)guides->data)->orientation,
((Guide*)guides->data)->guide_ID
);*/
success = TRUE;
if (g_list_next(guides) == NULL)
{
rtn_guide_id = 0;
}
else
{
GList* tmplist;
tmplist = g_list_next(guides);
rtn_guide_id = ((Guide*)tmplist->data)->guide_ID;
goto got_it;
}
}
guides = g_list_next(guides);
}
}
}
}
got_it:
return_args = procedural_db_return_args (&gimp_image_findnext_guide_proc,
success);
if (success)
return_args[1].value.pdb_int = rtn_guide_id;
return return_args;
}
/* The gimp_image_get_guide_orientation procedure definition */
ProcArg gimp_image_get_guide_orientation_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_orientation_out_args[] =
{
{ PDB_INT32,
"orientation",
"The guide's orientation - vert=0, horiz=1"
}
};
ProcRecord gimp_image_get_guide_orientation_proc =
{
"gimp_image_get_guide_orientation",
"Get orientation of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the orientations of the guide, where 0=vertical and 1=horizontal.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_orientation_args,
/* Output arguments */
1,
gimp_image_get_guide_orientation_out_args,
/* Exec method */
{ { gimp_image_get_guide_orientation_invoker } },
};
static Argument *
gimp_image_get_guide_orientation_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_orientation;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
switch (((Guide*)guides->data)->orientation)
{
case VERTICAL_GUIDE: rtn_orientation = 0; break;
case HORIZONTAL_GUIDE: rtn_orientation = 1; break;
default:
{
rtn_orientation = 0;
g_warning("Guide has bad orientation.");
break;
}
}
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_orientation_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_orientation;
return return_args;
}
/* The gimp_image_get_guide_position procedure definition */
ProcArg gimp_image_get_guide_position_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_position_out_args[] =
{
{ PDB_INT32,
"position",
"The guide's position relative to top or left of image"
}
};
ProcRecord gimp_image_get_guide_position_proc =
{
"gimp_image_get_guide_position",
"Get position of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the position of the guide relative to the top or left of the image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_position_args,
/* Output arguments */
1,
gimp_image_get_guide_position_out_args,
/* Exec method */
{ { gimp_image_get_guide_position_invoker } },
};
static Argument *
gimp_image_get_guide_position_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_position;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
rtn_position = ((Guide*)guides->data)->position;
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_position_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_position;
return return_args;
}
Guide*
gimp_image_add_hguide (GimpImage *gimage)
{
@ -784,6 +1414,7 @@ gimp_image_add_hguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = HORIZONTAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);
@ -799,6 +1430,7 @@ gimp_image_add_vguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = VERTICAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);

View File

@ -1,6 +1,7 @@
#ifndef __GIMPIMAGE_H__
#define __GIMPIMAGE_H__
#include "procedural_db.h"
#include "gimpimageF.h"
#include "boundary.h"
@ -81,6 +82,7 @@ struct _Guide
int ref_count;
int position;
int orientation;
guint32 guide_ID;
};
@ -197,5 +199,12 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* Exported for PDB */
extern ProcRecord gimp_image_add_hguide_proc;
extern ProcRecord gimp_image_add_vguide_proc;
extern ProcRecord gimp_image_delete_guide_proc;
extern ProcRecord gimp_image_findnext_guide_proc;
extern ProcRecord gimp_image_get_guide_orientation_proc;
extern ProcRecord gimp_image_get_guide_position_proc;
#endif

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gimpimageP.h"
#include "drawable.h"
@ -31,6 +32,16 @@
#include "layer_pvt.h"
#include "drawable_pvt.h" /* ick ick. */
/* Exported functions */
static Argument* gimp_image_add_hguide_invoker (Argument*);
static Argument* gimp_image_add_vguide_invoker (Argument*);
static Argument* gimp_image_delete_guide_invoker (Argument*);/*fixme:refcount*/
static Argument* gimp_image_findnext_guide_invoker (Argument*);
static Argument* gimp_image_get_guide_orientation_invoker (Argument*);
static Argument* gimp_image_get_guide_position_invoker (Argument*);
/* Local function declarations */
static void gimp_image_free_projection (GimpImage *);
static void gimp_image_allocate_shadow (GimpImage *, int, int, int);
@ -71,6 +82,8 @@ int valid_combinations[][MAX_CHANNELS + 1] =
{ -1, -1, COMBINE_INDEXED_A_INDEXED_A, -1, -1 },
};
guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
/*
* Static variables
@ -230,8 +243,7 @@ gimp_image_new (int width, int height, int base_type)
case INDEXED:
/* always allocate 256 colors for the colormap */
gimage->num_cols = 0;
gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE);
memset (gimage->cmap, 0, COLORMAP_SIZE);
gimage->cmap = (unsigned char *) g_malloc0 (COLORMAP_SIZE);
break;
default:
break;
@ -776,6 +788,624 @@ gimp_image_transform_color (GimpImage *gimage, GimpDrawable *drawable,
}
}
/* The gimp_image_add_hguide procedure definition */
ProcArg gimp_image_add_hguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"yposition",
"The guide's y-offset from top of image"
}
};
ProcArg gimp_image_add_hguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_hguide_proc =
{
"gimp_image_add_hguide",
"Add a horizontal Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the y-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_hguide_args,
/* Output arguments */
1,
gimp_image_add_hguide_out_args,
/* Exec method */
{ { gimp_image_add_hguide_invoker } },
};
static Argument *
gimp_image_add_hguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_hguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_hguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_add_vguide procedure definition */
ProcArg gimp_image_add_vguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"xposition",
"The guide's x-offset from left of image"
}
};
ProcArg gimp_image_add_vguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_vguide_proc =
{
"gimp_image_add_vguide",
"Add a vertical Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the x-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_vguide_args,
/* Output arguments */
1,
gimp_image_add_vguide_out_args,
/* Exec method */
{ { gimp_image_add_vguide_invoker } },
};
static Argument *
gimp_image_add_vguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_vguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_vguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_delete_guide procedure definition */
ProcArg gimp_image_delete_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of the Guide to be removed"
}
};
ProcRecord gimp_image_delete_guide_proc =
{
"gimp_image_delete_guide",
"Deletes a Guide from an image",
"This procedure takes an image and a guide_id as input and removes the specified Guide from the specified image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_delete_guide_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { gimp_image_delete_guide_invoker } },
};
static Argument *
gimp_image_delete_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
success = FALSE;
guides = gimage->guides;
while (guides)
{
if (((Guide*)guides->data)->guide_ID == guide_id)
{
GList *tmp_next;
/* printf("Gotcha at %p\n", ((Guide*)guides->data)); */
success = TRUE;
tmp_next = g_list_next(guides);
gimp_image_remove_guide (gimage, ((Guide*)guides->data));
guides = tmp_next;
}
else
{
guides = g_list_next(guides);
}
}
}
return_args = procedural_db_return_args (&gimp_image_delete_guide_proc,
success);
return return_args;
}
/* The gimp_image_findnext_guide procedure definition */
ProcArg gimp_image_findnext_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of current Guide (0 if first invocation)"
}
};
ProcArg gimp_image_findnext_guide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The next guide's guide_id"
}
};
ProcRecord gimp_image_findnext_guide_proc =
{
"gimp_image_findnext_guide",
"Find next Guide on an image",
"This procedure takes an image and a guide_id as input and finds the guide_id of the successor of the given guide_id in the image's Guide list. If the supplied guide_id is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide_id as an argument or the image has no guides.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_findnext_guide_args,
/* Output arguments */
1,
gimp_image_findnext_guide_out_args,
/* Exec method */
{ { gimp_image_findnext_guide_invoker } },
};
static Argument *
gimp_image_findnext_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
rtn_guide_id = 0;
if (guides == NULL) /* No guides */
{
rtn_guide_id = 0;
}
else
{
if (guide_id == 0) /* init - Return first guide_ID in list */
{
while (guides != NULL &&
((Guide*)guides->data)->position < 0)
guides = g_list_next(guides);
if (guides)
rtn_guide_id = ((Guide*)guides->data)->guide_ID;
}
else
{
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
/*printf("Gotcha at %p: %d, %d, %d\n",
((Guide*)guides->data),
((Guide*)guides->data)->position,
((Guide*)guides->data)->orientation,
((Guide*)guides->data)->guide_ID
);*/
success = TRUE;
if (g_list_next(guides) == NULL)
{
rtn_guide_id = 0;
}
else
{
GList* tmplist;
tmplist = g_list_next(guides);
rtn_guide_id = ((Guide*)tmplist->data)->guide_ID;
goto got_it;
}
}
guides = g_list_next(guides);
}
}
}
}
got_it:
return_args = procedural_db_return_args (&gimp_image_findnext_guide_proc,
success);
if (success)
return_args[1].value.pdb_int = rtn_guide_id;
return return_args;
}
/* The gimp_image_get_guide_orientation procedure definition */
ProcArg gimp_image_get_guide_orientation_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_orientation_out_args[] =
{
{ PDB_INT32,
"orientation",
"The guide's orientation - vert=0, horiz=1"
}
};
ProcRecord gimp_image_get_guide_orientation_proc =
{
"gimp_image_get_guide_orientation",
"Get orientation of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the orientations of the guide, where 0=vertical and 1=horizontal.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_orientation_args,
/* Output arguments */
1,
gimp_image_get_guide_orientation_out_args,
/* Exec method */
{ { gimp_image_get_guide_orientation_invoker } },
};
static Argument *
gimp_image_get_guide_orientation_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_orientation;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
switch (((Guide*)guides->data)->orientation)
{
case VERTICAL_GUIDE: rtn_orientation = 0; break;
case HORIZONTAL_GUIDE: rtn_orientation = 1; break;
default:
{
rtn_orientation = 0;
g_warning("Guide has bad orientation.");
break;
}
}
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_orientation_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_orientation;
return return_args;
}
/* The gimp_image_get_guide_position procedure definition */
ProcArg gimp_image_get_guide_position_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_position_out_args[] =
{
{ PDB_INT32,
"position",
"The guide's position relative to top or left of image"
}
};
ProcRecord gimp_image_get_guide_position_proc =
{
"gimp_image_get_guide_position",
"Get position of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the position of the guide relative to the top or left of the image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_position_args,
/* Output arguments */
1,
gimp_image_get_guide_position_out_args,
/* Exec method */
{ { gimp_image_get_guide_position_invoker } },
};
static Argument *
gimp_image_get_guide_position_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_position;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
rtn_position = ((Guide*)guides->data)->position;
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_position_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_position;
return return_args;
}
Guide*
gimp_image_add_hguide (GimpImage *gimage)
{
@ -784,6 +1414,7 @@ gimp_image_add_hguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = HORIZONTAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);
@ -799,6 +1430,7 @@ gimp_image_add_vguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = VERTICAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);

View File

@ -1,6 +1,7 @@
#ifndef __GIMPIMAGE_H__
#define __GIMPIMAGE_H__
#include "procedural_db.h"
#include "gimpimageF.h"
#include "boundary.h"
@ -81,6 +82,7 @@ struct _Guide
int ref_count;
int position;
int orientation;
guint32 guide_ID;
};
@ -197,5 +199,12 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* Exported for PDB */
extern ProcRecord gimp_image_add_hguide_proc;
extern ProcRecord gimp_image_add_vguide_proc;
extern ProcRecord gimp_image_delete_guide_proc;
extern ProcRecord gimp_image_findnext_guide_proc;
extern ProcRecord gimp_image_get_guide_orientation_proc;
extern ProcRecord gimp_image_get_guide_position_proc;
#endif

View File

@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include "drawable.h"
#include "errors.h"
#include "floating_sel.h"

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gimpimageP.h"
#include "drawable.h"
@ -31,6 +32,16 @@
#include "layer_pvt.h"
#include "drawable_pvt.h" /* ick ick. */
/* Exported functions */
static Argument* gimp_image_add_hguide_invoker (Argument*);
static Argument* gimp_image_add_vguide_invoker (Argument*);
static Argument* gimp_image_delete_guide_invoker (Argument*);/*fixme:refcount*/
static Argument* gimp_image_findnext_guide_invoker (Argument*);
static Argument* gimp_image_get_guide_orientation_invoker (Argument*);
static Argument* gimp_image_get_guide_position_invoker (Argument*);
/* Local function declarations */
static void gimp_image_free_projection (GimpImage *);
static void gimp_image_allocate_shadow (GimpImage *, int, int, int);
@ -71,6 +82,8 @@ int valid_combinations[][MAX_CHANNELS + 1] =
{ -1, -1, COMBINE_INDEXED_A_INDEXED_A, -1, -1 },
};
guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
/*
* Static variables
@ -230,8 +243,7 @@ gimp_image_new (int width, int height, int base_type)
case INDEXED:
/* always allocate 256 colors for the colormap */
gimage->num_cols = 0;
gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE);
memset (gimage->cmap, 0, COLORMAP_SIZE);
gimage->cmap = (unsigned char *) g_malloc0 (COLORMAP_SIZE);
break;
default:
break;
@ -776,6 +788,624 @@ gimp_image_transform_color (GimpImage *gimage, GimpDrawable *drawable,
}
}
/* The gimp_image_add_hguide procedure definition */
ProcArg gimp_image_add_hguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"yposition",
"The guide's y-offset from top of image"
}
};
ProcArg gimp_image_add_hguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_hguide_proc =
{
"gimp_image_add_hguide",
"Add a horizontal Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the y-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_hguide_args,
/* Output arguments */
1,
gimp_image_add_hguide_out_args,
/* Exec method */
{ { gimp_image_add_hguide_invoker } },
};
static Argument *
gimp_image_add_hguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_hguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_hguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_add_vguide procedure definition */
ProcArg gimp_image_add_vguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"xposition",
"The guide's x-offset from left of image"
}
};
ProcArg gimp_image_add_vguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_vguide_proc =
{
"gimp_image_add_vguide",
"Add a vertical Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the x-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_vguide_args,
/* Output arguments */
1,
gimp_image_add_vguide_out_args,
/* Exec method */
{ { gimp_image_add_vguide_invoker } },
};
static Argument *
gimp_image_add_vguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_vguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_vguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_delete_guide procedure definition */
ProcArg gimp_image_delete_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of the Guide to be removed"
}
};
ProcRecord gimp_image_delete_guide_proc =
{
"gimp_image_delete_guide",
"Deletes a Guide from an image",
"This procedure takes an image and a guide_id as input and removes the specified Guide from the specified image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_delete_guide_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { gimp_image_delete_guide_invoker } },
};
static Argument *
gimp_image_delete_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
success = FALSE;
guides = gimage->guides;
while (guides)
{
if (((Guide*)guides->data)->guide_ID == guide_id)
{
GList *tmp_next;
/* printf("Gotcha at %p\n", ((Guide*)guides->data)); */
success = TRUE;
tmp_next = g_list_next(guides);
gimp_image_remove_guide (gimage, ((Guide*)guides->data));
guides = tmp_next;
}
else
{
guides = g_list_next(guides);
}
}
}
return_args = procedural_db_return_args (&gimp_image_delete_guide_proc,
success);
return return_args;
}
/* The gimp_image_findnext_guide procedure definition */
ProcArg gimp_image_findnext_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of current Guide (0 if first invocation)"
}
};
ProcArg gimp_image_findnext_guide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The next guide's guide_id"
}
};
ProcRecord gimp_image_findnext_guide_proc =
{
"gimp_image_findnext_guide",
"Find next Guide on an image",
"This procedure takes an image and a guide_id as input and finds the guide_id of the successor of the given guide_id in the image's Guide list. If the supplied guide_id is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide_id as an argument or the image has no guides.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_findnext_guide_args,
/* Output arguments */
1,
gimp_image_findnext_guide_out_args,
/* Exec method */
{ { gimp_image_findnext_guide_invoker } },
};
static Argument *
gimp_image_findnext_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
rtn_guide_id = 0;
if (guides == NULL) /* No guides */
{
rtn_guide_id = 0;
}
else
{
if (guide_id == 0) /* init - Return first guide_ID in list */
{
while (guides != NULL &&
((Guide*)guides->data)->position < 0)
guides = g_list_next(guides);
if (guides)
rtn_guide_id = ((Guide*)guides->data)->guide_ID;
}
else
{
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
/*printf("Gotcha at %p: %d, %d, %d\n",
((Guide*)guides->data),
((Guide*)guides->data)->position,
((Guide*)guides->data)->orientation,
((Guide*)guides->data)->guide_ID
);*/
success = TRUE;
if (g_list_next(guides) == NULL)
{
rtn_guide_id = 0;
}
else
{
GList* tmplist;
tmplist = g_list_next(guides);
rtn_guide_id = ((Guide*)tmplist->data)->guide_ID;
goto got_it;
}
}
guides = g_list_next(guides);
}
}
}
}
got_it:
return_args = procedural_db_return_args (&gimp_image_findnext_guide_proc,
success);
if (success)
return_args[1].value.pdb_int = rtn_guide_id;
return return_args;
}
/* The gimp_image_get_guide_orientation procedure definition */
ProcArg gimp_image_get_guide_orientation_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_orientation_out_args[] =
{
{ PDB_INT32,
"orientation",
"The guide's orientation - vert=0, horiz=1"
}
};
ProcRecord gimp_image_get_guide_orientation_proc =
{
"gimp_image_get_guide_orientation",
"Get orientation of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the orientations of the guide, where 0=vertical and 1=horizontal.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_orientation_args,
/* Output arguments */
1,
gimp_image_get_guide_orientation_out_args,
/* Exec method */
{ { gimp_image_get_guide_orientation_invoker } },
};
static Argument *
gimp_image_get_guide_orientation_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_orientation;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
switch (((Guide*)guides->data)->orientation)
{
case VERTICAL_GUIDE: rtn_orientation = 0; break;
case HORIZONTAL_GUIDE: rtn_orientation = 1; break;
default:
{
rtn_orientation = 0;
g_warning("Guide has bad orientation.");
break;
}
}
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_orientation_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_orientation;
return return_args;
}
/* The gimp_image_get_guide_position procedure definition */
ProcArg gimp_image_get_guide_position_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_position_out_args[] =
{
{ PDB_INT32,
"position",
"The guide's position relative to top or left of image"
}
};
ProcRecord gimp_image_get_guide_position_proc =
{
"gimp_image_get_guide_position",
"Get position of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the position of the guide relative to the top or left of the image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_position_args,
/* Output arguments */
1,
gimp_image_get_guide_position_out_args,
/* Exec method */
{ { gimp_image_get_guide_position_invoker } },
};
static Argument *
gimp_image_get_guide_position_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_position;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
rtn_position = ((Guide*)guides->data)->position;
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_position_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_position;
return return_args;
}
Guide*
gimp_image_add_hguide (GimpImage *gimage)
{
@ -784,6 +1414,7 @@ gimp_image_add_hguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = HORIZONTAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);
@ -799,6 +1430,7 @@ gimp_image_add_vguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = VERTICAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);

View File

@ -1,6 +1,7 @@
#ifndef __GIMPIMAGE_H__
#define __GIMPIMAGE_H__
#include "procedural_db.h"
#include "gimpimageF.h"
#include "boundary.h"
@ -81,6 +82,7 @@ struct _Guide
int ref_count;
int position;
int orientation;
guint32 guide_ID;
};
@ -197,5 +199,12 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* Exported for PDB */
extern ProcRecord gimp_image_add_hguide_proc;
extern ProcRecord gimp_image_add_vguide_proc;
extern ProcRecord gimp_image_delete_guide_proc;
extern ProcRecord gimp_image_findnext_guide_proc;
extern ProcRecord gimp_image_get_guide_orientation_proc;
extern ProcRecord gimp_image_get_guide_position_proc;
#endif

View File

@ -119,4 +119,6 @@ gimage_foreach (GFunc func, gpointer user_data);
#define gimage_preview_valid gimp_image_preview_valid
#define gimage_invalidate_preview gimp_image_invalidate_preview
extern guint32 next_guide_id;
#endif /* __GIMAGE_H__ */

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include "gimpimageP.h"
#include "drawable.h"
@ -31,6 +32,16 @@
#include "layer_pvt.h"
#include "drawable_pvt.h" /* ick ick. */
/* Exported functions */
static Argument* gimp_image_add_hguide_invoker (Argument*);
static Argument* gimp_image_add_vguide_invoker (Argument*);
static Argument* gimp_image_delete_guide_invoker (Argument*);/*fixme:refcount*/
static Argument* gimp_image_findnext_guide_invoker (Argument*);
static Argument* gimp_image_get_guide_orientation_invoker (Argument*);
static Argument* gimp_image_get_guide_position_invoker (Argument*);
/* Local function declarations */
static void gimp_image_free_projection (GimpImage *);
static void gimp_image_allocate_shadow (GimpImage *, int, int, int);
@ -71,6 +82,8 @@ int valid_combinations[][MAX_CHANNELS + 1] =
{ -1, -1, COMBINE_INDEXED_A_INDEXED_A, -1, -1 },
};
guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
/*
* Static variables
@ -230,8 +243,7 @@ gimp_image_new (int width, int height, int base_type)
case INDEXED:
/* always allocate 256 colors for the colormap */
gimage->num_cols = 0;
gimage->cmap = (unsigned char *) g_malloc (COLORMAP_SIZE);
memset (gimage->cmap, 0, COLORMAP_SIZE);
gimage->cmap = (unsigned char *) g_malloc0 (COLORMAP_SIZE);
break;
default:
break;
@ -776,6 +788,624 @@ gimp_image_transform_color (GimpImage *gimage, GimpDrawable *drawable,
}
}
/* The gimp_image_add_hguide procedure definition */
ProcArg gimp_image_add_hguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"yposition",
"The guide's y-offset from top of image"
}
};
ProcArg gimp_image_add_hguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_hguide_proc =
{
"gimp_image_add_hguide",
"Add a horizontal Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the y-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_hguide_args,
/* Output arguments */
1,
gimp_image_add_hguide_out_args,
/* Exec method */
{ { gimp_image_add_hguide_invoker } },
};
static Argument *
gimp_image_add_hguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_hguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_hguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_add_vguide procedure definition */
ProcArg gimp_image_add_vguide_args[] =
{
{ PDB_IMAGE,
"image",
"the input image"
},
{ PDB_INT32,
"xposition",
"The guide's x-offset from left of image"
}
};
ProcArg gimp_image_add_vguide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The new guide's guide_id"
}
};
ProcRecord gimp_image_add_vguide_proc =
{
"gimp_image_add_vguide",
"Add a vertical Guide to an image",
"This procedure adds a horizontal Guide to an image. It takes the input image and the x-position of the new Guide as parameters. It returns the guide_id of the new Guide.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_add_vguide_args,
/* Output arguments */
1,
gimp_image_add_vguide_out_args,
/* Exec method */
{ { gimp_image_add_vguide_invoker } },
};
static Argument *
gimp_image_add_vguide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int offset;
GImage *gimage;
Guide *guide;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
offset = args[1].value.pdb_int;
guide = gimp_image_add_vguide ((void *) gimage);
guide->position = offset;
}
return_args = procedural_db_return_args (&gimp_image_add_vguide_proc,
success);
if (success)
return_args[1].value.pdb_int = guide->guide_ID;
return return_args;
}
/* The gimp_image_delete_guide procedure definition */
ProcArg gimp_image_delete_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of the Guide to be removed"
}
};
ProcRecord gimp_image_delete_guide_proc =
{
"gimp_image_delete_guide",
"Deletes a Guide from an image",
"This procedure takes an image and a guide_id as input and removes the specified Guide from the specified image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_delete_guide_args,
/* Output arguments */
0,
NULL,
/* Exec method */
{ { gimp_image_delete_guide_invoker } },
};
static Argument *
gimp_image_delete_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
success = FALSE;
guides = gimage->guides;
while (guides)
{
if (((Guide*)guides->data)->guide_ID == guide_id)
{
GList *tmp_next;
/* printf("Gotcha at %p\n", ((Guide*)guides->data)); */
success = TRUE;
tmp_next = g_list_next(guides);
gimp_image_remove_guide (gimage, ((Guide*)guides->data));
guides = tmp_next;
}
else
{
guides = g_list_next(guides);
}
}
}
return_args = procedural_db_return_args (&gimp_image_delete_guide_proc,
success);
return return_args;
}
/* The gimp_image_findnext_guide procedure definition */
ProcArg gimp_image_findnext_guide_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID of current Guide (0 if first invocation)"
}
};
ProcArg gimp_image_findnext_guide_out_args[] =
{
{ PDB_INT32,
"guide_id",
"The next guide's guide_id"
}
};
ProcRecord gimp_image_findnext_guide_proc =
{
"gimp_image_findnext_guide",
"Find next Guide on an image",
"This procedure takes an image and a guide_id as input and finds the guide_id of the successor of the given guide_id in the image's Guide list. If the supplied guide_id is 0, the procedure will return the first Guide. The procedure will return 0 if given the final guide_id as an argument or the image has no guides.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_findnext_guide_args,
/* Output arguments */
1,
gimp_image_findnext_guide_out_args,
/* Exec method */
{ { gimp_image_findnext_guide_invoker } },
};
static Argument *
gimp_image_findnext_guide_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_guide_id;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
rtn_guide_id = 0;
if (guides == NULL) /* No guides */
{
rtn_guide_id = 0;
}
else
{
if (guide_id == 0) /* init - Return first guide_ID in list */
{
while (guides != NULL &&
((Guide*)guides->data)->position < 0)
guides = g_list_next(guides);
if (guides)
rtn_guide_id = ((Guide*)guides->data)->guide_ID;
}
else
{
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
/*printf("Gotcha at %p: %d, %d, %d\n",
((Guide*)guides->data),
((Guide*)guides->data)->position,
((Guide*)guides->data)->orientation,
((Guide*)guides->data)->guide_ID
);*/
success = TRUE;
if (g_list_next(guides) == NULL)
{
rtn_guide_id = 0;
}
else
{
GList* tmplist;
tmplist = g_list_next(guides);
rtn_guide_id = ((Guide*)tmplist->data)->guide_ID;
goto got_it;
}
}
guides = g_list_next(guides);
}
}
}
}
got_it:
return_args = procedural_db_return_args (&gimp_image_findnext_guide_proc,
success);
if (success)
return_args[1].value.pdb_int = rtn_guide_id;
return return_args;
}
/* The gimp_image_get_guide_orientation procedure definition */
ProcArg gimp_image_get_guide_orientation_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_orientation_out_args[] =
{
{ PDB_INT32,
"orientation",
"The guide's orientation - vert=0, horiz=1"
}
};
ProcRecord gimp_image_get_guide_orientation_proc =
{
"gimp_image_get_guide_orientation",
"Get orientation of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the orientations of the guide, where 0=vertical and 1=horizontal.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_orientation_args,
/* Output arguments */
1,
gimp_image_get_guide_orientation_out_args,
/* Exec method */
{ { gimp_image_get_guide_orientation_invoker } },
};
static Argument *
gimp_image_get_guide_orientation_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_orientation;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
switch (((Guide*)guides->data)->orientation)
{
case VERTICAL_GUIDE: rtn_orientation = 0; break;
case HORIZONTAL_GUIDE: rtn_orientation = 1; break;
default:
{
rtn_orientation = 0;
g_warning("Guide has bad orientation.");
break;
}
}
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_orientation_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_orientation;
return return_args;
}
/* The gimp_image_get_guide_position procedure definition */
ProcArg gimp_image_get_guide_position_args[] =
{
{ PDB_IMAGE,
"image",
"The input image"
},
{ PDB_INT32,
"guide_ID",
"The guide_ID"
}
};
ProcArg gimp_image_get_guide_position_out_args[] =
{
{ PDB_INT32,
"position",
"The guide's position relative to top or left of image"
}
};
ProcRecord gimp_image_get_guide_position_proc =
{
"gimp_image_get_guide_position",
"Get position of a Guide on an image",
"This procedure takes an image and a guide_id as input and returns the position of the guide relative to the top or left of the image.",
"Adam D. Moss",
"Adam D. Moss",
"1998",
PDB_INTERNAL,
/* Input arguments */
2,
gimp_image_get_guide_position_args,
/* Output arguments */
1,
gimp_image_get_guide_position_out_args,
/* Exec method */
{ { gimp_image_get_guide_position_invoker } },
};
static Argument *
gimp_image_get_guide_position_invoker (Argument *args)
{
int success = TRUE;
int int_value;
int guide_id;
int rtn_position;
GImage *gimage;
GList *guides;
Argument *return_args;
/* the gimage */
if (success)
{
int_value = args[0].value.pdb_int;
if (! (gimage = gimage_get_ID (int_value)))
success = FALSE;
}
if (success)
{
guide_id = args[1].value.pdb_int;
guides = gimage->guides;
success = FALSE;
while (guides)
{
if ((((Guide*)guides->data)->guide_ID == guide_id) &&
(((Guide*)guides->data)->position>=0) )
{
success = TRUE;
rtn_position = ((Guide*)guides->data)->position;
goto got_it;
}
guides = g_list_next(guides);
}
}
got_it:
return_args = procedural_db_return_args
(&gimp_image_get_guide_position_proc, success);
if (success)
return_args[1].value.pdb_int = rtn_position;
return return_args;
}
Guide*
gimp_image_add_hguide (GimpImage *gimage)
{
@ -784,6 +1414,7 @@ gimp_image_add_hguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = HORIZONTAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);
@ -799,6 +1430,7 @@ gimp_image_add_vguide (GimpImage *gimage)
guide = g_new (Guide, 1);
guide->ref_count = 0;
guide->position = -1;
guide->guide_ID = next_guide_id++;
guide->orientation = VERTICAL_GUIDE;
gimage->guides = g_list_prepend (gimage->guides, guide);

View File

@ -1,6 +1,7 @@
#ifndef __GIMPIMAGE_H__
#define __GIMPIMAGE_H__
#include "procedural_db.h"
#include "gimpimageF.h"
#include "boundary.h"
@ -81,6 +82,7 @@ struct _Guide
int ref_count;
int position;
int orientation;
guint32 guide_ID;
};
@ -197,5 +199,12 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* Exported for PDB */
extern ProcRecord gimp_image_add_hguide_proc;
extern ProcRecord gimp_image_add_vguide_proc;
extern ProcRecord gimp_image_delete_guide_proc;
extern ProcRecord gimp_image_findnext_guide_proc;
extern ProcRecord gimp_image_get_guide_orientation_proc;
extern ProcRecord gimp_image_get_guide_position_proc;
#endif

View File

@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include "drawable.h"
#include "errors.h"
#include "floating_sel.h"

View File

@ -177,6 +177,12 @@ internal_procs_init ()
procedural_db_register (&gimage_disable_undo_proc); pcount++;
procedural_db_register (&gimage_clean_all_proc); pcount++;
procedural_db_register (&gimage_floating_sel_proc); pcount++;
procedural_db_register (&gimp_image_add_hguide_proc); pcount++;
procedural_db_register (&gimp_image_add_vguide_proc); pcount++;
procedural_db_register (&gimp_image_delete_guide_proc); pcount++;
procedural_db_register (&gimp_image_findnext_guide_proc); pcount++;
procedural_db_register (&gimp_image_get_guide_orientation_proc); pcount++;
procedural_db_register (&gimp_image_get_guide_position_proc); pcount++;
app_init_update_status(NULL, "GImage mask procedures",
pcount/total_pcount);

View File

@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include "drawable.h"
#include "errors.h"
#include "floating_sel.h"

View File

@ -1438,6 +1438,7 @@ xcf_load_image_props (XcfInfo *info,
guide = g_new (Guide, 1);
guide->position = position;
guide->orientation = orientation;
guide->guide_ID = next_guide_id++;
gimage->guides = g_list_prepend (gimage->guides, guide);
}

View File

@ -1438,6 +1438,7 @@ xcf_load_image_props (XcfInfo *info,
guide = g_new (Guide, 1);
guide->position = position;
guide->orientation = orientation;
guide->guide_ID = next_guide_id++;
gimage->guides = g_list_prepend (gimage->guides, guide);
}