diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_gizmo.c | 34 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace_api.c | 27 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_gizmo_wrap.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_toolsystem.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/gizmo/WM_gizmo_types.h | 8 | ||||
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c | 10 |
7 files changed, 80 insertions, 15 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 1278f27af75..ccce54227fe 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -372,6 +372,7 @@ extern StructRNA RNA_LockedTrackConstraint; extern StructRNA RNA_Macro; extern StructRNA RNA_MagicTexture; extern StructRNA RNA_Gizmo; +extern StructRNA RNA_GizmoGroupProperties; extern StructRNA RNA_GizmoProperties; extern StructRNA RNA_MarbleTexture; extern StructRNA RNA_MaskModifier; diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index 494c988a467..41e3929e8ae 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -548,6 +548,34 @@ static StructRNA *rna_Gizmo_refine(PointerRNA *mnp_ptr) /** \name Gizmo Group API * \{ */ +static wmGizmoGroupType *rna_GizmoGroupProperties_find_gizmo_group_type(PointerRNA *ptr) +{ + IDProperty *properties = (IDProperty *)ptr->data; + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(properties->name, false); + return gzgt; +} + +static StructRNA *rna_GizmoGroupProperties_refine(PointerRNA *ptr) +{ + wmGizmoGroupType *gzgt = rna_GizmoGroupProperties_find_gizmo_group_type(ptr); + + if (gzgt) + return gzgt->srna; + else + return ptr->type; +} + +static IDProperty *rna_GizmoGroupProperties_idprops(PointerRNA *ptr, bool create) +{ + if (create && !ptr->data) { + IDPropertyTemplate val = {0}; + ptr->data = IDP_New(IDP_GROUP, &val, "RNA_GizmoGroupProperties group"); + } + + return ptr->data; +} + + static wmGizmo *rna_GizmoGroup_gizmo_new( wmGizmoGroup *gzgroup, ReportList *reports, const char *idname) { @@ -1364,6 +1392,12 @@ static void rna_def_gizmogroup(BlenderRNA *brna) RNA_define_verify_sdna(1); /* not in sdna */ RNA_api_gizmogroup(srna); + + srna = RNA_def_struct(brna, "GizmoGroupProperties", NULL); + RNA_def_struct_ui_text(srna, "Gizmo Group Properties", "Input properties of a Gizmo Group"); + RNA_def_struct_refine_func(srna, "rna_GizmoGroupProperties_refine"); + RNA_def_struct_idprops_func(srna, "rna_GizmoGroupProperties_idprops"); + RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); } void RNA_def_wm_gizmo(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c index 331a8e77637..898dc296299 100644 --- a/source/blender/makesrna/intern/rna_workspace_api.c +++ b/source/blender/makesrna/intern/rna_workspace_api.c @@ -133,6 +133,23 @@ static PointerRNA rna_WorkspaceTool_operator_properties( return PointerRNA_NULL; } +static PointerRNA rna_WorkspaceTool_gizmo_group_properties( + bToolRef *tref, + ReportList *reports, + const char *idname) +{ + wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(idname, false); + if (gzgt != NULL) { + PointerRNA ptr; + WM_toolsystem_ref_properties_ensure_from_gizmo_group(tref, gzgt, &ptr); + return ptr; + } + else { + BKE_reportf(reports, RPT_ERROR, "Gizmo group '%s' not found!", idname); + } + return PointerRNA_NULL; +} + #else void RNA_api_workspace(StructRNA *srna) @@ -176,6 +193,16 @@ void RNA_api_workspace_tool(StructRNA *srna) RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); RNA_def_function_return(func, parm); + /* Access gizmo-group options (optionally create). */ + func = RNA_def_function(srna, "gizmo_group_properties", "rna_WorkspaceTool_gizmo_group_properties"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_string(func, "group", NULL, 0, "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return */ + parm = RNA_def_pointer(func, "result", "GizmoGroupProperties", "", ""); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR); + RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "refresh_from_context", "rna_WorkspaceTool_refresh_from_context"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN); } diff --git a/source/blender/python/intern/bpy_gizmo_wrap.c b/source/blender/python/intern/bpy_gizmo_wrap.c index 2a932cb6a99..411822ee4da 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.c +++ b/source/blender/python/intern/bpy_gizmo_wrap.c @@ -192,37 +192,30 @@ void BPY_RNA_gizmo_wrapper(wmGizmoType *gzt, void *userdata) static void gizmogroup_properties_init(wmGizmoGroupType *gzgt) { -#ifdef USE_SRNA PyTypeObject *py_class = gzgt->ext.data; -#endif RNA_struct_blender_type_set(gzgt->ext.srna, gzgt); -#ifdef USE_SRNA /* only call this so pyrna_deferred_register_class gives a useful error * WM_operatortype_append_ptr will call RNA_def_struct_identifier * later */ - RNA_def_struct_identifier(gzgt->srna, gzgt->idname); + RNA_def_struct_identifier_no_struct_map(gzgt->srna, gzgt->idname); if (pyrna_deferred_register_class(gzgt->srna, py_class) != 0) { PyErr_Print(); /* failed to register operator props */ PyErr_Clear(); } -#endif } void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata) { /* take care not to overwrite anything set in * WM_gizmomaptype_group_link_ptr before opfunc() is called */ -#ifdef USE_SRNA StructRNA *srna = gzgt->srna; -#endif *gzgt = *((wmGizmoGroupType *)userdata); -#ifdef USE_SRNA gzgt->srna = srna; /* restore */ -#endif -#ifdef USE_SRNA + /* don't do translations here yet */ +#if 0 /* Use i18n context from ext.srna if possible (py gizmogroups). */ if (gzgt->ext.srna) { RNA_def_struct_translation_context(gzgt->srna, RNA_struct_translation_context(gzgt->ext.srna)); diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 6203b9c80d1..af9551606da 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -94,6 +94,8 @@ void WM_toolsystem_ref_properties_ensure_ex( #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) +#define WM_toolsystem_ref_properties_ensure_from_gizmo_group(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/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index dc3e77eb130..c92172dff15 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -389,11 +389,11 @@ typedef struct wmGizmoGroupType { /* Only for convenient removal. */ struct wmKeyConfig *keyconf; - /* Disable for now, maybe some day we want properties. */ -#if 0 - /* rna for properties */ + /* Note: currently gizmo-group instances don't store properties, + * they're kept in the tool properties. */ + + /* RNA for properties */ struct StructRNA *srna; -#endif /* RNA integration */ ExtensionRNA ext; diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c index a44005a7d28..655d38a5206 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.c @@ -32,6 +32,7 @@ #include "MEM_guardedalloc.h" #include "RNA_access.h" +#include "RNA_define.h" #include "WM_api.h" #include "WM_types.h" @@ -83,7 +84,12 @@ void WM_gizmogrouptype_iter(GHashIterator *ghi) static wmGizmoGroupType *wm_gizmogrouptype_append__begin(void) { wmGizmoGroupType *gzgt = MEM_callocN(sizeof(wmGizmoGroupType), "gizmogrouptype"); - + gzgt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoGroupProperties); +#if 0 + /* Set the default i18n context now, so that opfunc can redefine it if needed! */ + RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; +#endif return gzgt; } static void wm_gizmogrouptype_append__end(wmGizmoGroupType *gzgt) @@ -91,6 +97,8 @@ static void wm_gizmogrouptype_append__end(wmGizmoGroupType *gzgt) BLI_assert(gzgt->name != NULL); BLI_assert(gzgt->idname != NULL); + RNA_def_struct_identifier(&BLENDER_RNA, gzgt->srna, gzgt->idname); + gzgt->type_update_flag |= WM_GIZMOMAPTYPE_KEYMAP_INIT; /* if not set, use default */ |