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/blender/editors | |
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/blender/editors')
-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 |
4 files changed, 35 insertions, 55 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); |