diff options
author | Demeter Dzadik <Mets> | 2020-06-30 16:01:56 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-06-30 16:06:33 +0300 |
commit | 5b03f49302a39577f2373906cfba19feebfaa9ba (patch) | |
tree | c7af4f8c0f5eb96f08f468decfd12ee3325a550d /source/blender | |
parent | e93663363ea11e2baa7518498abae3073b48a8b4 (diff) |
Custom Properties: support default values for strings
Differential Revision: https://developer.blender.org/D8102
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index cb9679ad925..79cf993e0cc 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -3473,6 +3473,24 @@ void RNA_property_string_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *prop, { StringPropertyRNA *sprop = (StringPropertyRNA *)rna_ensure_property(prop); + if (prop->magic != RNA_MAGIC) { + /* attempt to get the local ID values */ + const IDProperty *idp_ui = rna_idproperty_ui(prop); + + if (idp_ui) { + IDProperty *item; + + item = IDP_GetPropertyTypeFromGroup(idp_ui, "default", IDP_STRING); + if (item) { + strcpy(value, IDP_String(item)); + return; + } + } + + strcpy(value, ""); + return; + } + BLI_assert(RNA_property_type(prop) == PROP_STRING); strcpy(value, sprop->defaultvalue); @@ -3507,6 +3525,22 @@ int RNA_property_string_default_length(PointerRNA *UNUSED(ptr), PropertyRNA *pro { StringPropertyRNA *sprop = (StringPropertyRNA *)rna_ensure_property(prop); + if (prop->magic != RNA_MAGIC) { + /* attempt to get the local ID values */ + const IDProperty *idp_ui = rna_idproperty_ui(prop); + + if (idp_ui) { + IDProperty *item; + + item = IDP_GetPropertyTypeFromGroup(idp_ui, "default", IDP_STRING); + if (item) { + return strlen(IDP_String(item)); + } + } + + return 0; + } + BLI_assert(RNA_property_type(prop) == PROP_STRING); return strlen(sprop->defaultvalue); |