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/blender/windowmanager | |
parent | 0e7a592c3c16bfb77ca9410a49d00d416406bdec (diff) |
WM: generalize tool property initialization
Prepare for storing different kinds of properties in tools.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_toolsystem.h | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 11 |
2 files changed, 12 insertions, 6 deletions
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( |