brushes.pdb 5.56 KB
Newer Older
1
# GIMP - The GNU Image Manipulation Program
Manish Singh's avatar
Manish Singh committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# 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>

sub brushes_refresh {
21
    $blurb = 'Refresh current brushes. This function always succeeds.';
Manish Singh's avatar
Manish Singh committed
22 23 24

    $help = <<'HELP';
This procedure retrieves all brushes currently in the user's brush path
25
and updates the brush dialogs accordingly.
Manish Singh's avatar
Manish Singh committed
26 27
HELP

28
    &seth_pdb_misc('1997');
Manish Singh's avatar
Manish Singh committed
29 30

    %invoke = (
31 32 33 34 35 36
	code => <<'CODE'
{
  gimp_data_factory_data_refresh (gimp->brush_factory);
}
CODE
    );
Manish Singh's avatar
Manish Singh committed
37 38
}

39 40 41 42
sub brushes_get_list {
    $blurb = 'Retrieve a complete listing of the available brushes.';

    $help = <<'HELP';
43 44
This procedure returns a complete listing of available GIMP
brushes. Each name returned can be used as input to the
45
gimp_context_set_brush() procedure.
46 47 48 49
HELP

    &std_pdb_misc;

50
    @inargs = (
51
	{ name => 'filter', type => 'string', null_ok => 1,
52 53 54
          desc => 'An optional regular expression used to filter the list' }
    );

55 56 57 58
    @outargs = (
	{ name => 'brush_list', type => 'stringarray',
	  desc => 'The list of brush names',
	  array => { name => 'num_brushes',
59
		     desc => 'The number of brushes in the brush list' } }
60 61 62
    );

    %invoke = (
63
        headers => [ qw("core/gimpcontainer-filter.h") ],
64 65 66 67 68 69
	code    => <<'CODE'
{
  brush_list = gimp_container_get_filtered_name_array (gimp->brush_factory->container,
                                                       filter, &num_brushes);
}
CODE
70 71 72
    );
}

Manish Singh's avatar
Manish Singh committed
73
sub brushes_get_brush {
74
    &std_pdb_deprecated ('gimp-context-get-brush');
75

Manish Singh's avatar
Manish Singh committed
76
    @outargs = (
77
	{ name => 'name', type => 'string',
78
	  desc => 'The brush name' },
79
	{ name => 'width', type => 'int32',
80
	  desc => 'The brush width' },
81
	{ name => 'height', type => 'int32',
82
	  desc => 'The brush height' },
83
	{ name => 'spacing', type => '0 <= int32 <= 1000',
84
	  desc => 'The brush spacing' }
Manish Singh's avatar
Manish Singh committed
85 86 87
    );

    %invoke = (
88
	code => <<'CODE'
89 90 91 92 93
{
  GimpBrush *brush = gimp_context_get_brush (context);

  if (brush)
    {
94
      name    = g_strdup (gimp_object_get_name (GIMP_OBJECT (brush)));
95 96 97 98 99 100 101 102
      width   = brush->mask->width;
      height  = brush->mask->height;
      spacing = gimp_brush_get_spacing (brush);
    }
  else
    success = FALSE;
}
CODE
Manish Singh's avatar
Manish Singh committed
103 104 105 106
    );
}

sub brushes_get_spacing {
107
    &std_pdb_deprecated ('gimp-brush-get-spacing');
Manish Singh's avatar
Manish Singh committed
108

109
    @outargs = (
110
	{ name => 'spacing', type => '0 <= int32 <= 1000',
111
	  desc => 'The brush spacing' }
112 113 114 115 116 117 118 119 120 121 122 123 124
    );

    %invoke = (
	code =><<'CODE'
{
  GimpBrush *brush = gimp_context_get_brush (context);

  if (brush)
    spacing = gimp_brush_get_spacing (brush);
  else
    success = FALSE;
}
CODE
125
    );
Manish Singh's avatar
Manish Singh committed
126 127 128
}

sub brushes_set_spacing {
129
    &std_pdb_deprecated ('gimp-brush-set-spacing');
Manish Singh's avatar
Manish Singh committed
130

131 132
    @inargs = (
	{ name => 'spacing', type => '0 <= int32 <= 1000',
133
	  desc => 'The brush spacing' }
134
    );
Manish Singh's avatar
Manish Singh committed
135

Manish Singh's avatar
Manish Singh committed
136
    %invoke = (
137 138 139 140 141
	code => <<'CODE'
{
  gimp_brush_set_spacing (gimp_context_get_brush (context), spacing);
}
CODE
Manish Singh's avatar
Manish Singh committed
142
    );
Manish Singh's avatar
Manish Singh committed
143 144
}

Manish Singh's avatar
Manish Singh committed
145
sub brushes_get_brush_data {
146
    &std_pdb_deprecated ('gimp-brush-get-pixels');
Manish Singh's avatar
Manish Singh committed
147

148
    @inargs = (
149 150
	{ name => 'name', type => 'string', null_ok => 1,
	  desc => 'The brush name ("" means current active brush)' }
151
    );
Manish Singh's avatar
Manish Singh committed
152 153

    @outargs = (
154
	{ name => 'actual_name', type => 'string',
155
	  desc => 'The brush name' },
156
	{ name => 'opacity', type => '0 <= float <= 100',
157
	  desc => 'The brush opacity' },
158
	{ name => 'spacing', type => '0 <= int32 <= 1000',
159
	  desc => 'The brush spacing' },
160
	{ name => 'paint_mode', type => 'enum GimpLayerModeEffects',
161
	  desc => 'The paint mode' },
162
	{ name => 'width', type => 'int32',
163
	  desc => 'The brush width' },
164
	{ name => 'height', type => 'int32',
165
	  desc => 'The brush height' },
166
	{ name => 'mask_data', type => 'int8array',
167
	  desc => 'The brush mask data',
168
	  array => { name => 'length',
169
		     desc => 'Length of brush mask data' } }
Manish Singh's avatar
Manish Singh committed
170 171 172 173 174
    );

    %invoke = (
	code => <<'CODE'
{
175 176
  GimpBrush *brush;

177
  if (name && strlen (name))
Manish Singh's avatar
Manish Singh committed
178
    {
179 180
      brush = (GimpBrush *)
        gimp_container_get_child_by_name (gimp->brush_factory->container, name);
Manish Singh's avatar
Manish Singh committed
181 182
    }
  else
183
    {
184
      brush = gimp_context_get_brush (context);
185 186
    }

187
  if (brush)
Manish Singh's avatar
Manish Singh committed
188
    {
189
      actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (brush)));
190 191 192 193 194 195 196
      opacity     = 1.0;
      spacing     = gimp_brush_get_spacing (brush);
      paint_mode  = 0;
      width       = brush->mask->width;
      height      = brush->mask->height;
      length      = brush->mask->height * brush->mask->width;
      mask_data   = g_memdup (temp_buf_data (brush->mask), length);
Manish Singh's avatar
Manish Singh committed
197
    }
198 199
  else
    success = FALSE;
Manish Singh's avatar
Manish Singh committed
200 201 202 203 204
}
CODE
    );
}

205

206 207 208 209 210 211 212
@headers = qw(<string.h>
              "base/temp-buf.h"
              "core/gimp.h"
              "core/gimplist.h"
              "core/gimpbrush.h"
              "core/gimpcontext.h"
              "core/gimpdatafactory.h");
Manish Singh's avatar
Manish Singh committed
213

214 215 216 217 218
@procs = qw(brushes_refresh brushes_get_list
            brushes_get_brush
            brushes_get_spacing brushes_set_spacing
            brushes_get_brush_data);

219
%exports = (app => [@procs], lib => [@procs]);
Manish Singh's avatar
Manish Singh committed
220 221 222 223

$desc = 'Brushes';

1;