diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-11-16 20:50:59 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-12-04 12:23:41 +0300 |
commit | b3f388dca9e547c12db277b8422c620ca3b64eaa (patch) | |
tree | ffbf14c7371ef7dd96ac49cb0c6e1810c1708f6f /source/blender/makesrna | |
parent | fda791ab1241534e377bee84b3a214e1343094af (diff) |
UI: support Copy To Selected and Alt-Click for PropertyGroup members.
Rigify uses a property group to contain options of its rigs, so
currently it is impossible to use Alt-Click or Copy To Selected
to change a setting for multiple rigs at the same time.
The main problem here is that there is no efficient way to find
which bone the property group belongs to. To maintain performance,
implement this by checking the active bone if it is known. Copy
Data Path and related features still don't work, as data path
calculation can't use context.
Differential Revision: https://developer.blender.org/D6264
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 30 |
2 files changed, 23 insertions, 10 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 5bf6fb40c6a..7fe88ec94b7 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -40,6 +40,7 @@ struct Main; struct ReportList; struct Scene; struct bContext; +struct IDProperty; /* Types */ extern BlenderRNA BLENDER_RNA; @@ -1156,6 +1157,8 @@ struct PropertyElemRNA { }; bool RNA_path_resolve_elements(PointerRNA *ptr, const char *path, struct ListBase *r_elements); +char *RNA_path_from_struct_to_idproperty(PointerRNA *ptr, struct IDProperty *needle); + struct ID *RNA_find_real_ID_and_path(struct Main *bmain, struct ID *id, const char **r_path); char *RNA_path_from_ID_to_struct(PointerRNA *ptr); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 78cd99837c3..d8889455ac7 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -5738,11 +5738,28 @@ static char *rna_idp_path(PointerRNA *ptr, return path; } +/** + * Find the path from the structure referenced by the pointer to the IDProperty object. + * + * \param ptr Reference to the object owning the custom property storage. + * \param needle Custom property object to find. + * \return Relative path or NULL. + */ +char *RNA_path_from_struct_to_idproperty(PointerRNA *ptr, IDProperty *needle) +{ + IDProperty *haystack = RNA_struct_idprops(ptr, false); + + if (haystack) { /* can fail when called on bones */ + return rna_idp_path(ptr, haystack, needle, NULL); + } + else { + return NULL; + } +} + static char *rna_path_from_ID_to_idpgroup(PointerRNA *ptr) { PointerRNA id_ptr; - IDProperty *haystack; - IDProperty *needle; BLI_assert(ptr->owner_id != NULL); @@ -5753,14 +5770,7 @@ static char *rna_path_from_ID_to_idpgroup(PointerRNA *ptr) */ RNA_id_pointer_create(ptr->owner_id, &id_ptr); - haystack = RNA_struct_idprops(&id_ptr, false); - if (haystack) { /* can fail when called on bones */ - needle = ptr->data; - return rna_idp_path(&id_ptr, haystack, needle, NULL); - } - else { - return NULL; - } + return RNA_path_from_struct_to_idproperty(&id_ptr, ptr->data); } /** |