3 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * ***** END GPL LICENSE BLOCK *****
22 /** \file blender/editors/sculpt_paint/paint_ops.c
26 #include "MEM_guardedalloc.h"
29 #include "BLI_string.h"
30 #include "BLI_utildefines.h"
32 #include "DNA_object_types.h"
33 #include "DNA_scene_types.h"
34 #include "DNA_brush_types.h"
36 #include "BKE_brush.h"
37 #include "BKE_context.h"
38 #include "BKE_paint.h"
41 #include "ED_sculpt.h"
42 #include "ED_screen.h"
43 #include "UI_resources.h"
48 #include "RNA_access.h"
49 #include "RNA_define.h"
50 #include "RNA_enum_types.h"
52 #include "paint_intern.h"
53 #include "sculpt_intern.h"
60 static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
62 /*int type = RNA_enum_get(op->ptr, "type");*/
63 Paint *paint = paint_get_active(CTX_data_scene(C));
64 struct Brush *br = paint_brush(paint);
69 br = add_brush("Brush");
71 paint_brush_set(paint_get_active(CTX_data_scene(C)), br);
73 return OPERATOR_FINISHED;
76 static void BRUSH_OT_add(wmOperatorType *ot)
79 ot->name= "Add Brush";
80 ot->description= "Add brush by mode type";
81 ot->idname= "BRUSH_OT_add";
84 ot->exec= brush_add_exec;
87 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
91 static int brush_scale_size_exec(bContext *C, wmOperator *op)
93 Paint *paint= paint_get_active(CTX_data_scene(C));
94 struct Brush *brush= paint_brush(paint);
95 // Object *ob= CTX_data_active_object(C);
96 float scalar= RNA_float_get(op->ptr, "scalar");
101 const int old_size= brush_size(brush);
102 int size= (int)(scalar*old_size);
104 if (old_size == size) {
108 else if (scalar < 1) {
112 CLAMP(size, 1, 2000); // XXX magic number
114 brush_set_size(brush, size);
117 // unprojected radius
119 float unprojected_radius= scalar*brush_unprojected_radius(brush);
121 if (unprojected_radius < 0.001f) // XXX magic number
122 unprojected_radius= 0.001f;
124 brush_set_unprojected_radius(brush, unprojected_radius);
128 return OPERATOR_FINISHED;
131 static void BRUSH_OT_scale_size(wmOperatorType *ot)
134 ot->name= "Scale Sculpt/Paint Brush Size";
135 ot->description= "Change brush size by a scalar";
136 ot->idname= "BRUSH_OT_scale_size";
139 ot->exec= brush_scale_size_exec;
142 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
144 RNA_def_float(ot->srna, "scalar", 1, 0, 2, "Scalar", "Factor to scale brush size by", 0, 2);
147 static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op))
149 Scene *scene = CTX_data_scene(C);
150 Object *obact = CTX_data_active_object(C);
151 unsigned int paintcol = vpaint_get_current_col(scene->toolsettings->vpaint);
152 vpaint_fill(obact, paintcol);
154 ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
155 return OPERATOR_FINISHED;
158 static void PAINT_OT_vertex_color_set(wmOperatorType *ot)
161 ot->name= "Set Vertex Colors";
162 ot->idname= "PAINT_OT_vertex_color_set";
165 ot->exec= vertex_color_set_exec;
166 ot->poll= vertex_paint_mode_poll;
169 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
172 static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
174 Paint *paint = paint_get_active(CTX_data_scene(C));
175 struct Brush *brush = paint_brush(paint);
176 Object *ob = CTX_data_active_object(C);
178 if(!ob) return OPERATOR_CANCELLED;
180 if(ob->mode & OB_MODE_SCULPT)
181 brush_reset_sculpt(brush);
182 /* TODO: other modes */
184 return OPERATOR_FINISHED;
187 static void BRUSH_OT_reset(wmOperatorType *ot)
190 ot->name= "Reset Brush";
191 ot->description= "Return brush to defaults based on current tool";
192 ot->idname= "BRUSH_OT_reset";
195 ot->exec= brush_reset_exec;
198 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
201 /* generic functions for setting the active brush based on the tool */
202 static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode)
206 if(!brush_orig && !(brush_orig= bmain->brush.first)) {
210 /* get the next brush with the active tool */
211 for( brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first;
213 brush= brush->id.next ? brush->id.next : bmain->brush.first)
215 if( (brush->ob_mode & ob_mode) &&
216 (*(((char *)brush) + tool_offset) == tool)
226 static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, const size_t tool_offset, const int ob_mode)
228 struct Brush *brush, *brush_orig= paint_brush(paint);
230 brush= brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode);
233 paint_brush_set(paint, brush);
234 WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush);
235 return OPERATOR_FINISHED;
238 return OPERATOR_CANCELLED;
242 static int brush_sculpt_tool_set_exec(bContext *C, wmOperator *op)
244 Main *bmain= CTX_data_main(C);
245 Scene *scene= CTX_data_scene(C);
247 return brush_generic_tool_set(bmain, &scene->toolsettings->sculpt->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, sculpt_tool), OB_MODE_SCULPT);
250 static void BRUSH_OT_sculpt_tool_set(wmOperatorType *ot)
253 ot->name= "Sculpt Tool Set";
254 ot->description= "Set the sculpt tool";
255 ot->idname= "BRUSH_OT_sculpt_tool_set";
258 ot->exec= brush_sculpt_tool_set_exec;
261 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
264 ot->prop= RNA_def_enum(ot->srna, "tool", brush_sculpt_tool_items, 0, "Tool", "");
267 static int brush_vertex_tool_set_exec(bContext *C, wmOperator *op)
269 Main *bmain= CTX_data_main(C);
270 Scene *scene= CTX_data_scene(C);
272 return brush_generic_tool_set(bmain, &scene->toolsettings->vpaint->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, vertexpaint_tool), OB_MODE_VERTEX_PAINT);
275 static void BRUSH_OT_vertex_tool_set(wmOperatorType *ot)
278 ot->name= "Vertex Paint Tool Set";
279 ot->description= "Set the vertex paint tool";
280 ot->idname= "BRUSH_OT_vertex_tool_set";
283 ot->exec= brush_vertex_tool_set_exec;
286 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
289 ot->prop= RNA_def_enum(ot->srna, "tool", brush_vertex_tool_items, 0, "Tool", "");
292 static int brush_weight_tool_set_exec(bContext *C, wmOperator *op)
294 Main *bmain= CTX_data_main(C);
295 Scene *scene= CTX_data_scene(C);
296 /* vertexpaint_tool is used for weight paint mode */
297 return brush_generic_tool_set(bmain, &scene->toolsettings->wpaint->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, vertexpaint_tool), OB_MODE_WEIGHT_PAINT);
300 static void BRUSH_OT_weight_tool_set(wmOperatorType *ot)
303 ot->name= "Weight Paint Tool Set";
304 ot->description= "Set the weight paint tool";
305 ot->idname= "BRUSH_OT_weight_tool_set";
308 ot->exec= brush_weight_tool_set_exec;
311 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
314 ot->prop= RNA_def_enum(ot->srna, "tool", brush_vertex_tool_items, 0, "Tool", "");
317 static int brush_image_tool_set_exec(bContext *C, wmOperator *op)
319 Main *bmain= CTX_data_main(C);
320 Scene *scene= CTX_data_scene(C);
322 return brush_generic_tool_set(bmain, &scene->toolsettings->imapaint.paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, imagepaint_tool), OB_MODE_TEXTURE_PAINT);
325 static void BRUSH_OT_image_tool_set(wmOperatorType *ot)
328 ot->name= "Image Paint Tool Set";
329 ot->description= "Set the image tool";
330 ot->idname= "BRUSH_OT_image_tool_set";
333 ot->exec= brush_image_tool_set_exec;
336 ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
339 ot->prop= RNA_def_enum(ot->srna, "tool", brush_image_tool_items, 0, "Tool", "");
343 /**************************** registration **********************************/
345 void ED_operatortypes_paint(void)
348 WM_operatortype_append(BRUSH_OT_add);
349 WM_operatortype_append(BRUSH_OT_scale_size);
350 WM_operatortype_append(BRUSH_OT_curve_preset);
351 WM_operatortype_append(BRUSH_OT_reset);
353 /* note, particle uses a different system, can be added with existing operators in wm.py */
354 WM_operatortype_append(BRUSH_OT_sculpt_tool_set);
355 WM_operatortype_append(BRUSH_OT_vertex_tool_set);
356 WM_operatortype_append(BRUSH_OT_weight_tool_set);
357 WM_operatortype_append(BRUSH_OT_image_tool_set);
360 WM_operatortype_append(PAINT_OT_texture_paint_toggle);
361 WM_operatortype_append(PAINT_OT_image_paint);
362 WM_operatortype_append(PAINT_OT_sample_color);
363 WM_operatortype_append(PAINT_OT_grab_clone);
364 WM_operatortype_append(PAINT_OT_clone_cursor_set);
365 WM_operatortype_append(PAINT_OT_project_image);
366 WM_operatortype_append(PAINT_OT_image_from_view);
369 WM_operatortype_append(PAINT_OT_weight_paint_toggle);
370 WM_operatortype_append(PAINT_OT_weight_paint);
371 WM_operatortype_append(PAINT_OT_weight_set);
372 WM_operatortype_append(PAINT_OT_weight_from_bones);
375 WM_operatortype_append(PAINT_OT_vertex_paint_toggle);
376 WM_operatortype_append(PAINT_OT_vertex_paint);
377 WM_operatortype_append(PAINT_OT_vertex_color_set);
380 WM_operatortype_append(PAINT_OT_face_select_linked);
381 WM_operatortype_append(PAINT_OT_face_select_linked_pick);
382 WM_operatortype_append(PAINT_OT_face_select_all);
383 WM_operatortype_append(PAINT_OT_face_select_inverse);
384 WM_operatortype_append(PAINT_OT_face_select_hide);
385 WM_operatortype_append(PAINT_OT_face_select_reveal);
389 static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode)
393 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, 0, 0);
394 RNA_string_set(kmi->ptr, "mode", mode);
395 RNA_int_set(kmi->ptr, "index", 0);
396 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, 0, 0);
397 RNA_string_set(kmi->ptr, "mode", mode);
398 RNA_int_set(kmi->ptr, "index", 1);
399 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, 0, 0);
400 RNA_string_set(kmi->ptr, "mode", mode);
401 RNA_int_set(kmi->ptr, "index", 2);
402 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, 0, 0);
403 RNA_string_set(kmi->ptr, "mode", mode);
404 RNA_int_set(kmi->ptr, "index", 3);
405 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, 0, 0);
406 RNA_string_set(kmi->ptr, "mode", mode);
407 RNA_int_set(kmi->ptr, "index", 4);
408 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, 0, 0);
409 RNA_string_set(kmi->ptr, "mode", mode);
410 RNA_int_set(kmi->ptr, "index", 5);
411 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, 0, 0);
412 RNA_string_set(kmi->ptr, "mode", mode);
413 RNA_int_set(kmi->ptr, "index", 6);
414 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, 0, 0);
415 RNA_string_set(kmi->ptr, "mode", mode);
416 RNA_int_set(kmi->ptr, "index", 7);
417 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, 0, 0);
418 RNA_string_set(kmi->ptr, "mode", mode);
419 RNA_int_set(kmi->ptr, "index", 8);
420 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, 0, 0);
421 RNA_string_set(kmi->ptr, "mode", mode);
422 RNA_int_set(kmi->ptr, "index", 9);
423 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, KM_SHIFT, 0);
424 RNA_string_set(kmi->ptr, "mode", mode);
425 RNA_int_set(kmi->ptr, "index", 10);
426 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, KM_SHIFT, 0);
427 RNA_string_set(kmi->ptr, "mode", mode);
428 RNA_int_set(kmi->ptr, "index", 11);
429 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, KM_SHIFT, 0);
430 RNA_string_set(kmi->ptr, "mode", mode);
431 RNA_int_set(kmi->ptr, "index", 12);
432 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, KM_SHIFT, 0);
433 RNA_string_set(kmi->ptr, "mode", mode);
434 RNA_int_set(kmi->ptr, "index", 13);
435 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, KM_SHIFT, 0);
436 RNA_string_set(kmi->ptr, "mode", mode);
437 RNA_int_set(kmi->ptr, "index", 14);
438 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, KM_SHIFT, 0);
439 RNA_string_set(kmi->ptr, "mode", mode);
440 RNA_int_set(kmi->ptr, "index", 15);
441 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, KM_SHIFT, 0);
442 RNA_string_set(kmi->ptr, "mode", mode);
443 RNA_int_set(kmi->ptr, "index", 16);
444 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, KM_SHIFT, 0);
445 RNA_string_set(kmi->ptr, "mode", mode);
446 RNA_int_set(kmi->ptr, "index", 17);
447 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, KM_SHIFT, 0);
448 RNA_string_set(kmi->ptr, "mode", mode);
449 RNA_int_set(kmi->ptr, "index", 18);
450 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, KM_SHIFT, 0);
451 RNA_string_set(kmi->ptr, "mode", mode);
452 RNA_int_set(kmi->ptr, "index", 19);
455 static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path))
459 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", LEFTBRACKETKEY, KM_PRESS, 0, 0);
460 RNA_float_set(kmi->ptr, "scalar", 0.9);
462 kmi= WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
463 RNA_float_set(kmi->ptr, "scalar", 10.0/9.0); // 1.1111....
472 static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
473 const char *output_name, const char *input_name)
477 path = BLI_sprintfN("%s.%s", brush_path, input_name);
478 RNA_string_set(ptr, output_name, path);
482 static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
483 const char *prop, RCFlags flags)
487 brush_path = BLI_sprintfN("tool_settings.%s.brush", paint);
489 set_brush_rc_path(ptr, brush_path, "data_path", prop);
490 set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add");
491 set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle");
492 RNA_string_set(ptr, "image_id", brush_path);
495 set_brush_rc_path(ptr, brush_path, "fill_color_path", "color");
497 RNA_string_set(ptr, "zoom_path", "space_data.zoom");
499 MEM_freeN(brush_path);
502 static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint,
507 kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
508 set_brush_rc_props(kmi->ptr, paint, "size", flags);
510 kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
511 set_brush_rc_props(kmi->ptr, paint, "strength", flags);
513 if(flags & RC_ROTATION) {
514 kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0);
515 set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", flags);
519 void ED_keymap_paint(wmKeyConfig *keyconf)
526 keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0);
527 keymap->poll= sculpt_poll;
529 RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL);
530 RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT);
531 RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH);
534 RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
536 /* multires switch */
537 kmi= WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEUPKEY, KM_PRESS, 0, 0);
538 RNA_int_set(kmi->ptr, "level", 1);
539 RNA_boolean_set(kmi->ptr, "relative", 1);
541 kmi= WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEDOWNKEY, KM_PRESS, 0, 0);
542 RNA_int_set(kmi->ptr, "level", -1);
543 RNA_boolean_set(kmi->ptr, "relative", 1);
545 ed_keymap_paint_brush_switch(keymap, "sculpt");
546 ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size");
547 ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION);
549 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", DKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_DRAW);
550 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", SKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_SMOOTH);
551 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", PKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_PINCH);
552 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", IKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_INFLATE);
553 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", GKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_GRAB);
554 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", LKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_LAYER);
555 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", TKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "tool", SCULPT_TOOL_FLATTEN); /* was just TKEY in 2.4x */
556 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", CKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_CLAY);
557 RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", CKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "tool", SCULPT_TOOL_CREASE);
560 kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0);
561 RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.stroke_method");
563 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SKEY, KM_PRESS, KM_SHIFT, 0);
564 RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.use_smooth_stroke");
566 kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", RKEY, KM_PRESS, 0, 0);
567 RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.texture_angle_source_random");
569 /* Vertex Paint mode */
570 keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0);
571 keymap->poll= vertex_paint_mode_poll;
573 WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0);
574 WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
576 WM_keymap_add_item(keymap,
577 "PAINT_OT_vertex_color_set",KKEY, KM_PRESS, KM_SHIFT, 0);
579 ed_keymap_paint_brush_switch(keymap, "vertex_paint");
580 ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size");
581 ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR);
583 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
584 RNA_string_set(kmi->ptr, "data_path", "vertex_paint_object.data.use_paint_mask");
586 /* Weight Paint mode */
587 keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0);
588 keymap->poll= weight_paint_mode_poll;
590 WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0);
592 WM_keymap_add_item(keymap,
593 "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
595 ed_keymap_paint_brush_switch(keymap, "weight_paint");
596 ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size");
597 ed_keymap_paint_brush_radial_control(keymap, "weight_paint", 0);
599 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
600 RNA_string_set(kmi->ptr, "data_path", "weight_paint_object.data.use_paint_mask");
602 WM_keymap_verify_item(keymap, "PAINT_OT_weight_from_bones", WKEY, KM_PRESS, 0, 0);
604 /* Image/Texture Paint mode */
605 keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0);
606 keymap->poll= image_texture_paint_poll;
608 WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0);
609 WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0);
610 WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
611 WM_keymap_add_item(keymap, "PAINT_OT_clone_cursor_set", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
613 ed_keymap_paint_brush_switch(keymap, "image_paint");
614 ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size");
615 ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR|RC_ZOOM);
617 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
618 RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask");
621 keymap= WM_keymap_find(keyconf, "Face Mask", 0, 0);
622 keymap->poll= facemask_paint_poll;
624 WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, 0, 0);
625 WM_keymap_add_item(keymap, "PAINT_OT_face_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
626 WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, 0, 0);
627 RNA_boolean_set(WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
628 WM_keymap_add_item(keymap, "PAINT_OT_face_select_reveal", HKEY, KM_PRESS, KM_ALT, 0);
630 WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
631 WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked_pick", LKEY, KM_PRESS, 0, 0);