18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
21
$author = $copyright = 'Adam D. Moss';
26
my ($desc, $type, $max, $pos) = @_;
28
$blurb = "Add a $desc guide to an image.";
31
This procedure adds a $desc guide to an image. It takes the input image and the
32
$type-position of the new guide as parameters. It returns the guide ID of the
40
{ name => "${type}position", type => '0 <= int32',
41
desc => "The guide's ${type}-offset from $pos of image",
46
{ name => 'guide', type => 'guide', init => 1, alias => 'guide_ID',
47
desc => 'The new guide' }
50
my $func = substr($desc, 0, 1);
52
vars => [ 'GimpGuide *guide' ],
55
if (offset <= gimage->$max)
57
guide = gimp_image_add_${func}guide (gimage, offset, TRUE);
58
guide_ID = guide->guide_ID;
69
20
sub image_add_hguide {
70
&image_add_guide('horizontal', 'y', 'height', 'top');
21
$blurb = 'Add a horizontal guide to an image.';
24
This procedure adds a horizontal guide to an image. It takes the input
25
image and the y-position of the new guide as parameters. It returns
26
the guide ID of the new guide.
29
&adam_pdb_misc('1998');
32
{ name => 'image', type => 'image',
33
desc => 'The image' },
34
{ name => 'yposition', type => '0 <= int32',
35
desc => "The guide's y-offset from top of image" }
39
{ name => 'guide', type => 'guide',
40
desc => 'The new guide' }
46
if (yposition <= image->height)
50
g = gimp_image_add_hguide (image, yposition, TRUE);
51
guide = gimp_guide_get_ID (g);
73
60
sub image_add_vguide {
74
&image_add_guide('vertical', 'x', 'width', 'left');
61
$blurb = 'Add a vertical guide to an image.';
64
This procedure adds a vertical guide to an image. It takes the input
65
image and the x-position of the new guide as parameters. It returns
66
the guide ID of the new guide.
69
&adam_pdb_misc('1998');
72
{ name => 'image', type => 'image',
73
desc => 'The image' },
74
{ name => 'xposition', type => '0 <= int32',
75
desc => "The guide's x-offset from left of image" }
79
{ name => 'guide', type => 'guide',
80
desc => 'The new guide' }
86
if (xposition <= image->width)
90
g = gimp_image_add_vguide (image, xposition, TRUE);
91
guide = gimp_guide_get_ID (g);
77
100
sub image_delete_guide {
82
105
guide from the specified image.
108
&adam_pdb_misc('1998');
111
{ name => 'image', type => 'image',
112
desc => 'The image' },
89
113
{ name => 'guide', type => 'guide',
90
114
desc => 'The ID of the guide to be removed' }
94
vars => [ 'GList *guides' ],
99
for (guides = gimage->guides; guides; guides = g_list_next (guides))
101
GimpGuide *g = (GimpGuide *) guides->data;
103
if ((g->guide_ID == guide) && (g->position >= 0))
105
gimp_image_remove_guide (gimage, g, TRUE);
120
GimpGuide *g = gimp_image_get_guide (image, guide);
123
gimp_image_remove_guide (image, g, TRUE);
122
138
return 0 if given the final guide ID as an argument or the image has no guides.
141
&adam_pdb_misc('1998');
129
{ name => 'guide', type => 'guide',
144
{ name => 'image', type => 'image',
145
desc => 'The image' },
146
{ name => 'guide', type => 'guide', no_success => 1,
130
147
desc => 'The ID of the current guide (0 if first invocation)' }
134
{ name => 'next_guide', type => 'guide', init => 1,
151
{ name => 'next_guide', type => 'guide',
135
152
desc => "The next guide's ID" }
139
vars => [ 'GList *guides', 'gboolean guide_found' ],
142
if (gimage->guides != NULL)
147
for (guides = gimage->guides; guides; guides = g_list_next (guides))
149
GimpGuide *g = (GimpGuide *) guides->data;
154
if (guide == 0) /* init - Return first guide ID in list */
156
next_guide = g->guide_ID;
164
if (g->guide_ID == guide)
169
next_guide = g->guide_ID;
158
GimpGuide *g = gimp_image_get_next_guide (image, guide, &success);
161
next_guide = gimp_guide_get_ID (g);
187
172
orientations of the guide.
175
&adam_pdb_misc('1998');
178
{ name => 'image', type => 'image',
179
desc => 'The image' },
194
180
{ name => 'guide', type => 'guide',
195
181
desc => 'The guide' }
199
{ name => 'orientation', type => &std_orientation_enum, init => 1,
200
desc => "The guide's orientation: { %%desc%% }",
185
{ name => 'orientation',
186
type => 'enum GimpOrientationType (no GIMP_ORIENTATION_UNKNOWN)',
187
desc => "The guide's orientation",
201
188
libdef => 'GIMP_ORIENTATION_UNKNOWN' }
205
vars => [ 'GList *guides' ],
210
for (guides = gimage->guides; guides; guides = g_list_next (guides))
212
GimpGuide *g = (GimpGuide *) guides->data;
214
if ((g->guide_ID == guide) && (g->position >= 0))
216
orientation = g->orientation;
194
GimpGuide *g = gimp_image_get_guide (image, guide);
197
orientation = gimp_guide_get_orientation (g);
232
210
of the guide relative to the top or left of the image.
213
&adam_pdb_misc('1998');
216
{ name => 'image', type => 'image',
217
desc => 'The image' },
239
218
{ name => 'guide', type => 'guide',
240
219
desc => 'The guide' }
244
{ name => 'position', type => 'int32', init => 1, libdef => '-1',
223
{ name => 'position', type => 'int32', libdef => '-1',
245
224
desc => "The guide's position relative to top or left of image" }
249
vars => [ 'GList *guides' ],
254
for (guides = gimage->guides; guides; guides = g_list_next (guides))
256
GimpGuide *g = (GimpGuide *) guides->data;
258
if ((g->guide_ID == guide) && (g->position >= 0))
260
position = g->position;
230
GimpGuide *g = gimp_image_get_guide (image, guide);
233
position = gimp_guide_get_position (g);
271
@headers = qw("core/gimpimage-guides.h" "core/gimpimage-undo-push.h");
242
@headers = qw("core/gimpguide.h" "core/gimpimage-guides.h" "core/gimpimage-undo-push.h");
273
244
@procs = qw(image_add_hguide image_add_vguide image_delete_guide
274
245
image_find_next_guide image_get_guide_orientation
275
246
image_get_guide_position);
276
248
%exports = (app => [@procs], lib => [@procs]);
278
250
$desc = 'Guide procedures';