diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-29 15:30:09 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-29 15:30:09 +0300 |
commit | 6e76a35f07bb7e5c277347175804bb359b8f0477 (patch) | |
tree | 08b3ba9ddf39e7aadec5c838ecca9c2506e31756 /source/blender/windowmanager/intern | |
parent | f4ba7667dc34edc3fbd1118f8f0dbe818a8e7d43 (diff) |
Tool System: support data-blocks in tools
Needed so tools can set the active brush.
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 4c96afff9a1..67db38c13ed 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1828,6 +1828,7 @@ static int wm_operator_tool_set_exec(bContext *C, wmOperator *op) tool_def.spacetype = sa->spacetype; RNA_string_get(op->ptr, "keymap", tool_def.keymap); RNA_string_get(op->ptr, "manipulator_group", tool_def.manipulator_group); + RNA_string_get(op->ptr, "data_block", tool_def.data_block); WM_toolsystem_set(C, &tool_def); @@ -1849,6 +1850,7 @@ static void WM_OT_tool_set(wmOperatorType *ot) RNA_def_string(ot->srna, "keymap", NULL, KMAP_MAX_NAME, "Key Map", ""); RNA_def_string(ot->srna, "manipulator_group", NULL, MAX_NAME, "Manipulator Group", ""); + RNA_def_string(ot->srna, "data_block", NULL, MAX_NAME, "Data Block", ""); RNA_def_int(ot->srna, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX); } #endif /* USE_WORKSPACE_TOOL */ diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 22643c63368..7934d238cfb 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -37,6 +37,7 @@ #include "BKE_context.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_paint.h" #include "RNA_access.h" @@ -73,11 +74,19 @@ void WM_toolsystem_unlink(bContext *C, WorkSpace *workspace) } } -void WM_toolsystem_link(bContext *UNUSED(C), WorkSpace *workspace) +void WM_toolsystem_link(bContext *C, WorkSpace *workspace) { if (workspace->tool.manipulator_group[0]) { WM_manipulator_group_type_ensure(workspace->tool.manipulator_group); } + if (workspace->tool.data_block[0]) { + /* Currently only brush data-blocks supported. */ + Paint *p = BKE_paint_get_active_from_context(C); + struct Brush *brush = (struct Brush *)BKE_libblock_find_name(ID_BR, workspace->tool.data_block); + if (brush) { + BKE_paint_brush_set(p, brush); + } + } } void WM_toolsystem_set(bContext *C, const bToolDef *tool) @@ -92,6 +101,7 @@ void WM_toolsystem_set(bContext *C, const bToolDef *tool) if (&workspace->tool != tool) { BLI_strncpy(workspace->tool.keymap, tool->keymap, sizeof(tool->keymap)); BLI_strncpy(workspace->tool.manipulator_group, tool->manipulator_group, sizeof(tool->manipulator_group)); + BLI_strncpy(workspace->tool.data_block, tool->data_block, sizeof(tool->data_block)); workspace->tool.spacetype = tool->spacetype; } |