diff --git a/tools/pdbgen/Makefile.am b/tools/pdbgen/Makefile.am index 60d6278521..adff20a6d1 100644 --- a/tools/pdbgen/Makefile.am +++ b/tools/pdbgen/Makefile.am @@ -17,7 +17,8 @@ enum_headers = \ ../../app/shear_tool.h \ ../../app/color_balance.h \ ../../app/hue_saturation.h \ - ../../app/layerF.h + ../../app/layerF.h \ + ../../app/layer.h enums.pl: enumgen.pl $(enum_headers) cd $(srcdir) \ diff --git a/tools/pdbgen/app.pl b/tools/pdbgen/app.pl index ae80f77afd..18ffe22367 100644 --- a/tools/pdbgen/app.pl +++ b/tools/pdbgen/app.pl @@ -225,9 +225,10 @@ sub marshal_inargs { my $var = &arg_vname($_); if (exists $arg->{id_func}) { - $result .= <{id_func} (args[$argc].value.pdb_$type); -CODE + my $id_func = $arg->{id_func}; + $id_func = $_->{id_func} if exists $_->{id_func}; + + $result .= " $var = $id_func (args[$argc].value.pdb_$type);\n"; $result .= &make_arg_test($_, sub { ${$_[0]} =~ s/==/!=/ }, "$var == NULL"); } @@ -248,11 +249,12 @@ CODE } elsif ($pdbtype eq 'tattoo') { $result .= &make_arg_test($_, sub { ${$_[0]} =~ s/==/!=/ }, - '$var == 0'); + "$var == 0"); } elsif ($pdbtype eq 'unit') { + $typeinfo[0] = 'UNIT_PIXEL' unless defined $typeinfo[0]; $result .= &make_arg_test($_, sub { ${$_[0]} = "!(${$_[0]})" }, - "$var < UNIT_PIXEL || $var >= " . + "$var < $typeinfo[0] || $var >= " . 'gimp_unit_get_number_of_units ()'); } elsif ($pdbtype eq 'enum' && !$enums{$typeinfo[0]}->{contig}) { @@ -395,7 +397,15 @@ CODE $argc++; $outargs .= ' ' x 2; if (exists $arg->{id_ret_func}) { - $var = eval qq/"$arg->{id_ret_func}"/; + my $ret = eval qq/"$arg->{id_ret_func}"/; + $ret = eval qq/"$_->{id_ret_func}"/ if exists $_->{id_ret_func}; + + if (exists $_->{return_fail}) { + $var = "$var ? $ret : $_->{return_fail}"; + } + else { + $var = $ret; + } } $outargs .= "return_args[$argc].value.pdb_$type = $var;\n"; @@ -688,7 +698,7 @@ HEADER print IFILE "void $_" . ' ' x ($longest - length $_) . " (void);\n"; } chop $group_procs; - print IFILE "\n/* $total total procedures registered total */\n\n"; + print IFILE "\n/* $total procedures registered total */\n\n"; print IFILE "void\ninternal_procs_init (void)\n{\n$group_procs}\n"; close IFILE; &write_file($internal); diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl index ba53fc0c78..29425716ba 100644 --- a/tools/pdbgen/enums.pl +++ b/tools/pdbgen/enums.pl @@ -82,26 +82,36 @@ package Gimp::CodeGen::enums; GRAY => '1', INDEXED => '2' } }, + GuideOrientation => + { contig => 1, + header => 'gimpimage.h', + symbols => [ qw(HORIZONTAL_GUIDE VERTICAL_GUIDE) ], + mapping => { HORIZONTAL_GUIDE => '0', + VERTICAL_GUIDE => '1' }, + nicks => { HORIZONTAL_GUIDE => 'HORIZONTAL', + VERTICAL_GUIDE => 'VERTICAL' } + }, ChannelType => { contig => 1, header => 'gimpimage.h', - symbols => [ qw(Red Green Blue Gray Indexed Auxillary) ], - mapping => { Red => '0', - Green => '1', - Blue => '2', - Gray => '3', - Indexed => '4', - Auxillary => '5' } + symbols => [ qw(RED_CHANNEL GREEN_CHANNEL BLUE_CHANNEL + GRAY_CHANNEL INDEXED_CHANNEL AUXILLARY_CHANNEL) ], + mapping => { RED_CHANNEL => '0', + GREEN_CHANNEL => '1', + BLUE_CHANNEL => '2', + GRAY_CHANNEL => '3', + INDEXED_CHANNEL => '4', + AUXILLARY_CHANNEL => '5' } }, MergeType => { contig => 1, header => 'gimpimage.h', - symbols => [ qw(ExpandAsNecessary ClipToImage ClipToBottomLayer - FlattenImage) ], - mapping => { ExpandAsNecessary => '0', - ClipToImage => '1', - ClipToBottomLayer => '2', - FlattenImage => '3' } + symbols => [ qw(EXPAND_AS_NECESSARY CLIP_TO_IMAGE + CLIP_TO_BOTTOM_LAYER FLATTEN_IMAGE) ], + mapping => { EXPAND_AS_NECESSARY => '0', + CLIP_TO_IMAGE => '1', + CLIP_TO_BOTTOM_LAYER => '2', + FLATTEN_IMAGE => '3' } }, PDBArgType => { contig => 1, @@ -192,8 +202,8 @@ package Gimp::CodeGen::enums; DIFFERENCE_MODE => 'DIFFERENCE', ADDITION_MODE => 'ADDITION', SUBTRACT_MODE => 'SUBTRACT', - DARKEN_ONLY_MODE => 'DARKEN-ONLY', - LIGHTEN_ONLY_MODE => 'LIGHTEN-ONLY', + DARKEN_ONLY_MODE => 'DARKEN_ONLY', + LIGHTEN_ONLY_MODE => 'LIGHTEN_ONLY', HUE_MODE => 'HUE', SATURATION_MODE => 'SATURATION', COLOR_MODE => 'COLOR', @@ -360,6 +370,13 @@ package Gimp::CodeGen::enums; nicks => { ADD_WHITE_MASK => 'WHITE_MASK', ADD_BLACK_MASK => 'BLACK_MASK', ADD_ALPHA_MASK => 'ALPHA_MASK' } + }, + MaskApplyMode => + { contig => 1, + header => 'layer.h', + symbols => [ qw(APPLY DISCARD) ], + mapping => { APPLY => '0', + DISCARD => '1' } } ); diff --git a/tools/pdbgen/groups.pl b/tools/pdbgen/groups.pl index f5ebe2a1c6..eefd1ab399 100644 --- a/tools/pdbgen/groups.pl +++ b/tools/pdbgen/groups.pl @@ -19,4 +19,5 @@ @groups = qw(gdisplay edit floating_sel undo palette gradient convert channel_ops gimprc drawable parasite paths gradient_select unit procedural_db brushes text_tool brush_select color - misc tools channel patterns pattern_select layer gimage_mask); + misc tools channel patterns pattern_select layer gimage_mask + gimage guides); diff --git a/tools/pdbgen/pdb.pl b/tools/pdbgen/pdb.pl index 9a37483be6..279e6bed0a 100644 --- a/tools/pdbgen/pdb.pl +++ b/tools/pdbgen/pdb.pl @@ -33,39 +33,44 @@ package Gimp::CodeGen::pdb; color => { name => 'COLOR' , type => 'guchar *' }, - display => { name => 'DISPLAY', - type => 'GDisplay *', - headers => [ qw("gdisplay.h") ], - id_func => 'gdisplay_get_ID', - id_ret_func => '$var->ID' }, - image => { name => 'IMAGE', - type => 'GimpImage *', - headers => [ qw("procedural_db.h") ], - id_func => 'pdb_id_to_image', - id_ret_func => 'pdb_image_to_id ($var)' }, - layer => { name => 'LAYER', - type => 'GimpLayer *', - headers => [ qw("drawable.h" "layer.h") ], - id_func => 'layer_get_ID', - id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' }, - channel => { name => 'CHANNEL', - type => 'Channel *', - headers => [ qw("drawable.h" "channel.h") ], - id_func => 'channel_get_ID', - id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' }, - drawable => { name => 'DRAWABLE', - type => 'GimpDrawable *', - headers => [ qw("drawable.h") ], - id_func => 'gimp_drawable_get_ID', - id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' }, - selection => { name => 'SELECTION', - type => 'Channel *', - headers => [ qw("drawable.h" "channel.h") ], - id_func => 'channel_get_ID', - id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' }, - - parasite => { name => 'PARASITE', type => 'Parasite *', - headers => [ qw("libgimp/parasite.h") ] }, + display => { name => 'DISPLAY', + type => 'GDisplay *', + headers => [ qw("gdisplay.h") ], + id_func => 'gdisplay_get_ID', + id_ret_func => '$var->ID' }, + image => { name => 'IMAGE', + type => 'GimpImage *', + headers => [ qw("procedural_db.h") ], + id_func => 'pdb_id_to_image', + id_ret_func => 'pdb_image_to_id ($var)' }, + layer => { name => 'LAYER', + type => 'GimpLayer *', + headers => [ qw("drawable.h" "layer.h") ], + id_func => 'layer_get_ID', + id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' }, + channel => { name => 'CHANNEL', + type => 'Channel *', + headers => [ qw("drawable.h" "channel.h") ], + id_func => 'channel_get_ID', + id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' }, + drawable => { name => 'DRAWABLE', + type => 'GimpDrawable *', + headers => [ qw("drawable.h") ], + id_func => 'gimp_drawable_get_ID', + id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' }, + selection => { name => 'SELECTION', + type => 'Channel *', + headers => [ qw("drawable.h" "channel.h") ], + id_func => 'channel_get_ID', + id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' }, + layer_mask => { name => 'CHANNEL', + type => 'LayerMask *', + headers => [ qw("drawable.h" "channel.h") ], + id_func => 'layer_mask_get_ID', + id_ret_func => 'drawable_ID (GIMP_DRAWABLE ($var))' }, + parasite => { name => 'PARASITE', + type => 'Parasite *', + headers => [ qw("libgimp/parasite.h") ] }, boundary => { name => 'BOUNDARY', type => 'gpointer ' }, # ??? FIXME path => { name => 'PATH' , type => 'gpointer ' }, # ??? FIXME @@ -75,6 +80,7 @@ package Gimp::CodeGen::pdb; enum => { name => 'INT32', type => 'gint32 ' }, boolean => { name => 'INT32', type => 'gboolean ' }, tattoo => { name => 'INT32', type => 'gint32 ' }, + guide => { name => 'INT32', type => 'gint32 ' }, unit => { name => 'INT32', type => 'GUnit ' }, region => { name => 'REGION', type => 'gpointer ' } # not supported @@ -109,6 +115,11 @@ sub arg_parse { return @retvals; } + elsif ($arg =~ /^unit(?: \(min (.*?)\))?/) { + my @retvals = ('unit'); + push @retvals, $1 if $1; + return @retvals; + } elsif ($arg =~ /^(?:([+-.\d][^\s]*) \s* (<=|<))? \s* (\w+) \s* (?:(<=|<) \s* ([+-.\d][^\s]*))? diff --git a/tools/pdbgen/pdb/channel.pdb b/tools/pdbgen/pdb/channel.pdb index cdcff3c91f..363a4d6639 100644 --- a/tools/pdbgen/pdb/channel.pdb +++ b/tools/pdbgen/pdb/channel.pdb @@ -231,10 +231,10 @@ HELP $author = $copyright = 'Jay Cox'; $date = '1998'; CODE +$#procs--; @headers = qw("channel.h" "channel_pvt.h"); -$#procs--; unshift @procs, qw(channel_new channel_copy channel_delete); %exports = (app => [@procs]); diff --git a/tools/pdbgen/pdb/gimage.pdb b/tools/pdbgen/pdb/gimage.pdb new file mode 100644 index 0000000000..226dc3e5c0 --- /dev/null +++ b/tools/pdbgen/pdb/gimage.pdb @@ -0,0 +1,1214 @@ +# The GIMP -- an image manipulation program +# Copyright (C) 1995 Spencer Kimball and Peter Mattis + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# "Perlized" from C source by Manish Singh + +sub layer_arg () {{ + name => 'layer', + type => 'layer', + desc => 'The layer' +}} + +sub channel_arg () {{ + name => 'channel', + type => 'channel', + desc => 'The channel' +}} + +sub new_dim_args { + foreach (qw(width height)) { + push @inargs, { name => "new_$_", type => '0 < int32', + desc => "New image $_: %%desc%%" } + } +} + +sub image_list_proc { + my $type = shift; + + $blurb = "Returns the list of ${type}s contained in the specified image."; + + $help = < "${type}_ids", type => 'int32array', init => 1, + desc => "The list of ${type}s contained in the image", + array => { name => "num_${type}s", init => 1, + desc => "The number of ${type}s contained in the image" } } + ); + + %invoke = ( + vars => [ 'GSList *list = NULL', 'int i' ], + code => <${type}s; + num_${type}s = g_slist_length (list); + + if (num_${type}s) + { + ${type}_ids = g_new (gint32, num_${type}s); + for (i = 0; i < num_${type}s; i++, list = list->next) + ${type}_ids[i] = drawable_ID (GIMP_DRAWABLE (list->data)); + } +} +CODE + ); +} + +sub type_move { + my ($type, $op, $pos) = @_; + my $extra = ""; + + if ($op =~ /_/) { + ($op, $extra) = $op =~ /([^_]+)_(.*)/; + $extra =~ s/_/ /g; + } + + my $layer = ""; + $layer = ', or the layer has no alpha channel' if $type eq 'layer'; + + $blurb = ucfirst($op) . " the specified $type in the image's $type stack"; + $blurb .= " $extra of stack" if $extra; + + $help = <{desc} .= " to $op $extra"; + + if ($extra) { + $extra =~ s/ /_/g; + $extra = "_$extra"; + } + + %invoke = ( + code => "success = gimage_${op}_$type$extra (gimage, $type) != NULL;" + ); +} + +sub image_get_prop_proc { + my ($prop, $type, $desc, $func) = @_; + + $blurb = "Returns the $desc of the specified image."; + + $help = "This procedure returns the specified image's $desc. "; + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => $prop, type => $type, + desc => "The $desc", no_declare => 1 } + ); + + my $alias = $func ? "gimage_get_$prop (gimage)" : "gimage->$prop"; + $alias = "g_strdup ($alias)" if $type eq 'string'; + $outargs[0]->{alias} .= "$alias"; + + if ($type eq 'color') { + $outargs[0]->{init} = 1; + delete @{$outargs[0]}{qw(alias no_declare)}; + + $invoke{headers} = [ qw("gimpimage.h") ]; + + $invoke{code} = "{\n color = g_new (guchar, 3);\n"; + foreach (map { "${_}_PIX" } qw(RED GREEN BLUE)) { + $invoke{code} .= " $prop\[$_] = image->col[$_];\n"; + } + $invoke{code} .= "}\n"; + } +} + +sub image_set_prop_proc { + my ($prop, $type, $desc, $func) = @_; + + $blurb = "Set the $desc of the specified image."; + + $help = "This procedure sets the specified image's $desc. "; + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => $prop, type => $type, + desc => "The new image $desc" } + ); + + if ($type =~ /float/) { + $inargs[1]->{desc} .= ' (%%desc%%)'; + } + + $invoke{code} = $func ? "gimage_set_$prop (gimage, $prop);" + : "gimage->$prop = $prop;"; + + if ($type eq 'color') { + %invoke = ( + vars => [ 'int i' ], + code => <col[i] = $prop\[i]; +CODE + ); + } +} + +sub image_accessors { + my ($prop, $type, $desc, $func, $extra) = @_; + my (@extra, %extra); my $once = 0; + + ref($extra) ? (@extra = @$extra) : (@extra = ($extra, $extra)); + %extra = map { $once++ ? 'set' : 'get', $_ ? $_ : "" } @extra; + + foreach (keys %extra) { + my $proc = "image_${_}_$prop"; + + push @procs, $proc; + + eval <{desc}, $outargs[0]->{array}->{desc}) { + s/contained.*/currently open/ + } + + $blurb .= '.'; + $help .= ' in the GIMP.'; + + for ($invoke{code}) { + s/list = .*$/gimage_foreach (gimlist_cb, &list);/m; + s/DRAWABLE/IMAGE/; + s/drawable_ID/pdb_image_to_id/; + } +} + +sub image_new { + $blurb = 'Creates a new image with the specified width, height, and type.'; + + $help = <<'HELP'; +Creates a new image, undisplayed with the specified extents and type. A layer +should be created and added before this image is displayed, or subsequent calls +to 'gimp_display_new' with this image as an argument will fail. Layers can be +created using the 'gimp_layer_new' commands. They can be added to an image +using the 'gimp_image_add_layer' command. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'type', type => 'enum GimpImageBaseType', + desc => 'The type of image: { %%desc%% }' } + ); + + foreach (qw(height width)) { + unshift @inargs, { name => $_, type => '0 < int32', + desc => "The $_ of the image" } + } + + @outargs = ( + { name => 'image', type => 'image', alias => 'gimage', init => 1, + desc => 'The ID of the newly created image' } + ); + + %invoke = ( + code => <<'CODE' +success = (gimage = gimage_new (width, height, type)) != NULL; +CODE + ); +} + +sub image_resize { + $blurb = 'Resize the image to the specified extents.'; + + $help = <<'HELP'; +This procedure resizes the image so that it's new width and height are equal to +the supplied parameters. Offsets are also provided which describe the position +of the previous image's content. No bounds checking is currently provided, so +don't supply parameters that are out of bounds. All channels within the image +are resized according to the specified parameters; this includes the image +selection mask. All layers within the image are repositioned according to the +specified offsets. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + &new_dim_args; + + foreach (qw(x y)) { + push @inargs, { name => "off$_", type => 'int32', + desc => "$_ offset between upper left corner of old and + new images: (new - old)" } + } + + %invoke = ( + headers => [ qw("cursorutil.h") ], + code => <<'CODE' +{ + gimp_add_busy_cursors_until_idle (); + gimage_resize (gimage, new_width, new_height, offx, offy); +} +CODE + ); +} + +sub image_scale { + $blurb = 'Scale the image to the specified extents.'; + + $help = <<'HELP'; +This procedure scales the image so that it's new width and height are equal to +the supplied parameters. Offsets are also provided which describe the position +of the previous image's content. No bounds checking is currently provided, so +don't supply parameters that are out of bounds. All channels within the image +are scaled according to the specified parameters; this includes the image +selection mask. All layers within the image are repositioned according to the +specified offsets. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + &new_dim_args; + + %invoke = ( + code => <<'CODE' +{ + gimp_add_busy_cursors_until_idle (); + gimage_scale (gimage, new_width, new_height); +} +CODE + ); +} + +sub image_delete { + $blurb = 'Delete the specified image.'; + + $help = <<'HELP'; +If there are no other references to this image it will be deleted. Other +references are possible when more than one view to an image exists. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => 'gimage_delete (gimage);' ); +} + +sub image_free_shadow { + $blurb = "Free the specified image's shadow data (if it exists)."; + + $help = <<'HELP'; +This procedure is intended as a memory saving device. If any shadow memory has +been allocated, it will be freed automatically on a call to +'gimp_image_delete'. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => 'gimage_free_shadow (gimage);' ); +} + +sub image_get_layers { + &image_list_proc('layer'); + + $help .= 'The order of layers is from topmost to bottommost.'; +} + +sub image_get_channels { + &image_list_proc('channel'); + + $help .= <<'HELP'; +This does not include the selection mask, or layer masks. The order is from +topmost to bottommost. +HELP +} + +sub image_unset_active_channel { + $blurb = 'Unsets the active channel in the specified image.'; + + $help = <<'HELP'; +If an active channel exists, it is unset. There then exists no active channel, +and if desired, one can be set through a call to 'Set Active Channel'. No error +is returned in the case of no existing active channel. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => 'gimage_unset_active_channel (gimage);' ); +} + +sub image_pick_correlate_layer { + $blurb = 'Find the layer visible at the specified coordinates.'; + + $help = <<'HELP'; +This procedure finds the layer which is visible at the specified coordinates. +Layers which do not qualify are those whose extents do not pass within the +specified coordinates, or which are transparent at the specified coordinates. +This procedure will return -1 if no layer is found. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + foreach (qw(x y)) { + push @inargs, { name => $_, type => 'int32', + desc => "The $_ coordinate for the pick" } + } + + @outargs = ( + { name => 'layer', type => 'layer', init => 1, + desc => 'The layer found at the specified coordinates' } + ); + + %invoke = ( + code => 'layer = gimage_pick_correlate_layer (gimage, x, y);' + ); +} + +sub image_raise_layer { + &type_move('layer', 'raise', 'above'); + &std_pdb_misc; +} + +sub image_lower_layer { + &type_move('layer', 'lower', 'below'); + &std_pdb_misc; +} + +sub image_raise_layer_to_top { + &type_move('layer', 'raise_to_top', 'above'); + $copyright = "Wolfgang Hofer"; + $author = $copyright . ", Sven Neumann"; + $date = 1998; +} + +sub image_lower_layer_to_bottom { + &type_move('layer', 'lower_to_bottom', 'below'); + $copyright = "Wolfgang Hofer"; + $author = $copyright . ", Sven Neumann"; + $date = 1998; +} + +sub image_merge_visible_layers { + $blurb = 'Merge the visible image layers into one.'; + + $help = <<'HELP'; +This procedure combines the visible layers into a single layer using the +specified merge type. A merge type of EXPAND_AS_NECESSARY expands the final +layer to encompass the areas of the visible layers. A merge type of +CLIP_TO_IMAGE clips the final layer to the extents of the image. A merge type +of CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the bottommost +layer. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'merge_type', type => 'enum MergeType (no FLATTEN_IMAGE)', + desc => 'The type of merge: { %%desc%% }' } + ); + + @outargs = ( + { name => 'layer', type => 'layer', init => 1, + desc => 'The resulting layer' } + ); + + %invoke = ( + code => <<'CODE' +{ + layer = gimage_merge_visible_layers (gimage, merge_type); + success = layer != NULL; +} +CODE + ); +} + +sub image_merge_down { + $blurb = 'Merge the layer passed and the first visible layer below.'; + + $help = <<'HELP'; +This procedure combines the passed layer and the first visible layer below it +using the specified merge type. A merge type of EXPAND_AS_NECESSARY expands the +final layer to encompass the areas of the visible layers. A merge type of +CLIP_TO_IMAGE clips the final layer to the extents of the image. A merge type +of CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the bottommost +layer. +HELP + + $author = $copyright = 'Larry Ewing'; + $date = '1998'; + + @inargs = ( + &std_image_arg, + { name => 'merge_layer', type => 'layer', + desc => 'The layer to merge down from' }, + { name => 'merge_type', type => 'enum MergeType (no FLATTEN_IMAGE)', + desc => 'The type of merge: { %%desc%% }' } + ); + + @outargs = ( + { name => 'layer', type => 'layer', init => 1, + desc => 'The resulting layer' } + ); + + %invoke = ( + code => <<'CODE' +{ + layer = gimp_image_merge_down (gimage, merge_layer, merge_type); + success = layer != NULL; +} +CODE + ); +} + +sub image_flatten { + $blurb = <<'BLURB'; +Flatten all visible layers into a single layer. Discard all invisible layers. +BLURB + + $help = <<'HELP'; +This procedure combines the visible layers in a manner analogous to merging +with the CLIP_TO_IMAGE merge type. Non-visible layers are discarded, and the +resulting image is stripped of its alpha channel. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'layer', type => 'layer', init => 1, + desc => 'The resulting layer' } + ); + + %invoke = ( + code => 'success = (layer = gimage_flatten (gimage)) != NULL;' + ); +} + +sub image_add_layer { + $blurb = 'Add the specified layer to the image.'; + + $help = <<'HELP'; +This procedure adds the specified layer to the gimage at the given position. If +the position is specified as -1, then the layer is inserted at the top of the +layer stack. If the layer to be added has no alpha channel, it must be added at +position 0. The layer type must be compatible with the image base type. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &layer_arg, + { name => 'position', type => 'int32', + desc => 'The layer position' } + ); + + $invoke{code} = "{\n if ("; my $once = 0; + foreach (qw(color gray indexed)) { + my $base = $_ eq 'color' ? 'RGB' : uc($_); + $invoke{code} .= ' ' x 6 if $once++; + $invoke{code} .= < 'gimage_remove_layer (gimage, layer);' ); +} + +sub image_add_layer_mask { + $blurb = 'Add a layer mask to the specified layer.'; + + $help = <<'HELP'; +This procedure adds a layer mask to the specified layer. Layer masks serve as +an additional alpha channel for a layer. This procedure will fail if a number +of prerequisites aren't met. The layer cannot already have a layer mask. The +specified mask must exist and have the same dimensions as the layer. Both the +mask and the layer must have been created for use with the specified image. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &layer_arg, + { name => 'mask', type => 'layer_mask', + desc => 'The mask to add to the layer' } + ); + $inargs[1]->{desc} .= ' to receive the mask'; + + %invoke = ( + code => <<'CODE' +success = gimage_add_layer_mask (gimage, layer, mask) != NULL; +CODE + ); +} + +sub image_remove_layer_mask { + $blurb = 'Remove the specified layer mask from the layer.'; + + $help = <<'HELP'; +This procedure removes the specified layer mask from the layer. If the mask +doesn't exist, an error is returned. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &layer_arg, + { name => 'mode', type => 'enum MaskApplyMode', + desc => 'Removal mode: { %%desc%% }' } + ); + $inargs[1]->{desc} .= ' from which to remove mask'; + + %invoke = ( code => 'gimage_remove_layer_mask (gimage, layer, mode);' ); +} + +sub image_raise_channel { + &type_move('channel', 'raise', 'above'); + &std_pdb_misc; +} + +sub image_lower_channel { + &type_move('layer', 'lower', 'below'); + &std_pdb_misc; +} + +sub image_add_channel { + $blurb = 'Add the specified channel to the image.'; + + $help = <<'HELP'; +This procedure adds the specified channel to the image. The position channel is +not currently used, so the channel is always inserted at the top of the channel +stack. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &channel_arg, + { name => 'position', type => 'int32', + desc => 'The channel position' } + ); + + %invoke = ( + code => <<'CODE' +success = gimage_add_channel (gimage, channel, MAX (position, -1)) != NULL; +CODE + ); +} + +sub image_remove_channel { + $blurb = 'Remove the specified channel from the image.'; + + $help = <<'HELP'; +This procedure removes the specified channel from the image. If the channel +doesn't exist, an error is returned. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &channel_arg + ); + + %invoke = ( code => 'gimage_remove_channel (gimage, channel);' ); +} + +sub image_active_drawable { + $blurb = "Get the image's active drawable"; + + $help = <<'HELP'; +This procedure returns the ID of the image's active drawable. This can be +either a layer, a channel, or a layer mask. The active drawable is specified by +the active image channel. If that is -1, then by the active image layer. If the +active image layer has a layer mask and the layer mask is in edit mode, then +the layer mask is the active drawable. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'drawable', type => 'drawable', init => 1, + desc => 'The active drawable' } + ); + + %invoke = ( + code => <<'CODE' +success = (drawable = gimage_active_drawable (gimage)) != NULL; +CODE + ); +} + +sub image_base_type { + $blurb = 'Get the base type of the image.'; + + $help = <<'HELP'; +This procedure returns the image's base type. Layers in the image must be of +this subtype, but can have an optional alpha channel. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'base_type', type => 'enum GimpImageBaseType', init => 1, + desc => "The image's base type: { %%desc%% }" } + ); + + %invoke = ( code => 'base_type = gimage_base_type (gimage);' ); +} + +sub image_get_cmap { + $blurb = "Returns the image's colormap"; + + $help = <<'HELP'; +This procedure returns an actual pointer to the image's colormap, as well as +the number of bytes contained in the colormap. The actual number of colors in +the transmitted colormap will be "num_bytes" / 3. If the image is not of base +type INDEXED, this pointer will be NULL. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'cmap', type => 'int8array', init => 1, + desc => "The image's colormap", + array => { name => 'num_bytes', init => 1, + desc => 'Number of bytes in the colormap array: + %%desc%%' } } + ); + + %invoke = ( + code => <<'CODE' +{ + num_bytes = gimage->num_cols * 3; + cmap = g_new (gint8, num_bytes); + memcpy (cmap, gimage_cmap (gimage), num_bytes); +} +CODE + ); +} + +sub image_set_cmap { + $blurb = "Sets the entries in the image's colormap."; + + $help = <<'HELP'; +This procedure sets the entries in the specified image's colormap. The number +of entries is specified by the "num_bytes" parameter and corresponds to the +number of INT8 triples that must be contained in the "cmap" array. The actual +number of colors in the transmitted colormap is "num_bytes" / 3. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'cmap', type => 'int8array', + desc => "The new colormap values", + array => { name => 'num_bytes', type => '0 <= int32 <= 768', + desc => 'Number of bytes in the colormap array: + %%desc%%' } } + ); + + %invoke = ( + headers => [ qw("gdisplay.h") ], + code => <<'CODE' +{ + if (gimage->num_cols && gimage->cmap) + { + g_free (gimage->cmap); + gimage->cmap = NULL; + } + if (num_bytes) + { + gimage->cmap = g_new (guchar, COLORMAP_SIZE); + memcpy (gimage->cmap, cmap, num_bytes); + } + gimage->num_cols = num_bytes / 3; + + /* A colormap alteration affects the whole image */ + gdisplays_update_area (gimage, 0, 0, gimage->width, gimage->height); +} +CODE + ); +} + +sub image_enable_undo { + $blurb = "Enable the image's undo stack."; + + $help = <<'HELP'; +This procedure enables the image's undo stack, allowing subsequent operations +to store their undo steps. This is generally called in conjunction with +'gimp_image_disable_undo' to temporarily disable an image undo stack. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'enabled', type => 'boolean', + desc => 'True if the image undo has been enabled', + alias => 'success ? TRUE : FALSE', no_declare => 1 } + ); + + %invoke = ( code => 'success = gimage_enable_undo (gimage);' ); +} + +sub image_disable_undo { + $blurb = "Disable the image's undo stack."; + + $help = <<'HELP'; +This procedure disables the image's undo stack, allowing subsequent operations +to ignore their undo steps. This is generally called in conjunction with +'gimp_image_enable_undo' to temporarily disable an image undo stack. This is +advantageous because saving undo steps can be time and memory intensive. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'disabled', type => 'boolean', + desc => 'True if the image undo has been disabled', + alias => 'success ? TRUE : FALSE', no_declare => 1 } + ); + + %invoke = ( code => 'success = gimage_disable_undo (gimage);' ); +} + +sub image_clean_all { + $blurb = 'Set the image dirty count to 0.'; + + $help = <<'HELP'; +This procedure sets the specified image's dirty count to 0, allowing operations +to occur without having a 'dirtied' image. This is especially useful for cre +ating and loading images which should not initially be considered dirty, even +though layers must be created, filled, and installed in the image. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => 'gimage_clean_all (gimage);' ); +} + +sub image_floating_selection { + $blurb = 'Return the floating selection of the image.'; + + $help = <<'HELP'; +This procedure returns the image's floating_sel, if it exists. If it doesn't +exist, -1 is returned as the layer ID. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'floating_sel', type => 'layer', init => 1, + desc => "The image's floating selection", + return_fail => -1 } + ); + + %invoke = ( code => 'floating_sel = gimage_floating_sel (gimage);' ); +} + +sub image_floating_sel_attached_to { + $blurb = 'Return the drawable the floating selection is attached to.'; + + $help = <<'HELP'; +This procedure returns the drawable the image's floating selection is attached +to, if it exists. If it doesn't exist, -1 is returned as the drawable ID. +HELP + + $author = $copyright = 'Wolfgang Hofer'; + $date = '1998'; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'drawable', type => 'drawable', init => 1, + desc => 'The drawable the floating selection is attached to', + return_fail => -1 } + ); + + %invoke = ( + headers => [ qw("layer_pvt.h") ], + vars => [ 'Layer *floating_sel' ], + code => <<'CODE' +{ + floating_sel = gimage_floating_sel (gimage); + drawable = GIMP_DRAWABLE (GIMP_LAYER (floating_sel)->fs.drawable); +} +CODE + ); +} + +foreach (qw(width height)) { + push @procs, "image_$_"; + eval < '$_', type => 'int32', + desc => "The image's $_", + alias => 'gimage->$_', no_declare => 1 } + ); +} +SUB +} + +&image_accessors('active_layer', 'layer', 'active layer', 1, + [ <<'CODE1', <<'CODE2' ]); + $invoke{code} = "active_layer = $outargs[0]->{alias};"; + delete @{$outargs[0]}{qw(alias no_declare)}; + $outargs[0]->{return_fail} = -1; + $outargs[0]->{init} = 1; + + $help = <<'HELP'; +If there is an active layer, its ID will be returned, otherwise, -1. If a +channel is currently active, then no layer will be. If a layer mask is active, +then this will return the associated layer. +HELP +CODE1 + $help = <<'HELP'; +If the layer exists, it is set as the active layer in the image. Any previous +active layer or channel is set to inactive. An exception is a previously +existing floating selection, in which case this procedure will return an +execution error. +HELP +CODE2 + +&image_accessors('active_channel', 'channel', 'active channel', 1, + [ <<'CODE1', <<'CODE2' ]); + $invoke{code} = "active_channel = $outargs[0]->{alias};"; + delete @{$outargs[0]}{qw(alias no_declare)}; + $outargs[0]->{return_fail} = -1; + $outargs[0]->{init} = 1; + + $help = <<'HELP'; +If there is an active channel, this will return the channel ID, otherwise, -1. +HELP +CODE1 + $help = <<'HELP'; +If the channel exists, it is set as the active channel in the image. Any +previous active channel or channel is set to inactive. An exception is a +previously existing floating selection, in which case this procedure will +return an execution error. +HELP +CODE2 + +&image_accessors('selection', 'selection', 'selection', 1, + [ <<'CODE', undef ]); + $invoke{code} = "success = (selection = gimage_get_mask (gimage)) != NULL;"; + delete @{$outargs[0]}{qw(alias no_declare)}; + $outargs[0]->{desc} .= ' channel'; + $outargs[0]->{init} = 1; + + $help = <<'HELP'; +This will always return a valid ID for a selection--which is represented as a +channel internally. +HELP +CODE +$#procs--; + +my $comp_arg = <<'CODE'; + splice @inargs, 1, 0, ({ name => 'component', + type => 'enum ChannelType (no AUXILLARY_CHANNEL)', + desc => 'The image component: { %%desc%% }' }); + + $invoke{code} = <<'SUCCESS'; +{ + if (component == GRAY_CHANNEL) + success = gimage_base_type (gimage) == GRAY; + else if (component == INDEXED_CHANNEL) + success = gimage_base_type (gimage) == INDEXED; + else + success = gimage_base_type (gimage) == RGB; +} +SUCCESS +CODE + +my $comp_help = <<'CODE'; + $help =~ s/(component)/$1 (i.e. Red, Green, Blue intensity channels + in an RGB image)/; + $help =~ s/\. $/ /; + $help .= < 'modified', + visible => 'seen' +); + +foreach (sort keys %comp_action) { + my $help = $comp_help; + + $help =~ s/%%type%%/$_/e; + $help =~ s/%%action%%/$comp_action{$_}/e; + + &image_accessors("component_$_", 'boolean', "image component is $_", 1, + [ <{name} = '$_'; + \$outargs[0]->{desc} = 'Component is $_ (%%desc%%)'; + + chop \$outargs[0]->{alias}; + \$outargs[0]->{alias} .= ', component)'; + $help; +CODE1 + my \$code = <{name} = '$_'; + \$inargs[2]->{desc} = 'Component is $_ (%%desc%%)'; + $help; +CODE2 +} + +&image_accessors('filename', 'string', 'filename', 1, + [ <<'CODE', undef ]); + $help =~ s/\. $//; + $help .= <<'HELP'; +--if it was loaded or has since been saved. Otherwise, returns NULL. +HELP + + $outargs[0]->{alias} =~ s/get_//; +CODE + +&image_accessors('resolution', 'float', 'resolution', 0, + [ <<'CODE1', <<'CODE2' ]); + $help =~ s/\. $/ /; + $help .= <<'HELP'; +in dots per inch. This value is independent of any of the layers in this image. +HELP + + $author = $copyright = 'Austin Donnelly'; + $date = '1998'; + + push @outargs, { %{$outargs[0]} }; + + my $count = 0; + foreach $coord (qw(x y)) { + foreach (qw(name alias)) { + $outargs[$count]->{$_} =~ s/res/"${coord}res"/e + } + $outargs[$count++]->{desc} .= "in the $coord-axis, in dots per inch"; + } +CODE1 + $help =~ s/\. $/ /; + $help .= <<'HELP'; +in dots per inch. This value is independent of any of the layers in this image. +No scaling or resizing is performed. +HELP + + $author = $copyright = 'Austin Donnelly'; + $date = '1998'; + + push @inargs, { %{$inargs[1]} }; + + my $count = 1; undef %invoke; + foreach $coord (qw(x y)) { + my $arg = $inargs[$count]; + $arg->{name} =~ s/res/"${coord}res"/e; + $arg->{alias} = "gimage->$arg->{name}"; + $arg->{no_declare} = 1; + $arg->{desc} .= "in the $coord-axis, in dots per inch"; + $count++; + } +CODE2 + +my $unit_help = <<'HELP'; +This value is independent of any of the layers in this image. See the +gimp_unit_* procedure definitions for the valid range of unit IDs and a +description of the unit system. +HELP + +my $unit_misc = <<'CODE'; + $author = $copyright = 'Michael Naterrer'; + $date = '1998'; +CODE +&image_accessors('unit', 'unit (min UNIT_INCH)', 'unit', 0, + [ < 'tattoo', type => 'tattoo', + desc => 'The tattoo of the $_ to find' } + ); + + \@outargs = ( + { name => '$_', type => '$_', init => 1, + desc => 'The $_ with the specified tattoo' } + ); + + \%invoke = ( + code => <<'CODE' +{ + $_ = gimp_image_get_${_}_by_tattoo (gimage, tattoo); + success = $_ != NULL; +} +CODE + ); +} +SUB +} + +@headers = qw("gimage.h"); + +$extra{app}->{code} = <<'CODE'; +/* Yuup, this is somewhat unsmooth, to say the least */ + +static void +gimlist_cb (gpointer im, + gpointer data) +{ + GSList **l = (GSList **) data; + *l = g_slist_prepend (*l, im); +} +CODE + +unshift @procs, qw(list_images image_new image_resize image_scale image_delete + image_free_shadow image_get_layers image_get_channels + image_unset_active_channel image_pick_correlate_layer + image_raise_layer image_lower_layer image_raise_layer_to_top + image_lower_layer_to_bottom image_merge_visible_layers + image_merge_down image_flatten image_add_layer + image_remove_layer image_add_layer_mask + image_remove_layer_mask image_raise_channel + image_lower_channel image_add_channel image_remove_channel + image_active_drawable image_base_type image_get_cmap + image_set_cmap image_enable_undo image_disable_undo + image_clean_all image_floating_selection + image_floating_sel_attached_to); +%exports = (app => [@procs]); + +$desc = 'Image'; + +1; diff --git a/tools/pdbgen/pdb/guides.pdb b/tools/pdbgen/pdb/guides.pdb new file mode 100644 index 0000000000..4bc6b12aab --- /dev/null +++ b/tools/pdbgen/pdb/guides.pdb @@ -0,0 +1,302 @@ +# The GIMP -- an image manipulation program +# Copyright (C) 1995 Spencer Kimball and Peter Mattis + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# "Perlized" from C source by Manish Singh + +sub pdb_misc { + $author = $copyright = 'Adam D. Moss'; + $date = '1998'; +} + +sub image_add_guide { + my ($desc, $type, $max, $pos) = @_; + + $blurb = "Add a $desc guide to an image."; + + $help = < "${type}position", type => '0 < int32', + desc => "The guide's ${type}-offset from $pos of image", + alias => 'offset' } + ); + + @outargs = ( + { name => 'guide_id', type => 'guide', init => 1, + desc => 'The new guide' } + ); + + my $func = substr($desc, 0, 1); + %invoke = ( + vars => [ 'Guide *guide' ], + code => <$max) + { + guide = gimp_image_add_${func}guide (gimage); + guide->position = offset; + guide_id = guide->guide_ID; + } + else + success = FALSE; +} +CODE + ); +} + +# The defs + +sub image_add_hguide { + &image_add_guide('horizontal', 'y', 'height', 'top'); +} + +sub image_add_vguide { + &image_add_guide('vertical', 'x', 'width', 'left'); +} + +sub image_delete_guide { + $blurb = 'Deletes a guide from an image.'; + + $help = <<'HELP'; +This procedure takes an image and a guide ID as input and removes the specified +guide from the specified image. +HELP + + &pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'guide', type => 'guide', + desc => 'The ID of the guide to be removed' } + ); + + %invoke = ( + headers => [ qw("undo.h") ], + vars => [ 'GList *guides' ], + code => <<'CODE' +{ + success = FALSE; + + guides = gimage->guides; + + while (guides) + { + if ((((Guide *) guides->data)->guide_ID == guide) && + (((Guide *) guides->data)->position >= 0)) + { + GList *tmp_next; + + success = TRUE; + + tmp_next = guides->next; + + ((Guide *) guides->data)->position = -1; + undo_push_guide (gimage, ((Guide *) guides->data)); + /* gimp_image_remove_guide (gimage, ((Guide *) guides->data)); */ + + guides = tmp_next; + } + else + guides = guides->next; + } +} +CODE + ); +} + +sub image_find_next_guide { + $blurb = 'Find next guide on an image.'; + + $help = <<'HELP'; +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. +HELP + + &pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'guide', type => 'guide', + desc => 'The ID of the current guide (0 if first invocation)' } + ); + + @outargs = ( + { name => 'next_guide', type => 'guide', init => 1, + desc => "The next guide's ID" } + ); + + %invoke = ( + vars => [ 'GList *guides' ], + code => <<'CODE' +{ + guides = gimage->guides; + + if (guides != NULL) + { + if (guide == 0) /* init - Return first guide ID in list */ + { + while (guides && (((Guide *) guides->data)->position < 0)) + guides = guides->next; + + if (guides) /* didn't just come to end of list */ + next_guide = ((Guide *) guides->data)->guide_ID; + } + else + { + success = FALSE; + + while (guides) + { + if ((((Guide *) guides->data)->guide_ID == guide) && + (((Guide *) guides->data)->position >= 0)) + { + GList* tmplist; + + success = TRUE; + + tmplist = guides->next; + + while (tmplist && (((Guide *) tmplist->data)->position < 0)) + tmplist = tmplist->next; + + if (tmplist); + next_guide = ((Guide *) tmplist->data)->guide_ID; + + break; + } + + guides = guides->next; + } + + } + } +} +CODE + ); +} + +sub image_get_guide_orientation { + $blurb = 'Get orientation of a guide on an image.'; + + $help = <<'HELP'; +This procedure takes an image and a guide ID as input and returns the +orientations of the guide. +HELP + + &pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'guide', type => 'guide', + desc => 'The guide' } + ); + + @outargs = ( + { name => 'orientation', type => 'enum GuideOrientation', init => 1, + desc => "The guide's orientation: { %%desc%% }" } + ); + + %invoke = ( + vars => [ 'GList *guides' ], + code => <<'CODE' +{ + guides = gimage->guides; + + success = FALSE; + + while (guides) + { + if ((((Guide *) guides->data)->guide_ID == guide) && + (((Guide *) guides->data)->position >= 0)) + { + orientation = ((Guide *) guides->data)->orientation; + success = TRUE; + break; + } + + guides = guides->next; + } +} +CODE + ); +} + +sub image_get_guide_position { + $blurb = 'Get position of a guide on an image.'; + + $help = <<'HELP'; +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. +HELP + + &pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'guide', type => 'guide', + desc => 'The guide' } + ); + + @outargs = ( + { name => 'position', type => 'int32', init => 1, + desc => "The guide's position relative to top or left of image" } + ); + + %invoke = ( + vars => [ 'GList *guides' ], + code => <<'CODE' +{ + guides = gimage->guides; + + success = FALSE; + + while (guides) + { + if ((((Guide *) guides->data)->guide_ID == guide) && + (((Guide *) guides->data)->position >= 0)) + { + position = ((Guide *) guides->data)->position; + success = TRUE; + break; + } + + guides = guides->next; + } +} +CODE + ); +} + +@headers = qw("gimage.h"); + +@procs = qw(image_add_hguide image_add_vguide image_delete_guide + image_find_next_guide image_get_guide_orientation + image_get_guide_position); +%exports = (app => [@procs]); + +$desc = 'Guide procedures'; + +1; diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb new file mode 100644 index 0000000000..226dc3e5c0 --- /dev/null +++ b/tools/pdbgen/pdb/image.pdb @@ -0,0 +1,1214 @@ +# The GIMP -- an image manipulation program +# Copyright (C) 1995 Spencer Kimball and Peter Mattis + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# "Perlized" from C source by Manish Singh + +sub layer_arg () {{ + name => 'layer', + type => 'layer', + desc => 'The layer' +}} + +sub channel_arg () {{ + name => 'channel', + type => 'channel', + desc => 'The channel' +}} + +sub new_dim_args { + foreach (qw(width height)) { + push @inargs, { name => "new_$_", type => '0 < int32', + desc => "New image $_: %%desc%%" } + } +} + +sub image_list_proc { + my $type = shift; + + $blurb = "Returns the list of ${type}s contained in the specified image."; + + $help = < "${type}_ids", type => 'int32array', init => 1, + desc => "The list of ${type}s contained in the image", + array => { name => "num_${type}s", init => 1, + desc => "The number of ${type}s contained in the image" } } + ); + + %invoke = ( + vars => [ 'GSList *list = NULL', 'int i' ], + code => <${type}s; + num_${type}s = g_slist_length (list); + + if (num_${type}s) + { + ${type}_ids = g_new (gint32, num_${type}s); + for (i = 0; i < num_${type}s; i++, list = list->next) + ${type}_ids[i] = drawable_ID (GIMP_DRAWABLE (list->data)); + } +} +CODE + ); +} + +sub type_move { + my ($type, $op, $pos) = @_; + my $extra = ""; + + if ($op =~ /_/) { + ($op, $extra) = $op =~ /([^_]+)_(.*)/; + $extra =~ s/_/ /g; + } + + my $layer = ""; + $layer = ', or the layer has no alpha channel' if $type eq 'layer'; + + $blurb = ucfirst($op) . " the specified $type in the image's $type stack"; + $blurb .= " $extra of stack" if $extra; + + $help = <{desc} .= " to $op $extra"; + + if ($extra) { + $extra =~ s/ /_/g; + $extra = "_$extra"; + } + + %invoke = ( + code => "success = gimage_${op}_$type$extra (gimage, $type) != NULL;" + ); +} + +sub image_get_prop_proc { + my ($prop, $type, $desc, $func) = @_; + + $blurb = "Returns the $desc of the specified image."; + + $help = "This procedure returns the specified image's $desc. "; + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => $prop, type => $type, + desc => "The $desc", no_declare => 1 } + ); + + my $alias = $func ? "gimage_get_$prop (gimage)" : "gimage->$prop"; + $alias = "g_strdup ($alias)" if $type eq 'string'; + $outargs[0]->{alias} .= "$alias"; + + if ($type eq 'color') { + $outargs[0]->{init} = 1; + delete @{$outargs[0]}{qw(alias no_declare)}; + + $invoke{headers} = [ qw("gimpimage.h") ]; + + $invoke{code} = "{\n color = g_new (guchar, 3);\n"; + foreach (map { "${_}_PIX" } qw(RED GREEN BLUE)) { + $invoke{code} .= " $prop\[$_] = image->col[$_];\n"; + } + $invoke{code} .= "}\n"; + } +} + +sub image_set_prop_proc { + my ($prop, $type, $desc, $func) = @_; + + $blurb = "Set the $desc of the specified image."; + + $help = "This procedure sets the specified image's $desc. "; + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => $prop, type => $type, + desc => "The new image $desc" } + ); + + if ($type =~ /float/) { + $inargs[1]->{desc} .= ' (%%desc%%)'; + } + + $invoke{code} = $func ? "gimage_set_$prop (gimage, $prop);" + : "gimage->$prop = $prop;"; + + if ($type eq 'color') { + %invoke = ( + vars => [ 'int i' ], + code => <col[i] = $prop\[i]; +CODE + ); + } +} + +sub image_accessors { + my ($prop, $type, $desc, $func, $extra) = @_; + my (@extra, %extra); my $once = 0; + + ref($extra) ? (@extra = @$extra) : (@extra = ($extra, $extra)); + %extra = map { $once++ ? 'set' : 'get', $_ ? $_ : "" } @extra; + + foreach (keys %extra) { + my $proc = "image_${_}_$prop"; + + push @procs, $proc; + + eval <{desc}, $outargs[0]->{array}->{desc}) { + s/contained.*/currently open/ + } + + $blurb .= '.'; + $help .= ' in the GIMP.'; + + for ($invoke{code}) { + s/list = .*$/gimage_foreach (gimlist_cb, &list);/m; + s/DRAWABLE/IMAGE/; + s/drawable_ID/pdb_image_to_id/; + } +} + +sub image_new { + $blurb = 'Creates a new image with the specified width, height, and type.'; + + $help = <<'HELP'; +Creates a new image, undisplayed with the specified extents and type. A layer +should be created and added before this image is displayed, or subsequent calls +to 'gimp_display_new' with this image as an argument will fail. Layers can be +created using the 'gimp_layer_new' commands. They can be added to an image +using the 'gimp_image_add_layer' command. +HELP + + &std_pdb_misc; + + @inargs = ( + { name => 'type', type => 'enum GimpImageBaseType', + desc => 'The type of image: { %%desc%% }' } + ); + + foreach (qw(height width)) { + unshift @inargs, { name => $_, type => '0 < int32', + desc => "The $_ of the image" } + } + + @outargs = ( + { name => 'image', type => 'image', alias => 'gimage', init => 1, + desc => 'The ID of the newly created image' } + ); + + %invoke = ( + code => <<'CODE' +success = (gimage = gimage_new (width, height, type)) != NULL; +CODE + ); +} + +sub image_resize { + $blurb = 'Resize the image to the specified extents.'; + + $help = <<'HELP'; +This procedure resizes the image so that it's new width and height are equal to +the supplied parameters. Offsets are also provided which describe the position +of the previous image's content. No bounds checking is currently provided, so +don't supply parameters that are out of bounds. All channels within the image +are resized according to the specified parameters; this includes the image +selection mask. All layers within the image are repositioned according to the +specified offsets. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + &new_dim_args; + + foreach (qw(x y)) { + push @inargs, { name => "off$_", type => 'int32', + desc => "$_ offset between upper left corner of old and + new images: (new - old)" } + } + + %invoke = ( + headers => [ qw("cursorutil.h") ], + code => <<'CODE' +{ + gimp_add_busy_cursors_until_idle (); + gimage_resize (gimage, new_width, new_height, offx, offy); +} +CODE + ); +} + +sub image_scale { + $blurb = 'Scale the image to the specified extents.'; + + $help = <<'HELP'; +This procedure scales the image so that it's new width and height are equal to +the supplied parameters. Offsets are also provided which describe the position +of the previous image's content. No bounds checking is currently provided, so +don't supply parameters that are out of bounds. All channels within the image +are scaled according to the specified parameters; this includes the image +selection mask. All layers within the image are repositioned according to the +specified offsets. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + &new_dim_args; + + %invoke = ( + code => <<'CODE' +{ + gimp_add_busy_cursors_until_idle (); + gimage_scale (gimage, new_width, new_height); +} +CODE + ); +} + +sub image_delete { + $blurb = 'Delete the specified image.'; + + $help = <<'HELP'; +If there are no other references to this image it will be deleted. Other +references are possible when more than one view to an image exists. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => 'gimage_delete (gimage);' ); +} + +sub image_free_shadow { + $blurb = "Free the specified image's shadow data (if it exists)."; + + $help = <<'HELP'; +This procedure is intended as a memory saving device. If any shadow memory has +been allocated, it will be freed automatically on a call to +'gimp_image_delete'. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => 'gimage_free_shadow (gimage);' ); +} + +sub image_get_layers { + &image_list_proc('layer'); + + $help .= 'The order of layers is from topmost to bottommost.'; +} + +sub image_get_channels { + &image_list_proc('channel'); + + $help .= <<'HELP'; +This does not include the selection mask, or layer masks. The order is from +topmost to bottommost. +HELP +} + +sub image_unset_active_channel { + $blurb = 'Unsets the active channel in the specified image.'; + + $help = <<'HELP'; +If an active channel exists, it is unset. There then exists no active channel, +and if desired, one can be set through a call to 'Set Active Channel'. No error +is returned in the case of no existing active channel. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => 'gimage_unset_active_channel (gimage);' ); +} + +sub image_pick_correlate_layer { + $blurb = 'Find the layer visible at the specified coordinates.'; + + $help = <<'HELP'; +This procedure finds the layer which is visible at the specified coordinates. +Layers which do not qualify are those whose extents do not pass within the +specified coordinates, or which are transparent at the specified coordinates. +This procedure will return -1 if no layer is found. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + foreach (qw(x y)) { + push @inargs, { name => $_, type => 'int32', + desc => "The $_ coordinate for the pick" } + } + + @outargs = ( + { name => 'layer', type => 'layer', init => 1, + desc => 'The layer found at the specified coordinates' } + ); + + %invoke = ( + code => 'layer = gimage_pick_correlate_layer (gimage, x, y);' + ); +} + +sub image_raise_layer { + &type_move('layer', 'raise', 'above'); + &std_pdb_misc; +} + +sub image_lower_layer { + &type_move('layer', 'lower', 'below'); + &std_pdb_misc; +} + +sub image_raise_layer_to_top { + &type_move('layer', 'raise_to_top', 'above'); + $copyright = "Wolfgang Hofer"; + $author = $copyright . ", Sven Neumann"; + $date = 1998; +} + +sub image_lower_layer_to_bottom { + &type_move('layer', 'lower_to_bottom', 'below'); + $copyright = "Wolfgang Hofer"; + $author = $copyright . ", Sven Neumann"; + $date = 1998; +} + +sub image_merge_visible_layers { + $blurb = 'Merge the visible image layers into one.'; + + $help = <<'HELP'; +This procedure combines the visible layers into a single layer using the +specified merge type. A merge type of EXPAND_AS_NECESSARY expands the final +layer to encompass the areas of the visible layers. A merge type of +CLIP_TO_IMAGE clips the final layer to the extents of the image. A merge type +of CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the bottommost +layer. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'merge_type', type => 'enum MergeType (no FLATTEN_IMAGE)', + desc => 'The type of merge: { %%desc%% }' } + ); + + @outargs = ( + { name => 'layer', type => 'layer', init => 1, + desc => 'The resulting layer' } + ); + + %invoke = ( + code => <<'CODE' +{ + layer = gimage_merge_visible_layers (gimage, merge_type); + success = layer != NULL; +} +CODE + ); +} + +sub image_merge_down { + $blurb = 'Merge the layer passed and the first visible layer below.'; + + $help = <<'HELP'; +This procedure combines the passed layer and the first visible layer below it +using the specified merge type. A merge type of EXPAND_AS_NECESSARY expands the +final layer to encompass the areas of the visible layers. A merge type of +CLIP_TO_IMAGE clips the final layer to the extents of the image. A merge type +of CLIP_TO_BOTTOM_LAYER clips the final layer to the size of the bottommost +layer. +HELP + + $author = $copyright = 'Larry Ewing'; + $date = '1998'; + + @inargs = ( + &std_image_arg, + { name => 'merge_layer', type => 'layer', + desc => 'The layer to merge down from' }, + { name => 'merge_type', type => 'enum MergeType (no FLATTEN_IMAGE)', + desc => 'The type of merge: { %%desc%% }' } + ); + + @outargs = ( + { name => 'layer', type => 'layer', init => 1, + desc => 'The resulting layer' } + ); + + %invoke = ( + code => <<'CODE' +{ + layer = gimp_image_merge_down (gimage, merge_layer, merge_type); + success = layer != NULL; +} +CODE + ); +} + +sub image_flatten { + $blurb = <<'BLURB'; +Flatten all visible layers into a single layer. Discard all invisible layers. +BLURB + + $help = <<'HELP'; +This procedure combines the visible layers in a manner analogous to merging +with the CLIP_TO_IMAGE merge type. Non-visible layers are discarded, and the +resulting image is stripped of its alpha channel. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'layer', type => 'layer', init => 1, + desc => 'The resulting layer' } + ); + + %invoke = ( + code => 'success = (layer = gimage_flatten (gimage)) != NULL;' + ); +} + +sub image_add_layer { + $blurb = 'Add the specified layer to the image.'; + + $help = <<'HELP'; +This procedure adds the specified layer to the gimage at the given position. If +the position is specified as -1, then the layer is inserted at the top of the +layer stack. If the layer to be added has no alpha channel, it must be added at +position 0. The layer type must be compatible with the image base type. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &layer_arg, + { name => 'position', type => 'int32', + desc => 'The layer position' } + ); + + $invoke{code} = "{\n if ("; my $once = 0; + foreach (qw(color gray indexed)) { + my $base = $_ eq 'color' ? 'RGB' : uc($_); + $invoke{code} .= ' ' x 6 if $once++; + $invoke{code} .= < 'gimage_remove_layer (gimage, layer);' ); +} + +sub image_add_layer_mask { + $blurb = 'Add a layer mask to the specified layer.'; + + $help = <<'HELP'; +This procedure adds a layer mask to the specified layer. Layer masks serve as +an additional alpha channel for a layer. This procedure will fail if a number +of prerequisites aren't met. The layer cannot already have a layer mask. The +specified mask must exist and have the same dimensions as the layer. Both the +mask and the layer must have been created for use with the specified image. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &layer_arg, + { name => 'mask', type => 'layer_mask', + desc => 'The mask to add to the layer' } + ); + $inargs[1]->{desc} .= ' to receive the mask'; + + %invoke = ( + code => <<'CODE' +success = gimage_add_layer_mask (gimage, layer, mask) != NULL; +CODE + ); +} + +sub image_remove_layer_mask { + $blurb = 'Remove the specified layer mask from the layer.'; + + $help = <<'HELP'; +This procedure removes the specified layer mask from the layer. If the mask +doesn't exist, an error is returned. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &layer_arg, + { name => 'mode', type => 'enum MaskApplyMode', + desc => 'Removal mode: { %%desc%% }' } + ); + $inargs[1]->{desc} .= ' from which to remove mask'; + + %invoke = ( code => 'gimage_remove_layer_mask (gimage, layer, mode);' ); +} + +sub image_raise_channel { + &type_move('channel', 'raise', 'above'); + &std_pdb_misc; +} + +sub image_lower_channel { + &type_move('layer', 'lower', 'below'); + &std_pdb_misc; +} + +sub image_add_channel { + $blurb = 'Add the specified channel to the image.'; + + $help = <<'HELP'; +This procedure adds the specified channel to the image. The position channel is +not currently used, so the channel is always inserted at the top of the channel +stack. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &channel_arg, + { name => 'position', type => 'int32', + desc => 'The channel position' } + ); + + %invoke = ( + code => <<'CODE' +success = gimage_add_channel (gimage, channel, MAX (position, -1)) != NULL; +CODE + ); +} + +sub image_remove_channel { + $blurb = 'Remove the specified channel from the image.'; + + $help = <<'HELP'; +This procedure removes the specified channel from the image. If the channel +doesn't exist, an error is returned. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + &channel_arg + ); + + %invoke = ( code => 'gimage_remove_channel (gimage, channel);' ); +} + +sub image_active_drawable { + $blurb = "Get the image's active drawable"; + + $help = <<'HELP'; +This procedure returns the ID of the image's active drawable. This can be +either a layer, a channel, or a layer mask. The active drawable is specified by +the active image channel. If that is -1, then by the active image layer. If the +active image layer has a layer mask and the layer mask is in edit mode, then +the layer mask is the active drawable. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'drawable', type => 'drawable', init => 1, + desc => 'The active drawable' } + ); + + %invoke = ( + code => <<'CODE' +success = (drawable = gimage_active_drawable (gimage)) != NULL; +CODE + ); +} + +sub image_base_type { + $blurb = 'Get the base type of the image.'; + + $help = <<'HELP'; +This procedure returns the image's base type. Layers in the image must be of +this subtype, but can have an optional alpha channel. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'base_type', type => 'enum GimpImageBaseType', init => 1, + desc => "The image's base type: { %%desc%% }" } + ); + + %invoke = ( code => 'base_type = gimage_base_type (gimage);' ); +} + +sub image_get_cmap { + $blurb = "Returns the image's colormap"; + + $help = <<'HELP'; +This procedure returns an actual pointer to the image's colormap, as well as +the number of bytes contained in the colormap. The actual number of colors in +the transmitted colormap will be "num_bytes" / 3. If the image is not of base +type INDEXED, this pointer will be NULL. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'cmap', type => 'int8array', init => 1, + desc => "The image's colormap", + array => { name => 'num_bytes', init => 1, + desc => 'Number of bytes in the colormap array: + %%desc%%' } } + ); + + %invoke = ( + code => <<'CODE' +{ + num_bytes = gimage->num_cols * 3; + cmap = g_new (gint8, num_bytes); + memcpy (cmap, gimage_cmap (gimage), num_bytes); +} +CODE + ); +} + +sub image_set_cmap { + $blurb = "Sets the entries in the image's colormap."; + + $help = <<'HELP'; +This procedure sets the entries in the specified image's colormap. The number +of entries is specified by the "num_bytes" parameter and corresponds to the +number of INT8 triples that must be contained in the "cmap" array. The actual +number of colors in the transmitted colormap is "num_bytes" / 3. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'cmap', type => 'int8array', + desc => "The new colormap values", + array => { name => 'num_bytes', type => '0 <= int32 <= 768', + desc => 'Number of bytes in the colormap array: + %%desc%%' } } + ); + + %invoke = ( + headers => [ qw("gdisplay.h") ], + code => <<'CODE' +{ + if (gimage->num_cols && gimage->cmap) + { + g_free (gimage->cmap); + gimage->cmap = NULL; + } + if (num_bytes) + { + gimage->cmap = g_new (guchar, COLORMAP_SIZE); + memcpy (gimage->cmap, cmap, num_bytes); + } + gimage->num_cols = num_bytes / 3; + + /* A colormap alteration affects the whole image */ + gdisplays_update_area (gimage, 0, 0, gimage->width, gimage->height); +} +CODE + ); +} + +sub image_enable_undo { + $blurb = "Enable the image's undo stack."; + + $help = <<'HELP'; +This procedure enables the image's undo stack, allowing subsequent operations +to store their undo steps. This is generally called in conjunction with +'gimp_image_disable_undo' to temporarily disable an image undo stack. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'enabled', type => 'boolean', + desc => 'True if the image undo has been enabled', + alias => 'success ? TRUE : FALSE', no_declare => 1 } + ); + + %invoke = ( code => 'success = gimage_enable_undo (gimage);' ); +} + +sub image_disable_undo { + $blurb = "Disable the image's undo stack."; + + $help = <<'HELP'; +This procedure disables the image's undo stack, allowing subsequent operations +to ignore their undo steps. This is generally called in conjunction with +'gimp_image_enable_undo' to temporarily disable an image undo stack. This is +advantageous because saving undo steps can be time and memory intensive. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'disabled', type => 'boolean', + desc => 'True if the image undo has been disabled', + alias => 'success ? TRUE : FALSE', no_declare => 1 } + ); + + %invoke = ( code => 'success = gimage_disable_undo (gimage);' ); +} + +sub image_clean_all { + $blurb = 'Set the image dirty count to 0.'; + + $help = <<'HELP'; +This procedure sets the specified image's dirty count to 0, allowing operations +to occur without having a 'dirtied' image. This is especially useful for cre +ating and loading images which should not initially be considered dirty, even +though layers must be created, filled, and installed in the image. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + %invoke = ( code => 'gimage_clean_all (gimage);' ); +} + +sub image_floating_selection { + $blurb = 'Return the floating selection of the image.'; + + $help = <<'HELP'; +This procedure returns the image's floating_sel, if it exists. If it doesn't +exist, -1 is returned as the layer ID. +HELP + + &std_pdb_misc; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'floating_sel', type => 'layer', init => 1, + desc => "The image's floating selection", + return_fail => -1 } + ); + + %invoke = ( code => 'floating_sel = gimage_floating_sel (gimage);' ); +} + +sub image_floating_sel_attached_to { + $blurb = 'Return the drawable the floating selection is attached to.'; + + $help = <<'HELP'; +This procedure returns the drawable the image's floating selection is attached +to, if it exists. If it doesn't exist, -1 is returned as the drawable ID. +HELP + + $author = $copyright = 'Wolfgang Hofer'; + $date = '1998'; + + @inargs = ( &std_image_arg ); + + @outargs = ( + { name => 'drawable', type => 'drawable', init => 1, + desc => 'The drawable the floating selection is attached to', + return_fail => -1 } + ); + + %invoke = ( + headers => [ qw("layer_pvt.h") ], + vars => [ 'Layer *floating_sel' ], + code => <<'CODE' +{ + floating_sel = gimage_floating_sel (gimage); + drawable = GIMP_DRAWABLE (GIMP_LAYER (floating_sel)->fs.drawable); +} +CODE + ); +} + +foreach (qw(width height)) { + push @procs, "image_$_"; + eval < '$_', type => 'int32', + desc => "The image's $_", + alias => 'gimage->$_', no_declare => 1 } + ); +} +SUB +} + +&image_accessors('active_layer', 'layer', 'active layer', 1, + [ <<'CODE1', <<'CODE2' ]); + $invoke{code} = "active_layer = $outargs[0]->{alias};"; + delete @{$outargs[0]}{qw(alias no_declare)}; + $outargs[0]->{return_fail} = -1; + $outargs[0]->{init} = 1; + + $help = <<'HELP'; +If there is an active layer, its ID will be returned, otherwise, -1. If a +channel is currently active, then no layer will be. If a layer mask is active, +then this will return the associated layer. +HELP +CODE1 + $help = <<'HELP'; +If the layer exists, it is set as the active layer in the image. Any previous +active layer or channel is set to inactive. An exception is a previously +existing floating selection, in which case this procedure will return an +execution error. +HELP +CODE2 + +&image_accessors('active_channel', 'channel', 'active channel', 1, + [ <<'CODE1', <<'CODE2' ]); + $invoke{code} = "active_channel = $outargs[0]->{alias};"; + delete @{$outargs[0]}{qw(alias no_declare)}; + $outargs[0]->{return_fail} = -1; + $outargs[0]->{init} = 1; + + $help = <<'HELP'; +If there is an active channel, this will return the channel ID, otherwise, -1. +HELP +CODE1 + $help = <<'HELP'; +If the channel exists, it is set as the active channel in the image. Any +previous active channel or channel is set to inactive. An exception is a +previously existing floating selection, in which case this procedure will +return an execution error. +HELP +CODE2 + +&image_accessors('selection', 'selection', 'selection', 1, + [ <<'CODE', undef ]); + $invoke{code} = "success = (selection = gimage_get_mask (gimage)) != NULL;"; + delete @{$outargs[0]}{qw(alias no_declare)}; + $outargs[0]->{desc} .= ' channel'; + $outargs[0]->{init} = 1; + + $help = <<'HELP'; +This will always return a valid ID for a selection--which is represented as a +channel internally. +HELP +CODE +$#procs--; + +my $comp_arg = <<'CODE'; + splice @inargs, 1, 0, ({ name => 'component', + type => 'enum ChannelType (no AUXILLARY_CHANNEL)', + desc => 'The image component: { %%desc%% }' }); + + $invoke{code} = <<'SUCCESS'; +{ + if (component == GRAY_CHANNEL) + success = gimage_base_type (gimage) == GRAY; + else if (component == INDEXED_CHANNEL) + success = gimage_base_type (gimage) == INDEXED; + else + success = gimage_base_type (gimage) == RGB; +} +SUCCESS +CODE + +my $comp_help = <<'CODE'; + $help =~ s/(component)/$1 (i.e. Red, Green, Blue intensity channels + in an RGB image)/; + $help =~ s/\. $/ /; + $help .= < 'modified', + visible => 'seen' +); + +foreach (sort keys %comp_action) { + my $help = $comp_help; + + $help =~ s/%%type%%/$_/e; + $help =~ s/%%action%%/$comp_action{$_}/e; + + &image_accessors("component_$_", 'boolean', "image component is $_", 1, + [ <{name} = '$_'; + \$outargs[0]->{desc} = 'Component is $_ (%%desc%%)'; + + chop \$outargs[0]->{alias}; + \$outargs[0]->{alias} .= ', component)'; + $help; +CODE1 + my \$code = <{name} = '$_'; + \$inargs[2]->{desc} = 'Component is $_ (%%desc%%)'; + $help; +CODE2 +} + +&image_accessors('filename', 'string', 'filename', 1, + [ <<'CODE', undef ]); + $help =~ s/\. $//; + $help .= <<'HELP'; +--if it was loaded or has since been saved. Otherwise, returns NULL. +HELP + + $outargs[0]->{alias} =~ s/get_//; +CODE + +&image_accessors('resolution', 'float', 'resolution', 0, + [ <<'CODE1', <<'CODE2' ]); + $help =~ s/\. $/ /; + $help .= <<'HELP'; +in dots per inch. This value is independent of any of the layers in this image. +HELP + + $author = $copyright = 'Austin Donnelly'; + $date = '1998'; + + push @outargs, { %{$outargs[0]} }; + + my $count = 0; + foreach $coord (qw(x y)) { + foreach (qw(name alias)) { + $outargs[$count]->{$_} =~ s/res/"${coord}res"/e + } + $outargs[$count++]->{desc} .= "in the $coord-axis, in dots per inch"; + } +CODE1 + $help =~ s/\. $/ /; + $help .= <<'HELP'; +in dots per inch. This value is independent of any of the layers in this image. +No scaling or resizing is performed. +HELP + + $author = $copyright = 'Austin Donnelly'; + $date = '1998'; + + push @inargs, { %{$inargs[1]} }; + + my $count = 1; undef %invoke; + foreach $coord (qw(x y)) { + my $arg = $inargs[$count]; + $arg->{name} =~ s/res/"${coord}res"/e; + $arg->{alias} = "gimage->$arg->{name}"; + $arg->{no_declare} = 1; + $arg->{desc} .= "in the $coord-axis, in dots per inch"; + $count++; + } +CODE2 + +my $unit_help = <<'HELP'; +This value is independent of any of the layers in this image. See the +gimp_unit_* procedure definitions for the valid range of unit IDs and a +description of the unit system. +HELP + +my $unit_misc = <<'CODE'; + $author = $copyright = 'Michael Naterrer'; + $date = '1998'; +CODE +&image_accessors('unit', 'unit (min UNIT_INCH)', 'unit', 0, + [ < 'tattoo', type => 'tattoo', + desc => 'The tattoo of the $_ to find' } + ); + + \@outargs = ( + { name => '$_', type => '$_', init => 1, + desc => 'The $_ with the specified tattoo' } + ); + + \%invoke = ( + code => <<'CODE' +{ + $_ = gimp_image_get_${_}_by_tattoo (gimage, tattoo); + success = $_ != NULL; +} +CODE + ); +} +SUB +} + +@headers = qw("gimage.h"); + +$extra{app}->{code} = <<'CODE'; +/* Yuup, this is somewhat unsmooth, to say the least */ + +static void +gimlist_cb (gpointer im, + gpointer data) +{ + GSList **l = (GSList **) data; + *l = g_slist_prepend (*l, im); +} +CODE + +unshift @procs, qw(list_images image_new image_resize image_scale image_delete + image_free_shadow image_get_layers image_get_channels + image_unset_active_channel image_pick_correlate_layer + image_raise_layer image_lower_layer image_raise_layer_to_top + image_lower_layer_to_bottom image_merge_visible_layers + image_merge_down image_flatten image_add_layer + image_remove_layer image_add_layer_mask + image_remove_layer_mask image_raise_channel + image_lower_channel image_add_channel image_remove_channel + image_active_drawable image_base_type image_get_cmap + image_set_cmap image_enable_undo image_disable_undo + image_clean_all image_floating_selection + image_floating_sel_attached_to); +%exports = (app => [@procs]); + +$desc = 'Image'; + +1; diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb index 03c941f89d..0656222bf5 100644 --- a/tools/pdbgen/pdb/layer.pdb +++ b/tools/pdbgen/pdb/layer.pdb @@ -425,8 +425,7 @@ sub layer_mask { $blurb = "Get the specified layer's mask if it exists."; $help = <<'HELP'; -This procedure returns the specified layer's mask. If there is no layer mask, -the procedure fails. +This procedure returns the specified layer's mask, or -1 if none exists. HELP &std_pdb_misc; @@ -436,10 +435,9 @@ HELP @outargs = ( { name => 'mask', type => 'channel', desc => 'The layer mask', - alias => 'layer->mask', no_declare => 1 } + alias => 'layer->mask', no_declare => 1, + return_fail => -1 } ); - - %invoke = ( code => 'success = layer->mask ? TRUE : FALSE;' ); } sub layer_is_floating_sel { @@ -543,10 +541,10 @@ HELP $author = $copyright = 'Jay Cox'; $date = '1998'; CODE +$#procs--; @headers = qw("layer.h" "layer_pvt.h"); -$#procs--; unshift @procs, qw(layer_new layer_copy layer_create_mask layer_scale layer_resize layer_delete layer_translate layer_add_alpha layer_set_offsets layer_mask layer_is_floating_sel); diff --git a/tools/pdbgen/pdb/parasite.pdb b/tools/pdbgen/pdb/parasite.pdb index 387f22ed33..1b71fbacdb 100644 --- a/tools/pdbgen/pdb/parasite.pdb +++ b/tools/pdbgen/pdb/parasite.pdb @@ -17,11 +17,9 @@ # "Perlized" from C source by Manish Singh -# The defs - sub pdb_misc { $author = $copyright = 'Jay Cox'; - $date = 1998; + $date = '1998'; } sub name_arg {{ @@ -44,15 +42,20 @@ sub drawable_arg () {{ desc => 'The drawable' }} -sub drawable_convert { - foreach ($blurb, $help, $inargs[0]->{desc}) { s/the gimp/a drawable/ } +sub convert_proc { + my ($type, $arg, $var) = @_; + my $desc = ($type =~ /^[aeiou]/ ? 'an ' : 'a ') . $type; - unshift @inargs, &drawable_arg; + foreach ($blurb, $help, $inargs[0]->{desc}) { s/the gimp/$desc/e } - $invoke{code} =~ s/gimp/gimp_drawable/; - $invoke{code} =~ s/\(((?!gimp).*?(?:parasite|name))/(drawable, $1/; + unshift @inargs, $arg; + + $invoke{code} =~ s/gimp/"gimp_$type"/e; + $invoke{code} =~ s/\(((?!gimp).*?(?:parasite|name))/"($var, $1"/e; } +# The defs + sub parasite_new { $blurb = 'Creates a new parasite.'; @@ -158,31 +161,8 @@ sub parasite_list { %invoke = ( code => 'parasites = gimp_parasite_list (&num_parasites);' ); } -sub drawable_find_parasite { - &find_parasite; - &drawable_convert; - $blurb =~ s/\.$/in a drawable./; -} - -sub drawable_attach_parasite { - &attach_parasite; - &drawable_convert; -} - -sub drawable_detach_parasite { - &detach_parasite; - &drawable_convert; -} - -sub drawable_parasite_list { - ¶site_list; - @inargs = ( &drawable_arg ); - &drawable_convert; - @inargs = ( &drawable_arg ); - $outargs[0]->{init} = 1; -} - -@headers = qw("libgimp/parasite.h" "gimpparasite.h" "gimpdrawable.h"); +@headers = qw("libgimp/parasite.h" "gimpparasite.h" "gimpdrawable.h" + "gimpimage.h"); $extra{lib}->{protos} = <<'CODE'; void gimp_attach_new_parasite (const char *name, int flags, int size @@ -202,7 +182,39 @@ CODE @procs = qw(parasite_new find_parasite attach_parasite detach_parasite parasite_list); -push @procs, map { 'drawable_' . $_ } @procs[1..4]; + +@types = ( + ['drawable', '&drawable_arg' , 'drawable'], + ['image' , '&std_image_arg', 'gimage' ] +); + +foreach $type (@types) { + foreach (@procs[1..4]) { + my $desc = ($type->[0] =~ /^[aeiou]/ ? 'an ' : 'a ') . $type->[0]; + my $args = join(', ', map { /^&/ ? $_ : "'$_'" } @$type); + my $pre = ""; my $post = ""; + + if (/find/) { + $pre = "\$blurb =~ s/\\.\$/ in $desc/;"; + } + elsif (/list/) { + $pre = "\@inargs = ( $type->[1] );"; + $post = "\@inargs = ( $type->[1] ); \$outargs[0]->{init} = 1;"; + } + + eval <[0]_$_ { + \&$_; + $pre + &convert_proc($args); + $post; +} +SUB + + push @procs, "$type->[0]_$_"; + } +} + %exports = (app => [@procs], lib => [@procs[1..3]]); $desc = 'Parasite procedures';