Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / sculpt_paint / paint_ops.c
index f03c119..3a8ab12 100644 (file)
@@ -47,6 +47,7 @@
 
 #include "WM_api.h"
 #include "WM_types.h"
+#include "WM_toolsystem.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -452,9 +453,23 @@ static int brush_select_exec(bContext *C, wmOperator *op)
                        return OPERATOR_CANCELLED;
        }
 
-       return brush_generic_tool_set(bmain, paint, tool, tool_offset,
-                                     paint_mode, tool_name, create_missing,
-                                     toggle);
+       /* TODO(campbell): Use the toolsystem for now, ideally the toolsystem will display brushes directly
+        * so we don't need to sync between tools and brushes. */
+       if (false) {
+               return brush_generic_tool_set(
+                           bmain, paint, tool, tool_offset,
+                           paint_mode, tool_name, create_missing,
+                           toggle);
+       }
+       else {
+               WorkSpace *workspace = CTX_wm_workspace(C);
+               if (WM_toolsystem_ref_set_by_name(C, workspace, NULL, tool_name, true)) {
+                       return OPERATOR_FINISHED;
+               }
+               else {
+                       return OPERATOR_CANCELLED;
+               }
+       }
 }
 
 static void PAINT_OT_brush_select(wmOperatorType *ot)
@@ -493,9 +508,10 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
        RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 }
 
-static wmKeyMapItem *keymap_brush_select(wmKeyMap *keymap, int paint_mode,
-                                         int tool, int keymap_type,
-                                         int keymap_modifier)
+static wmKeyMapItem *keymap_brush_select(
+        wmKeyMap *keymap, int paint_mode,
+        int tool, int keymap_type,
+        int keymap_modifier)
 {
        wmKeyMapItem *kmi;
        kmi = WM_keymap_add_item(keymap, "PAINT_OT_brush_select",
@@ -1035,7 +1051,6 @@ void ED_operatortypes_paint(void)
        WM_operatortype_append(PAINT_OT_image_from_view);
        WM_operatortype_append(PAINT_OT_brush_colors_flip);
        WM_operatortype_append(PAINT_OT_add_texture_paint_slot);
-       WM_operatortype_append(PAINT_OT_delete_texture_paint_slot);
        WM_operatortype_append(PAINT_OT_add_simple_uvs);
 
        /* weight */
@@ -1081,20 +1096,6 @@ void ED_operatortypes_paint(void)
        WM_operatortype_append(PAINT_OT_mask_lasso_gesture);
 }
 
-
-static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode)
-{
-       wmKeyMapItem *kmi;
-       int i;
-       /* index 0-9 (zero key is tenth), shift key for index 10-19 */
-       for (i = 0; i < 20; i++) {
-               kmi = WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set",
-                                        ZEROKEY + ((i + 1) % 10), KM_PRESS, i < 10 ? 0 : KM_SHIFT, 0);
-               RNA_string_set(kmi->ptr, "mode", mode);
-               RNA_int_set(kmi->ptr, "index", i);
-       }
-}
-
 static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path))
 {
        wmKeyMapItem *kmi;
@@ -1299,7 +1300,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        RNA_int_set(kmi->ptr, "level", -1);
        RNA_boolean_set(kmi->ptr, "relative", true);
 
-       ed_keymap_paint_brush_switch(keymap, "sculpt");
        ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size");
        ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION);
 
@@ -1339,7 +1339,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap,
                           "PAINT_OT_vertex_color_set", KKEY, KM_PRESS, KM_SHIFT, 0);
 
-       ed_keymap_paint_brush_switch(keymap, "vertex_paint");
        ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size");
        ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR | RC_COLOR_OVERRIDE | RC_ROTATION);
 
@@ -1372,7 +1371,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap,
                           "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
 
-       ed_keymap_paint_brush_switch(keymap, "weight_paint");
        ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size");
        ed_keymap_paint_brush_radial_control(keymap, "weight_paint", RC_WEIGHT);
 
@@ -1413,7 +1411,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SKEY, KM_PRESS, 0, 0);
 
-       ed_keymap_paint_brush_switch(keymap, "image_paint");
        ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size");
        ed_keymap_paint_brush_radial_control(
                keymap, "image_paint",