diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_toolsystem.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 350327e8590..0aa5e16a519 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -49,6 +49,7 @@ #include "BKE_workspace.h" #include "RNA_access.h" +#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" @@ -132,8 +133,8 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t bToolRef_Runtime *tref_rt = tref->runtime; if (tref_rt->gizmo_group[0]) { - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(tref_rt->gizmo_group, false); - if (wgt != NULL) { + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(tref_rt->gizmo_group, false); + if (gzgt != NULL) { bool found = false; /* TODO(campbell) */ @@ -154,8 +155,8 @@ static void toolsystem_unlink_ref(bContext *C, WorkSpace *workspace, bToolRef *t UNUSED_VARS(workspace); #endif if (!found) { - wmGizmoMapType *mmap_type = WM_gizmomaptype_ensure(&wgt->mmap_params); - WM_gizmomaptype_group_unlink(C, bmain, mmap_type, wgt); + wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&gzgt->gzmap_params); + WM_gizmomaptype_group_unlink(C, bmain, gzmap_type, gzgt); } } } @@ -173,9 +174,9 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre bToolRef_Runtime *tref_rt = tref->runtime; if (tref_rt->gizmo_group[0]) { const char *idname = tref_rt->gizmo_group; - wmGizmoGroupType *wgt = WM_gizmogrouptype_find(idname, false); - if (wgt != NULL) { - WM_gizmo_group_type_ensure_ptr(wgt); + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + if (gzgt != NULL) { + WM_gizmo_group_type_ensure_ptr(gzgt); } else { CLOG_WARN(WM_LOG_TOOLS, "'%s' widget not found", idname); @@ -184,20 +185,37 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre if (tref_rt->data_block[0]) { Main *bmain = CTX_data_main(C); + if ((tref->space_type == SPACE_VIEW3D) && + (tref->mode == CTX_MODE_PARTICLE)) - /* Currently only brush data-blocks supported. */ - struct Brush *brush = (struct Brush *)BKE_libblock_find_name(bmain, ID_BR, tref_rt->data_block); - - if (brush) { - wmWindowManager *wm = bmain->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { - if (workspace == WM_window_get_active_workspace(win)) { - Scene *scene = WM_window_get_active_scene(win); - ViewLayer *view_layer = WM_window_get_active_view_layer(win); - Paint *paint = BKE_paint_get_active(scene, view_layer); - if (paint) { - if (brush) { - BKE_paint_brush_set(paint, brush); + { + const EnumPropertyItem *items = rna_enum_particle_edit_hair_brush_items; + const int i = RNA_enum_from_identifier(items, tref_rt->data_block); + if (i != -1) { + const int value = items[i].value; + wmWindowManager *wm = bmain->wm.first; + for (wmWindow *win = wm->windows.first; win; win = win->next) { + if (workspace == WM_window_get_active_workspace(win)) { + Scene *scene = WM_window_get_active_scene(win); + ToolSettings *ts = scene->toolsettings; + ts->particle.brushtype = value; + } + } + } + } + else { + struct Brush *brush = (struct Brush *)BKE_libblock_find_name(bmain, ID_BR, tref_rt->data_block); + if (brush) { + wmWindowManager *wm = bmain->wm.first; + for (wmWindow *win = wm->windows.first; win; win = win->next) { + if (workspace == WM_window_get_active_workspace(win)) { + Scene *scene = WM_window_get_active_scene(win); + ViewLayer *view_layer = WM_window_get_active_view_layer(win); + Paint *paint = BKE_paint_get_active(scene, view_layer); + if (paint) { + if (brush) { + BKE_paint_brush_set(paint, brush); + } } } } |