brushes.pdb 5.82 KB
Newer Older
1
# GIMP - The GNU Image Manipulation Program
Manish Singh's avatar
Manish Singh committed
2 3
# Copyright (C) 1995 Spencer Kimball and Peter Mattis

4
# This program is free software: you can redistribute it and/or modify
Manish Singh's avatar
Manish Singh committed
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
Manish Singh's avatar
Manish Singh committed
7 8 9 10 11 12 13 14
# (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
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Manish Singh's avatar
Manish Singh committed
16 17 18 19

# "Perlized" from C source by Manish Singh <yosh@gimp.org>

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

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

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

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

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

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

    &std_pdb_misc;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    @outargs = (
153
	{ name => 'actual_name', type => 'string',
154
	  desc => 'The brush name' },
155
	{ name => 'opacity', type => '0 <= float <= 100',
156
	  desc => 'The brush opacity' },
157
	{ name => 'spacing', type => '0 <= int32 <= 1000',
158
	  desc => 'The brush spacing' },
159
	{ name => 'paint_mode', type => 'enum GimpLayerMode',
160
          default => 'GIMP_LAYER_MODE_NORMAL',
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 178
  if (paint_mode == GIMP_LAYER_MODE_OVERLAY_LEGACY)
    paint_mode = GIMP_LAYER_MODE_SOFTLIGHT_LEGACY;
179

180
  if (name && strlen (name))
181
    brush = gimp_pdb_get_brush (gimp, name, FALSE, error);
Manish Singh's avatar
Manish Singh committed
182
  else
183
    brush = gimp_context_get_brush (context);
184

185
  if (brush)
Manish Singh's avatar
Manish Singh committed
186
    {
187 188
      GimpTempBuf *mask = gimp_brush_get_mask (brush);

189
      actual_name = g_strdup (gimp_object_get_name (brush));
190 191 192
      opacity     = 1.0;
      spacing     = gimp_brush_get_spacing (brush);
      paint_mode  = 0;
193 194 195 196
      width       = gimp_brush_get_width  (brush);
      height      = gimp_brush_get_height (brush);
      length      = gimp_temp_buf_get_data_size (mask);
      mask_data   = g_memdup (gimp_temp_buf_get_data (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
@headers = qw(<string.h>
              "core/gimp.h"
              "core/gimpbrush.h"
              "core/gimpcontext.h"
210
              "core/gimpdatafactory.h"
211
              "core/gimptempbuf.h"
212
              "gimppdb-utils.h");
Manish Singh's avatar
Manish Singh committed
213

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

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

$desc = 'Brushes';
223 224 225
$doc_title = 'gimpbrushes';
$doc_short_desc = 'Functions for manipulating brushes.';
$doc_long_desc = 'Functions related to getting and setting brushes.';
Manish Singh's avatar
Manish Singh committed
226 227

1;