-Yosh
This commit is contained in:
Manish Singh 1999-03-28 06:36:11 +00:00
parent 21b5cd4467
commit a1a1b78c1b
18 changed files with 595 additions and 339 deletions

2
tools/pdbgen/.cvsignore Normal file
View File

@ -0,0 +1,2 @@
Makefile
Makefile.in

10
tools/pdbgen/Makefile.am Normal file
View File

@ -0,0 +1,10 @@
enum_headers = \
../../app/convert.h \
../../app/channel_ops.h \
../../app/text_tool.h \
../../app/gimpdrawable.h \
../../app/gimpimage.h
enums.pl: enumgen.pl $(enum_headers)
cd $(srcdir) \
&& $(PERL) enumgen.pl $(enum_headers)

View File

@ -79,7 +79,7 @@ sub declare_args {
unless (exists $_->{no_declare}) {
$result .= ' ' x 2 . $arg->{type} . &arg_vname($_);
if (!exists $_->{no_init} && exists $_->{init}) {
$result .= $arg->{type} =~ /\*$/ ? ' = NULL' : '0'
$result .= $arg->{type} =~ /\*$/ ? ' = NULL' : ' = 0'
}
$result .= ";\n";
@ -359,7 +359,6 @@ CODE
$out->{headers}->{$header}++;
}
}
$out->{headers}->{q/"procedural_db.h"/}++;
$out->{code} .= "\nstatic Argument *\n";
$out->{code} .= "${name}_invoker (Argument *args)\n{\n";
@ -460,14 +459,17 @@ CODE
}
$invoker .= &marshal_inargs($proc, 0);
$invoker .= "\n" if $invoker && $invoker !~ /\n\n/s;
my $frag = &format_code_frag($proc->{invoke}->{code}, $success);
my $frag = "";
if (exists $proc->{invoke}->{code}) {
$frag = &format_code_frag($proc->{invoke}->{code}, $success);
$frag = ' ' x 2 . "if (success)\n" . $frag if $success;
$success = ($frag =~ /success =/) unless $success;
}
chomp $invoker if !$frag;
$code .= $invoker . $frag;
$code .= "\n" if $frag =~ /\n\n/s || $invoker;
$code .= &marshal_outargs($proc) . "}\n";
@ -505,6 +507,8 @@ static ProcRecord ${name}_proc =
{ { ${name}_invoker } }
};
CODE
delete $out->{headers}->{q/"procedural_db.h"/};
}
my $gpl = <<'GPL';
@ -553,6 +557,7 @@ HEADER
my $cfile = "$destdir/${group}_cmds.c$FILE_EXT";
open CFILE, "> $cfile" or die "Can't open $cmdfile: $!\n";
print CFILE $gpl;
print CFILE qq/#include "procedural_db.h"\n\n/;
foreach $header (sort keys %{$out->{headers}}) {
print CFILE "#include $header\n";
}

View File

@ -41,6 +41,53 @@ package Gimp::CodeGen::enums;
symbols => [ qw(PIXELS POINTS) ],
mapping => { PIXELS => '0',
POINTS => '1' }
},
GimpFillType =>
{ contig => 1,
symbols => [ qw(FOREGROUND_FILL BACKGROUND_FILL WHITE_FILL
TRANSPARENT_FILL NO_FILL) ],
mapping => { FOREGROUND_FILL => '0',
BACKGROUND_FILL => '1',
WHITE_FILL => '2',
TRANSPARENT_FILL => '3',
NO_FILL => '4' }
},
GimpImageType =>
{ contig => 1,
symbols => [ qw(RGB_GIMAGE RGBA_GIMAGE GRAY_GIMAGE GRAYA_GIMAGE
INDEXED_GIMAGE INDEXEDA_GIMAGE) ],
mapping => { RGB_GIMAGE => '0',
RGBA_GIMAGE => '1',
GRAY_GIMAGE => '2',
GRAYA_GIMAGE => '3',
INDEXED_GIMAGE => '4',
INDEXEDA_GIMAGE => '5' }
},
GimpImageBaseType =>
{ contig => 1,
symbols => [ qw(RGB GRAY INDEXED) ],
mapping => { RGB => '0',
GRAY => '1',
INDEXED => '2' }
},
ChannelType =>
{ contig => 1,
symbols => [ qw(Red Green Blue Gray Indexed Auxillary) ],
mapping => { Red => '0',
Green => '1',
Blue => '2',
Gray => '3',
Indexed => '4',
Auxillary => '5' }
},
MergeType =>
{ contig => 1,
symbols => [ qw(ExpandAsNecessary ClipToImage ClipToBottomLayer
FlattenImage) ],
mapping => { ExpandAsNecessary => '0',
ClipToImage => '1',
ClipToBottomLayer => '2',
FlattenImage => '3' }
}
);

View File

@ -16,5 +16,5 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Modify this list for the groups to parse in the pdb directory
@groups = qw(gdisplay edit floating_sel undo palette gradient
convert channel_ops text gimprc parasite);
@groups = qw(gdisplay edit floating_sel undo palette gradient convert
channel_ops text gimprc drawable parasite paths);

View File

@ -93,8 +93,8 @@ sub arg_parse {
my ($name, $remove) = ($1, $2);
my @retvals = ('enum', $name);
if ($remove && $remove =~ / \(no /) {
$remove =~ s/ \(no (.*?)\)$/$1/;
if ($remove && $remove =~ m@ \(no @) {
chop $remove; ($remove = substr($remove, 5)) =~ s/ $//;
push @retvals, split(/,\s*/, $remove);
}

View File

@ -26,9 +26,8 @@ sub simple_inargs {
sub simple_invoke {
my $type = shift;
%invoke = (
headers => [ qw("gimage.h" "convert.h") ],
code => <<CODE
if (success = (gimage_base_type (gimage) != $type))
if ((success = (gimage_base_type (gimage) != $type)))
convert_image ((void *) gimage, $type, 0, 0, 0);
CODE
);
@ -81,7 +80,6 @@ HELP
);
%invoke = (
headers => [ qw("gimage.h" "convert.h") ],
code => <<'CODE'
{
success = (gimage_base_type (gimage) != INDEXED);
@ -122,14 +120,15 @@ HELP
(palette_type == MAKE_PALETTE)' },
{ name => 'palette', type => 'string',
desc => 'The name of the custom palette to use, ignored unless
(palette_type == CUSTOM_PALETTE)' }
(palette_type == CUSTOM_PALETTE)',
alias => 'palette_name' }
);
%invoke = (
headers => [ qw("gimage.h" "convert.h" "palette.h") ],
headers => [ qw("palette.h") ],
code => <<'CODE'
{
if (success = (gimage_base_type (gimage) != INDEXED))
if ((success = (gimage_base_type (gimage) != INDEXED)))
{
PaletteEntriesP entries, the_palette = NULL;
GSList *list;
@ -179,6 +178,8 @@ CODE
);
}
@headers = qw("gimage.h" "convert.h");
@procs = qw(convert_rgb convert_grayscale convert_indexed
convert_indexed_palette);
%exports = (app => [@procs]);

View File

@ -40,14 +40,13 @@ HELP
);
%invoke = (
headers => [ qw("gdisplay.h") ],
vars => [ 'guint scale = 0x101' ],
code => <<'CODE'
{
if (gimage->layers == NULL)
success = FALSE;
else
if (gimage->layers)
success = (gdisp = gdisplay_new (gimage, scale)) != NULL;
else
success = FALSE;
}
CODE
);
@ -68,10 +67,7 @@ HELP
desc => 'The display to delete', alias => 'gdisp' }
);
%invoke = (
headers => [ qw("gdisplay.h") ],
code => 'gtk_widget_destroy (gdisp->shell);'
);
%invoke = ( code => 'gtk_widget_destroy (gdisp->shell);' );
}
sub displays_flush {
@ -85,12 +81,11 @@ HELP
&std_pdb_misc;
%invoke = (
headers => [ qw("gdisplay.h") ],
code => 'gdisplays_flush ();'
);
%invoke = ( code => 'gdisplays_flush ();' );
}
@headers = qw("gdisplay.h");
@procs = qw(display_new display_delete displays_flush);
%exports = (app => [@procs], lib => [@procs]);

View File

@ -17,8 +17,38 @@
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
sub drawable_arg {
{ name => 'drawable', type => 'drawable', desc => 'The drawable' }
sub drawable_arg {{
name => 'drawable',
type => 'drawable',
desc => 'The drawable',
no_success => 1
}}
sub drawable_prop_proc {
my ($return, $name, $type, $func, $desc) = @_;
$blurb = "Returns $return.";
&std_pdb_misc;
@inargs = ( &drawable_arg );
@outargs = (
{ name => $name, type => $type, desc => $desc,
alias => "drawable_$func (drawable)", no_declare => 1 }
);
}
sub drawable_type_proc {
my ($desc, $type, $func) = @_;
$help = <<HELP;
This procedure returns non-zero if the specified drawable is of type
{ $type }.
HELP
&drawable_prop_proc("whether the drawable is $desc type", $func, 'boolean',
$func, "non-zero if the drawable is $desc type")
}
sub drawable_merge_shadow {
@ -38,11 +68,9 @@ HELP
{ name => 'undo', type => 'boolean',
desc => 'Push merge to undo stack?' }
);
delete $inargs[0]->{no_success};
%invoke = (
headers => [ qw("drawable.h") ],
code => 'drawable_merge_shadow (drawable, undo);'
);
%invoke = ( code => 'drawable_merge_shadow (drawable, undo);' );
}
sub drawable_fill {
@ -67,8 +95,193 @@ HELP
desc => 'The type of fill: %%desc%%' }
);
%invoke = ( code => 'drawable_fill (drawable, fill_type);' );
}
sub drawable_update {
$blurb = 'Update the specified region of the drawable.';
$help = <<'HELP';
This procedure updates the specified region of the drawable. The (x, y)
coordinate pair is relative to the drawable's origin, not to the image origin.
Therefore, the entire drawable can be updated with: {x->0, y->0, w->width,
h->height }.
HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'x', type => 'int32',
desc => 'x coordinate of upper left corner of update region' },
{ name => 'y', type => 'int32',
desc => 'y coordinate of upper left corner of update region' },
{ name => 'width', type => 'int32',
desc => 'Width of update region' },
{ name => 'height', type => 'int32',
desc => 'Height of update region' }
);
%invoke = ( code => 'drawable_update (drawable, x, y, width, height);' );
}
sub drawable_mask_bounds {
$blurb = <<'BLURB';
Find the bounding box of the current selection in relation to the specified
drawable.
BLURB
$help = <<'HELP';
This procedure returns the whether there is a selection. If there is one, the
upper left and lower righthand corners of its bounding box are returned. These
coordinates are specified relative to the drawable's origin, and bounded by
the drawable's extents.
HELP
&std_pdb_misc;
@inargs = ( &drawable_arg );
@outargs = (
{ name => 'non_empty', type => 'boolean',
desc => 'TRUE if there is a selection' },
);
my $pos = 1;
foreach $where ('upper left', 'lower right') {
foreach (qw(x y)) {
push @outargs, { name => "$_$pos", type => 'int32',
desc => '$_ coordinate of the $where corner of
selection bounds' }
}
$pos++;
}
%invoke = (
headers => [ qw("drawable.h") ],
code => 'drawable_fill (drawable, fill_type);'
code => <<'CODE'
non_empty = drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
CODE
);
}
sub drawable_gimage {
$blurb = "Returns the drawable's image.";
$help = "This procedure returns the drawable's image.";
&std_pdb_misc;
@inargs = ( &drawable_arg );
@outargs = ( &std_image_arg );
$outargs[0]->{desc} = "The drawable's image";
%invoke = (
code => 'success = (gimage = drawable_gimage (drawable)) != NULL;'
);
}
sub drawable_type {
$help = "This procedure returns the drawable's type.";
&drawable_prop_proc("the drawable's type", 'type', 'enum GimpImageType',
'type',"The drawable's type: %%desc%%");
delete $inargs[0]->{no_success};
}
sub drawable_has_alpha {
$help = <<'HELP';
This procedure returns whether the specified drawable has an alpha channel.
This can only be true for layers, and the associated type will be one of:
{ RGBA , GRAYA, INDEXEDA }.
HELP
&drawable_prop_proc('non-zero if the drawable has an alpha channel',
'has_alpha', 'boolean', 'has_alpha',
'Does the drawable have an alpha channel?');
}
sub drawable_type_with_alpha {
$help = <<'HELP';
This procedure returns the drawable's type if an alpha channel were added. If
the type is currently Gray, for instance, the returned type would be GrayA. If
the drawable already has an alpha channel, the drawable's type is simply
returned.
HELP
&drawable_prop_proc("the drawable's type with alpha", 'type_with_alpha',
'enum GimpImageType (no RGB_GIMAGE, GRAY_GIMAGE,
INDEXED_GIMAGE)', 'type_with_alpha',
"The drawable's type with alpha: %%desc%%");
}
sub drawable_color {
&drawable_type_proc('an RGB', 'RGB, RGBA', 'color');
}
sub drawable_gray {
&drawable_type_proc('a grayscale', 'Gray, GrayA', 'gray');
}
sub drawable_indexed {
&drawable_type_proc('an indexed', 'Indexed, IndexedA', 'indexed');
}
sub drawable_bytes {
$help = <<'HELP';
This procedure returns the number of bytes per pixel (or the number of
channels) for the specified drawable.
HELP
&drawable_prop_proc('the bytes per pixel', 'bytes', 'int32', 'bytes',
'Bytes per pixel');
}
sub drawable_width {
$help = "This procedure returns the specified drawable's width in pixels.";
&drawable_prop_proc('the width of the drawable', 'width', 'int32',
'width', 'Width of drawable');
}
sub drawable_height {
$help = "This procedure returns the specified drawable's height in pixels.";
&drawable_prop_proc('the height of the drawable', 'height', 'int32',
'height', 'Height of drawable');
}
sub drawable_offsets {
$blurb = 'Returns the offsets for the drawable.';
$help = <<'HELP';
This procedure returns the specified drawable's offsets. This only makes sense
if the drawable is a layer since channels are anchored. The offsets of a
channel will be returned as 0.
HELP
&std_pdb_misc;
@inargs = ( &drawable_arg );
foreach (qw(x y)) {
push @outargs, { name => "offset_$_", type => 'int32',
desc => "$_ offset of drawable" }
}
%invoke = ( code => 'drawable_offsets (drawable, &offset_x, &offset_y);' );
}
@headers = qw("drawable.h");
@procs = qw(drawable_merge_shadow drawable_fill drawable_update
drawable_mask_bounds drawable_gimage drawable_type
drawable_has_alpha drawable_type_with_alpha drawable_color
drawable_gray drawable_indexed drawable_bytes drawable_width
drawable_height drawable_offsets);
%exports = (app => [@procs]);
$desc = 'Drawable procedures';
1;

View File

@ -40,14 +40,13 @@ HELP
);
%invoke = (
headers => [ qw("gdisplay.h") ],
vars => [ 'guint scale = 0x101' ],
code => <<'CODE'
{
if (gimage->layers == NULL)
success = FALSE;
else
if (gimage->layers)
success = (gdisp = gdisplay_new (gimage, scale)) != NULL;
else
success = FALSE;
}
CODE
);
@ -68,10 +67,7 @@ HELP
desc => 'The display to delete', alias => 'gdisp' }
);
%invoke = (
headers => [ qw("gdisplay.h") ],
code => 'gtk_widget_destroy (gdisp->shell);'
);
%invoke = ( code => 'gtk_widget_destroy (gdisp->shell);' );
}
sub displays_flush {
@ -85,12 +81,11 @@ HELP
&std_pdb_misc;
%invoke = (
headers => [ qw("gdisplay.h") ],
code => 'gdisplays_flush ();'
);
%invoke = ( code => 'gdisplays_flush ();' );
}
@headers = qw("gdisplay.h");
@procs = qw(display_new display_delete displays_flush);
%exports = (app => [@procs], lib => [@procs]);

View File

@ -194,7 +194,6 @@ HELP
&sample_outargs;
%invoke = (
headers => [ qw("gradient.h") ],
vars => ['gdouble r, g, b, a', 'gdouble *pv'],
code => <<'CODE'
{
@ -218,6 +217,8 @@ CODE
);
}
@headers = qw("gradient.h");
@procs = qw(gradients_get_list gradients_get_active gradients_set_active
gradients_sample_uniform gradients_sample_custom);
%exports = (app => [@procs], lib => [@procs]);

View File

@ -194,7 +194,6 @@ HELP
&sample_outargs;
%invoke = (
headers => [ qw("gradient.h") ],
vars => ['gdouble r, g, b, a', 'gdouble *pv'],
code => <<'CODE'
{
@ -218,6 +217,8 @@ CODE
);
}
@headers = qw("gradient.h");
@procs = qw(gradients_get_list gradients_get_active gradients_set_active
gradients_sample_uniform gradients_sample_custom);
%exports = (app => [@procs], lib => [@procs]);

View File

@ -49,7 +49,7 @@ CODE
sub invoke_set {
%invoke = (
headers => [ qw("gimpimage.h" "palette.h") ],
headers => [ qw("gimpimage.h") ],
code => <<CODE
palette_set_@{[shift]}ground (col[RED_PIX], col[GREEN_PIX], col[BLUE_PIX]);
CODE
@ -124,10 +124,7 @@ HELP
&std_pdb_misc;
%invoke = (
headers => [ qw("palette.h") ],
code => 'palette_set_default_colors ();'
);
%invoke = ( code => 'palette_set_default_colors ();' );
}
sub palette_swap_colors {
@ -140,10 +137,7 @@ HELP
&std_pdb_misc;
%invoke = (
headers => [ qw("palette.h") ],
code => 'palette_swap_colors ();'
);
%invoke = ( code => 'palette_swap_colors ();' );
}
sub palette_refresh {
@ -158,7 +152,6 @@ HELP
$date = '1998';
%invoke = (
headers => [ qw("palette.h") ],
code => <<'CODE'
{
/* FIXME: I've hardcoded success to be TRUE, because brushes_init() is a
@ -177,6 +170,8 @@ CODE
);
}
@headers = qw("palette.h");
@procs = qw(palette_get_foreground palette_get_background
palette_set_foreground palette_set_background
palette_set_default_colors palette_swap_colors

View File

@ -24,6 +24,19 @@ sub pdb_misc {
$date = 1998;
}
sub name_arg {{
name => 'name',
type => 'string',
desc => "The name of the parasite to $_[0]",
no_success => 1
}}
sub parasite_outarg {{
name => 'parasite',
type => 'parasite',
desc => "The $_[0] parasite"
}}
sub parasite_new {
$blurb = 'Creates a new parasite.';
@ -32,8 +45,7 @@ sub parasite_new {
&pdb_misc;
@inargs = (
{ name => 'name', type => 'string',
desc => 'The name of the parasite to create', no_success => 1 },
&name_arg('create'),
{ name => 'flags', type => 'int32',
desc => 'The flags (persistance == 1)' },
{ name => 'size', type => '0 <= int32',
@ -42,13 +54,9 @@ sub parasite_new {
desc => 'The data', no_success => 1 }
);
@outargs = (
{ name => 'parasite', type => 'parasite',
desc => 'The new parasite' }
);
@outargs = ( &parasite_outarg('new') );
%invoke = (
headers => [ qw("libgimp/parasite.h") ],
code => <<'CODE'
{
if (size > 0 && data == NULL)
@ -60,7 +68,45 @@ CODE
);
}
@procs = qw(parasite_new);
sub parasite_find {
$blurb = 'Finds the named parasite.';
$help = <<'HELP';
Finds and returns the named parasite that was previously attached to the gimp.
HELP
&pdb_misc;
@inargs = ( &name_arg('find') );
@outargs = ( &parasite_outarg('found') );
%invoke = (
headers => [ qw("gimpparasite.h") ],
code => <<'CODE'
success = (parasite = parasite_copy (gimp_find_parasite (name))) != NULL;
CODE
);
}
sub parasite_attach {
$blurb = 'Add a parasite to the gimp.';
$help = <<'HELP';
This procedure attaches a parasite to the gimp. It has no return values.
HELP
&pdb_misc;
@inargs = (
{ name => 'parasite', type => 'parasite',
desc => 'The parasite to attach to the gimp' }
);
}
@headers = qw("libgimp/parasite.h");
@procs = qw(parasite_new parasite_find parasite_attach);
%exports = (app => [@procs]);
$desc = 'Parasite procedures';

View File

@ -25,10 +25,10 @@ sub pdb_misc {
# The defs
sub path_list {
$blurb = 'List the paths associated with the passed image';
$blurb = 'List the paths associated with the passed image.';
$help = <<'HELP';
List the paths associated with the passed image
List the paths associated with the passed image.
HELP
&pdb_misc;
@ -37,36 +37,31 @@ HELP
$inargs[0]->{desc} = 'The ID of the image to list the paths from';
@outargs = (
{ name => 'num_paths',
type => 'stringarray',
desc => 'list of the paths belonging to this image',
array => {
name => 'num_gradients',
desc => 'list of the paths belonging to this image',
alias => 'paths_list'
}
}
{ name => 'paths_list', type => 'stringarray', init => 1,
desc => 'List of the paths belonging to this image',
array => { name => 'num_paths', init => 1,
desc => 'The number of paths returned' } }
);
%invoke = (
headers => [ qw("paths_cmds.h") ],
code => <<CODE
vars => [ 'PathsList *plist' ],
code => <<'CODE'
{
PathsList *plist = gimage->paths;
plist = gimage->paths;
if(plist && plist->bz_paths)
if (plist && plist->bz_paths)
{
gint count = 0;
GSList *pl = plist->bz_paths;
num_paths = g_slist_length(plist->bz_paths);
num_paths = g_slist_length (pl);
paths_list = g_malloc(sizeof(gchar *) * num_paths);
while(pl)
paths_list = g_new (gchar *, num_paths);
while (pl)
{
PATHP pptr = pl->data;
paths_list[count++] = g_strdup(pptr->name->str);
pl = g_slist_next(pl);
paths_list[count++] = g_strdup (pptr->name->str);
pl = pl->next;
}
}
}
@ -75,112 +70,95 @@ CODE
}
sub path_get_points {
$blurb = 'List the points associated with the named path';
$blurb = 'List the points associated with the named path.';
$help = <<'HELP';
List the points associated with the named path
List the points associated with the named path.
HELP
&pdb_misc;
@inargs = ( &std_image_arg,
{
name => 'pathname',
type => 'string',
@inargs = (
&std_image_arg,
{ name => 'pathname', type => 'string',
desc => 'the name of the path whose points should be listed',
alias => 'pname'
}
alias => 'pname' }
);
$inargs[0]->{desc} = 'The ID of the image to list the paths from';
@outargs = (
{
name => 'paths_type',
type => 'int32',
desc => 'The type of the path. Currently only one type (1 = Bezier) is supported',
alias => 'pathtype'
},
{
name => 'pathclosed',
type => 'int32',
alias => 'closed',
desc => 'Return if the path is closed. {0=path open, 1= path closed}'
},
{ name => 'num_path_point_details',
type => 'floatarray',
alias => 'pnts',
desc => 'The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be {1.0= BEZIER_ANCHOR, 2.0= BEZIER_CONTROL}. Note all points are returned in pixel resolution',
array => {
name => 'points_pairs',
desc => 'The number of point returned. Each point is made up of (x,y,pnt_type) of floats',
alias => 'points_pairs'
}
}
{ name => 'paths_type', type => 'int32',
desc => 'The type of the path. Currently only one type (1 = Bezier)
is supported',
alias => 'pptr->pathtype', no_declare => 1 },
{ name => 'path_closed', type => 'int32',
desc => 'Return if the path is closed. {0=path open, 1= path
closed}',
alias => 'pptr->closed', no_declare => 1 },
{ name => 'points_pairs', type => 'floatarray',
desc => 'The points in the path represented as 3 floats. The first is
the x pos, next is the y pos, last is the type of the pnt.
The type field is dependant on the path type. For beziers
(type 1 paths) the type can either be {1.0= BEZIER_ANCHOR,
2.0= BEZIER_CONTROL}. Note all points are returned in pixel
resolution',
alias => 'pnts', init => 1,
array => { name => 'num_path_point_details',
desc => 'The number of points returned. Each point is
made up of (x,y,pnt_type) of floats',
alias => 'num_pdetails', init => 1 } }
);
%invoke = (
headers => [ qw("paths_cmds.h") ],
code => <<CODE
vars => [ 'PathsList *plist', 'PATHP pptr = NULL' ],
code => <<'CODE'
{
/* Get the path with the given name */
PathsList *plist = gimage->paths;
plist = gimage->paths;
if(pname && plist && plist->bz_paths)
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
PATHP pptr;
while(pl)
while (pl)
{
pptr = pl->data;
if(strcmp(pname,pptr->name->str) == 0)
{
/* Found the path */
break;
}
pl = g_slist_next(pl);
if (strcmp (pname, pptr->name->str) == 0)
break; /* Found the path */
pl = pl->next;
pptr = NULL;
}
if(pl && pptr)
if (pl && pptr)
{
gint num_pdetails;
GSList *points_list;
gint pcount = 0;
/* Get the details for this path */
pathtype = pptr->pathtype;
closed = pptr->closed;
points_list = pptr->path_details;
if(points_list)
if (points_list)
{
num_pdetails = g_slist_length(points_list);
points_pairs = num_pdetails*3; /* 3 floats for each point */
num_pdetails = g_slist_length (points_list) * 3;
pnts = g_malloc(sizeof(gdouble)*3*num_pdetails);
pnts = g_new (gdouble, num_pdetails);
/* fill points and types in */
while(points_list)
while (points_list)
{
PATHPOINTP ppoint = points_list->data;
pnts[pcount] = ppoint->x;
pnts[pcount+1] = ppoint->y;
pnts[pcount+2] = (gfloat)ppoint->type; /* Bit of fiddle but should be understandable why it was done */
pnts[pcount + 1] = ppoint->y;
pnts[pcount + 2] = (gfloat) ppoint->type; /* Bit of fiddle but should be understandable why it was done */
pcount += 3;
points_list = g_slist_next(points_list);
}
}
}
else
{
success = FALSE;
points_list = points_list->next;
}
}
else
{
success = FALSE;
}
else
success = FALSE;
}
}
CODE
@ -188,7 +166,7 @@ CODE
}
sub path_get_current {
$blurb = 'The name of the current path. Error if no paths';
$blurb = 'The name of the current path. Error if no paths.';
$help = <<'HELP';
The name of the current path. Error if no paths.
@ -200,125 +178,103 @@ HELP
$inargs[0]->{desc} = 'The ID of the image to get the current paths from';
@outargs = (
{ name => 'current_path_name',
type => 'string',
{ name => 'current_path_name', type => 'string',
desc => 'The name of the current path',
alias => 'pname'
}
alias => 'g_strdup (pptr->name->str)', no_declare => 1 }
);
%invoke = (
headers => [ qw("paths_cmds.h") ],
code => <<CODE
vars => [ 'PathsList *plist', 'PATHP pptr = NULL' ],
code => <<'CODE'
{
/* Get the path with the given name */
PathsList *plist = gimage->paths;
plist = gimage->paths;
if(plist && plist->bz_paths)
{
PATHP pptr = NULL;
if(plist->last_selected_row >= 0)
{
pptr = (PATHP)g_slist_nth_data(plist->bz_paths,plist->last_selected_row);
pname = g_strdup(pptr->name->str);
}
if (plist && plist->bz_paths && plist->last_selected_row >= 0)
pptr = (PATHP) g_slist_nth_data (plist->bz_paths, plist->last_selected_row);
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
}
CODE
);
}
sub path_set_current {
$blurb = 'List the paths associated with the passed image';
$blurb = 'List the paths associated with the passed image.';
$help = <<'HELP';
List the paths associated with the passed image
List the paths associated with the passed image.
HELP
&pdb_misc;
@inargs = ( &std_image_arg,
{
name => 'set_current_path_name',
type => 'string',
@inargs = (
&std_image_arg,
{ name => 'set_current_path_name', type => 'string',
desc => 'The name of the path to set the current path to',
alias => 'pname'
},
alias => 'pname' }
);
$inargs[0]->{desc} = 'The ID of the image to list set the paths in';
%invoke = (
headers => [ qw("paths_cmds.h") ],
code => <<CODE
{
if(pname && paths_set_path(gimage,pname))
{
success = TRUE;
}
else
{
success = FALSE;
}
}
}
CODE
);
%invoke = ( code => 'success = paths_set_path (gimage, pname);' );
}
sub path_set_points {
$blurb = 'Set the points associated with the named path';
$blurb = 'Set the points associated with the named path.';
$help = <<'HELP';
Set the points associated with the named path
Set the points associated with the named path.
HELP
&pdb_misc;
@inargs = ( &std_image_arg,
{ name => 'pathname',
type => 'string',
alias => 'pname',
desc => 'the name of the path to create (if it exists then all current points are removed). This will not be set as the current path.You will have to do a gimp_set_current_path after creating the path to make it current.'
},
{ name => 'ptype',
type => 'int32',
desc => 'The type of the path. Currently only one type (1 = Bezier) is supported'
},
{ name => 'points_pairs',
type => 'floatarray',
alias => 'pnts',
desc => 'The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be {1.0= BEZIER_ANCHOR, 2.0= BEZIER_CONTROL}. Note all points are returned in pixel resolution',
array => {
name => 'num_path_points',
desc => 'The number of points in the path. Each point is made up of (x,y) of floats. Currently only the creation of bezier curves is allowed. The type parameter must be set to (1) to indicate a BEZIER type curve.\n For BEZIERS.\n Note the that points must be given in the following order... ACCACCAC ... If the path is not closed the last control point is missed off. Points consist of three control points (control/anchor/control) so for a curve that is not closed there must be at least two points passed (2 x,y pairs). If num_path_pnts%3 = 0 then the path is assumed to be closed and the points are ACCACCACCACC.',
alias => 'numpoints'
}
}
@inargs = (
&std_image_arg,
{ name => 'pathname', type => 'string',
desc => 'The name of the path to create (if it exists then all
current points are removed). This will not be set as the
current path. You will have to do a gimp_set_current_path
after creating the path to make it current.',
alias => 'pname', init => 1 },
{ name => 'ptype', type => 'int32',
desc => 'The type of the path. Currently only one type (1 = Bezier)
is supported' },
{ name => 'points_pairs', type => 'floatarray', alias => 'pnts',
desc => 'The points in the path represented as 3 floats. The first is
the x pos, next is the y pos, last is the type of the pnt.
The type field is dependant on the path type. For beziers
(type 1 paths) the type can either be {1.0= BEZIER_ANCHOR,
2.0= BEZIER_CONTROL}. Note all points are returned in pixel
resolution',
array => { name => 'num_path_points',
desc => 'The number of points in the path. Each point is
made up of (x,y) of floats. Currently only the
creation of bezier curves is allowed. The type
parameter must be set to (1) to indicate a BEZIER
type curve. For BEZIERS. Note the that points
must be given in the following order... ACCACCAC
... If the path is not closed the last control
point is missed off. Points consist of three
control points (control/anchor/control) so for a
curve that is not closed there must be at least
two points passed (2 x,y pairs). If num_path_pnts
% 3 = 0 then the path is assumed to be closed
and the points are ACCACCACCACC.',
alias => 'numpoints', init => 1 } }
);
$inargs[0]->{desc} = 'The ID of the image to set the paths in';
%invoke = (
headers => [ qw("paths_cmds.h") ],
code => <<CODE
vars => [ 'gboolean pclosed = FALSE' ],
code => <<'CODE'
{
gint pclosed = FALSE;
if((numpoints/2)%3 == 0)
if ((numpoints / 2) % 3 == 0)
pclosed = TRUE;
else if ((numpoints/2)%3 != 2)
else if ((numpoints / 2) % 3 != 2)
success = FALSE;
if(success && !paths_set_path_points(gimage,pname,ptype,pclosed,numpoints,pnts))
if (success && !paths_set_path_points (gimage, pname, ptype, pclosed,
numpoints, pnts))
success = FALSE;
}
CODE
@ -326,10 +282,10 @@ CODE
}
sub path_stroke_current {
$blurb = 'Stroke the current path in the passed image';
$blurb = 'Stroke the current path in the passed image.';
$help = <<'HELP';
Stroke the current path in the passed image
Stroke the current path in the passed image.
HELP
&pdb_misc;
@ -338,41 +294,34 @@ HELP
$inargs[0]->{desc} = 'The ID of the image which contains the path to stroke';
%invoke = (
headers => [ qw("paths_cmds.h") ],
code => <<CODE
vars => [ 'PathsList *plist', 'PATHP pptr = NULL' ],
code => <<'CODE'
{
/* Get the path with the given name */
PathsList *plist = gimage->paths;
plist = gimage->paths;
if(plist && plist->bz_paths)
if (plist && plist->bz_paths && plist->last_selected_row >= 0)
{
GSList *pl = plist->bz_paths;
PATHP pptr = NULL;
if ((pptr = (PATHP) g_slist_nth_data (plist->bz_paths,
plist->last_selected_row)))
if(plist->last_selected_row >= 0 &&
(pptr = (PATHP)g_slist_nth_data(plist->bz_paths,plist->last_selected_row)))
{
/* Found the path to stroke.. */
paths_stroke(gimage,plist,pptr);
}
paths_stroke (gimage, plist, pptr); /* Found the path to stroke.. */
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
}
CODE
);
}
@procs = qw(path_list path_get_points path_get_current path_set_current path_set_points path_stroke_current);
@headers = qw("gimage.h" "pathsP.h");
@procs = qw(path_list path_get_points path_get_current path_set_current
path_set_points path_stroke_current);
%exports = (app => [@procs]);
$desc = 'Gradient UI';
$desc = 'Paths';
1;

View File

@ -130,7 +130,6 @@ HELP
&render_outargs;
%invoke = (
headers => [ qw("text_tool.h") ],
vars => ['gchar *fontname[2048]'],
code => <<'CODE'
{
@ -176,7 +175,6 @@ HELP
&extents_outargs;
%invoke = (
headers => [ qw("text_tool.h") ],
code => <<'CODE'
{
success = text_get_xlfd (size, size_type, foundry, family, weight,
@ -223,7 +221,6 @@ HELP
&render_outargs;
%invoke = (
headers => [ qw("text_tool.h") ],
pass_through => 'text',
pass_args => [ 0..8 ],
make_args => [ &fontname_makeargs ]
@ -251,13 +248,14 @@ HELP
&extents_outargs;
%invoke = (
headers => [ qw("text_tool.h") ],
pass_through => 'text_get_extents',
pass_args => [ 0..2 ],
make_args => [ &fontname_makeargs ]
);
}
@headers = qw("text_tool.h");
@procs = qw(text text_get_extents text_fontname text_get_extents_fontname);
%exports = (app => [@procs]);

View File

@ -38,10 +38,7 @@ HELP
&inargs;
%invoke = (
headers => [ qw("undo.h") ],
code => 'undo_push_group_start (gimage, MISC_UNDO);'
);
%invoke = ( code => 'undo_push_group_start (gimage, MISC_UNDO);' );
}
sub undo_push_group_end {
@ -57,12 +54,11 @@ HELP
&inargs;
%invoke = (
headers => [ qw("undo.h") ],
code => 'undo_push_group_end (gimage);'
);
%invoke = ( code => 'undo_push_group_end (gimage);' );
}
@headers = qw("undo.h");
@procs = qw(undo_push_group_start undo_push_group_end);
%exports = (app => [@procs]);

View File

@ -56,7 +56,7 @@ $evalcode = <<'CODE';
&$safeeval("do '$main::srcdir/stddefs.pdb'");
# Group properties
undef $desc; undef $code;
undef $desc; undef $code; undef @headers;
# Load the file in and get the group info
&$safeeval("require '$main::srcdir/pdb/$file.pdb'");
@ -89,10 +89,12 @@ $evalcode = <<'CODE';
}
}
$pdb{$proc} = $entry;
push @{$entry->{invoke}->{headers}}, @headers if scalar @headers;
}
# Find out what to do with these entries
while (($dest, $procs) = each %exports) { push @{$gen{$dest}}, @$procs; }
while (($dest, $procs) = each %exports) { push @{$gen{$dest}}, @$procs }
}
CODE
@ -112,7 +114,7 @@ require 'enums.pl';
require 'util.pl';
# Squash whitespace into just single spaces between words
sub trimspace { for (${$_[0]}) { s/[\n\s]+/ /g; s/^ //; s/ $//; } }
sub trimspace { for (${$_[0]}) { s/\s+/ /gs; s/^ //; s/ $//; } }
# Trim spaces and escape quotes C-style
sub nicetext {