WM: generalize tool property initialization
Prepare for storing different kinds of properties in tools.
This commit is contained in:
@@ -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++) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user