Node socket values now only have soft limits, rather than hard limits, so you
[blender.git] / source / blender / makesrna / intern / rna_brush.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Blender Foundation (2008), Juho Veps�l�inen
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 /** \file blender/makesrna/intern/rna_brush.c
24  *  \ingroup RNA
25  */
26
27
28 #include <stdlib.h>
29 #include <assert.h>
30
31 #include "RNA_define.h"
32
33 #include "rna_internal.h"
34
35 #include "DNA_brush_types.h"
36 #include "DNA_texture_types.h"
37 #include "DNA_scene_types.h"
38 #include "DNA_object_types.h"
39
40 #include "BLI_math.h"
41
42 #include "IMB_imbuf.h"
43
44 #include "WM_types.h"
45
46 static EnumPropertyItem prop_direction_items[] = {
47         {0, "ADD", 0, "Add", "Add effect of brush"},
48         {BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"},
49         {0, NULL, 0, NULL, NULL}};
50
51 EnumPropertyItem brush_sculpt_tool_items[] = {
52         {SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""},
53         {SCULPT_TOOL_CLAY, "CLAY", ICON_BRUSH_CLAY, "Clay", ""},
54         {SCULPT_TOOL_CLAY_STRIPS, "CLAY_STRIPS", ICON_BRUSH_CLAY_STRIPS, "Clay Strips", ""},
55         {SCULPT_TOOL_CREASE, "CREASE",ICON_BRUSH_CREASE, "Crease", ""},
56         {SCULPT_TOOL_DRAW, "DRAW", ICON_BRUSH_SCULPT_DRAW, "Draw", ""},
57         {SCULPT_TOOL_FILL, "FILL", ICON_BRUSH_FILL, "Fill", ""},
58         {SCULPT_TOOL_FLATTEN, "FLATTEN", ICON_BRUSH_FLATTEN, "Flatten", ""},
59         {SCULPT_TOOL_GRAB, "GRAB", ICON_BRUSH_GRAB, "Grab", ""},
60         {SCULPT_TOOL_INFLATE, "INFLATE", ICON_BRUSH_INFLATE, "Inflate", ""},
61         {SCULPT_TOOL_LAYER, "LAYER", ICON_BRUSH_LAYER, "Layer", ""},
62         {SCULPT_TOOL_NUDGE, "NUDGE", ICON_BRUSH_NUDGE, "Nudge", ""},
63         {SCULPT_TOOL_PINCH, "PINCH", ICON_BRUSH_PINCH, "Pinch", ""},
64         {SCULPT_TOOL_ROTATE, "ROTATE", ICON_BRUSH_ROTATE, "Rotate", ""},
65         {SCULPT_TOOL_SCRAPE, "SCRAPE", ICON_BRUSH_SCRAPE, "Scrape", ""},
66         {SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""},
67         {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""},
68         {SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""},
69         {0, NULL, 0, NULL, NULL}};
70
71
72 EnumPropertyItem brush_vertex_tool_items[] = {
73         {PAINT_BLEND_MIX, "MIX", ICON_BRUSH_MIX, "Mix", "Use mix blending mode while painting"},
74         {PAINT_BLEND_ADD, "ADD", ICON_BRUSH_ADD, "Add", "Use add blending mode while painting"},
75         {PAINT_BLEND_SUB, "SUB", ICON_BRUSH_SUBTRACT, "Subtract", "Use subtract blending mode while painting"},
76         {PAINT_BLEND_MUL, "MUL", ICON_BRUSH_MULTIPLY, "Multiply", "Use multiply blending mode while painting"},
77         {PAINT_BLEND_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"},
78         {PAINT_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"},
79         {PAINT_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"},
80         {0, NULL, 0, NULL, NULL}};
81         
82 EnumPropertyItem brush_image_tool_items[] = {
83         {PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""},
84         {PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""},
85         {PAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SMEAR, "Smear", ""},
86         {PAINT_TOOL_CLONE, "CLONE", ICON_BRUSH_CLONE, "Clone", ""},
87         {0, NULL, 0, NULL, NULL}};
88
89 #ifdef RNA_RUNTIME
90
91 #include "MEM_guardedalloc.h"
92
93 #include "DNA_object_types.h"
94
95 #include "RNA_access.h"
96
97 #include "BKE_texture.h"
98 #include "BKE_brush.h"
99 #include "BKE_icons.h"
100 #include "BKE_paint.h"
101
102 #include "WM_api.h"
103
104 static int rna_SculptCapabilities_has_accumulate_get(PointerRNA *ptr)
105 {
106         Brush *br = (Brush*)ptr->data;
107         return ELEM6(br->sculpt_tool,
108                                  SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CREASE,
109                                  SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_LAYER);
110 }
111
112 static int rna_SculptCapabilities_has_auto_smooth_get(PointerRNA *ptr)
113 {
114         Brush *br = (Brush*)ptr->data;
115         return br->sculpt_tool != SCULPT_TOOL_SMOOTH;
116 }
117
118 static int rna_SculptCapabilities_has_height_get(PointerRNA *ptr)
119 {
120         Brush *br = (Brush*)ptr->data;
121         return br->sculpt_tool == SCULPT_TOOL_LAYER;
122 }
123
124 static int rna_SculptCapabilities_has_jitter_get(PointerRNA *ptr)
125 {
126         Brush *br = (Brush*)ptr->data;
127         return (!(br->flag & BRUSH_ANCHORED) &&
128                         !(br->flag & BRUSH_RESTORE_MESH) &&
129                         !ELEM4(br->sculpt_tool,
130                                    SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
131                                    SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
132 }
133
134 static int rna_SculptCapabilities_has_normal_weight_get(PointerRNA *ptr)
135 {
136         Brush *br = (Brush*)ptr->data;
137         return ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
138 }
139
140 static int rna_SculptCapabilities_has_persistence_get(PointerRNA *ptr)
141 {
142         Brush *br = (Brush*)ptr->data;
143         return br->sculpt_tool == SCULPT_TOOL_LAYER;
144 }
145
146 static int rna_SculptCapabilities_has_pinch_factor_get(PointerRNA *ptr)
147 {
148         Brush *br = (Brush*)ptr->data;
149         return ELEM(br->sculpt_tool, SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE);
150 }
151
152 static int rna_SculptCapabilities_has_plane_offset_get(PointerRNA *ptr)
153 {
154         Brush *br = (Brush*)ptr->data;
155         return ELEM5(br->sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS,
156                                  SCULPT_TOOL_FILL, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_SCRAPE);
157 }
158
159 static int rna_SculptCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
160 {
161         Brush *br = (Brush*)ptr->data;
162         return ((br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) &&
163                         !(br->flag & BRUSH_ANCHORED) &&
164                         !ELEM4(br->sculpt_tool,
165                                    SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
166                                    SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
167 }
168
169 static int rna_SculptCapabilities_has_sculpt_plane_get(PointerRNA *ptr)
170 {
171         Brush *br = (Brush*)ptr->data;
172         return !ELEM3(br->sculpt_tool, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH,
173                                   SCULPT_TOOL_SMOOTH);
174 }
175
176 static int rna_SculptCapabilities_has_secondary_color_get(PointerRNA *ptr)
177 {
178         Brush *br = (Brush*)ptr->data;
179         return ELEM10(br->sculpt_tool,
180                                   SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS,
181                                   SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_FILL,
182                                   SCULPT_TOOL_FLATTEN, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH,
183                                   SCULPT_TOOL_SCRAPE);
184 }
185
186 static int rna_SculptCapabilities_has_smooth_stroke_get(PointerRNA *ptr)
187 {
188         Brush *br = (Brush*)ptr->data;
189         return (!(br->flag & BRUSH_ANCHORED) &&
190                         !(br->flag & BRUSH_RESTORE_MESH) &&
191                         !ELEM4(br->sculpt_tool,
192                                    SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
193                                    SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
194 }
195
196 static int rna_SculptCapabilities_has_space_attenuation_get(PointerRNA *ptr)
197 {
198         Brush *br = (Brush*)ptr->data;
199         return ((br->flag & BRUSH_SPACE) &&
200                         !ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
201                            SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK));
202 }
203
204 static int rna_SculptCapabilities_has_spacing_get(PointerRNA *ptr)
205 {
206         Brush *br = (Brush*)ptr->data;
207         return (!(br->flag & BRUSH_ANCHORED) &&
208                         !ELEM4(br->sculpt_tool,
209                                    SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
210                                    SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB));
211 }
212
213 static int rna_SculptCapabilities_has_strength_get(PointerRNA *ptr)
214 {
215         Brush *br = (Brush*)ptr->data;
216         return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK);
217 }
218
219 static PointerRNA rna_Brush_sculpt_capabilities_get(PointerRNA *ptr)
220 {
221         return rna_pointer_inherit_refine(ptr, &RNA_SculptCapabilities, ptr->id.data);
222 }
223
224 static void rna_Brush_reset_icon(Brush *br, const char *UNUSED(type))
225 {
226         ID *id = &br->id;
227
228         if (br->flag & BRUSH_CUSTOM_ICON)
229                 return;
230
231         if (id->icon_id >= BIFICONID_LAST) {
232                 BKE_icon_delete(id);
233                 BKE_previewimg_free_id(id);
234         }
235
236         id->icon_id = 0;
237 }
238
239 static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
240 {
241         Brush *br = (Brush*)ptr->data;
242         WM_main_add_notifier(NC_BRUSH|NA_EDITED, br);
243         /*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */
244 }
245
246 static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
247 {
248         Brush *br = (Brush*)ptr->data;
249         rna_Brush_reset_icon(br, "sculpt");
250         rna_Brush_update(bmain, scene, ptr);
251 }
252  
253 static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
254 {
255         Brush *br = (Brush*)ptr->data;
256         rna_Brush_reset_icon(br, "vertex_paint");
257         rna_Brush_update(bmain, scene, ptr);
258 }
259  
260 static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr)
261 {
262         Brush *br = (Brush*)ptr->data;
263         rna_Brush_reset_icon(br, "image_paint");
264         rna_Brush_update(bmain, scene, ptr);
265 }
266
267 static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
268 {
269         Brush *br = (Brush*)ptr->data;
270
271         if (br->icon_imbuf) {
272                 IMB_freeImBuf(br->icon_imbuf);
273                 br->icon_imbuf = NULL;
274         }
275
276         br->id.icon_id = 0;
277
278         if (br->flag & BRUSH_CUSTOM_ICON) {
279                 BKE_previewimg_get(&br->id);
280                 BKE_icon_changed(BKE_icon_getid(&br->id));
281         }
282
283         WM_main_add_notifier(NC_BRUSH|NA_EDITED, br);
284 }
285
286 static void rna_Brush_set_size(PointerRNA *ptr, int value)
287 {
288         Brush* brush = ptr->data;
289
290         /* scale unprojected radius so it stays consistent with brush size */
291         brush_scale_unprojected_radius(&brush->unprojected_radius,
292                                                                    value, brush->size);
293         brush->size = value;
294 }
295
296 static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value)
297 {
298         Brush* brush = ptr->data;
299
300         /* scale brush size so it stays consistent with unprojected_radius */
301         brush_scale_size(&brush->size, value, brush->unprojected_radius);
302         brush->unprojected_radius = value;
303 }
304
305 static EnumPropertyItem *rna_Brush_direction_itemf(bContext *UNUSED(C), PointerRNA *ptr,
306                                                    PropertyRNA *UNUSED(prop), int *UNUSED(free))
307 {
308         static EnumPropertyItem prop_default_items[] = {
309                 {0, NULL, 0, NULL, NULL}};
310
311         static EnumPropertyItem prop_flatten_contrast_items[] = {
312                 {0, "FLATTEN", 0, "Flatten", "Add effect of brush"},
313                 {BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"},
314                 {0, NULL, 0, NULL, NULL}};
315
316         static EnumPropertyItem prop_fill_deepen_items[] = {
317                 {0, "FILL", 0, "Fill", "Add effect of brush"},
318                 {BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"},
319                 {0, NULL, 0, NULL, NULL}};
320
321         static EnumPropertyItem prop_scrape_peaks_items[] = {
322                 {0, "SCRAPE", 0, "Scrape", "Add effect of brush"},
323                 {BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"},
324                 {0, NULL, 0, NULL, NULL}};
325
326         static EnumPropertyItem prop_pinch_magnify_items[] = {
327                 {0, "PINCH", 0, "Pinch", "Add effect of brush"},
328                 {BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"},
329                 {0, NULL, 0, NULL, NULL}};
330
331         static EnumPropertyItem prop_inflate_deflate_items[] = {
332                 {0, "INFLATE", 0, "Inflate", "Add effect of brush"},
333                 {BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"},
334                 {0, NULL, 0, NULL, NULL}};
335
336         Brush *me = (Brush*)(ptr->data);
337
338         switch (me->sculpt_tool) {
339                 case SCULPT_TOOL_DRAW:
340                 case SCULPT_TOOL_CREASE:
341                 case SCULPT_TOOL_BLOB:
342                 case SCULPT_TOOL_LAYER:
343                 case SCULPT_TOOL_CLAY:
344                         return prop_direction_items;
345
346                 case SCULPT_TOOL_FLATTEN:
347                         return prop_flatten_contrast_items;
348
349                 case SCULPT_TOOL_FILL:
350                         return prop_fill_deepen_items;
351
352                 case SCULPT_TOOL_SCRAPE:
353                         return prop_scrape_peaks_items;
354
355                 case SCULPT_TOOL_PINCH:
356                         return prop_pinch_magnify_items;
357
358                 case SCULPT_TOOL_INFLATE:
359                         return prop_inflate_deflate_items;
360
361                 default:
362                         return prop_default_items;
363         }
364 }
365
366 #else
367
368 static void rna_def_brush_texture_slot(BlenderRNA *brna)
369 {
370         StructRNA *srna;
371         PropertyRNA *prop;
372
373         static EnumPropertyItem prop_map_mode_items[] = {
374                 {MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""},
375                 {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
376                 {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
377                 {0, NULL, 0, NULL, NULL}};
378
379         srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot");
380         RNA_def_struct_sdna(srna, "MTex");
381         RNA_def_struct_ui_text(srna, "Brush Texture Slot", "Texture slot for textures in a Brush datablock");
382
383         prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
384         RNA_def_property_float_sdna(prop, NULL, "rot");
385         RNA_def_property_range(prop, 0, M_PI*2);
386         RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation");
387         RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
388
389         prop = RNA_def_property(srna, "map_mode", PROP_ENUM, PROP_NONE);
390         RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
391         RNA_def_property_enum_items(prop, prop_map_mode_items);
392         RNA_def_property_ui_text(prop, "Mode", "");
393         RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
394 }
395
396 static void rna_def_sculpt_capabilities(BlenderRNA *brna)
397 {
398         StructRNA *srna;
399         PropertyRNA *prop;
400
401         srna = RNA_def_struct(brna, "SculptCapabilities", NULL);
402         RNA_def_struct_sdna(srna, "Brush");
403         RNA_def_struct_nested(brna, srna, "Brush");
404         RNA_def_struct_ui_text(srna, "Sculpt Capabilities",
405                                                    "Read-only indications of which brush operations "
406                                                    "are supported by the current sculpt tool");
407
408 #define BRUSH_CAPABILITY(prop_name_, ui_name_)                                                  \
409         prop = RNA_def_property(srna, #prop_name_,                                                      \
410                                                         PROP_BOOLEAN, PROP_NONE);                                       \
411         RNA_def_property_clear_flag(prop, PROP_EDITABLE);                                       \
412         RNA_def_property_boolean_funcs(prop, "rna_SculptCapabilities_"          \
413                                                                    #prop_name_ "_get", NULL);                   \
414         RNA_def_property_ui_text(prop, ui_name_, NULL)
415
416         BRUSH_CAPABILITY(has_accumulate, "Has Accumulate");
417         BRUSH_CAPABILITY(has_auto_smooth, "Has Auto Smooth");
418         BRUSH_CAPABILITY(has_height, "Has Height");
419         BRUSH_CAPABILITY(has_jitter, "Has Jitter");
420         BRUSH_CAPABILITY(has_normal_weight, "Has Crease/Pinch Factor");
421         BRUSH_CAPABILITY(has_persistence, "Has Persistence");
422         BRUSH_CAPABILITY(has_pinch_factor, "Has Pinch Factor");
423         BRUSH_CAPABILITY(has_plane_offset, "Has Plane Offset");
424         BRUSH_CAPABILITY(has_random_texture_angle, "Has Random Texture Angle");
425         BRUSH_CAPABILITY(has_sculpt_plane, "Has Sculpt Plane");
426         BRUSH_CAPABILITY(has_secondary_color, "Has Secondary Color");
427         BRUSH_CAPABILITY(has_smooth_stroke, "Has Smooth Stroke");
428         BRUSH_CAPABILITY(has_space_attenuation, "Has Space Attenuation");
429         BRUSH_CAPABILITY(has_spacing, "Has Spacing");
430         BRUSH_CAPABILITY(has_strength, "Has Strength");
431
432 #undef SCULPT_CAPABILITY
433 }
434
435 static void rna_def_brush(BlenderRNA *brna)
436 {
437         StructRNA *srna;
438         PropertyRNA *prop;
439         
440         static EnumPropertyItem prop_blend_items[] = {
441                 {IMB_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting"},
442                 {IMB_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting"},
443                 {IMB_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting"},
444                 {IMB_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting"},
445                 {IMB_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting"},
446                 {IMB_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting"},
447                 {IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting"},
448                 {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"},
449                 {0, NULL, 0, NULL, NULL}};
450         
451         static EnumPropertyItem brush_stroke_method_items[] = {
452                 {0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"},
453                 {BRUSH_RESTORE_MESH, "DRAG_DOT", 0, "Drag Dot", "Allows a single dot to be carefully positioned"},
454                 {BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"},
455                 {BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", "Keep the brush anchored to the initial location"},
456                 {BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"},
457                 {0, NULL, 0, NULL, NULL}};
458
459         static EnumPropertyItem texture_angle_source_items[] = {
460                 {0, "USER", 0, "User", "Rotate the brush texture by given angle"},
461                 {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"},
462                 {BRUSH_RANDOM_ROTATION, "RANDOM", 0, "Random", "Rotate the brush texture at random"},
463                 {0, NULL, 0, NULL, NULL}};
464
465         static EnumPropertyItem texture_angle_source_no_random_items[] = {
466                 {0, "USER", 0, "User", "Rotate the brush texture by given angle"},
467                 {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"},
468                 {0, NULL, 0, NULL, NULL}};
469
470         static EnumPropertyItem brush_sculpt_plane_items[] = {
471                 {SCULPT_DISP_DIR_AREA, "AREA", 0, "Area Plane", ""},
472                 {SCULPT_DISP_DIR_VIEW, "VIEW", 0, "View Plane", ""},
473                 {SCULPT_DISP_DIR_X, "X", 0, "X Plane", ""},
474                 {SCULPT_DISP_DIR_Y, "Y", 0, "Y Plane", ""},
475                 {SCULPT_DISP_DIR_Z, "Z", 0, "Z Plane", ""},
476                 {0, NULL, 0, NULL, NULL}};
477
478         srna = RNA_def_struct(brna, "Brush", "ID");
479         RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting");
480         RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA);
481
482         /* enums */
483         prop = RNA_def_property(srna, "blend", PROP_ENUM, PROP_NONE);
484         RNA_def_property_enum_items(prop, prop_blend_items);
485         RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode");
486         RNA_def_property_update(prop, 0, "rna_Brush_update");
487
488         prop = RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE);
489         RNA_def_property_enum_items(prop, brush_sculpt_tool_items);
490         RNA_def_property_ui_text(prop, "Sculpt Tool", "");
491         RNA_def_property_update(prop, 0, "rna_Brush_sculpt_tool_update");
492
493         prop = RNA_def_property(srna, "vertex_tool", PROP_ENUM, PROP_NONE);
494         RNA_def_property_enum_sdna(prop, NULL, "vertexpaint_tool");
495         RNA_def_property_enum_items(prop, brush_vertex_tool_items);
496         RNA_def_property_ui_text(prop, "Vertex/Weight Paint Tool", "");
497         RNA_def_property_update(prop, 0, "rna_Brush_vertex_tool_update");
498         
499         prop = RNA_def_property(srna, "image_tool", PROP_ENUM, PROP_NONE);
500         RNA_def_property_enum_sdna(prop, NULL, "imagepaint_tool");
501         RNA_def_property_enum_items(prop, brush_image_tool_items);
502         RNA_def_property_ui_text(prop, "Image Paint Tool", "");
503         RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update");
504
505         prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
506         RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
507         RNA_def_property_enum_items(prop, prop_direction_items);
508         RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Brush_direction_itemf");
509         RNA_def_property_ui_text(prop, "Direction", "");
510         RNA_def_property_update(prop, 0, "rna_Brush_update");
511
512         prop = RNA_def_property(srna, "stroke_method", PROP_ENUM, PROP_NONE);
513         RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
514         RNA_def_property_enum_items(prop, brush_stroke_method_items);
515         RNA_def_property_ui_text(prop, "Stroke Method", "");
516         RNA_def_property_update(prop, 0, "rna_Brush_update");
517
518         prop = RNA_def_property(srna, "texture_angle_source_random", PROP_ENUM, PROP_NONE);
519         RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
520         RNA_def_property_enum_items(prop, texture_angle_source_items);
521         RNA_def_property_ui_text(prop, "Texture Angle Source", "");
522         RNA_def_property_update(prop, 0, "rna_Brush_update");
523
524         prop = RNA_def_property(srna, "texture_angle_source_no_random", PROP_ENUM, PROP_NONE);
525         RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
526         RNA_def_property_enum_items(prop, texture_angle_source_no_random_items);
527         RNA_def_property_ui_text(prop, "Texture Angle Source", "");
528         RNA_def_property_update(prop, 0, "rna_Brush_update");
529
530         prop = RNA_def_property(srna, "sculpt_plane", PROP_ENUM, PROP_NONE);
531         RNA_def_property_enum_items(prop, brush_sculpt_plane_items);
532         RNA_def_property_ui_text(prop, "Sculpt Plane", "");
533         RNA_def_property_update(prop, 0, "rna_Brush_update");
534         
535         /* number values */
536         prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE);
537         RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL);
538         RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10);
539         RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0);
540         RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels");
541         RNA_def_property_update(prop, 0, "rna_Brush_update");
542         
543         prop = RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE);
544         RNA_def_property_float_funcs(prop, NULL, "rna_Brush_set_unprojected_radius", NULL);
545         RNA_def_property_range(prop, 0.001, FLT_MAX);
546         RNA_def_property_ui_range(prop, 0.001, 1, 0, 0);
547         RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units");
548         RNA_def_property_update(prop, 0, "rna_Brush_update");
549
550         prop = RNA_def_property(srna, "jitter", PROP_FLOAT, PROP_NONE);
551         RNA_def_property_float_sdna(prop, NULL, "jitter");
552         RNA_def_property_range(prop, 0.0f, 1.0f);
553         RNA_def_property_ui_text(prop, "Jitter", "Jitter the position of the brush while painting");
554         RNA_def_property_update(prop, 0, "rna_Brush_update");
555
556         prop = RNA_def_property(srna, "spacing", PROP_INT, PROP_PERCENTAGE);
557         RNA_def_property_int_sdna(prop, NULL, "spacing");
558         RNA_def_property_range(prop, 1, 1000);
559         RNA_def_property_ui_range(prop, 1, 500, 5, 0);
560         RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush daubs as a percentage of brush diameter");
561         RNA_def_property_update(prop, 0, "rna_Brush_update");
562
563         prop = RNA_def_property(srna, "smooth_stroke_radius", PROP_INT, PROP_DISTANCE);
564         RNA_def_property_range(prop, 10, 200);
565         RNA_def_property_ui_text(prop, "Smooth Stroke Radius", "Minimum distance from last point before stroke continues");
566         RNA_def_property_update(prop, 0, "rna_Brush_update");
567
568         prop = RNA_def_property(srna, "smooth_stroke_factor", PROP_FLOAT, PROP_FACTOR);
569         RNA_def_property_range(prop, 0.5, 0.99);
570         RNA_def_property_ui_text(prop, "Smooth Stroke Factor", "Higher values give a smoother stroke");
571         RNA_def_property_update(prop, 0, "rna_Brush_update");
572         
573         prop = RNA_def_property(srna, "rate", PROP_FLOAT, PROP_NONE);
574         RNA_def_property_float_sdna(prop, NULL, "rate");
575         RNA_def_property_range(prop, 0.0001f , 10000.0f);
576         RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 3);
577         RNA_def_property_ui_text(prop, "Rate", "Interval between paints for Airbrush");
578         RNA_def_property_update(prop, 0, "rna_Brush_update");
579         
580         prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
581         RNA_def_property_range(prop, 0.0, 1.0);
582         RNA_def_property_float_sdna(prop, NULL, "rgb");
583         RNA_def_property_ui_text(prop, "Color", "");
584         RNA_def_property_update(prop, 0, "rna_Brush_update");
585         
586         prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
587         RNA_def_property_float_sdna(prop, NULL, "alpha");
588         RNA_def_property_float_default(prop, 0.5f);
589         RNA_def_property_range(prop, 0.0f, 10.0f);
590         RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 0.001);
591         RNA_def_property_ui_text(prop, "Strength", "How powerful the effect of the brush is when applied");
592         RNA_def_property_update(prop, 0, "rna_Brush_update");
593
594         prop = RNA_def_property(srna, "plane_offset", PROP_FLOAT, PROP_DISTANCE);
595         RNA_def_property_float_sdna(prop, NULL, "plane_offset");
596         RNA_def_property_float_default(prop, 0);
597         RNA_def_property_range(prop, -2.0f, 2.0f);
598         RNA_def_property_ui_range(prop, -0.5f, 0.5f, 0.001, 0.001);
599         RNA_def_property_ui_text(prop, "Plane Offset",
600                                  "Adjust plane on which the brush acts towards or away from the object surface");
601         RNA_def_property_update(prop, 0, "rna_Brush_update");
602
603         prop = RNA_def_property(srna, "plane_trim", PROP_FLOAT, PROP_DISTANCE);
604         RNA_def_property_float_sdna(prop, NULL, "plane_trim");
605         RNA_def_property_float_default(prop, 0.5f);
606         RNA_def_property_range(prop, 0, 1.0f);
607         RNA_def_property_ui_text(prop, "Plane Trim",
608                                  "If a vertex is further away from offset plane than this, then it is not affected");
609         RNA_def_property_update(prop, 0, "rna_Brush_update");
610
611         prop = RNA_def_property(srna, "height", PROP_FLOAT, PROP_DISTANCE);
612         RNA_def_property_float_sdna(prop, NULL, "height");
613         RNA_def_property_float_default(prop, 0.5f);
614         RNA_def_property_range(prop, 0, 1.0f);
615         RNA_def_property_ui_text(prop, "Brush Height", "Affectable height of brush (layer height for layer tool, i.e.)");
616         RNA_def_property_update(prop, 0, "rna_Brush_update");
617
618         prop = RNA_def_property(srna, "texture_sample_bias", PROP_FLOAT, PROP_DISTANCE);
619         RNA_def_property_float_sdna(prop, NULL, "texture_sample_bias");
620         RNA_def_property_float_default(prop, 0);
621         RNA_def_property_range(prop, -1, 1);
622         RNA_def_property_ui_text(prop, "Texture Sample Bias", "Value added to texture samples");
623         RNA_def_property_update(prop, 0, "rna_Brush_update");
624
625         prop = RNA_def_property(srna, "normal_weight", PROP_FLOAT, PROP_FACTOR);
626         RNA_def_property_float_sdna(prop, NULL, "normal_weight");
627         RNA_def_property_float_default(prop, 0);
628         RNA_def_property_range(prop, 0.0f, 1.0f);
629         RNA_def_property_ui_text(prop, "Normal Weight", "How much grab will pull vertexes out of surface during a grab");
630         RNA_def_property_update(prop, 0, "rna_Brush_update");
631
632         prop = RNA_def_property(srna, "crease_pinch_factor", PROP_FLOAT, PROP_FACTOR);
633         RNA_def_property_float_sdna(prop, NULL, "crease_pinch_factor");
634         RNA_def_property_float_default(prop, 2.0f/3.0f);
635         RNA_def_property_range(prop, 0.0f, 1.0f);
636         RNA_def_property_ui_text(prop, "Crease Brush Pinch Factor", "How much the crease brush pinches");
637         RNA_def_property_update(prop, 0, "rna_Brush_update");
638
639         prop = RNA_def_property(srna, "auto_smooth_factor", PROP_FLOAT, PROP_FACTOR);
640         RNA_def_property_float_sdna(prop, NULL, "autosmooth_factor");
641         RNA_def_property_float_default(prop, 0);
642         RNA_def_property_range(prop, 0.0f, 1.0f);
643         RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 0.001);
644         RNA_def_property_ui_text(prop, "Autosmooth", "Amount of smoothing to automatically apply to each stroke");
645         RNA_def_property_update(prop, 0, "rna_Brush_update");
646
647         /* flag */
648         prop = RNA_def_property(srna, "use_airbrush", PROP_BOOLEAN, PROP_NONE);
649         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH);
650         RNA_def_property_ui_text(prop, "Airbrush", "Keep applying paint effect while holding mouse (spray)");
651         RNA_def_property_update(prop, 0, "rna_Brush_update");
652         
653         prop = RNA_def_property(srna, "use_original_normal", PROP_BOOLEAN, PROP_NONE);
654         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ORIGINAL_NORMAL);
655         RNA_def_property_ui_text(prop, "Original Normal",
656                                  "When locked keep using normal of surface where stroke was initiated");
657         RNA_def_property_update(prop, 0, "rna_Brush_update");
658         
659         prop = RNA_def_property(srna, "use_wrap", PROP_BOOLEAN, PROP_NONE);
660         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_TORUS);
661         RNA_def_property_ui_text(prop, "Wrap", "Enable torus wrapping while painting");
662         RNA_def_property_update(prop, 0, "rna_Brush_update");
663         
664         prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
665         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ALPHA_PRESSURE);
666         RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
667         RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength");
668         RNA_def_property_update(prop, 0, "rna_Brush_update");
669         
670         prop = RNA_def_property(srna, "use_offset_pressure", PROP_BOOLEAN, PROP_NONE);
671         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_OFFSET_PRESSURE);
672         RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
673         RNA_def_property_ui_text(prop, "Plane Offset Pressure", "Enable tablet pressure sensitivity for offset");
674         RNA_def_property_update(prop, 0, "rna_Brush_update");
675
676         prop = RNA_def_property(srna, "use_pressure_size", PROP_BOOLEAN, PROP_NONE);
677         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SIZE_PRESSURE);
678         RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
679         RNA_def_property_ui_text(prop, "Size Pressure", "Enable tablet pressure sensitivity for size");
680         RNA_def_property_update(prop, 0, "rna_Brush_update");
681         
682         prop = RNA_def_property(srna, "use_pressure_jitter", PROP_BOOLEAN, PROP_NONE);
683         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_JITTER_PRESSURE);
684         RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
685         RNA_def_property_ui_text(prop, "Jitter Pressure", "Enable tablet pressure sensitivity for jitter");
686         RNA_def_property_update(prop, 0, "rna_Brush_update");
687
688         prop = RNA_def_property(srna, "use_pressure_spacing", PROP_BOOLEAN, PROP_NONE);
689         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACING_PRESSURE);
690         RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
691         RNA_def_property_ui_text(prop, "Spacing Pressure", "Enable tablet pressure sensitivity for spacing");
692         RNA_def_property_update(prop, 0, "rna_Brush_update");
693
694         prop = RNA_def_property(srna, "use_inverse_smooth_pressure", PROP_BOOLEAN, PROP_NONE);
695         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_INVERSE_SMOOTH_PRESSURE);
696         RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
697         RNA_def_property_ui_text(prop, "Inverse Smooth Pressure", "Lighter pressure causes more smoothing to be applied");
698         RNA_def_property_update(prop, 0, "rna_Brush_update");
699         
700         prop = RNA_def_property(srna, "use_rake", PROP_BOOLEAN, PROP_NONE);
701         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RAKE);
702         RNA_def_property_ui_text(prop, "Rake", "Rotate the brush texture to match the stroke direction");
703         RNA_def_property_update(prop, 0, "rna_Brush_update");
704
705         prop = RNA_def_property(srna, "use_random_rotation", PROP_BOOLEAN, PROP_NONE);
706         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RANDOM_ROTATION);
707         RNA_def_property_ui_text(prop, "Random Rotation", "Rotate the brush texture at random");
708         RNA_def_property_update(prop, 0, "rna_Brush_update");
709
710         prop = RNA_def_property(srna, "use_plane_trim", PROP_BOOLEAN, PROP_NONE);
711         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_PLANE_TRIM);
712         RNA_def_property_ui_text(prop, "Use Plane Trim", "Enable Plane Trim");
713         RNA_def_property_update(prop, 0, "rna_Brush_update");
714
715         prop = RNA_def_property(srna, "use_frontface", PROP_BOOLEAN, PROP_NONE);
716         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FRONTFACE);
717         RNA_def_property_ui_text(prop, "Use Front-Face", "Brush only affects vertexes that face the viewer");
718         RNA_def_property_update(prop, 0, "rna_Brush_update");
719
720         prop = RNA_def_property(srna, "use_anchor", PROP_BOOLEAN, PROP_NONE);
721         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ANCHORED);
722         RNA_def_property_ui_text(prop, "Anchored", "Keep the brush anchored to the initial location");
723         RNA_def_property_update(prop, 0, "rna_Brush_update");
724
725         prop = RNA_def_property(srna, "use_space", PROP_BOOLEAN, PROP_NONE);
726         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACE);
727         RNA_def_property_ui_text(prop, "Space", "Limit brush application to the distance specified by spacing");
728         RNA_def_property_update(prop, 0, "rna_Brush_update");
729
730         prop = RNA_def_property(srna, "use_smooth_stroke", PROP_BOOLEAN, PROP_NONE);
731         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SMOOTH_STROKE);
732         RNA_def_property_ui_text(prop, "Smooth Stroke", "Brush lags behind mouse and follows a smoother path");
733         RNA_def_property_update(prop, 0, "rna_Brush_update");
734
735         prop = RNA_def_property(srna, "use_persistent", PROP_BOOLEAN, PROP_NONE);
736         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_PERSISTENT);
737         RNA_def_property_ui_text(prop, "Persistent", "Sculpt on a persistent layer of the mesh");
738         RNA_def_property_update(prop, 0, "rna_Brush_update");
739
740         prop = RNA_def_property(srna, "use_accumulate", PROP_BOOLEAN, PROP_NONE);
741         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ACCUMULATE);
742         RNA_def_property_ui_text(prop, "Accumulate", "Accumulate stroke daubs on top of each other");
743         RNA_def_property_update(prop, 0, "rna_Brush_update");
744         
745         prop = RNA_def_property(srna, "use_space_attenuation", PROP_BOOLEAN, PROP_NONE);
746         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACE_ATTEN);
747         RNA_def_property_ui_text(prop, "Use Automatic Strength Adjustment",
748                                  "Automatically adjust strength to give consistent results for different spacings");
749         RNA_def_property_update(prop, 0, "rna_Brush_update");
750
751         /* adaptive space is not implemented yet */
752         prop = RNA_def_property(srna, "use_adaptive_space", PROP_BOOLEAN, PROP_NONE);
753         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ADAPTIVE_SPACE);
754         RNA_def_property_ui_text(prop, "Adaptive Spacing",
755                                  "Space daubs according to surface orientation instead of screen space");
756         RNA_def_property_update(prop, 0, "rna_Brush_update");
757
758         prop = RNA_def_property(srna, "use_locked_size", PROP_BOOLEAN, PROP_NONE);
759         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_LOCK_SIZE);
760         RNA_def_property_ui_text(prop, "Use Blender Units",
761                                  "When locked brush stays same size relative to object; when unlocked brush size is "
762                                  "given in pixels");
763         RNA_def_property_update(prop, 0, "rna_Brush_update");
764
765         prop = RNA_def_property(srna, "use_texture_overlay", PROP_BOOLEAN, PROP_NONE);
766         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_TEXTURE_OVERLAY);
767         RNA_def_property_ui_text(prop, "Use Texture Overlay", "Show texture in viewport");
768         RNA_def_property_update(prop, 0, "rna_Brush_update");
769
770         prop = RNA_def_property(srna, "use_edge_to_edge", PROP_BOOLEAN, PROP_NONE);
771         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_EDGE_TO_EDGE);
772         RNA_def_property_ui_text(prop, "Edge-to-edge", "Drag anchor brush from edge-to-edge");
773         RNA_def_property_update(prop, 0, "rna_Brush_update");
774
775         prop = RNA_def_property(srna, "use_restore_mesh", PROP_BOOLEAN, PROP_NONE);
776         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RESTORE_MESH);
777         RNA_def_property_ui_text(prop, "Restore Mesh", "Allow a single dot to be carefully positioned");
778         RNA_def_property_update(prop, 0, "rna_Brush_update");
779
780         prop = RNA_def_property(srna, "use_fixed_texture", PROP_BOOLEAN, PROP_NONE);
781         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FIXED_TEX);
782         RNA_def_property_ui_text(prop, "Fixed Texture", "Keep texture origin in fixed position");
783         RNA_def_property_update(prop, 0, "rna_Brush_update");
784         
785         /* only for projection paint, TODO, other paint modes */
786         prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
787         RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BRUSH_LOCK_ALPHA);
788         RNA_def_property_ui_text(prop, "Alpha", "When this is disabled, lock alpha while painting");
789         RNA_def_property_update(prop, 0, "rna_Brush_update");
790
791         prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
792         RNA_def_property_flag(prop, PROP_NEVER_NULL);
793         RNA_def_property_ui_text(prop, "Curve", "Editable falloff curve");
794         RNA_def_property_update(prop, 0, "rna_Brush_update");
795
796         /* paint mode flags */
797         prop = RNA_def_property(srna, "use_paint_sculpt", PROP_BOOLEAN, PROP_NONE);
798         RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_SCULPT);
799         RNA_def_property_ui_text(prop, "Use Sculpt", "Use this brush in sculpt mode");
800
801         prop = RNA_def_property(srna, "use_paint_vertex", PROP_BOOLEAN, PROP_NONE);
802         RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_VERTEX_PAINT);
803         RNA_def_property_ui_text(prop, "Use Vertex", "Use this brush in vertex paint mode");
804
805         prop = RNA_def_property(srna, "use_paint_weight", PROP_BOOLEAN, PROP_NONE);
806         RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_WEIGHT_PAINT);
807         RNA_def_property_ui_text(prop, "Use Weight", "Use this brush in weight paint mode");
808
809         prop = RNA_def_property(srna, "use_paint_image", PROP_BOOLEAN, PROP_NONE);
810         RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_TEXTURE_PAINT);
811         RNA_def_property_ui_text(prop, "Use Texture", "Use this brush in texture paint mode");
812
813         /* texture */
814         prop = RNA_def_property(srna, "texture_slot", PROP_POINTER, PROP_NONE);
815         RNA_def_property_struct_type(prop, "BrushTextureSlot");
816         RNA_def_property_pointer_sdna(prop, NULL, "mtex");
817         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
818         RNA_def_property_ui_text(prop, "Texture Slot", "");
819         
820         prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
821         RNA_def_property_pointer_sdna(prop, NULL, "mtex.tex");
822         RNA_def_property_flag(prop, PROP_EDITABLE);
823         RNA_def_property_ui_text(prop, "Texture", "");
824         RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_update");
825
826         prop = RNA_def_property(srna, "texture_overlay_alpha", PROP_INT, PROP_PERCENTAGE);
827         RNA_def_property_int_sdna(prop, NULL, "texture_overlay_alpha");
828         RNA_def_property_range(prop, 1, 100);
829         RNA_def_property_ui_text(prop, "Texture Overlay Alpha", "");
830         RNA_def_property_update(prop, 0, "rna_Brush_update");
831
832         prop = RNA_def_property(srna, "cursor_color_add", PROP_FLOAT, PROP_COLOR);
833         RNA_def_property_float_sdna(prop, NULL, "add_col");
834         RNA_def_property_array(prop, 3);
835         RNA_def_property_ui_text(prop, "Add Color", "Color of cursor when adding");
836         RNA_def_property_update(prop, 0, "rna_Brush_update");
837
838         prop = RNA_def_property(srna, "cursor_color_subtract", PROP_FLOAT, PROP_COLOR);
839         RNA_def_property_float_sdna(prop, NULL, "sub_col");
840         RNA_def_property_array(prop, 3);
841         RNA_def_property_ui_text(prop, "Subtract Color", "Color of cursor when subtracting");
842         RNA_def_property_update(prop, 0, "rna_Brush_update");
843
844         prop = RNA_def_property(srna, "use_custom_icon", PROP_BOOLEAN, PROP_NONE);
845         RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_CUSTOM_ICON);
846         RNA_def_property_ui_text(prop, "Custom Icon", "Set the brush icon from an image file");
847         RNA_def_property_update(prop, 0, "rna_Brush_icon_update");
848
849         prop = RNA_def_property(srna, "icon_filepath", PROP_STRING, PROP_FILEPATH);
850         RNA_def_property_string_sdna(prop, NULL, "icon_filepath");
851         RNA_def_property_ui_text(prop, "Brush Icon Filepath", "File path to brush icon");
852         RNA_def_property_update(prop, 0, "rna_Brush_icon_update");
853
854         /* clone tool */
855         prop = RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE);
856         RNA_def_property_pointer_sdna(prop, NULL, "clone.image");
857         RNA_def_property_flag(prop, PROP_EDITABLE);
858         RNA_def_property_ui_text(prop, "Clone Image", "Image for clone tool");
859         RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update");
860         
861         prop = RNA_def_property(srna, "clone_alpha", PROP_FLOAT, PROP_NONE);
862         RNA_def_property_float_sdna(prop, NULL, "clone.alpha");
863         RNA_def_property_range(prop, 0.0f, 1.0f);
864         RNA_def_property_ui_text(prop, "Clone Alpha", "Opacity of clone image display");
865         RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update");
866
867         prop = RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_XYZ);
868         RNA_def_property_float_sdna(prop, NULL, "clone.offset");
869         RNA_def_property_ui_text(prop, "Clone Offset", "");
870         RNA_def_property_ui_range(prop, -1.0f , 1.0f, 10.0f, 3);
871         RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update");
872
873         /* brush capabilities (mode-dependent) */
874         prop = RNA_def_property(srna, "sculpt_capabilities", PROP_POINTER, PROP_NONE);
875         RNA_def_property_flag(prop, PROP_NEVER_NULL);
876         RNA_def_property_struct_type(prop, "SculptCapabilities");
877         RNA_def_property_pointer_funcs(prop, "rna_Brush_sculpt_capabilities_get", NULL, NULL, NULL);
878         RNA_def_property_ui_text(prop, "Sculpt Capabilities", "Brush's capabilities in sculpt mode");
879 }
880
881
882 /* A brush stroke is a list of changes to the brush that
883  * can occur during a stroke
884  *
885  *  o 3D location of the brush
886  *  o 2D mouse location
887  *  o Tablet pressure
888  *  o Direction flip
889  *  o Tool switch
890  *  o Time
891  */
892 static void rna_def_operator_stroke_element(BlenderRNA *brna)
893 {
894         StructRNA *srna;
895         PropertyRNA *prop;
896
897         srna = RNA_def_struct(brna, "OperatorStrokeElement", "PropertyGroup");
898         RNA_def_struct_ui_text(srna, "Operator Stroke Element", "");
899
900         prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ);
901         RNA_def_property_flag(prop, PROP_IDPROPERTY);
902         RNA_def_property_array(prop, 3);
903         RNA_def_property_ui_text(prop, "Location", "");
904
905         prop = RNA_def_property(srna, "mouse", PROP_FLOAT, PROP_XYZ);
906         RNA_def_property_flag(prop, PROP_IDPROPERTY);
907         RNA_def_property_array(prop, 2);
908         RNA_def_property_ui_text(prop, "Mouse", "");
909
910         prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE);
911         RNA_def_property_flag(prop, PROP_IDPROPERTY);
912         RNA_def_property_range(prop, 0.0f, 1.0f);
913         RNA_def_property_ui_text(prop, "Pressure", "Tablet pressure");
914
915         prop = RNA_def_property(srna, "pen_flip", PROP_BOOLEAN, PROP_NONE);
916         RNA_def_property_flag(prop, PROP_IDPROPERTY);
917         RNA_def_property_ui_text(prop, "Flip", "");
918
919         /* used in uv painting */
920         prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
921         RNA_def_property_flag(prop, PROP_IDPROPERTY);
922         RNA_def_property_ui_text(prop, "Time", "");
923         
924         /* used for Grease Pencil sketching sessions */
925         prop = RNA_def_property(srna, "is_start", PROP_BOOLEAN, PROP_NONE);
926         RNA_def_property_flag(prop, PROP_IDPROPERTY);
927         RNA_def_property_ui_text(prop, "Is Stroke Start", "");
928
929         /* XXX: Tool (this will be for pressing a modifier key for a different brush,
930                         e.g. switching to a Smooth brush in the middle of the stroke */
931
932         /* XXX: i don't think blender currently supports the ability to properly do a remappable modifier
933          *      in the middle of a stroke */
934 }
935
936 void RNA_def_brush(BlenderRNA *brna)
937 {
938         rna_def_brush(brna);
939         rna_def_sculpt_capabilities(brna);
940         rna_def_brush_texture_slot(brna);
941         rna_def_operator_stroke_element(brna);
942 }
943
944 #endif