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:
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c69
1 files changed, 64 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 8c76edd2f17..079f71d7be3 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1249,12 +1249,9 @@ void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, En
}
}
-void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA *prop,
- EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
-{
- RNA_property_enum_items(C, ptr, prop, r_item, r_totitem, r_free);
-
#ifdef WITH_INTERNATIONAL
+static void property_enum_translate(PropertyRNA *prop, EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
+{
if (!(prop->flag & PROP_ENUM_NO_TRANSLATE)) {
int i;
@@ -1300,9 +1297,71 @@ void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA
*r_item = nitem;
}
+}
+#endif
+
+void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA *prop,
+ EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
+{
+ RNA_property_enum_items(C, ptr, prop, r_item, r_totitem, r_free);
+
+#ifdef WITH_INTERNATIONAL
+ property_enum_translate(prop, r_item, r_totitem, r_free);
#endif
}
+void RNA_property_enum_items_gettexted_all(bContext *C, PointerRNA *ptr, PropertyRNA *prop,
+ EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
+{
+ EnumPropertyRNA *eprop = (EnumPropertyRNA *)rna_ensure_property(prop);
+ int mem_size = sizeof(EnumPropertyItem) * (eprop->totitem + 1);
+ /* first return all items */
+ *r_free = true;
+ *r_item = MEM_mallocN(mem_size, "enum_gettext_all");
+ memcpy(*r_item, eprop->item, mem_size);
+
+ if (r_totitem)
+ *r_totitem = eprop->totitem;
+
+ if (eprop->itemf && (C != NULL || (prop->flag & PROP_ENUM_NO_CONTEXT))) {
+ EnumPropertyItem *item;
+ int i;
+ bool free = false;
+
+ if (prop->flag & PROP_ENUM_NO_CONTEXT)
+ item = eprop->itemf(NULL, ptr, prop, &free);
+ else
+ item = eprop->itemf(C, ptr, prop, &free);
+
+ /* any callbacks returning NULL should be fixed */
+ BLI_assert(item != NULL);
+
+ for (i = 0; i < eprop->totitem; i++) {
+ bool exists = false;
+ int i_fixed;
+
+ /* items that do not exist on list are returned, but have their names/identifiers NULLed out */
+ for (i_fixed = 0; item[i_fixed].identifier; i_fixed++) {
+ if (STREQ(item[i_fixed].identifier, (*r_item)[i].identifier)) {
+ exists = true;
+ break;
+ }
+ }
+
+ if (!exists) {
+ (*r_item)[i].name = NULL;
+ (*r_item)[i].identifier = "";
+ }
+ }
+
+ if (free)
+ MEM_freeN(item);
+ }
+
+#ifdef WITH_INTERNATIONAL
+ property_enum_translate(prop, r_item, r_totitem, r_free);
+#endif
+}
bool RNA_property_enum_value(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *r_value)
{