2.5/Paint:
[blender-staging.git] / source / blender / editors / sculpt_paint / paint_ops.c
1 /**
2  *
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place - Suite 330, Boston, MA        02111-1307, USA.
18  *
19  * ***** END GPL LICENSE BLOCK *****
20  */
21
22 #include "DNA_brush_types.h"
23 #include "DNA_object_types.h"
24 #include "DNA_scene_types.h"
25
26 #include "BKE_brush.h"
27 #include "BKE_context.h"
28 #include "BKE_paint.h"
29
30 #include "ED_sculpt.h"
31 #include "UI_resources.h"
32
33 #include "WM_api.h"
34 #include "WM_types.h"
35
36 #include "RNA_access.h"
37 #include "RNA_define.h"
38 #include "RNA_enum_types.h"
39
40 #include "paint_intern.h"
41
42 #include <string.h>
43
44 /* Brush operators */
45 static int brush_add_exec(bContext *C, wmOperator *op)
46 {
47         /*int type = RNA_enum_get(op->ptr, "type");*/
48         Brush *br = NULL;
49
50         br = add_brush("Brush");
51
52         if(br)
53                 paint_brush_set(paint_get_active(CTX_data_scene(C)), br);
54         
55         return OPERATOR_FINISHED;
56 }
57
58 static EnumPropertyItem brush_type_items[] = {
59         {OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt", ""},
60         {OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
61         {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
62         {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
63         {0, NULL, 0, NULL, NULL}};
64
65 void BRUSH_OT_add(wmOperatorType *ot)
66 {
67         /* identifiers */
68         ot->name= "Add Brush";
69         ot->idname= "BRUSH_OT_add";
70         
71         /* api callbacks */
72         ot->exec= brush_add_exec;
73         
74         /* flags */
75         ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
76
77         RNA_def_enum(ot->srna, "type", brush_type_items, OB_MODE_VERTEX_PAINT, "Type", "Which paint mode to create the brush for.");
78 }
79
80 /**************************** registration **********************************/
81
82 void ED_operatortypes_paint(void)
83 {
84         /* brush */
85         WM_operatortype_append(BRUSH_OT_add);
86         WM_operatortype_append(BRUSH_OT_curve_preset);
87
88         /* image */
89         WM_operatortype_append(PAINT_OT_texture_paint_toggle);
90         WM_operatortype_append(PAINT_OT_texture_paint_radial_control);
91         WM_operatortype_append(PAINT_OT_image_paint);
92         WM_operatortype_append(PAINT_OT_image_paint_radial_control);
93         WM_operatortype_append(PAINT_OT_sample_color);
94         WM_operatortype_append(PAINT_OT_grab_clone);
95         WM_operatortype_append(PAINT_OT_clone_cursor_set);
96
97         /* weight */
98         WM_operatortype_append(PAINT_OT_weight_paint_toggle);
99         WM_operatortype_append(PAINT_OT_weight_paint_radial_control);
100         WM_operatortype_append(PAINT_OT_weight_paint);
101
102         /* vertex */
103         WM_operatortype_append(PAINT_OT_vertex_paint_radial_control);
104         WM_operatortype_append(PAINT_OT_vertex_paint_toggle);
105         WM_operatortype_append(PAINT_OT_vertex_paint);
106 }
107