1998-10-24 13:21:56 +08:00
|
|
|
# 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 <yosh@gimp.org>
|
|
|
|
|
1999-03-11 02:56:56 +08:00
|
|
|
# Common arguments
|
1998-10-24 13:21:56 +08:00
|
|
|
sub inargs {
|
|
|
|
@inargs = (
|
|
|
|
{ name => 'drawable', type => 'drawable',
|
1999-03-11 02:56:56 +08:00
|
|
|
desc => "The drawable to @{[shift]}",
|
|
|
|
get => &std_image_arg }
|
1998-10-24 13:21:56 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Common invoker for checking for image/drawable consistency
|
|
|
|
sub invoke {
|
|
|
|
%invoke = (
|
|
|
|
headers => [ qw("global_edit.h") ],
|
1999-03-11 02:56:56 +08:00
|
|
|
code => "success = @{[shift]};"
|
1998-10-24 13:21:56 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
# The defs
|
|
|
|
|
|
|
|
sub edit_cut {
|
|
|
|
$blurb = 'Cut from the specified drawable.';
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
|
|
|
If there is a selection in the image, then the area specified by the selection
|
|
|
|
is cut from the specified drawable and placed in an internal GIMP edit buffer.
|
|
|
|
It can subsequently be retrieved using the 'gimp-edit-paste' command. If there
|
|
|
|
is no selection, then the specified drawable will be removed and its contents
|
|
|
|
stored in the internal GIMP edit buffer. The drawable MUST belong to the
|
|
|
|
specified image, or an error is returned.
|
|
|
|
HELP
|
|
|
|
|
|
|
|
&std_pdb_misc;
|
|
|
|
&inargs('cut from');
|
1999-03-11 02:56:56 +08:00
|
|
|
&invoke('edit_cut (gimage, drawable) != NULL');
|
1998-10-24 13:21:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub edit_copy {
|
|
|
|
$blurb = 'Copy from the specified drawable.';
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
|
|
|
If there is a selection in the image, then the area specified by the selection
|
|
|
|
is copied from the specified drawable and placed in an internal GIMP edit
|
|
|
|
buffer. It can subsequently be retrieved using the 'gimp-edit-paste' command.
|
|
|
|
If there is no selection, then the specified drawable's contents will be stored
|
|
|
|
in the internal GIMP edit buffer. The drawable MUST belong to the specified
|
|
|
|
image, or an error is returned.
|
|
|
|
HELP
|
|
|
|
|
|
|
|
&std_pdb_misc;
|
|
|
|
&inargs('copy from');
|
1999-03-11 02:56:56 +08:00
|
|
|
&invoke('edit_copy (gimage, drawable) != NULL');
|
1998-10-24 13:21:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub edit_paste {
|
|
|
|
$blurb = 'Paste buffer to the specified drawable.';
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
|
|
|
This procedure pastes a copy of the internal GIMP edit buffer to the specified
|
|
|
|
drawable. The GIMP edit buffer will be empty unless a call was previously made
|
|
|
|
to either 'gimp-edit-cut' or 'gimp-edit-copy'. The "paste_into" option
|
|
|
|
specifies whether to clear the current image selection, or to paste the buffer
|
|
|
|
"behind" the selection. This allows the selection to act as a mask for the
|
|
|
|
pasted buffer. Anywhere that the selection mask is non-zero, the pasted buffer
|
|
|
|
will show through. The pasted buffer will be a new layer in the image which is
|
|
|
|
designated as the image floating selection. If the image has a floating
|
|
|
|
selection at the time of pasting, the old floating selection will be anchored
|
|
|
|
to it's drawable before the new floating selection is added. This procedure
|
|
|
|
returns the new floating layer. The resulting floating selection will already
|
|
|
|
be attached to the specified drawable, and a subsequent call to
|
|
|
|
floating_sel_attach is not needed.
|
|
|
|
HELP
|
|
|
|
|
|
|
|
&std_pdb_misc;
|
|
|
|
|
|
|
|
&inargs('paste to');
|
|
|
|
push @inargs, { name => 'paste_into', type => 'boolean',
|
|
|
|
desc => 'Clear selection, or paste behind it?' };
|
|
|
|
|
|
|
|
@outargs = (
|
|
|
|
{ name => 'floating_sel', type => 'layer',
|
1999-03-11 07:34:26 +08:00
|
|
|
desc => 'The new floating selection', alias => 'layer', init => 1 }
|
1998-10-24 13:21:56 +08:00
|
|
|
);
|
|
|
|
|
1999-03-11 02:56:56 +08:00
|
|
|
&invoke('layer != NULL');
|
1998-10-24 13:21:56 +08:00
|
|
|
$cmd = "layer = edit_paste (gimage, drawable, global_buf, paste_into);\n";
|
1999-03-11 02:56:56 +08:00
|
|
|
$invoke{code} = "{\n" . ' ' x 2 . $cmd . ' ' x 2 . $invoke{code} . "\n}\n";
|
1998-10-24 13:21:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub edit_clear {
|
|
|
|
$blurb = 'Clear selected area of drawable.';
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
|
|
|
This procedure clears the specified drawable. If the drawable has an alpha
|
|
|
|
channel, the cleared pixels will become transparent. If the drawable does not
|
|
|
|
have an alpha channel, cleared pixels will be set to the background color. This
|
|
|
|
procedure only affects regions within a selection if there is a selection
|
|
|
|
active.
|
|
|
|
HELP
|
|
|
|
|
|
|
|
&std_pdb_misc;
|
|
|
|
&inargs('clear from');
|
|
|
|
&invoke('edit_clear (gimage, drawable)');
|
|
|
|
}
|
|
|
|
|
|
|
|
sub edit_fill {
|
|
|
|
$blurb = 'Fill selected area of drawable.';
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
|
|
|
This procedure fills the specified drawable with the background color. This
|
|
|
|
procedure only affects regions within a selection if there is a selection
|
|
|
|
active.
|
|
|
|
HELP
|
|
|
|
|
|
|
|
&std_pdb_misc;
|
|
|
|
&inargs('fill to');
|
|
|
|
&invoke('edit_fill (gimage, drawable)');
|
|
|
|
}
|
|
|
|
|
|
|
|
sub edit_stroke {
|
|
|
|
$blurb = 'Stroke the current selection';
|
|
|
|
|
|
|
|
$help = <<'HELP';
|
|
|
|
This procedure strokes the current selection, painting along the selection
|
|
|
|
boundary with the active brush and foreground color. The paint is applied to
|
|
|
|
the specified drawable regardless of the active selection.
|
|
|
|
HELP
|
|
|
|
|
|
|
|
&std_pdb_misc;
|
|
|
|
&inargs('stroke to');
|
|
|
|
&invoke('gimage_mask_stroke (gimage, drawable)');
|
|
|
|
push @{$invoke{headers}}, qw("gimage_mask.h");
|
|
|
|
}
|
|
|
|
|
|
|
|
@procs = qw(edit_cut edit_copy edit_paste edit_clear edit_fill edit_stroke);
|
|
|
|
%exports = (app => [@procs]);
|
|
|
|
|
|
|
|
$desc = 'Edit procedures';
|
|
|
|
|
|
|
|
# For edit_paste
|
|
|
|
$code = "extern TileManager *global_buf;\n";
|
|
|
|
|
|
|
|
1;
|