diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-07 00:42:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-07 00:43:56 +0300 |
commit | fb932bb52a65c147689f5940aa0f347066ba0547 (patch) | |
tree | 700b721559370d073ca83324400bc2415f91b797 /source/blender/makesrna/intern/rna_workspace_api.c | |
parent | 150864dfb95c7b39dfd491805156599609ab3e2a (diff) |
Cleanup: use BKE_brush_tool_get/set macros
Also add API call WM_toolsystem_ref_sync_from_context
(was in rna_workspace_api.c)
Diffstat (limited to 'source/blender/makesrna/intern/rna_workspace_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace_api.c | 62 |
1 files changed, 1 insertions, 61 deletions
diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c index 4cb74ac1479..fd268c898ff 100644 --- a/source/blender/makesrna/intern/rna_workspace_api.c +++ b/source/blender/makesrna/intern/rna_workspace_api.c @@ -75,67 +75,7 @@ static void rna_WorkspaceTool_refresh_from_context( bToolRef *tref, Main *bmain) { - bToolRef_Runtime *tref_rt = tref->runtime; - if ((tref_rt == NULL) || (tref_rt->data_block[0] == '\0')) { - return; - } - wmWindowManager *wm = bmain->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { - WorkSpace *workspace = WM_window_get_active_workspace(win); - if (&workspace->id == id) { - Scene *scene = WM_window_get_active_scene(win); - ToolSettings *ts = scene->toolsettings; - ViewLayer *view_layer = WM_window_get_active_view_layer(win); - Object *ob = OBACT(view_layer); - if (ob == NULL) { - /* pass */ - } - else if ((tref->space_type == SPACE_VIEW3D) && - (tref->mode == CTX_MODE_PARTICLE) && - (ob->mode & OB_MODE_PARTICLE_EDIT)) - { - const EnumPropertyItem *items = rna_enum_particle_edit_hair_brush_items; - const int i = RNA_enum_from_value(items, ts->particle.brushtype); - const EnumPropertyItem *item = &items[i]; - if (!STREQ(tref_rt->data_block, item->identifier)) { - STRNCPY(tref_rt->data_block, item->identifier); - STRNCPY(tref->idname, item->name); - } - } - else if ((tref->space_type == SPACE_IMAGE) && - (tref->mode == SI_MODE_UV) && - (ob->mode & - OB_MODE_EDIT)) - { - const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items; - const int i = RNA_enum_from_value(items, ts->uv_sculpt_tool); - const EnumPropertyItem *item = &items[i]; - if (!STREQ(tref_rt->data_block, item->identifier)) { - STRNCPY(tref_rt->data_block, item->identifier); - STRNCPY(tref->idname, item->name); - } - } - else { - 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; - 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); - } - } - } - } - } - } + WM_toolsystem_ref_sync_from_context(bmain, (WorkSpace *)id, tref); } static PointerRNA rna_WorkspaceTool_operator_properties( |