diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-07 02:54:14 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-07 02:54:56 +0300 |
commit | 895295a9f0cb85c7c48c395621b9c9d7e5fc78a3 (patch) | |
tree | f9621ae96c65433301ba2a8ba401d43ad0df68d4 /source/blender/editors | |
parent | 87a6aab2518ed391c755e3e7aeae9692f25569ae (diff) |
Paint: update shortcut detection for new logic
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_region_tooltip.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 4e1218c3b2f..6d3ba95fda5 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -56,6 +56,7 @@ #include "BKE_context.h" #include "BKE_screen.h" #include "BKE_library.h" +#include "BKE_paint.h" #include "WM_api.h" #include "WM_types.h" @@ -457,42 +458,37 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is } if (shortcut == NULL) { - int mode = CTX_data_mode_enum(C); + ePaintMode paint_mode = BKE_paintmode_get_active_from_context(C); const char *tool_attr = NULL; - uint tool_offset = 0; - switch (mode) { - case CTX_MODE_SCULPT: + switch (paint_mode) { + case ePaintSculpt: tool_attr = "sculpt_tool"; - tool_offset = offsetof(Brush, sculpt_tool); break; - case CTX_MODE_PAINT_VERTEX: + case ePaintVertex: tool_attr = "vertex_paint_tool"; - tool_offset = offsetof(Brush, vertexpaint_tool); break; - case CTX_MODE_PAINT_WEIGHT: + case ePaintWeight: tool_attr = "weight_paint_tool"; - tool_offset = offsetof(Brush, weightpaint_tool); break; - case CTX_MODE_PAINT_TEXTURE: + case ePaintTexture2D: + case ePaintTextureProjective: tool_attr = "texture_paint_tool"; - tool_offset = offsetof(Brush, imagepaint_tool); + paint_mode = ePaintTextureProjective; break; default: break; } if (tool_attr != NULL) { - struct Main *bmain = CTX_data_main(C); - Brush *brush = (Brush *)BKE_libblock_find_name(bmain, ID_BR, tool_name); - if (brush) { - Object *ob = CTX_data_active_object(C); + const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode); + const int i = RNA_enum_from_name(items, tool_name); + if (i != -1) { wmOperatorType *ot = WM_operatortype_find("paint.brush_select", true); - PointerRNA op_props; WM_operator_properties_create_ptr(&op_props, ot); - RNA_enum_set(&op_props, "paint_mode", ob->mode); - RNA_enum_set(&op_props, tool_attr, *(((char *)brush) + tool_offset)); + RNA_enum_set(&op_props, "paint_mode", paint_mode); + RNA_enum_set(&op_props, tool_attr, items[i].value); /* Check for direct access to the tool. */ char shortcut_brush[128] = ""; |