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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-14 20:05:25 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-14 20:05:25 +0300
commita2175968a7a21bd09463ac9582130c593d27094d (patch)
tree26456772fb769aa67a9bc381908eb277bc76a097 /source/blender/editors/interface/interface.c
parent4a8e571e8d3b5a4f8d223d40594b1be96206a141 (diff)
RNA
* Added RNA list viewer. This is currently drawn in the outliner window, the UI is limited but it is just intended to test RNA at the moment. * Added UI names for currently wrapped properties. * Made iterating collections a bit more convenient.
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 7fa9615f64c..4fbc1147d11 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2232,64 +2232,73 @@ uiBut *uiDefRNABut(uiBlock *block, int retval, PointerRNA *ptr, PropertyRNA *pro
{
uiBut *but;
- switch(prop->type) {
+ switch(RNA_property_type(prop, ptr)) {
case PROP_BOOLEAN: {
- int value;
+ int value, length;
- if(prop->arraylength)
+ length= RNA_property_array_length(prop, ptr);
+
+ if(length)
value= RNA_property_boolean_get_array(prop, ptr, index);
else
value= RNA_property_boolean_get(prop, ptr);
- but= ui_def_but(block, TOG, 0, (value)? "True": "False", x1, y1, x2, y2, NULL, 0, 0, 0, 0, (char*)prop->description);
+ but= ui_def_but(block, TOG, 0, (value)? "True": "False", x1, y1, x2, y2, NULL, 0, 0, 0, 0, (char*)RNA_property_ui_description(prop, ptr));
break;
}
case PROP_INT: {
- IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
- but= ui_def_but(block, NUM, 0, "", x1, y1, x2, y2, NULL, iprop->softmin, iprop->softmax, iprop->step, 0, (char*)prop->description);
+ int softmin, softmax, step;
+
+ RNA_property_int_ui_range(prop, ptr, &softmin, &softmax, &step);
+ but= ui_def_but(block, NUM, 0, "", x1, y1, x2, y2, NULL, softmin, softmax, step, 0, (char*)RNA_property_ui_description(prop, ptr));
break;
}
case PROP_FLOAT: {
- FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
- but= ui_def_but(block, NUM, 0, "", x1, y1, x2, y2, NULL, fprop->softmin, fprop->softmax, fprop->step, fprop->precision, (char*)prop->description);
+ float softmin, softmax, step, precision;
+
+ RNA_property_float_ui_range(prop, ptr, &softmin, &softmax, &step, &precision);
+ but= ui_def_but(block, NUM, 0, "", x1, y1, x2, y2, NULL, softmin, softmax, step, precision, (char*)RNA_property_ui_description(prop, ptr));
break;
}
case PROP_ENUM: {
- EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
+ const PropertyEnumItem *item;
DynStr *dynstr;
char *menu;
- int i;
+ int i, totitem;
+
+ RNA_property_enum_items(prop, ptr, &item, &totitem);
dynstr= BLI_dynstr_new();
- BLI_dynstr_appendf(dynstr, "%s%%t", prop->name);
- for(i=0; i<eprop->totitem; i++)
- BLI_dynstr_appendf(dynstr, "|%s %%x%d", eprop->item[i].name, eprop->item[i].value);
+ BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop, ptr));
+ for(i=0; i<totitem; i++)
+ BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value);
menu= BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
- but= ui_def_but(block, MENU, 0, menu, x1, y1, x2, y2, NULL, 0, 0, 0, 0, (char*)prop->description);
+ but= ui_def_but(block, MENU, 0, menu, x1, y1, x2, y2, NULL, 0, 0, 0, 0, (char*)RNA_property_ui_description(prop, ptr));
MEM_freeN(menu);
break;
}
case PROP_STRING: {
- StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
- but= ui_def_but(block, TEX, 0, "", x1, y1, x2, y2, NULL, 0, sprop->maxlength, 0, 0, (char*)prop->description);
+ but= ui_def_but(block, TEX, 0, "", x1, y1, x2, y2, NULL, 0, RNA_property_string_maxlength(prop, ptr), 0, 0, (char*)RNA_property_ui_description(prop, ptr));
break;
}
case PROP_POINTER: {
PointerRNA pptr;
+ PropertyRNA *nameprop;
char name[256]= "", *nameptr= name;
RNA_property_pointer_get(prop, ptr, &pptr);
if(pptr.data) {
- if(pptr.type && pptr.type->nameproperty)
- nameptr= RNA_property_string_get_alloc(pptr.type->nameproperty, &pptr, name, sizeof(name));
+ nameprop= RNA_struct_name_property(&pptr);
+ if(pptr.type && nameprop)
+ nameptr= RNA_property_string_get_alloc(nameprop, &pptr, name, sizeof(name));
else
- strcpy(nameptr, "unknown");
+ strcpy(nameptr, "->");
}
- but= ui_def_but(block, BUT, 0, nameptr, x1, y1, x2, y2, NULL, 0, 0, 0, 0, (char*)prop->description);
+ but= ui_def_but(block, BUT, 0, nameptr, x1, y1, x2, y2, NULL, 0, 0, 0, 0, (char*)RNA_property_ui_description(prop, ptr));
but->flag |= UI_TEXT_LEFT;
if(nameptr != name)