diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-10 15:36:02 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-10 15:36:02 +0400 |
commit | 3496437585c79d590b18d423d1b34d93f226f296 (patch) | |
tree | 3487baf8ec4cac148802ed6ac46ce8186d6c9dc0 /source | |
parent | 146a887b81b45ca92972e037976ccf9205da97ee (diff) |
2.5:
* RNA: enum items with "" indentifier are now interpreted as separators.
* Add Object menu: added consistent names, separators.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 21 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 34 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 27 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 19 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 9 |
8 files changed, 62 insertions, 66 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index a76fdcbf39d..b84a3ab469c 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2123,7 +2123,9 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, 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 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, 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 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, 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; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 0bf64f75552..bb6ca6c502f 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -439,6 +439,9 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, 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 @@ static char *ui_menu_enumpropname(char *opname, char *propname, int retval) 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 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname) 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 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname) 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); } } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 27fb0731d67..1b968508918 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2438,40 +2438,6 @@ typedef struct uiMenuInfo { /************************ 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; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 11f6b443912..da3b5e1e6b3 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -243,16 +243,18 @@ void ED_object_base_init_from_view(bContext *C, Base *base) /* ******************* 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_FONT, "TEXT", 0, "Text", ""}, {OB_MBALL, "META", 0, "Meta", ""}, - {OB_LAMP, "LAMP", 0, "Lamp", ""}, - {OB_CAMERA, "CAMERA", 0, "Camera", ""}, + {OB_FONT, "TEXT", 0, "Text", ""}, + {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 @@ static EnumPropertyItem prop_mesh_types[] = { {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 @@ static int object_primitive_add_invoke(bContext *C, wmOperator *op, wmEvent *eve 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); diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 059afad4c70..ec509dbf863 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -119,6 +119,11 @@ static void rna_print_c_string(FILE *f, const char *str) 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 @@ static int rna_enum_bitmask(PropertyRNA *prop) 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 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR 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 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property 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 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr 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"); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index eb53d0fbf51..42f6250728f 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -666,7 +666,7 @@ int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *iden 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_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *iden int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier) { for (; item->identifier; item++) { - if(item->value==value) { + if(item->identifier[0] && item->value==value) { *identifier = item->identifier; return 1; } @@ -689,7 +689,7 @@ int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const cha int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name) { for (; item->identifier; item++) { - if(item->value==value) { + if(item->identifier[0] && item->value==value) { *name = item->name; return 1; } diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 2916c1bcb6e..2b414adf05b 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1117,7 +1117,7 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item for(i=0; item[i].identifier; i++) { eprop->totitem++; - if(item[i].value == eprop->defaultvalue) + if(item[i].identifier[0] && item[i].value == eprop->defaultvalue) defaultfound= 1; } @@ -1280,7 +1280,7 @@ void RNA_def_property_enum_default(PropertyRNA *prop, int value) eprop->defaultvalue= value; for(i=0; i<eprop->totitem; i++) { - if(eprop->item[i].value == eprop->defaultvalue) + if(eprop->item[i].identifier[0] && eprop->item[i].value == eprop->defaultvalue) defaultfound= 1; } diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 557d472afef..0b605db20cf 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -516,6 +516,13 @@ static int rna_StringProperty_max_length_get(PointerRNA *ptr) return ((StringPropertyRNA*)prop)->maxlength; } +static int rna_enum_check_separator(CollectionPropertyIterator *iter, void *data) +{ + EnumPropertyItem *item= (EnumPropertyItem*)data; + + return (item->identifier[0] != 0); +} + static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; @@ -524,7 +531,7 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point rna_idproperty_check(&prop, ptr); eprop= (EnumPropertyRNA*)prop; - rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem, NULL); + rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem, rna_enum_check_separator); } static void rna_EnumPropertyItem_identifier_get(PointerRNA *ptr, char *value) |