diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-02 08:39:20 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-02 08:39:20 +0300 |
commit | dce12293d0dbaf0ae1e2ea90dc46ae7e40763f31 (patch) | |
tree | b5d8d133e5b6fc150efd9389100882da28cd11f3 /source | |
parent | 0e7a592c3c16bfb77ca9410a49d00d416406bdec (diff) |
WM: generalize tool property initialization
Prepare for storing different kinds of properties in tools.
Diffstat (limited to 'source')
4 files changed, 15 insertions, 9 deletions
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c index 0f3046f19cb..5212d36a5a2 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c @@ -266,7 +266,7 @@ static void gizmo_mesh_spin_init_draw_prepare( { PointerRNA ptr; bToolRef *tref = WM_toolsystem_ref_from_context((bContext *)C); - WM_toolsystem_ref_properties_ensure(tref, ggd->data.ot_spin, &ptr); + WM_toolsystem_ref_properties_ensure_from_operator(tref, ggd->data.ot_spin, &ptr); const int axis_flag = RNA_property_enum_get(&ptr, ggd->data.ot_spin_gizmo_axis_prop); for (int i = 0; i < 4; i++) { bool hide = (axis_flag & (1 << i)) == 0; @@ -410,7 +410,7 @@ static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgrou { PointerRNA ptr; bToolRef *tref = WM_toolsystem_ref_from_context((bContext *)C); - WM_toolsystem_ref_properties_ensure(tref, ggd->data.ot_spin, &ptr); + WM_toolsystem_ref_properties_ensure_from_operator(tref, ggd->data.ot_spin, &ptr); const int axis_flag = RNA_property_enum_get(&ptr, ggd->data.ot_spin_gizmo_axis_prop); for (int i = 0; i < ARRAY_SIZE(ggd->gizmos.icon_button); i++) { for (int j = 0; j < 2; j++) { diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c index 78e617450e8..331a8e77637 100644 --- a/source/blender/makesrna/intern/rna_workspace_api.c +++ b/source/blender/makesrna/intern/rna_workspace_api.c @@ -124,7 +124,7 @@ static PointerRNA rna_WorkspaceTool_operator_properties( if (ot != NULL) { PointerRNA ptr; - WM_toolsystem_ref_properties_ensure(tref, ot, &ptr); + WM_toolsystem_ref_properties_ensure_from_operator(tref, ot, &ptr); return ptr; } else { diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index f4505bef962..6203b9c80d1 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -40,6 +40,7 @@ struct wmOperatorType; struct PointerRNA; struct ScrArea; struct Main; +struct StructRNA; /* wm_toolsystem.c */ @@ -88,7 +89,11 @@ void WM_toolsystem_do_msg_notify_tag_refresh( struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val); struct IDProperty *WM_toolsystem_ref_properties_ensure_idprops(struct bToolRef *tref); -void WM_toolsystem_ref_properties_ensure(struct bToolRef *tref, struct wmOperatorType *ot, struct PointerRNA *ptr); +void WM_toolsystem_ref_properties_ensure_ex( + struct bToolRef *tref, const char *idname, struct StructRNA *type, struct PointerRNA *r_ptr); + +#define WM_toolsystem_ref_properties_ensure_from_operator(tref, ot, r_ptr) \ + WM_toolsystem_ref_properties_ensure_ex(tref, (ot)->idname, (ot)->srna, r_ptr) void WM_toolsystem_ref_properties_init_for_keymap( struct bToolRef *tref, struct PointerRNA *dst_ptr, struct PointerRNA *src_ptr, struct wmOperatorType *ot); diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index a0859c8aa4b..ecbcc31c56f 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -632,21 +632,22 @@ IDProperty *WM_toolsystem_ref_properties_ensure_idprops(bToolRef *tref) return tref->properties; } -void WM_toolsystem_ref_properties_ensure(bToolRef *tref, wmOperatorType *ot, PointerRNA *ptr) + +void WM_toolsystem_ref_properties_ensure_ex(bToolRef *tref, const char *idname, StructRNA *type, PointerRNA *r_ptr) { IDProperty *group = WM_toolsystem_ref_properties_ensure_idprops(tref); - IDProperty *prop = IDP_GetPropertyFromGroup(group, ot->idname); + IDProperty *prop = IDP_GetPropertyFromGroup(group, idname); if (prop == NULL) { IDPropertyTemplate val = {0}; - prop = IDP_New(IDP_GROUP, &val, "wmOperatorProperties"); - STRNCPY(prop->name, ot->idname); + prop = IDP_New(IDP_GROUP, &val, "wmGenericProperties"); + STRNCPY(prop->name, idname); IDP_ReplaceInGroup_ex(group, prop, NULL); } else { BLI_assert(prop->type == IDP_GROUP); } - RNA_pointer_create(NULL, ot->srna, prop, ptr); + RNA_pointer_create(NULL, type, prop, r_ptr); } void WM_toolsystem_ref_properties_init_for_keymap( |