Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-11-06 04:08:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-06 04:39:51 +0300
commita90bcdf93d82bf5d9964b12bb20af696ca66654e (patch)
treee57a15e78d957955db370ad8a8591d024de57b8f /source/blender/makesrna/intern/rna_workspace_api.c
parent29dfe9a61456dba8c8e4cdae0a90cfa3eef1cd2a (diff)
Tool System: use tool type enum to access brushes
Previously the brush names were used which had the limit that: - Brush names that were deleted wouldn't show up in the toolbar. - Naming collisions between user defined brushes and existing tools broke tool selection. Now brushes are created as needed when tools are selected. Note, vertex/weight paint combine tool and blend modes, this should be split out into a separate enum.
Diffstat (limited to 'source/blender/makesrna/intern/rna_workspace_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_workspace_api.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c
index 83ee5195fd8..4cb74ac1479 100644
--- a/source/blender/makesrna/intern/rna_workspace_api.c
+++ b/source/blender/makesrna/intern/rna_workspace_api.c
@@ -116,13 +116,20 @@ static void rna_WorkspaceTool_refresh_from_context(
}
}
else {
- Paint *paint = BKE_paint_get_active(scene, view_layer);
- if (paint) {
+ const ePaintMode paint_mode = BKE_paintmode_get_from_tool(tref);
+ Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode);
+ const EnumPropertyItem *items = BKE_paint_get_tool_enum_from_paintmode(paint_mode);
+ if (paint && paint->brush && items) {
const ID *brush = (ID *)paint->brush;
- if (brush) {
- if (!STREQ(tref_rt->data_block, brush->name + 2)) {
- STRNCPY(tref_rt->data_block, brush->name + 2);
- STRNCPY(tref->idname, brush->name + 2);
+ const char tool_type = *(char *)POINTER_OFFSET(brush, paint->runtime.tool_offset);
+ const int i = RNA_enum_from_value(items, tool_type);
+ /* Possible when loading files from the future. */
+ if (i != -1) {
+ const char *name = items[i].name;
+ const char *identifier = items[i].identifier;
+ if (!STREQ(tref_rt->data_block, identifier)) {
+ STRNCPY(tref_rt->data_block, identifier);
+ STRNCPY(tref->idname, name);
}
}
}