diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-08-11 12:39:59 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-08-11 13:02:26 +0400 |
commit | 028fd29eeb092b6ed0625ed4d59b8100ae69596f (patch) | |
tree | 0cb15b15f17e6d9f16fef74631e3838e8962fafe /source/blender/makesrna/intern/rna_access.c | |
parent | 5d1d23d5bdb0e5937520f16063f8d16fb049850c (diff) |
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 69 |
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) { |