Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
GIMP
Commits
66c75cb5
Commit
66c75cb5
authored
Apr 10, 1999
by
Manish Singh
Browse files
Lossa stuff
-Yosh
parent
583ecaad
Changes
18
Hide whitespace changes
Inline
Side-by-side
tools/pdbgen/Makefile.am
View file @
66c75cb5
...
...
@@ -5,7 +5,14 @@ enum_headers = \
../../app/gimpdrawable.h
\
../../app/gimpimage.h
\
../../app/procedural_db.h
\
../../app/paint_funcs.h
../../app/paint_funcs.h
\
../../app/blend.h
\
../../app/bucket_fill.h
\
../../app/clone.h
\
../../app/convolve.h
\
../../app/channel.h
\
../../app/eraser.h
\
../../app/paint_core.h
enums.pl
:
enumgen.pl $(enum_headers)
cd
$(srcdir)
\
...
...
tools/pdbgen/app.pl
View file @
66c75cb5
...
...
@@ -124,7 +124,18 @@ sub declare_args {
}
$result
;
}
}
sub
declare_vars
{
my
$proc
=
shift
;
my
$code
=
"";
if
(
exists
$proc
->
{
invoke
}
->
{
vars
})
{
foreach
(
@
{
$proc
->
{
invoke
}
->
{
vars
}})
{
$code
.=
'
'
x
2
.
$_
.
"
;
\n
";
}
}
$code
;
}
sub
make_arg_recs
{
my
$proc
=
shift
;
...
...
@@ -212,7 +223,7 @@ CODE
$result
.=
'
? TRUE : FALSE
'
if
$pdbtype
eq
'
boolean
';
$result
.=
"
;
\n
";
if
(
$pdbtype
eq
'
string
')
{
if
(
$pdbtype
eq
'
string
'
||
$pdbtype
eq
'
parasite
'
)
{
$result
.=
&make_arg_test
(
$_
,
sub
{
$
{
$_
[
0
]}
=~
s/==/!=/
},
"
$var
== NULL
");
}
...
...
@@ -276,12 +287,35 @@ CODE
if
(
$pdbtype
eq
'
enum
')
{
my
$symbols
=
$enums
{
shift
@typeinfo
}
->
{
symbols
};
foreach
(
@typeinfo
)
{
$extra
.=
"
||
$var
==
$_
"
}
my
(
$start
,
$end
)
=
(
0
,
$#$symbols
);
my
$syms
=
"
@
$symbols
";
my
$test
=
$syms
;
foreach
(
@typeinfo
)
{
$test
=~
s/$_ //
}
$typeinfo
[
0
]
=
$symbols
->
[
0
];
$typeinfo
[
1
]
=
'
<
';
$typeinfo
[
2
]
=
$symbols
->
[
$#$symbols
];
$typeinfo
[
3
]
=
'
>
';
if
(
$syms
=~
/$test/g
)
{
if
(
pos
$syms
==
length
$syms
)
{
$start
=
@typeinfo
;
}
else
{
$end
-=
@typeinfo
;
}
}
else
{
foreach
(
@typeinfo
)
{
$extra
.=
"
||
$var
==
$_
";
}
}
$typeinfo
[
0
]
=
$symbols
->
[
$start
];
if
(
$start
!=
$end
)
{
$typeinfo
[
1
]
=
'
<
';
$typeinfo
[
2
]
=
$symbols
->
[
$end
];
$typeinfo
[
3
]
=
'
>
';
}
else
{
$typeinfo
[
1
]
=
'
!=
';
undef
@typeinf
[
2
..
3
];
}
}
elsif
(
$pdbtype
eq
'
float
')
{
foreach
(
@typeinfo
[
0
,
2
])
{
...
...
@@ -421,12 +455,15 @@ CODE
}
$code
.=
&declare_args
(
$tempproc
,
$out
,
qw(inargs)
)
.
"
\n
";
$code
.=
&declare_vars
(
$proc
);
my
$marshal
=
"";
foreach
(
@
{
$tempproc
->
{
inargs
}})
{
my
$argproc
;
$argproc
->
{
inargs
}
=
[
$_
];
$marshal
.=
&marshal_inargs
(
$argproc
,
$_
->
{
argpos
});
chop
$marshal
;
}
$marshal
.=
"
\n
"
if
$marshal
;
if
(
$success
)
{
$marshal
.=
<<CODE;
...
...
@@ -479,12 +516,7 @@ CODE
$invoker
.=
'
'
x
2
.
"
Argument *return_args;
\n
"
if
scalar
@outargs
;
$invoker
.=
&declare_args
(
$proc
,
$out
,
qw(inargs outargs)
);
if
(
exists
$proc
->
{
invoke
}
->
{
vars
})
{
foreach
(
@
{
$proc
->
{
invoke
}
->
{
vars
}})
{
$invoker
.=
'
'
x
2
.
$_
.
"
;
\n
";
}
}
$invoker
.=
&declare_vars
(
$proc
);
$invoker
.=
&marshal_inargs
(
$proc
,
0
);
$invoker
.=
"
\n
"
if
$invoker
&&
$invoker
!~
/\n\n/s
;
...
...
tools/pdbgen/enumgen.pl
View file @
66c75cb5
...
...
@@ -72,9 +72,6 @@ my $footer = <<'FOOTER';
:1;
FOOTER
$header
=~
s/^://mg
;
$footer
=~
s/^://mg
;
my
(
$enumname
,
$contig
,
$symbols
,
@nicks
,
@mapping
,
$before
,
$chop
);
# Most of this enum parsing stuff was swiped from makeenums.pl in GTK+
...
...
@@ -233,17 +230,19 @@ while (<>) {
}
$code
.=
<<ENTRY;
$enumname =>
{ contig => $contig,
symbols => [ qw($symbols) ],
mapping => { $mapping }$nicks
},
:
$enumname =>
:
{ contig => $contig,
:
symbols => [ qw($symbols) ],
:
mapping => { $mapping }$nicks
:
},
ENTRY
}
}
$code
=~
s/,\n$/\n/s
;
foreach
(
$header
,
$code
,
$footer
)
{
s/^://mg
}
$outfile
=
"
$destdir
/enums.pl
$FILE_EXT
";
open
OUTFILE
,
"
>
$outfile
";
print
OUTFILE
$header
,
$code
,
$footer
;
...
...
tools/pdbgen/enums.pl
View file @
66c75cb5
...
...
@@ -190,6 +190,82 @@ package Gimp::CodeGen::enums;
DIVIDE_MODE
=>
'
DIVIDE/DODGE
',
ERASE_MODE
=>
'
ERASE
',
REPLACE_MODE
=>
'
REPLACE
'
}
},
GradientType
=>
{
contig
=>
1
,
symbols
=>
[
qw(Linear BiLinear Radial Square ConicalSymmetric
ConicalAsymmetric ShapeburstAngular
ShapeburstSpherical ShapeburstDimpled
SpiralClockwise SpiralAntiClockwise)
],
mapping
=>
{
Linear
=>
'
0
',
BiLinear
=>
'
1
',
Radial
=>
'
2
',
Square
=>
'
3
',
ConicalSymmetric
=>
'
4
',
ConicalAsymmetric
=>
'
5
',
ShapeburstAngular
=>
'
6
',
ShapeburstSpherical
=>
'
7
',
ShapeburstDimpled
=>
'
8
',
SpiralClockwise
=>
'
9
',
SpiralAntiClockwise
=>
'
10
'
}
},
BlendMode
=>
{
contig
=>
1
,
symbols
=>
[
qw(FG_BG_RGB_MODE FG_BG_HSV_MODE FG_TRANS_MODE
CUSTOM_MODE)
],
mapping
=>
{
FG_BG_RGB_MODE
=>
'
0
',
FG_BG_HSV_MODE
=>
'
1
',
FG_TRANS_MODE
=>
'
2
',
CUSTOM_MODE
=>
'
3
'
}
},
RepeatMode
=>
{
contig
=>
1
,
symbols
=>
[
qw(REPEAT_NONE REPEAT_SAWTOOTH REPEAT_TRIANGULAR)
],
mapping
=>
{
REPEAT_NONE
=>
'
0
',
REPEAT_SAWTOOTH
=>
'
1
',
REPEAT_TRIANGULAR
=>
'
2
'
}
},
FillMode
=>
{
contig
=>
1
,
symbols
=>
[
qw(FgColorFill BgColorFill PatternFill)
],
mapping
=>
{
FgColorFill
=>
'
0
',
BgColorFill
=>
'
1
',
PatternFill
=>
'
2
'
}
},
CloneType
=>
{
contig
=>
1
,
symbols
=>
[
qw(ImageClone PatternClone)
],
mapping
=>
{
ImageClone
=>
'
0
',
PatternClone
=>
'
1
'
}
},
ConvolveType
=>
{
contig
=>
1
,
symbols
=>
[
qw(Blur Sharpen Custom)
],
mapping
=>
{
Blur
=>
'
0
',
Sharpen
=>
'
1
',
Custom
=>
'
2
'
}
},
ChannelOps
=>
{
contig
=>
1
,
symbols
=>
[
qw(ADD SUB REPLACE INTERSECT)
],
mapping
=>
{
ADD
=>
'
0
',
SUB
=>
'
1
',
REPLACE
=>
'
2
',
INTERSECT
=>
'
3
'
}
},
BrushApplicationMode
=>
{
contig
=>
1
,
symbols
=>
[
qw(HARD SOFT PRESSURE)
],
mapping
=>
{
HARD
=>
'
0
',
SOFT
=>
'
1
',
PRESSURE
=>
'
2
'
}
},
PaintApplicationMode
=>
{
contig
=>
1
,
symbols
=>
[
qw(CONSTANT INCREMENTAL)
],
mapping
=>
{
CONSTANT
=>
'
0
',
INCREMENTAL
=>
'
1
'
},
nicks
=>
{
CONSTANT
=>
'
CONTINUOUS
'
}
}
);
...
...
tools/pdbgen/groups.pl
View file @
66c75cb5
...
...
@@ -18,4 +18,4 @@
# Modify this list for the groups to parse in the pdb directory
@groups
=
qw(gdisplay edit floating_sel undo palette gradient convert
channel_ops gimprc drawable parasite paths gradient_select
unit procedural_db brushes)
;
unit procedural_db brushes
text_tool brush_select
)
;
tools/pdbgen/lib.pl
View file @
66c75cb5
...
...
@@ -220,6 +220,7 @@ CODE
$var
=
$_
->
{
name
};
$var
.=
'
_ID
'
if
$id
;
$return_marshal
.=
'
'
x
2
if
$#outargs
;
$return_marshal
.=
<<CODE
$var = ${head}return_vals[$argc].data.d_$type${foot};
CODE
...
...
tools/pdbgen/pdb/brush_select.pdb
View file @
66c75cb5
...
...
@@ -30,7 +30,7 @@ sub brush_args {(
spacing)' },
{ name => 'paint_mode',
type => 'enum LayerModeEffects (no ERASE_MODE, REPLACE_MODE)',
desc => 'The initial paint mode: { %%desc%%' }
desc => 'The initial paint mode: { %%desc%%
}
' }
)}
sub brushes_popup {
...
...
@@ -65,7 +65,7 @@ sub brushes_popup {
newdialog = brush_select_new (title, NULL, 0.0, 0, 0);
/* Add to list of proc to run when brush changes */
/* change_callbacks = g_list_append (change_callbacks, g_strdup(name)); */
/* change_callbacks = g_list_append (change_callbacks, g_strdup
(name)); */
newdialog->callback_name = g_strdup (name);
/* Add to active brush dialogs list */
...
...
@@ -78,7 +78,7 @@ CODE
);
}
sub brush_close_popup {
sub brush
es
_close_popup {
$blurb = 'Popdown the Gimp brush selection.';
$help = 'This procedure closes an opened brush selection dialog.';
...
...
@@ -116,7 +116,7 @@ CODE
);
}
sub brush_set_popup {
sub brush
es
_set_popup {
$blurb = 'Sets the current brush selection in a popup.';
$help = $blurb;
...
...
@@ -152,10 +152,12 @@ sub brush_set_popup {
bsp->paint_mode = paint_mode;
bsp->spacing_data->value = bsp->spacing_value;
gtk_signal_emit_by_name (GTK_OBJECT (bsp->spacing_data), "value_changed");
gtk_signal_emit_by_name (GTK_OBJECT (bsp->spacing_data),
"value_changed");
bsp->opacity_data->value = bsp->opacity_value * 100.0;
gtk_signal_emit_by_name (GTK_OBJECT (bsp->opacity_data), "value_changed");
gtk_signal_emit_by_name (GTK_OBJECT (bsp->opacity_data),
"value_changed");
gtk_option_menu_set_history (GTK_OPTION_MENU (bsp->option_menu), bsp->paint_mode);
...
...
@@ -170,100 +172,11 @@ CODE
);
}
sub brush_get_brush_data {
$blurb = <<'BLURB';
Retrieve information about the specified brush (including data).
BLURB
$help = <<'HELP';
This procedure retrieves information about the brush. This includes the
brush name, and the sample data for the brush.
HELP
&pdb_misc;
@inargs = (
{ name => 'name', type => 'string',
desc => 'The brush name ("" means current active brush)' },
&sample_size_arg
);
@outargs = (
{ name => 'name', type => 'string',
desc => 'The brush name',
alias => 'g_strdup (grad->name)', no_declare => 1 },
{ name => 'grad_data', type => 'floatarray', alias => 'values',
desc => 'The brush sample data',
array => { name => 'width',
desc => 'The brush sample width (r,g,b,a)',
alias => 'sample_size * 4', no_declare => 1 } }
);
%invoke = (
headers => [ qw("brush_select.h") ],
vars => ['brush_t *grad'],
code => <<'CODE'
{
if (strlen (name))
{
GSList *list = brush_list;
success = FALSE;
while (list)
{
grad = list->data;
if (!strcmp (grad->name, name))
{
success = TRUE;
break; /* We found it! */
}
list = list->next;
}
}
else
success = (grad = curr_brush) != NULL;
if (success)
{
gdouble *values, *pv;
gdouble pos, delta;
gdouble r, g, b, a;
int i = sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
pv = values = g_new (gdouble, i * 4);
curr_brush = grad;
while (i--)
{
grad_get_color_at (pos, &r, &g, &b, &a);
*pv++ = r;
*pv++ = g;
*pv++ = b;
*pv++ = a;
pos += delta;
}
curr_brush = oldgrad;
}
}
CODE
);
}
@headers = qw("brush_select.h");
$extra{app}->{code} = <<'CODE';
static BrushSelectP
brush_get_brushselect(gchar *name)
brush_get_brushselect
(gchar *name)
{
GSList *list = active_dialogs;
BrushSelectP bsp;
...
...
@@ -282,8 +195,7 @@ brush_get_brushselect(gchar *name)
}
CODE
@procs = qw(brushes_popup brushes_close_popup brushes_set_popup
brushes_get_brush_data);
@procs = qw(brushes_popup brushes_close_popup brushes_set_popup);
%exports = (app => [@procs]);
$desc = 'Brush UI';
...
...
tools/pdbgen/pdb/brushes.pdb
View file @
66c75cb5
...
...
@@ -17,6 +17,20 @@
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
sub brush_arg () {{
name => 'name',
type => 'string',
desc => 'The brush name'
}}
sub dim_args {
my @args;
foreach (qw(width height)) {
push @args, { name => $_, type => 'int32', desc => "The brush $_" };
}
@args;
}
sub opacity_arg () {{
name => 'opacity',
type => '0 <= float <= 100',
...
...
@@ -35,6 +49,17 @@ sub paint_mode_arg () {{
desc => 'The paint mode: { %%desc%% }'
}}
sub brush_outargs {
foreach (@outargs) {
my $alias = "brushp->$_->{name}";
$alias = "g_strdup ($alias)" if $_->{type} eq 'string';
$alias =~ s/brushp/brushp->mask/ if $_->{name} =~ /width|height/;
$_->{alias} = $alias;
$_->{no_declare} = 1;
}
}
# The defs
sub brushes_refresh {
...
...
@@ -78,20 +103,13 @@ HELP
&std_pdb_misc;
@outargs = (
{ name => 'name', type => 'string',
desc => 'The brush name',
alias => 'g_strdup (brushp->name)', no_declare => 1 },
{ name => 'width', type => 'int32',
desc => 'The brush width',
alias => 'brushp->mask->width', no_declare => 1 },
{ name => 'height', type => 'int32',
desc => 'The brush height',
alias => 'brushp->mask->height', no_declare => 1 },
{ name => 'spacing', type => 'int32',
desc => 'The brush spacing: (% of MAX [width, height])',
alias => 'brushp->spacing', no_declare => 1 }
&brush_arg,
&dim_args,
&spacing_arg
);
&brush_outargs;
%invoke = (
vars => ['GimpBrush *brushp'],
code => 'success = (brushp = get_active_brush ()) != NULL;'
...
...
@@ -111,10 +129,7 @@ HELP
&std_pdb_misc;
@inargs = (
{ name => 'name', type => 'string',
desc => 'The brush name' }
);
@inargs = ( &brush_arg );
%invoke = (
vars => ['GimpBrush *brushp'],
...
...
@@ -228,11 +243,121 @@ HELP
%invoke = ( code => 'gimp_brush_set_paint_mode (paint_mode);' );
}
sub brushes_list {
$blurb = 'Retrieve a complete listing of the available brushes.';
$help = <<'HELP';
This procedure returns a complete listing of available GIMP brushes. Each name
returned can be used as input to the 'gimp_brushes_set_brush'.
HELP
&std_pdb_misc;
@outargs = (
{ name => 'brush_list', type => 'stringarray',
desc => 'The list of brush names',
alias => 'brushes',
array => { name => 'num_brushes',
desc => 'The number of brushes in the brush list',
alias => 'brush_list->num_brushes', no_declare => 1 } }
);
%invoke = (
vars => [ 'GSList *list', 'int i = 0' ],
code => <<'CODE'
{
brushes = g_new (char *, brush_list->num_brushes);
success = (list = GIMP_LIST (brush_list)->list) != NULL;
while (list)
{
brushes[i++] = g_strdup (((GimpBrush *) list->data)->name);
list = list->next;
}
}
CODE
);
}
sub brushes_get_brush_data {
$blurb = <<'BLURB';
Retrieve information about the currently active brush (including data).
BLURB
$help = <<'HELP';
This procedure retrieves information about the currently active brush. This
includes the brush name, and the brush extents (width and height). It also
returns the brush data.
HELP
$author = $copyright = 'Andy Thomas';
$date = '1998';
@inargs = ( &brush_arg );
$inargs[0]->{desc} = 'the brush name ("" means current active pattern)';
@outargs = (
&brush_arg,
&opacity_arg,
&spacing_arg,
&paint_mode_arg,
&dim_args,
);
&brush_outargs;
$outargs[1]->{alias} = '1.0';
$outargs[3]->{alias} = '0';
push @outargs, { name => 'mask_data', type => 'int8array',
desc => 'The brush mask data',
array => { name => 'length',
desc => 'Length of brush mask data' } };
%invoke = (
vars => ['GimpBrushP brushp = NULL'],
code => <<'CODE'
{
if (strlen (name))
{
GSList list = GIMP_LIST (brush_list)->list;
success = FALSE;
while (list)
{
brushp = (GimpBrushP) list->data;
if (!strcmp (brushp->name, name))
{
success = TRUE;
break;
}
list = list->next;
}
}
else
success = (brushp = get_active_brush ()) != NULL;
if (success)
{
length = brushp->mask->height * brushp->mask->width;
mask_data = g_new (gint8, length);
g_memmove (mask_data, temp_buf_data (brushp->mask), length);
}
}
CODE
);
}
@headers = qw("gimpbrushlist.h");
@procs = qw(brushes_refresh brushes_get_brush brushes_set_brush
brushes_get_opacity brushes_set_opacity brushes_get_spacing
brushes_set_spacing brushes_get_paint_mode brushes_set_paint_mode);
brushes_set_spacing brushes_get_paint_mode brushes_set_paint_mode
brushes_list brushes_get_brush_data);
%exports = (app => [@procs]);
$desc = 'Brushes';
...
...
tools/pdbgen/pdb/convert.pdb
View file @
66c75cb5
...
...
@@ -82,7 +82,7 @@ HELP
%invoke = (
code => <<'CODE'
{
success =
(
gimage_base_type (gimage) != INDEXED
)
;
success = gimage_base_type (gimage) != INDEXED;
if (num_cols < 1 || num_cols > MAXNUMCOLORS)
success = FALSE;
...
...
@@ -114,7 +114,7 @@ HELP
{ name => 'dither', type => 'boolean',
desc => 'Floyd-Steinberg dithering' },
{ name => 'palette_type', type => 'enum ConvertPaletteType',
desc => 'The type of palette to use: %%desc%%', no_success => 1 },
desc => 'The type of palette to use:
{
%%desc%%
}
', no_success => 1 },
{ name => 'num_cols', type => 'int32',
desc => 'the number of colors to quantize to, ignored unless
(palette_type == MAKE_PALETTE)' },
...
...
@@ -149,10 +149,10 @@ HELP
if (!palette_entries_list)
palette_init_palettes (FALSE);
for (list = palette_entries_list; list; list =
g_s
list
_
next
(list)
)
for (list = palette_entries_list; list; list = list
->
next)
{
entries = (PaletteEntriesP) list->data;
if (strcmp (palette_name, entries->name)
== 0
)
if (
!
strcmp (palette_name, entries->name))
{
the_palette = entries;
break;
...
...
tools/pdbgen/pdb/drawable.pdb