mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 04:22:29 +00:00
18d9161eea
2004-04-15 Michael Natterer <mitch@gimp.org> Get rid of the "current_context" which was in fact just a bunch of global variables. Instead, pass the needed context all the way from the GUI and the PDB to the core. This is a prerequisite for macro recording and generally helps separating the various subsystems from each other. Work in progress... * app/core/gimp.[ch]: removed member "current_context" and gimp_[get|set]_current_context(). * app/core/gimp-edit.[ch] * app/core/gimpdrawable-blend.[ch] * app/core/gimpdrawable-bucket-fill.[ch] * app/core/gimpdrawable-offset.[ch] * app/core/gimpdrawable-transform.[ch] * app/core/gimpimage-crop.[ch] * app/core/gimpimage-flip.[ch] * app/core/gimpimage-merge.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-rotate.[ch] * app/core/gimpimage.[ch] * app/core/gimpimagefile.[ch] * app/core/gimpitem-linked.[ch] * app/core/gimpitem.[ch] * app/core/gimplayer.[ch] * app/core/gimpselection.[ch] * app/core/gimptemplate.[ch] * app/file/file-open.[ch] * app/file/file-save.[ch] * app/pdb/procedural_db.[ch] * app/text/gimptext-compat.[ch] * app/text/gimptextlayer-transform.[ch] * app/gui/brush-select.[ch] * app/gui/font-select.[ch] * app/gui/gradient-select.[ch] * app/gui/palette-select.[ch] * app/gui/pattern-select.[ch]: added tons of "GimpContext *context" parameters and use the passed context instead of gimp_get_current_context(). * app/app_procs.c * app/batch.c * app/core/gimpchannel.c * app/core/gimpdrawable.c * app/paint/gimperaser.c * app/paint/gimppaintbrush.c * app/plug-in/plug-in-message.c * app/plug-in/plug-ins.c * app/text/gimptextlayer.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcroptool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpinktool.c * app/tools/gimptransformtool.c * app/vectors/gimpvectors.c * app/gui/convert-dialog.c * app/gui/drawable-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/offset-dialog.c * app/gui/select-commands.c * app/gui/vectors-commands.c * app/widgets/gimpdnd.c * app/widgets/gimpdocumentview.c * app/widgets/gimphelp.c * app/widgets/gimpthumbbox.c: pass gimp_get_user_context() or GIMP_CONTEXT(tool_options) or whatever is the right context to the changed core functions. * tools/pdbgen/app.pl: pass "GimpContext *context" to all generated PDB invokers. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/font_select.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/paint_tools.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/palette_select.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: pass the new context parameter to the changed core functions. * app/pdb/*_cmds.c: regenerated.
278 lines
7.4 KiB
Plaintext
278 lines
7.4 KiB
Plaintext
# 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>
|
|
|
|
# Text
|
|
|
|
sub pdb_misc {
|
|
&std_pdb_misc;
|
|
$author = 'Martin Edlman';
|
|
$date = '1998';
|
|
}
|
|
|
|
sub text_arg () {{
|
|
name => 'text',
|
|
type => 'string',
|
|
desc => 'The text to generate'
|
|
}}
|
|
|
|
sub fontname_arg () {{
|
|
name => 'fontname',
|
|
type => 'string',
|
|
desc => 'The name of the font'
|
|
}}
|
|
|
|
sub size_args () {(
|
|
{ name => 'size', type => '0 < float',
|
|
desc => 'The size of text in either pixels or points' },
|
|
{ name => 'size_type', type => 'enum SizeType',
|
|
desc => 'The units of specified size: %%desc%%' }
|
|
)}
|
|
|
|
sub render_args () {(
|
|
&std_image_arg,
|
|
{ name => 'drawable', type => 'drawable',
|
|
desc => 'The affected drawable: (-1 for a new text layer)',
|
|
no_success => 1 },
|
|
{ name => 'x', type => 'float',
|
|
desc => 'The x coordinate for the left of the text bounding box' },
|
|
{ name => 'y', type => 'float',
|
|
desc => 'The y coordinate for the top of the text bounding box' },
|
|
&text_arg,
|
|
{ name => 'border', type => '-1 <= int32',
|
|
desc => 'The size of the border: %%desc%%' },
|
|
&std_antialias_arg,
|
|
&size_args
|
|
)}
|
|
|
|
@props = qw(foundry family weight slant set_width spacing registry encoding);
|
|
|
|
sub font_prop_args {
|
|
my @result;
|
|
foreach (@props) {
|
|
(my $desc = $_) =~ s/_/-/g;
|
|
push @result, { name => $_, type => 'string', no_validate => 1,
|
|
desc => qq/The font $desc/ }
|
|
}
|
|
@result;
|
|
}
|
|
|
|
sub render_outargs {
|
|
@outargs = (
|
|
{ name => 'text_layer', type => 'layer',
|
|
desc => 'The new text layer', init => 1 }
|
|
);
|
|
}
|
|
|
|
sub extents_outargs {
|
|
foreach (qw(width height ascent descent)) {
|
|
push @outargs, { name => $_, type => 'int32',
|
|
desc => "The $_ of the specified font" }
|
|
}
|
|
}
|
|
|
|
sub text_fontname {
|
|
$blurb = <<'BLURB';
|
|
Add text at the specified location as a floating selection or a new layer.
|
|
BLURB
|
|
|
|
$help = <<'HELP';
|
|
This tool requires a fontname matching an installed PangoFT2 font.
|
|
You can specify the fontsize in units of pixels
|
|
or points, and the appropriate metric is specified using the size_type
|
|
argument. The x and y parameters together control the placement of the new
|
|
text by specifying the upper left corner of the text bounding box. If the
|
|
specified drawable parameter is valid, the text will be created as a floating
|
|
selection attached to the drawable. If the drawable parameter is not valid
|
|
(-1), the text will appear as a new layer. Finally, a border can be specified
|
|
around the final rendered text. The border is measured in pixels.
|
|
|
|
HELP
|
|
|
|
&pdb_misc;
|
|
$author .= ' & Sven Neumann';
|
|
$date .= '- 2001';
|
|
|
|
@inargs = (
|
|
&render_args,
|
|
&fontname_arg
|
|
);
|
|
|
|
&render_outargs;
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
|
|
success = FALSE;
|
|
|
|
if (success)
|
|
{
|
|
gchar *real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
|
|
|
|
text_layer = text_render (gimage, drawable, context,
|
|
x, y, real_fontname, text,
|
|
border, antialias);
|
|
if (text_layer == NULL)
|
|
success = FALSE;
|
|
|
|
g_free (real_fontname);
|
|
}
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub text_get_extents_fontname {
|
|
$blurb = 'Get extents of the bounding box for the specified text.';
|
|
|
|
$help = <<'HELP';
|
|
This tool returns the width and height of a bounding box for the specified text
|
|
string with the specified font information. Ascent and descent for the
|
|
specified font are returned as well.
|
|
HELP
|
|
|
|
&pdb_misc;
|
|
$author .= ' & Sven Neumann';
|
|
$date .= '- 2001';
|
|
|
|
@inargs = (
|
|
&text_arg,
|
|
&size_args,
|
|
&fontname_arg
|
|
);
|
|
|
|
&extents_outargs;
|
|
$outargs[0]->{void_ret} = 1;
|
|
|
|
%invoke = (
|
|
vars => [ 'gchar *real_fontname' ],
|
|
code => <<'CODE'
|
|
{
|
|
real_fontname = g_strdup_printf ("%s %d", fontname, (gint) size);
|
|
|
|
success = text_get_extents (real_fontname, text,
|
|
&width, &height,
|
|
&ascent, &descent);
|
|
|
|
g_free (real_fontname);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub text {
|
|
$blurb = <<'BLURB';
|
|
Add text at the specified location as a floating selection or a new layer.
|
|
BLURB
|
|
|
|
$help = <<'HELP';
|
|
This tool requires font information in the form of nine parameters: size,
|
|
foundry, family, weight, slant, set_width, spacing, registry, encoding. The
|
|
font size can either be specified in units of pixels or points, and the
|
|
appropriate metric is specified using the size_type argument. The x and y
|
|
parameters together control the placement of the new text by specifying the
|
|
upper left corner of the text bounding box. If the antialias parameter is
|
|
non-zero, the generated text will blend more smoothly with underlying layers.
|
|
This option requires more time and memory to compute than non-antialiased text;
|
|
the resulting floating selection or layer, however, will require the same
|
|
amount of memory with or without antialiasing. If the specified drawable
|
|
parameter is valid, the text will be created as a floating selection attached
|
|
to the drawable. If the drawable parameter is not valid (-1), the text will
|
|
appear as a new layer. Finally, a border can be specified around the final
|
|
rendered text. The border is measured in pixels. If the border is specified
|
|
as -1, empty spaces around the text will not be cropped.
|
|
HELP
|
|
|
|
&pdb_misc;
|
|
|
|
@inargs = (
|
|
&render_args,
|
|
&font_prop_args
|
|
);
|
|
|
|
&render_outargs;
|
|
|
|
%invoke = (
|
|
code => <<'CODE'
|
|
{
|
|
if (drawable && ! gimp_item_is_attached (GIMP_ITEM (drawable)))
|
|
success = FALSE;
|
|
|
|
if (success)
|
|
{
|
|
gchar *real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
|
|
|
|
text_layer = text_render (gimage, drawable, context,
|
|
x, y, real_fontname, text,
|
|
border, antialias);
|
|
if (text_layer == NULL)
|
|
success = FALSE;
|
|
|
|
g_free (real_fontname);
|
|
}
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
sub text_get_extents {
|
|
$blurb = 'Get extents of the bounding box for the specified text.';
|
|
|
|
$help = <<'HELP';
|
|
This tool returns the width and height of a bounding box for the specified text
|
|
string with the specified font information. Ascent and descent for the
|
|
specified font are returned as well.
|
|
HELP
|
|
|
|
&pdb_misc;
|
|
|
|
@inargs = (
|
|
&text_arg,
|
|
&size_args,
|
|
&font_prop_args
|
|
);
|
|
|
|
&extents_outargs;
|
|
$outargs[0]->{void_ret} = 1;
|
|
|
|
%invoke = (
|
|
vars => [ 'gchar *real_fontname' ],
|
|
code => <<'CODE'
|
|
{
|
|
real_fontname = g_strdup_printf ("%s %d", family, (gint) size);
|
|
|
|
success = text_get_extents (real_fontname, text,
|
|
&width, &height,
|
|
&ascent, &descent);
|
|
|
|
g_free (real_fontname);
|
|
}
|
|
CODE
|
|
);
|
|
}
|
|
|
|
@headers = qw("libgimpbase/gimpbase.h" "text/gimptext-compat.h");
|
|
|
|
@procs = qw(text_fontname text_get_extents_fontname text text_get_extents);
|
|
%exports = (app => [@procs], lib => [@procs]);
|
|
|
|
$desc = 'Text procedures';
|
|
|
|
1;
|