[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21483] branches/blender2.5/blender/source /blender: 2.5:
Brecht Van Lommel
brecht at blender.org
Fri Jul 10 13:36:02 CEST 2009
Revision: 21483
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21483
Author: blendix
Date: 2009-07-10 13:36:02 +0200 (Fri, 10 Jul 2009)
Log Message:
-----------
2.5:
* RNA: enum items with "" indentifier are now interpreted as separators.
* Add Object menu: added consistent names, separators.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/interface/interface.c
branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
branches/blender2.5/blender/source/blender/editors/object/object_edit.c
branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_define.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_rna.c
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-07-10 11:33:01 UTC (rev 21482)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-07-10 11:36:02 UTC (rev 21483)
@@ -2123,7 +2123,9 @@
dynstr= BLI_dynstr_new();
BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop));
for(i=0; i<totitem; i++) {
- if(item[i].icon)
+ if(!item[i].identifier[0])
+ BLI_dynstr_appendf(dynstr, "|%l");
+ else if(item[i].icon)
BLI_dynstr_appendf(dynstr, "|%s %%i%d %%x%d", item[i].name, item[i].icon, item[i].value);
else
BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value);
@@ -2142,7 +2144,7 @@
RNA_property_enum_items(ptr, prop, &item, &totitem);
for(i=0; i<totitem; i++) {
- if(item[i].value == (int)max) {
+ if(item[i].identifier[0] && item[i].value == (int)max) {
str= (char*)item[i].name;
icon= item[i].icon;
}
@@ -2165,7 +2167,7 @@
RNA_property_enum_items(ptr, prop, &item, &totitem);
for(i=0; i<totitem; i++) {
- if(item[i].value == (int)max) {
+ if(item[i].identifier[0] && item[i].value == (int)max) {
if(item[i].description[0])
tip= (char*)item[i].description;
break;
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-07-10 11:33:01 UTC (rev 21482)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-07-10 11:36:02 UTC (rev 21483)
@@ -439,6 +439,9 @@
uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1));
for(a=0; a<totitem; a++) {
+ if(!item[a].identifier[0])
+ continue;
+
name= (!uiname || uiname[0])? (char*)item[a].name: "";
icon= item[a].icon;
value= item[a].value;
@@ -557,13 +560,11 @@
if(prop) {
const EnumPropertyItem *item;
int totitem, i;
+ char *name;
RNA_property_enum_items(&ptr, prop, &item, &totitem);
-
- for (i=0; i<totitem; i++) {
- if(item[i].value==retval)
- return (char*)item[i].name;
- }
+ if(RNA_enum_name(item, retval, &name))
+ return name;
}
return "";
@@ -603,7 +604,10 @@
RNA_property_enum_items(&ptr, prop, &item, &totitem);
for(i=0; i<totitem; i++)
- uiItemEnumO(layout, (char*)item[i].name, item[i].icon, opname, propname, item[i].value);
+ if(item[i].identifier[0])
+ uiItemEnumO(layout, (char*)item[i].name, item[i].icon, opname, propname, item[i].value);
+ else
+ uiItemS(layout);
}
}
@@ -889,7 +893,10 @@
RNA_property_enum_items(ptr, prop, &item, &totitem);
for(i=0; i<totitem; i++)
- uiItemEnumR(layout, (char*)item[i].name, 0, ptr, propname, item[i].value);
+ if(item[i].identifier[0])
+ uiItemEnumR(layout, (char*)item[i].name, 0, ptr, propname, item[i].value);
+ else
+ uiItemS(layout);
}
}
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c 2009-07-10 11:33:01 UTC (rev 21482)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c 2009-07-10 11:36:02 UTC (rev 21483)
@@ -2438,40 +2438,6 @@
/************************ Menu Definitions to uiBlocks ***********************/
-const char *ui_menu_enumpropname(char *opname, const char *propname, int retval)
-{
- wmOperatorType *ot= WM_operatortype_find(opname);
- PointerRNA ptr;
- PropertyRNA *prop;
-
- if(!ot || !ot->srna)
- return "";
-
- RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
- prop= RNA_struct_find_property(&ptr, propname);
-
- if(prop) {
- const EnumPropertyItem *item;
- int totitem, i;
-
- RNA_property_enum_items(&ptr, prop, &item, &totitem);
-
- for (i=0; i<totitem; i++) {
- if(item[i].value==retval)
- return item[i].name;
- }
- }
-
- return "";
-}
-
-typedef struct MenuItemLevel {
- int opcontext;
- char *opname;
- char *propname;
- PointerRNA rnapoin;
-} MenuItemLevel;
-
static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info)
{
uiBlock *block;
Modified: branches/blender2.5/blender/source/blender/editors/object/object_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/object/object_edit.c 2009-07-10 11:33:01 UTC (rev 21482)
+++ branches/blender2.5/blender/source/blender/editors/object/object_edit.c 2009-07-10 11:36:02 UTC (rev 21483)
@@ -243,16 +243,18 @@
/* ******************* add object operator ****************** */
static EnumPropertyItem prop_object_types[] = {
- {OB_EMPTY, "EMPTY", 0, "Empty", ""},
{OB_MESH, "MESH", 0, "Mesh", ""},
{OB_CURVE, "CURVE", 0, "Curve", ""},
{OB_SURF, "SURFACE", 0, "Surface", ""},
+ {OB_MBALL, "META", 0, "Meta", ""},
{OB_FONT, "TEXT", 0, "Text", ""},
- {OB_MBALL, "META", 0, "Meta", ""},
- {OB_LAMP, "LAMP", 0, "Lamp", ""},
- {OB_CAMERA, "CAMERA", 0, "Camera", ""},
+ {0, "", 0, NULL, NULL},
{OB_ARMATURE, "ARMATURE", 0, "Armature", ""},
{OB_LATTICE, "LATTICE", 0, "Lattice", ""},
+ {OB_EMPTY, "EMPTY", 0, "Empty", ""},
+ {0, "", 0, NULL, NULL},
+ {OB_CAMERA, "CAMERA", 0, "Camera", ""},
+ {OB_LAMP, "LAMP", 0, "Lamp", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -327,6 +329,7 @@
{4, "ICOSPHERE", 0, "Icosphere", ""},
{5, "CYLINDER", 0, "Cylinder", ""},
{6, "CONE", 0, "Cone", ""},
+ {0, "", 0, NULL, NULL},
{7, "GRID", 0, "Grid", ""},
{8, "MONKEY", 0, "Monkey", ""},
{0, NULL, 0, NULL, NULL}
@@ -619,16 +622,18 @@
uiPopupMenu *pup= uiPupMenuBegin(C, "Add Object", 0);
uiLayout *layout= uiPupMenuLayout(pup);
- uiItemMenuEnumO(layout, NULL, ICON_OUTLINER_OB_MESH, "OBJECT_OT_mesh_add", "type");
- uiItemMenuEnumO(layout, NULL, ICON_OUTLINER_OB_CURVE, "OBJECT_OT_curve_add", "type");
- uiItemMenuEnumO(layout, NULL, ICON_OUTLINER_OB_SURFACE, "OBJECT_OT_surface_add", "type");
- uiItemO(layout, NULL, ICON_OUTLINER_OB_FONT, "OBJECT_OT_text_add");
+ uiItemMenuEnumO(layout, "Mesh", ICON_OUTLINER_OB_MESH, "OBJECT_OT_mesh_add", "type");
+ uiItemMenuEnumO(layout, "Curve", ICON_OUTLINER_OB_CURVE, "OBJECT_OT_curve_add", "type");
+ uiItemMenuEnumO(layout, "Surface", ICON_OUTLINER_OB_SURFACE, "OBJECT_OT_surface_add", "type");
uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_META, "OBJECT_OT_object_add", "type", OB_MBALL);
+ uiItemO(layout, "Text", ICON_OUTLINER_OB_FONT, "OBJECT_OT_text_add");
+ uiItemS(layout);
+ uiItemO(layout, "Armature", ICON_OUTLINER_OB_ARMATURE, "OBJECT_OT_armature_add");
+ uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_LATTICE, "OBJECT_OT_object_add", "type", OB_LATTICE);
+ uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_EMPTY, "OBJECT_OT_object_add", "type", OB_EMPTY);
+ uiItemS(layout);
uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_CAMERA, "OBJECT_OT_object_add", "type", OB_CAMERA);
uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_LAMP, "OBJECT_OT_object_add", "type", OB_LAMP);
- uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_EMPTY, "OBJECT_OT_object_add", "type", OB_EMPTY);
- uiItemO(layout, NULL, ICON_OUTLINER_OB_ARMATURE, "OBJECT_OT_armature_add");
- uiItemEnumO(layout, NULL, ICON_OUTLINER_OB_LATTICE, "OBJECT_OT_object_add", "type", OB_LATTICE);
uiPupMenuEnd(C, pup);
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c 2009-07-10 11:33:01 UTC (rev 21482)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c 2009-07-10 11:36:02 UTC (rev 21483)
@@ -119,6 +119,11 @@
static char *escape[] = {"\''", "\"\"", "\??", "\\\\","\aa", "\bb", "\ff", "\nn", "\rr", "\tt", "\vv", NULL};
int i, j;
+ if(!str) {
+ fprintf(f, "NULL");
+ return;
+ }
+
fprintf(f, "\"");
for(i=0; str[i]; i++) {
for(j=0; escape[j]; j++)
@@ -262,7 +267,8 @@
if(eprop->item) {
for(a=0; a<eprop->totitem; a++)
- mask |= eprop->item[a].value;
+ if(eprop->item[a].identifier[0])
+ mask |= eprop->item[a].value;
}
return mask;
@@ -971,7 +977,8 @@
fprintf(f, "enum {\n");
for(i=0; i<eprop->totitem; i++)
- fprintf(f, "\t%s_%s_%s = %d,\n", srna->identifier, prop->identifier, eprop->item[i].identifier, eprop->item[i].value);
+ if(eprop->item[i].identifier[0])
+ fprintf(f, "\t%s_%s_%s = %d,\n", srna->identifier, prop->identifier, eprop->item[i].identifier, eprop->item[i].value);
fprintf(f, "};\n\n");
}
@@ -1059,7 +1066,8 @@
fprintf(f, "\tenum %s_enum {\n", prop->identifier);
for(i=0; i<eprop->totitem; i++)
- fprintf(f, "\t\t%s_%s = %d,\n", prop->identifier, eprop->item[i].identifier, eprop->item[i].value);
+ if(eprop->item[i].identifier[0])
+ fprintf(f, "\t\t%s_%s = %d,\n", prop->identifier, eprop->item[i].identifier, eprop->item[i].value);
fprintf(f, "\t};\n");
}
@@ -1577,8 +1585,9 @@
rna_print_c_string(f, eprop->item[i].name); fprintf(f, ", ");
rna_print_c_string(f, eprop->item[i].description); fprintf(f, "}, ");
- if(eprop->defaultvalue == eprop->item[i].value)
- defaultfound= 1;
+ if(eprop->item[i].identifier[0])
+ if(eprop->defaultvalue == eprop->item[i].value)
+ defaultfound= 1;
}
fprintf(f, "{0, NULL, 0, NULL, NULL}};\n\n");
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c 2009-07-10 11:33:01 UTC (rev 21482)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c 2009-07-10 11:36:02 UTC (rev 21483)
@@ -666,7 +666,7 @@
RNA_property_enum_items(ptr, prop, &item, NULL);
for(; item->identifier; item++) {
- if(strcmp(item->identifier, identifier)==0) {
+ if(item->identifier[0] && strcmp(item->identifier, identifier)==0) {
*value = item->value;
return 1;
}
@@ -678,7 +678,7 @@
int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier)
{
for (; item->identifier; item++) {
- if(item->value==value) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list