~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/layer.pdb

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# The GIMP -- an image manipulation program
 
1
# GIMP - The GNU Image Manipulation Program
2
2
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 
4
4
# This program is free software; you can redistribute it and/or modify
17
17
 
18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
19
19
 
20
 
sub layer_arg () {{
21
 
    name => 'layer',
22
 
    type => 'layer',
23
 
    desc => 'The layer'
24
 
}}
25
 
 
26
 
sub layer_dim_proc {
27
 
    my ($op, $morehelp, @args) = @_;
28
 
 
29
 
    $blurb = "\u$op the layer to the specified extents.";
30
 
 
31
 
    my $ops = $op =~ /e$/ ? "${op}s" : "${op}es";
32
 
    $help = <<HELP;
33
 
This procedure $ops the layer so that it's new width and height are equal to
34
 
the supplied parameters. $morehelp This operation only works if the layer has
35
 
been added to an image.
36
 
HELP
37
 
 
38
 
    &std_pdb_misc;
39
 
 
40
 
    @inargs = (
41
 
        &layer_arg,
42
 
        { name => 'new_width', type => '0 < int32',
43
 
          desc => 'New layer width: (%%desc%%)' },
44
 
        { name => 'new_height', type => '0 < int32',
45
 
          desc => 'New layer height: (%%desc%%)' },
46
 
    );
47
 
    push @inargs, @args;
48
 
 
49
 
    my $args = "";
50
 
    my $call;
51
 
    foreach (@args) {
52
 
        $args .= ', ' if $args;
53
 
        $args .= $_->{name};
54
 
    }
55
 
 
56
 
    if ($op eq 'scale') {
57
 
        $call = "gimp_item_scale_by_origin (GIMP_ITEM (layer), new_width, new_height, gimp->config->interpolation_type, NULL, $args);";
58
 
    } else {
59
 
        $call = "gimp_item_resize (GIMP_ITEM (layer), context, new_width, new_height, $args);";
60
 
    }
61
 
 
62
 
    $invoke{code} = <<"CODE";
63
 
{
64
 
  success = gimp_item_is_attached (GIMP_ITEM (layer));
65
 
 
66
 
  if (success)
67
 
    $call
68
 
}
69
 
CODE
70
 
}
71
 
 
72
 
sub layer_get_prop_proc {
73
 
    my ($prop, $type, $desc, $undo, $core_type, $core_var) = @_;
74
 
 
75
 
    $core_type = 'layer' unless $core_type;
76
 
    $core_var  = 'layer' unless $core_var;
77
 
 
78
 
    $blurb = "Get the $desc of the specified layer.";
79
 
 
80
 
    $help = "This procedure returns the specified layer's $desc. ";
81
 
 
82
 
    &std_pdb_misc;
83
 
 
84
 
    @inargs = ( &layer_arg );
85
 
 
86
 
    @outargs = (
87
 
        { name => $prop, type => $type,
88
 
          desc => "The layer $desc", no_declare => 1 }
89
 
    );
90
 
 
91
 
    my $alias = "gimp_${core_type}_get_$prop ($core_var)";
92
 
    $alias = "g_strdup ($alias)" if $type eq 'string';
93
 
    $outargs[0]->{alias} .= "$alias";
94
 
}
95
 
 
96
 
sub layer_set_prop_proc {
97
 
    my ($prop, $type, $desc, $undo, $core_type, $core_var) = @_;
98
 
 
99
 
    $core_type = 'layer' unless $core_type;
100
 
    $core_var  = 'layer' unless $core_var;
101
 
 
102
 
    $blurb = "Set the $desc of the specified layer.";
103
 
 
104
 
    $help = "This procedure sets the specified layer's $desc. ";
105
 
 
106
 
    &std_pdb_misc;
107
 
 
108
 
    @inargs = (
109
 
        &layer_arg,
110
 
        { name => $prop, type => $type,
111
 
          desc => "The new layer $desc" }
112
 
    );
113
 
 
114
 
    if ($type =~ /float/) {
115
 
        $inargs[1]->{desc} .= ' (%%desc%%)';
116
 
    }
117
 
 
118
 
    $invoke{code} = $undo ? "gimp_${core_type}_set_$prop ($core_var, $prop, TRUE);"
119
 
                          : "gimp_${core_type}_set_$prop ($core_var, $prop);";
120
 
}
121
 
 
122
 
sub layer_accessors {
123
 
    my ($prop, $type, $desc, $setting, $undo, $extra, $core_type, $core_var) = @_;
124
 
 
125
 
    $core_type = 'layer' unless $core_type;
126
 
    $core_var  = 'layer' unless $core_var;
127
 
 
128
 
    my (@extra, %extra); my $once = 0;
129
 
 
130
 
     my $change = "s/ ($desc)/'s \$1 setting/";
131
 
    (my $common = "\n; foreach (\$blurb, \$help) { $change }") =~ s/'s//;
132
 
 
133
 
    my %modify = (
134
 
        get => "$common \$outargs[0]->{desc} =~ $change;",
135
 
        set => "$common \$inargs[1]->{desc}  =~ $change;",
136
 
    );
137
 
 
138
 
    ref($extra) ? (@extra = @$extra) : (@extra = ($extra, $extra));
139
 
    %extra = map { $once++ ? 'set' : 'get', $_ ? $_ : "" } @extra;
140
 
 
141
 
    foreach (sort keys %extra) {
142
 
        my $proc = "layer_${_}_$prop";
143
 
 
144
 
        push @procs, $proc;
145
 
 
146
 
        eval <<SUB;
147
 
sub @{[ scalar caller ]}::$proc {
148
 
    \&layer_${_}_prop_proc('$prop', '$type', '$desc', $undo,
149
 
                           '$core_type', '$core_var');
150
 
    $extra{$_}
151
 
    @{[ $setting ? $modify{$_} : "" ]}
152
 
}
153
 
SUB
154
 
    }
155
 
}
156
 
 
157
20
sub layer_new {
158
21
    $blurb = 'Create a new layer.';
159
22
 
161
24
This procedure creates a new layer with the specified width, height, and type.
162
25
Name, opacity, and mode are also supplied parameters. The new layer still needs
163
26
to be added to the image, as this is not automatic. Add the new layer with the
164
 
'gimp_image_add_layer' command. Other attributes such as layer mask modes, and
 
27
gimp_image_add_layer() command. Other attributes such as layer mask modes, and
165
28
offsets should be set with explicit procedure calls.
166
29
HELP
167
30
 
168
31
    &std_pdb_misc;
169
32
 
170
33
    @inargs = (
171
 
        &std_image_arg,
172
 
        { name => 'width', type => '0 < int32',
173
 
          desc => 'The layer width: (%%desc%%)' },
174
 
        { name => 'height', type => '0 < int32',
175
 
          desc => 'The layer height: (%%desc%%)' },
 
34
        { name => 'image', type => 'image',
 
35
          desc => 'The image to which to add the layer' },
 
36
        { name => 'width', type => '1 <= int32',
 
37
          desc => 'The layer width' },
 
38
        { name => 'height', type => '1 <= int32',
 
39
          desc => 'The layer height' },
176
40
        { name => 'type', type => 'enum GimpImageType',
177
 
          desc => 'The layer type: { %%desc%% }' },
 
41
          desc => 'The layer type' },
178
42
        { name => 'name', type => 'string',
179
43
          desc => 'The layer name', null_ok => 1 },
180
44
        { name => 'opacity', type => '0 <= float <= 100',
181
 
          desc => 'The layer opacity: (%%desc%%)' },
 
45
          desc => 'The layer opacity' },
182
46
        { name => 'mode', type => 'enum GimpLayerModeEffects',
183
 
          desc => 'The layer combination mode: { %%desc%% }' }
 
47
          desc => 'The layer combination mode' }
184
48
    );
185
 
    $inargs[0]->{desc} .= ' to which to add the layer';
186
49
 
187
50
    @outargs = (
188
51
        { name => 'layer', type => 'layer', wrap => 1,
189
 
          desc => 'The newly created layer', init => 1 }
 
52
          desc => 'The newly created layer' }
190
53
    );
191
54
 
192
55
    %invoke = (
193
56
        code => <<'CODE'
194
57
{
195
 
  layer = gimp_layer_new (gimage,
196
 
                          width, height,
197
 
                          type,
198
 
                          name,
 
58
  layer = gimp_layer_new (image, width, height, type, name,
199
59
                          opacity / 100.0, mode);
200
 
  success = (layer != NULL);
 
60
 
 
61
  if (! layer)
 
62
    success = FALSE;
201
63
}
202
64
CODE
203
65
    );
217
79
    &std_pdb_misc;
218
80
 
219
81
    @inargs = (
220
 
        &layer_arg,
 
82
        { name => 'layer', type => 'layer',
 
83
          desc => 'The layer to copy' },
221
84
        { name => 'add_alpha', type => 'boolean',
222
85
          desc => 'Add an alpha channel to the copied layer' }
223
86
    );
224
 
    $inargs[0]->{desc} .= ' to copy';
225
87
 
226
88
    @outargs = (
227
 
        { name => 'layer_copy', type => 'layer', init => 1, wrap => 1,
 
89
        { name => 'layer_copy', type => 'layer', wrap => 1,
228
90
          desc => 'The newly copied layer' }
229
91
    );
230
92
 
231
93
    %invoke = (
232
 
        code => 'success = (layer_copy = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer), G_TYPE_FROM_INSTANCE (layer), add_alpha))) != NULL;'
 
94
        code => <<'CODE'
 
95
{
 
96
  layer_copy = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer),
 
97
                                                G_TYPE_FROM_INSTANCE (layer),
 
98
                                                add_alpha));
 
99
  if (! layer_copy)
 
100
    success = FALSE;
 
101
}
 
102
CODE
233
103
    );
234
104
}
235
105
 
238
108
 
239
109
    $help = <<'HELP';
240
110
This procedure creates a layer mask for the specified layer. Layer masks serve
241
 
as an additional alpha channel for a layer. A number of ifferent types of
 
111
as an additional alpha channel for a layer. A number of different types of
242
112
masks are allowed for initialisation: completely white masks (which will
243
113
leave the layer fully visible), completely black masks (which will give the
244
114
layer complete transparency, the layer's already existing alpha channel
245
115
(which will leave the layer fully visible, but which may be more useful than
246
116
a white mask), the current selection or a grayscale copy of the layer. The
247
117
layer mask still needs to be added to the layer. This can be done with a call
248
 
to 'gimp_layer_add_mask'.
 
118
to gimp_layer_add_mask().
249
119
HELP
250
120
 
251
121
    &std_pdb_misc;
252
122
 
253
123
    @inargs = (
254
 
        &layer_arg,
 
124
        { name => 'layer', type => 'layer',
 
125
          desc => 'The layer to which to add the mask' },
255
126
        { name => 'mask_type', type => 'enum GimpAddMaskType',
256
 
          desc => 'The type of mask: { %%desc%% }' }
 
127
          desc => 'The type of mask' }
257
128
    );
258
 
    $inargs[0]->{desc} .= ' to which to add the mask';
259
129
 
260
130
    @outargs = (
261
131
        { name => 'mask', type => 'layer_mask',
262
 
          desc => 'The newly created mask', init => 1 }
 
132
          desc => 'The newly created mask' }
263
133
    );
264
134
 
265
135
    %invoke = (
266
136
        code => <<'CODE'
267
 
success = (mask = gimp_layer_create_mask (layer, (GimpAddMaskType) mask_type)) != NULL;
 
137
{
 
138
  GimpChannel *channel = NULL;
 
139
 
 
140
  if (mask_type == GIMP_ADD_CHANNEL_MASK)
 
141
    {
 
142
      channel = gimp_image_get_active_channel (GIMP_ITEM (layer)->image);
 
143
 
 
144
      if (! channel)
 
145
        success = FALSE;
 
146
    }
 
147
 
 
148
  if (success)
 
149
    {
 
150
      mask = gimp_layer_create_mask (layer, mask_type, channel);
 
151
 
 
152
      if (! mask)
 
153
        success = FALSE;
 
154
    }
 
155
}
268
156
CODE
269
157
    );
270
158
}
276
164
This procedure adds a layer mask to the specified layer. Layer masks serve as
277
165
an additional alpha channel for a layer. This procedure will fail if a number
278
166
of prerequisites aren't met. The layer cannot already have a layer mask. The
279
 
specified mask must exist and have the same dimensions as the layer. Both the
280
 
mask and the layer must have been created for use with the specified image.
 
167
specified mask must exist and have the same dimensions as the layer. The layer must have been created for use with the specified image and the mask must have been created with the procedure 'gimp-layer-create-mask'.
281
168
HELP
282
169
 
283
170
    &std_pdb_misc;
284
171
 
285
172
    @inargs = (
286
 
        &layer_arg,
 
173
        { name => 'layer', type => 'layer',
 
174
          desc => 'The layer to receive the mask' },
287
175
        { name => 'mask', type => 'layer_mask',
288
176
          desc => 'The mask to add to the layer' }
289
177
    );
290
 
    $inargs[0]->{desc} .= ' to receive the mask';
291
178
 
292
179
    %invoke = (
293
180
        code => <<'CODE'
294
181
{
295
 
  success = gimp_item_is_attached (GIMP_ITEM (layer));
296
 
 
297
 
  if (success)
 
182
  if (gimp_item_is_attached (GIMP_ITEM (layer)))
298
183
    gimp_layer_add_mask (layer, mask, TRUE);
 
184
  else
 
185
    success = FALSE;
299
186
}
300
187
CODE
301
188
    );
312
199
    &std_pdb_misc;
313
200
 
314
201
    @inargs = (
315
 
        &layer_arg,
 
202
        { name => 'layer', type => 'layer',
 
203
          desc => 'The layer from which to remove mask' },
316
204
        { name => 'mode', type => 'enum GimpMaskApplyMode',
317
 
          desc => 'Removal mode: { %%desc%% }' }
 
205
          desc => 'Removal mode' }
318
206
    );
319
 
    $inargs[0]->{desc} .= ' from which to remove mask';
320
207
 
321
 
    %invoke = ( code => <<'CODE'
 
208
    %invoke = (
 
209
        code => <<'CODE'
322
210
{
323
 
  success = gimp_item_is_attached (GIMP_ITEM (layer));
324
 
 
325
 
  if (success)
 
211
  if (gimp_item_is_attached (GIMP_ITEM (layer)))
326
212
    gimp_layer_apply_mask (layer, mode, TRUE);
 
213
  else
 
214
    success = FALSE;
327
215
}
328
216
CODE
329
217
    );
330
218
}
331
219
 
332
220
sub layer_scale {
333
 
    my $arg = { name => 'local_origin', type => 'boolean',
334
 
                desc => 'Use a local origin (as opposed to the image origin)' };
 
221
    $blurb = 'Scale the layer to the specified extents.';
335
222
 
336
 
    &layer_dim_proc('scale', <<'HELP', $arg);
337
 
The "local_origin" parameter specifies whether to scale from the center of the
338
 
layer, or from the image origin.
 
223
    $help = <<'HELP';
 
224
This procedure scales the layer so that its new width and height are
 
225
equal to the supplied parameters. The 'local-origin' parameter
 
226
specifies whether to scale from the center of the layer, or from the
 
227
image origin. This operation only works if the layer has been added to
 
228
an image.
339
229
HELP
 
230
 
 
231
    &std_pdb_misc;
 
232
 
 
233
    @inargs = (
 
234
        { name => 'layer', type => 'layer',
 
235
          desc => 'The layer' },
 
236
        { name => 'new_width', type => '1 <= int32',
 
237
          desc => 'New layer width' },
 
238
        { name => 'new_height', type => '1 <= int32',
 
239
          desc => 'New layer height' },
 
240
        { name => 'local_origin', type => 'boolean',
 
241
          desc => 'Use a local origin (as opposed to the image origin)' }
 
242
    );
 
243
 
 
244
    %invoke = (
 
245
        code => <<'CODE'
 
246
{
 
247
  if (gimp_item_is_attached (GIMP_ITEM (layer)))
 
248
    gimp_item_scale_by_origin (GIMP_ITEM (layer), new_width, new_height,
 
249
                               gimp->config->interpolation_type, NULL,
 
250
                               local_origin);
 
251
  else
 
252
    success = FALSE;
 
253
}
 
254
CODE
 
255
    );
340
256
}
341
257
 
342
258
sub layer_resize {
343
 
    my @args;
344
 
    foreach (qw(x y)) {
345
 
        push @args, { name => "off$_", type => 'int32',
346
 
                      desc => "$_ offset between upper left corner of old and
347
 
                               new layers: (old - new)" }
348
 
    }
 
259
    $blurb = 'Resize the layer to the specified extents.';
349
260
 
350
 
    &layer_dim_proc('resize', <<'HELP', @args);
351
 
Offsets are also provided which describe the position of the previous layer's
352
 
content.
 
261
    $help = <<'HELP';
 
262
This procedure resizes the layer so that its new width and height are
 
263
equal to the supplied parameters. Offsets are also provided which
 
264
describe the position of the previous layer's content. This operation
 
265
only works if the layer has been added to an image.
353
266
HELP
 
267
 
 
268
    &std_pdb_misc;
 
269
 
 
270
    @inargs = (
 
271
        { name => 'layer', type => 'layer',
 
272
          desc => 'The layer' },
 
273
        { name => 'new_width', type => '1 <= int32',
 
274
          desc => 'New layer width' },
 
275
        { name => 'new_height', type => '1 <= int32',
 
276
          desc => 'New layer height' },
 
277
        { name => 'offx', type => 'int32',
 
278
          desc => 'x offset between upper left corner of old and
 
279
                   new layers: (old - new)' },
 
280
        { name => 'offy', type => 'int32',
 
281
          desc => 'y offset between upper left corner of old and
 
282
                   new layers: (old - new)' }
 
283
    );
 
284
 
 
285
    %invoke = (
 
286
        code => <<'CODE'
 
287
{
 
288
  if (gimp_item_is_attached (GIMP_ITEM (layer)))
 
289
    gimp_item_resize (GIMP_ITEM (layer), context,
 
290
                      new_width, new_height, offx, offy);
 
291
  else
 
292
    success = FALSE;
 
293
}
 
294
CODE
 
295
    );
354
296
}
355
297
 
356
298
sub layer_resize_to_image_size {
361
303
the width and height of its image container.
362
304
HELP
363
305
 
364
 
    $author = $copyright = 'Manish Singh';
365
 
    $date = '2003';
366
 
 
367
 
    @inargs = ( &layer_arg );
368
 
    $inargs[0]->{desc} .= ' to resize';
369
 
 
370
 
    %invoke = ( code => <<'CODE' );
 
306
    &yosh_pdb_misc('2003');
 
307
 
 
308
    @inargs = (
 
309
        { name => 'layer', type => 'layer',
 
310
          desc => 'The layer to resize' }
 
311
    );
 
312
 
 
313
    %invoke = (
 
314
        code => <<'CODE'
371
315
{
372
 
  success = gimp_item_is_attached (GIMP_ITEM (layer));
373
 
 
374
 
  if (success)
 
316
  if (gimp_item_is_attached (GIMP_ITEM (layer)))
375
317
    gimp_layer_resize_to_image (layer, context);
 
318
  else
 
319
    success = FALSE;
376
320
}
377
321
CODE
 
322
    );
378
323
}
379
324
 
380
325
sub layer_translate {
390
335
 
391
336
    &std_pdb_misc;
392
337
 
393
 
    @inargs = ( &layer_arg );
394
 
    foreach (qw(x y)) {
395
 
        push @inargs, { name => "off$_", type => 'int32',
396
 
                        desc => "Offset in $_ direction" }
397
 
    }
 
338
    @inargs = (
 
339
        { name => 'layer', type => 'layer',
 
340
          desc => 'The layer' },
 
341
        { name => 'offx', type => 'int32',
 
342
          desc => "Offset in x direction" },
 
343
        { name => 'offy', type => 'int32',
 
344
          desc => "Offset in y direction" }
 
345
    );
398
346
 
399
 
    %invoke = ( code => <<'CODE');
 
347
    %invoke = (
 
348
        code => <<'CODE'
400
349
{
401
 
  GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer));
 
350
  GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
402
351
 
403
 
  gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_ITEM_DISPLACE,
 
352
  gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_DISPLACE,
404
353
                               _("Move Layer"));
405
354
 
406
355
  gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE);
408
357
  if (gimp_item_get_linked (GIMP_ITEM (layer)))
409
358
    gimp_item_linked_translate (GIMP_ITEM (layer), offx, offy, TRUE);
410
359
 
411
 
  gimp_image_undo_group_end (gimage);
 
360
  gimp_image_undo_group_end (image);
412
361
}
413
362
CODE
 
363
    );
414
364
}
415
365
 
416
366
sub layer_add_alpha {
428
378
 
429
379
    &std_pdb_misc;
430
380
 
431
 
    @inargs = ( &layer_arg );
 
381
    @inargs = (
 
382
        { name => 'layer', type => 'layer',
 
383
          desc => 'The layer' }
 
384
    );
432
385
 
433
 
    %invoke = ( code => 'gimp_layer_add_alpha (layer);' );
 
386
    %invoke = (
 
387
        code => <<'CODE'
 
388
{
 
389
  gimp_layer_add_alpha (layer);
 
390
}
 
391
CODE
 
392
    );
434
393
}
435
394
 
436
395
sub layer_set_offsets {
437
 
    &layer_translate;
438
 
 
439
396
    $blurb = 'Set the layer offsets.';
440
397
 
441
398
    $help = <<'HELP';
444
401
only on layers which have been added to an image.
445
402
HELP
446
403
 
447
 
    foreach (qw(x y)) {
448
 
        $invoke{code} =~
449
 
            s/(off$_),/$1 - GIMP_ITEM (layer)->offset_$_,/;
450
 
    }
 
404
    &std_pdb_misc;
 
405
 
 
406
    @inargs = (
 
407
        { name => 'layer', type => 'layer',
 
408
          desc => 'The layer' },
 
409
        { name => 'offx', type => 'int32',
 
410
          desc => "Offset in x direction" },
 
411
        { name => 'offy', type => 'int32',
 
412
          desc => "Offset in y direction" }
 
413
    );
 
414
 
 
415
    %invoke = (
 
416
        code => <<'CODE'
 
417
{
 
418
  GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
 
419
 
 
420
  gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_DISPLACE,
 
421
                               _("Move Layer"));
 
422
 
 
423
  offx -= GIMP_ITEM (layer)->offset_x;
 
424
  offy -= GIMP_ITEM (layer)->offset_y;
 
425
 
 
426
  gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE);
 
427
 
 
428
  if (gimp_item_get_linked (GIMP_ITEM (layer)))
 
429
    gimp_item_linked_translate (GIMP_ITEM (layer), offx, offy, TRUE);
 
430
 
 
431
  gimp_image_undo_group_end (image);
 
432
}
 
433
CODE
 
434
    );
451
435
}
452
436
 
453
437
sub layer_get_mask {
459
443
 
460
444
    &std_pdb_misc;
461
445
 
462
 
    @inargs = ( &layer_arg );
 
446
    @inargs = (
 
447
        { name => 'layer', type => 'layer',
 
448
          desc => 'The layer' }
 
449
    );
463
450
 
464
451
    @outargs = (
465
 
        { name => 'mask', type => 'channel',
 
452
        { name => 'mask', type => 'layer_mask',
466
453
          desc => 'The layer mask',
467
 
          alias => 'layer->mask', no_declare => 1,
468
454
          return_fail => -1 }
469
455
    );
 
456
 
 
457
    %invoke = (
 
458
        code => <<'CODE'
 
459
{
 
460
  mask = gimp_layer_get_mask (layer);
 
461
}
 
462
CODE
 
463
    );
470
464
}
471
465
 
472
466
sub layer_from_mask {
478
472
 
479
473
    $author = $copyright = 'Geert Jordaens';
480
474
    $date = '2004';
481
 
 
482
475
    $since = '2.2';
483
476
 
484
477
    @inargs = (
487
480
    );
488
481
 
489
482
    @outargs = (
490
 
        { name => 'layer', type => 'layer', init => 1,
 
483
        { name => 'layer', type => 'layer',
491
484
          desc => 'The mask\'s layer',
492
485
          return_fail => -1 }
493
486
    );
512
505
 
513
506
    &std_pdb_misc;
514
507
 
515
 
    @inargs = ( &layer_arg );
 
508
    @inargs = (
 
509
        { name => 'layer', type => 'layer',
 
510
          desc => 'The layer' }
 
511
    );
516
512
 
517
513
    @outargs = (
518
514
        { name => 'is_floating_sel', type => 'boolean',
519
 
          desc => 'Non-zero if the layer is a floating selection',
520
 
          alias => 'gimp_layer_is_floating_sel (layer)', no_declare => 1 }
 
515
          desc => 'TRUE if the layer is a floating selection' }
 
516
    );
 
517
 
 
518
    %invoke = (
 
519
        code => <<'CODE'
 
520
{
 
521
  is_floating_sel = gimp_layer_is_floating_sel (layer);
 
522
}
 
523
CODE
521
524
    );
522
525
}
523
526
 
527
530
    $help = <<'HELP';
528
531
This procedure creates a new layer as a copy of the specified drawable.  The
529
532
new layer still needs to be added to the image, as this is not automatic.  Add
530
 
the new layer with the 'gimp_image_add_layer' command. Other attributes such
 
533
the new layer with the gimp_image_add_layer() command. Other attributes such
531
534
as layer mask modes, and offsets should be set with explicit procedure calls.
532
535
HELP
533
536
 
541
544
     );
542
545
 
543
546
    @outargs = (
544
 
        { name => 'layer_copy', type => 'layer', init => 1,
 
547
        { name => 'layer_copy', type => 'layer',
545
548
          desc => 'The newly copied layer' }
546
549
    );
547
550
 
570
573
    );
571
574
}
572
575
 
573
 
&layer_accessors('preserve_trans', 'boolean', 'preserve transperancy', 1, 1);
574
 
 
575
 
&layer_accessors('apply_mask', 'boolean', 'apply mask', 0, 0,
576
 
                 [ <<'CODE1', <<'CODE2' ]);
577
 
    $help .= <<'HELP';
578
 
If the value is non-zero, then the layer mask for this layer is currently being
579
 
composited with the layer's alpha channel.
580
 
HELP
581
 
CODE1
582
 
    $help .= <<'HELP';
583
 
This controls whether the layer's mask is currently affecting the alpha
584
 
channel. If there is no layer mask, this function will return an error.
585
 
HELP
586
 
CODE2
587
 
 
588
 
&layer_accessors('show_mask', 'boolean', 'show mask', 0, 0,
589
 
                 [ <<'CODE1', <<'CODE2' ]);
590
 
    $help .= <<'HELP';
591
 
If the value is non-zero, then the layer mask for this layer is currently being
592
 
shown instead of the layer.
593
 
HELP
594
 
CODE1
595
 
    $help .= <<'HELP';
596
 
This controls whether the layer or it's mask is visible. Non-zero values
597
 
indicate that the mask should be visible. If the layer has no mask, then this
598
 
function returns an error.
599
 
HELP
600
 
CODE2
601
 
 
602
 
&layer_accessors('edit_mask', 'boolean', 'show mask', 0, 0,
603
 
                 [ <<'CODE1', <<'CODE2' ]);
604
 
    $help .= <<'HELP';
605
 
 If the value is non-zero, then the layer mask for this layer is currently
 
576
sub layer_get_lock_alpha {
 
577
    $blurb = 'Get the lock alpha channel setting of the specified layer.';
 
578
 
 
579
    $help = <<'HELP';
 
580
This procedure returns the specified layer's lock alpha channel setting.
 
581
HELP
 
582
 
 
583
    &std_pdb_misc;
 
584
 
 
585
    @inargs = (
 
586
        { name => 'layer', type => 'layer',
 
587
          desc => 'The layer' }
 
588
    );
 
589
 
 
590
    @outargs = (
 
591
        { name => 'lock_alpha', type => 'boolean',
 
592
          desc => 'The layer\'s lock alpha channel setting' }
 
593
    );
 
594
 
 
595
    %invoke = (
 
596
        code => <<'CODE'
 
597
{
 
598
  lock_alpha = gimp_layer_get_lock_alpha (layer);
 
599
}
 
600
CODE
 
601
    );
 
602
}
 
603
 
 
604
sub layer_set_lock_alpha {
 
605
    $blurb = 'Set the lock alpha channel setting of the specified layer.';
 
606
 
 
607
    $help = <<'HELP';
 
608
This procedure sets the specified layer's lock alpha channel setting.
 
609
HELP
 
610
 
 
611
    &std_pdb_misc;
 
612
 
 
613
    @inargs = (
 
614
        { name => 'layer', type => 'layer',
 
615
          desc => 'The layer' },
 
616
        { name => 'lock_alpha', type => 'boolean',
 
617
          desc => 'The new layer\'s lock alpha channel setting' }
 
618
    );
 
619
 
 
620
    %invoke = (
 
621
        code => <<'CODE'
 
622
{
 
623
  gimp_layer_set_lock_alpha (layer, lock_alpha, TRUE);
 
624
}
 
625
CODE
 
626
    );
 
627
}
 
628
 
 
629
sub layer_get_apply_mask {
 
630
    $blurb = 'Get the apply mask setting of the specified layer.';
 
631
 
 
632
    $help = <<'HELP';
 
633
This procedure returns the specified layer's apply mask setting. If
 
634
the value is TRUE, then the layer mask for this layer is currently
 
635
being composited with the layer's alpha channel.
 
636
HELP
 
637
 
 
638
    &std_pdb_misc;
 
639
 
 
640
    @inargs = (
 
641
        { name => 'layer', type => 'layer',
 
642
          desc => 'The layer' }
 
643
    );
 
644
 
 
645
    @outargs = (
 
646
        { name => 'apply_mask', type => 'boolean',
 
647
          desc => 'The layer\'s apply mask setting' }
 
648
    );
 
649
 
 
650
    %invoke = (
 
651
        code => <<'CODE'
 
652
{
 
653
  if (layer->mask)
 
654
    apply_mask = gimp_layer_mask_get_apply (layer->mask);
 
655
  else
 
656
    apply_mask = FALSE;
 
657
}
 
658
CODE
 
659
    );
 
660
}
 
661
 
 
662
sub layer_set_apply_mask {
 
663
    $blurb = 'Set the apply mask setting of the specified layer.';
 
664
 
 
665
    $help = <<'HELP';
 
666
This procedure sets the specified layer's apply mask setting. This
 
667
controls whether the layer's mask is currently affecting the alpha
 
668
channel. If there is no layer mask, this function will return an
 
669
error.
 
670
HELP
 
671
 
 
672
    &std_pdb_misc;
 
673
 
 
674
    @inargs = (
 
675
        { name => 'layer', type => 'layer',
 
676
          desc => 'The layer' },
 
677
        { name => 'apply_mask', type => 'boolean',
 
678
          desc => 'The new layer\'s apply mask setting' }
 
679
    );
 
680
 
 
681
    %invoke = (
 
682
        code => <<'CODE'
 
683
{
 
684
  if (layer->mask)
 
685
    gimp_layer_mask_set_apply (layer->mask, apply_mask, TRUE);
 
686
  else
 
687
    success = FALSE;
 
688
}
 
689
CODE
 
690
    );
 
691
}
 
692
 
 
693
sub layer_get_show_mask {
 
694
    $blurb = 'Get the show mask setting of the specified layer.';
 
695
 
 
696
    $help = <<'HELP';
 
697
This procedure returns the specified layer's show mask setting. This
 
698
controls whether the layer or its mask is visible. TRUE indicates
 
699
that the mask should be visible. If the layer has no mask,
 
700
then this function returns an error.
 
701
HELP
 
702
 
 
703
    &std_pdb_misc;
 
704
 
 
705
    @inargs = (
 
706
        { name => 'layer', type => 'layer',
 
707
          desc => 'The layer' }
 
708
    );
 
709
 
 
710
    @outargs = (
 
711
        { name => 'show_mask', type => 'boolean',
 
712
          desc => 'The layer\'s show mask setting' }
 
713
    );
 
714
 
 
715
    %invoke = (
 
716
        code => <<'CODE'
 
717
{
 
718
  if (layer->mask)
 
719
    show_mask = gimp_layer_mask_get_show (layer->mask);
 
720
  else
 
721
    show_mask = FALSE;
 
722
}
 
723
CODE
 
724
    );
 
725
}
 
726
 
 
727
sub layer_set_show_mask {
 
728
    $blurb = 'Set the show mask setting of the specified layer.';
 
729
 
 
730
    $help = <<'HELP';
 
731
This procedure sets the specified layer's show mask setting. This
 
732
controls whether the layer's mask is currently affecting the alpha
 
733
channel. If there is no layer mask, this function will return an
 
734
error.
 
735
HELP
 
736
 
 
737
    &std_pdb_misc;
 
738
 
 
739
    @inargs = (
 
740
        { name => 'layer', type => 'layer',
 
741
          desc => 'The layer' },
 
742
        { name => 'show_mask', type => 'boolean',
 
743
          desc => 'The new layer\'s show mask setting' }
 
744
    );
 
745
 
 
746
    %invoke = (
 
747
        code => <<'CODE'
 
748
{
 
749
  if (layer->mask)
 
750
    gimp_layer_mask_set_show (layer->mask, show_mask, TRUE);
 
751
  else
 
752
    success = FALSE;
 
753
}
 
754
CODE
 
755
    );
 
756
}
 
757
 
 
758
sub layer_get_edit_mask {
 
759
    $blurb = 'Get the edit mask setting of the specified layer.';
 
760
 
 
761
    $help = <<'HELP';
 
762
This procedure returns the specified layer's edit mask setting. If
 
763
the value is TRUE, then the layer mask for this layer is currently
606
764
active, and not the layer.
607
765
HELP
608
 
CODE1
609
 
    $help .= <<'HELP';
610
 
This controls whether the layer or it's mask is currently active for editing.
611
 
If the specified layer has no layer mask, then this procedure will return an
612
 
error.
 
766
 
 
767
    &std_pdb_misc;
 
768
 
 
769
    @inargs = (
 
770
        { name => 'layer', type => 'layer',
 
771
          desc => 'The layer' }
 
772
    );
 
773
 
 
774
    @outargs = (
 
775
        { name => 'edit_mask', type => 'boolean',
 
776
          desc => 'The layer\'s edit mask setting' }
 
777
    );
 
778
 
 
779
    %invoke = (
 
780
        code => <<'CODE'
 
781
{
 
782
  if (layer->mask)
 
783
    edit_mask = gimp_layer_mask_get_edit (layer->mask);
 
784
  else
 
785
    edit_mask = FALSE;
 
786
}
 
787
CODE
 
788
    );
 
789
}
 
790
 
 
791
sub layer_set_edit_mask {
 
792
    $blurb = 'Set the edit mask setting of the specified layer.';
 
793
 
 
794
    $help = <<'HELP';
 
795
This procedure sets the specified layer's edit mask setting. This
 
796
controls whether the layer or it's mask is currently active for
 
797
editing.  If the specified layer has no layer mask, then this
 
798
procedure will return an error.
613
799
HELP
614
 
CODE2
615
 
 
616
 
&layer_accessors('opacity', '0 <= float <= 100', 'opacity', 0, 1,
617
 
                 [ '$outargs[0]->{alias} =
618
 
                        "gimp_layer_get_opacity (layer) * 100.0"',
619
 
                   '$invoke{code} =~
620
 
                        s%opacity, %opacity / 100.0, %' ]);
621
 
 
622
 
&layer_accessors('mode', 'enum GimpLayerModeEffects', 'combination mode', 0, 1);
623
 
 
624
 
@headers = qw("config/gimpcoreconfig.h" "core/gimp.h" "core/gimpimage-undo.h"
625
 
              "core/gimpitem-linked.h" "pdb_glue.h" "gimp-intl.h");
626
 
 
627
 
unshift @procs, qw(layer_new layer_new_from_drawable layer_copy
628
 
                   layer_add_alpha
629
 
                   layer_scale layer_resize layer_resize_to_image_size
630
 
                   layer_translate layer_set_offsets
631
 
                   layer_create_mask layer_get_mask layer_from_mask
632
 
                   layer_add_mask layer_remove_mask
633
 
                   layer_is_floating_sel);
 
800
 
 
801
    &std_pdb_misc;
 
802
 
 
803
    @inargs = (
 
804
        { name => 'layer', type => 'layer',
 
805
          desc => 'The layer' },
 
806
        { name => 'edit_mask', type => 'boolean',
 
807
          desc => 'The new layer\'s edit mask setting' }
 
808
    );
 
809
 
 
810
    %invoke = (
 
811
        code => <<'CODE'
 
812
{
 
813
  if (layer->mask)
 
814
    gimp_layer_mask_set_edit (layer->mask, edit_mask);
 
815
  else
 
816
    success = FALSE;
 
817
}
 
818
CODE
 
819
    );
 
820
}
 
821
 
 
822
sub layer_get_opacity {
 
823
    $blurb = 'Get the opacity of the specified layer.';
 
824
    $help  = "This procedure returns the specified layer's opacity.";
 
825
 
 
826
    &std_pdb_misc;
 
827
 
 
828
    @inargs = (
 
829
        { name => 'layer', type => 'layer',
 
830
          desc => 'The layer' }
 
831
    );
 
832
 
 
833
    @outargs = (
 
834
        { name => 'opacity', type => '0 <= float <= 100',
 
835
          desc => 'The layer opacity' }
 
836
    );
 
837
 
 
838
    %invoke = (
 
839
        code => <<'CODE'
 
840
{
 
841
  opacity = gimp_layer_get_opacity (layer) * 100.0;
 
842
}
 
843
CODE
 
844
    );
 
845
}
 
846
 
 
847
sub layer_set_opacity {
 
848
    $blurb = 'Set the opacity of the specified layer.';
 
849
    $help  = "This procedure sets the specified layer's opacity.";
 
850
 
 
851
    &std_pdb_misc;
 
852
 
 
853
    @inargs = (
 
854
        { name => 'layer', type => 'layer',
 
855
          desc => 'The layer' },
 
856
        { name => 'opacity', type => '0 <= float <= 100',
 
857
          desc => 'The new layer opacity' }
 
858
    );
 
859
 
 
860
    %invoke = (
 
861
        code => <<'CODE'
 
862
{
 
863
  gimp_layer_set_opacity (layer, opacity / 100.0, TRUE);
 
864
}
 
865
CODE
 
866
    );
 
867
}
 
868
 
 
869
sub layer_get_mode {
 
870
    $blurb = 'Get the combination mode of the specified layer.';
 
871
    $help  = "This procedure returns the specified layer's combination mode.";
 
872
 
 
873
    &std_pdb_misc;
 
874
 
 
875
    @inargs = (
 
876
        { name => 'layer', type => 'layer',
 
877
          desc => 'The layer' }
 
878
    );
 
879
 
 
880
    @outargs = (
 
881
        { name => 'mode', type => 'enum GimpLayerModeEffects',
 
882
          desc => 'The layer combination mode' }
 
883
    );
 
884
 
 
885
    %invoke = (
 
886
        code => <<'CODE'
 
887
{
 
888
  mode = gimp_layer_get_mode (layer);
 
889
}
 
890
CODE
 
891
    );
 
892
}
 
893
 
 
894
sub layer_set_mode {
 
895
    $blurb = 'Set the combination mode of the specified layer.';
 
896
    $help  = "This procedure sets the specified layer's combination mode.";
 
897
 
 
898
    &std_pdb_misc;
 
899
 
 
900
    @inargs = (
 
901
        { name => 'layer', type => 'layer',
 
902
          desc => 'The layer' },
 
903
        { name => 'mode', type => 'enum GimpLayerModeEffects',
 
904
          desc => 'The new layer combination mode' }
 
905
    );
 
906
 
 
907
    %invoke = (
 
908
        code => <<'CODE'
 
909
{
 
910
  gimp_layer_set_mode (layer, mode, TRUE);
 
911
}
 
912
CODE
 
913
    );
 
914
}
 
915
 
 
916
 
 
917
@headers = qw("config/gimpcoreconfig.h"
 
918
              "core/gimp.h"
 
919
              "core/gimpimage-undo.h"
 
920
              "core/gimpitem-linked.h"
 
921
              "gimp-intl.h");
 
922
 
 
923
@procs = qw(layer_new layer_new_from_drawable layer_copy
 
924
            layer_add_alpha
 
925
            layer_scale layer_resize layer_resize_to_image_size
 
926
            layer_translate layer_set_offsets
 
927
            layer_create_mask layer_get_mask layer_from_mask
 
928
            layer_add_mask layer_remove_mask
 
929
            layer_is_floating_sel
 
930
            layer_get_lock_alpha layer_set_lock_alpha
 
931
            layer_get_apply_mask layer_set_apply_mask
 
932
            layer_get_show_mask layer_set_show_mask
 
933
            layer_get_edit_mask layer_set_edit_mask
 
934
            layer_get_opacity layer_set_opacity
 
935
            layer_get_mode layer_set_mode);
 
936
 
634
937
%exports = (app => [@procs], lib => [@procs]);
635
938
 
636
939
$desc = 'Layer';