Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2016-02-09 14:44:06 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-02-09 14:51:07 +0300
commit337b718695c8b31dadc22438b9f1af40d225e0ad (patch)
tree976974961c40f6d764beef0a1389599998fe3496 /source/blender/makesrna/intern/rna_rna.c
parentae2036e69b88abb5c65179a70e97be17655bc7d4 (diff)
Fix T47371 - add access to 'static' enum items.
Some dynamic enums, which do not need a valid context pointer, have their 'itemf' callback always called. This is annoying for introspection tools (like the ones generating translations, or API documentation), because it means they never have access to all possible options (enum items). So now, there is also an `enum_items_static` accessor to get only statically-defined enum items. Note: only i18n tools take advantage of this currently, others are still to be updated. Reviewers: campbellbarton, sergey Differential Revision: https://developer.blender.org/D1782
Diffstat (limited to 'source/blender/makesrna/intern/rna_rna.c')
-rw-r--r--source/blender/makesrna/intern/rna_rna.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 382258ff751..f04aa3caf4d 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -854,7 +854,8 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point
rna_idproperty_check(&prop, ptr);
/* eprop = (EnumPropertyRNA *)prop; */
- RNA_property_enum_items(NULL, ptr, prop, &item, &totitem, &free);
+ RNA_property_enum_items_ex(
+ NULL, ptr, prop, STREQ(iter->prop->identifier, "enum_items_static"), &item, &totitem, &free);
rna_iterator_array_begin(iter, (void *)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator);
}
@@ -1423,6 +1424,14 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna)
"rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Items", "Possible values for the property");
+ prop = RNA_def_property(srna, "enum_items_static", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "EnumPropertyItem");
+ RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next",
+ "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Static Items",
+ "Possible values for the property (never calls optional dynamic generation of those)");
+
srna = RNA_def_struct(brna, "EnumPropertyItem", NULL);
RNA_def_struct_ui_text(srna, "Enum Item Definition", "Definition of a choice in an RNA enum property");
RNA_def_struct_ui_icon(srna, ICON_RNA);