[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52527] trunk/blender/source/blender/ editors/interface: add ENUM support for layout.prop_search() / uiItemPointerR
Campbell Barton
ideasman42 at gmail.com
Sat Nov 24 06:15:55 CET 2012
Revision: 52527
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52527
Author: campbellbarton
Date: 2012-11-24 05:15:48 +0000 (Sat, 24 Nov 2012)
Log Message:
-----------
add ENUM support for layout.prop_search() / uiItemPointerR
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface.c
trunk/blender/source/blender/editors/interface/interface_layout.c
Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c 2012-11-24 04:51:56 UTC (rev 52526)
+++ trunk/blender/source/blender/editors/interface/interface.c 2012-11-24 05:15:48 UTC (rev 52527)
@@ -1677,7 +1677,7 @@
{
if (but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
PropertyType type;
- char *buf = NULL;
+ const char *buf = NULL;
int buf_len;
type = RNA_property_type(but->rnaprop);
@@ -1686,11 +1686,22 @@
/* RNA string */
buf = RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
}
+ else if (type == PROP_ENUM) {
+ /* RNA enum */
+ int value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
+ if (RNA_property_enum_name(but->block->evil_C, &but->rnapoin, but->rnaprop, value, &buf)) {
+ BLI_strncpy(str, buf, maxlen);
+ buf = str;
+ }
+ }
else if (type == PROP_POINTER) {
/* RNA pointer */
PointerRNA ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
buf = RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
}
+ else {
+ BLI_assert(0);
+ }
if (!buf) {
str[0] = '\0';
@@ -1698,7 +1709,7 @@
else if (buf && buf != str) {
/* string was too long, we have to truncate */
memcpy(str, buf, MIN2(maxlen, (size_t)buf_len + 1));
- MEM_freeN(buf);
+ MEM_freeN((void *)buf);
}
}
else if (but->type == IDPOIN) {
@@ -1841,6 +1852,17 @@
return 0;
}
+ else if (type == PROP_ENUM) {
+ int value;
+ if (RNA_property_enum_value(but->block->evil_C, &but->rnapoin, but->rnaprop, str, &value)) {
+ RNA_property_enum_set(&but->rnapoin, but->rnaprop, value);
+ return 1;
+ }
+ return 0;
+ }
+ else {
+ BLI_assert(0);
+ }
}
}
else if (but->type == IDPOIN) {
Modified: trunk/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_layout.c 2012-11-24 04:51:56 UTC (rev 52526)
+++ trunk/blender/source/blender/editors/interface/interface_layout.c 2012-11-24 05:15:48 UTC (rev 52527)
@@ -1384,6 +1384,12 @@
but->rnasearchprop = searchprop;
but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT;
+ if (RNA_property_type(prop) == PROP_ENUM) {
+ /* XXX, this will have a menu string,
+ * but in this case we just want the text */
+ but->str[0] = 0;
+ }
+
uiButSetSearchFunc(but, rna_search_cb, but, NULL, NULL);
}
}
@@ -1407,8 +1413,8 @@
}
type = RNA_property_type(prop);
- if (!ELEM(type, PROP_POINTER, PROP_STRING)) {
- RNA_warning("Property %s must be a pointer or string", propname);
+ if (!ELEM3(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) {
+ RNA_warning("Property %s must be a pointer, string or enum", propname);
return;
}
More information about the Bf-blender-cvs
mailing list