From f10541f7cfa13b3f2c92abea2c99c2901efbf91a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Jun 2009 01:08:39 +0000 Subject: UI * Added option for panel to be closed by default. * Added support for RNA property and enum icons in buttons. * Remove some deprecated RNA menu code. * Fix issue with newly created panels not being inserted in the right place. * Fix issue with 3-split layout not being divided correctly. * FIx issue with menu items not drawing correct using python UI. --- source/blender/editors/interface/interface.c | 118 +++++++++++---------------- 1 file changed, 47 insertions(+), 71 deletions(-) (limited to 'source/blender/editors/interface/interface.c') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index b3f24be2f9a..99c520db7b8 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1859,18 +1859,24 @@ void ui_check_but(uiBut *but) case ICONTOG: case ICONTOGN: - if(but->flag & UI_SELECT) but->iconadd= 1; - else but->iconadd= 0; + if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + if(but->flag & UI_SELECT) but->iconadd= 1; + else but->iconadd= 0; + } break; case ICONROW: - value= ui_get_but_val(but); - but->iconadd= (int)value- (int)(but->hardmin); + if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + value= ui_get_but_val(but); + but->iconadd= (int)value- (int)(but->hardmin); + } break; case ICONTEXTROW: - value= ui_get_but_val(but); - but->iconadd= (int)value- (int)(but->hardmin); + if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + value= ui_get_but_val(but); + but->iconadd= (int)value- (int)(but->hardmin); + } break; } @@ -2267,7 +2273,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, uiBut *but; PropertyRNA *prop; PropertyType proptype; - int freestr= 0; + int freestr= 0, icon= 0; prop= RNA_struct_find_property(ptr, propname); @@ -2279,14 +2285,22 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, if(type == MENU && proptype == PROP_ENUM) { const EnumPropertyItem *item; DynStr *dynstr; - int i, totitem; + int i, totitem, value; RNA_property_enum_items(ptr, prop, &item, &totitem); + value= RNA_property_enum_get(ptr, prop); dynstr= BLI_dynstr_new(); BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop)); - for(i=0; iicon= (BIFIconID)icon; + but->flag |= UI_HAS_ICON; + but->flag|= UI_ICON_LEFT; } if (!prop || !RNA_property_editable(&but->rnapoin, prop)) { @@ -2653,8 +2679,10 @@ uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, short x1, s but= ui_def_but_rna(block, type, retval, "", x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); if(but) { - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; + if(icon) { + but->icon= (BIFIconID) icon; + but->flag|= UI_HAS_ICON; + } ui_check_but(but); } @@ -2736,8 +2764,10 @@ uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *s but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); if(but) { - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; + if(icon) { + but->icon= (BIFIconID) icon; + but->flag|= UI_HAS_ICON; + } but->flag|= UI_ICON_LEFT; ui_check_but(but); } @@ -2779,60 +2809,6 @@ uiBut *uiDefMenuSep(uiBlock *block) return uiDefBut(block, SEPR, 0, "", 0, y, MENU_WIDTH, MENU_SEP_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); } -uiBut *uiDefMenuSub(uiBlock *block, uiBlockCreateFunc func, char *name) -{ - int y= ui_menu_y(block) - MENU_ITEM_HEIGHT; - return uiDefIconTextBlockBut(block, func, NULL, ICON_BLANK1, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ""); -} - -uiBut *uiDefMenuTogR(uiBlock *block, PointerRNA *ptr, char *propname, char *propvalue, char *name) -{ - uiBut *but; - PropertyRNA *prop; - PropertyType type; - const EnumPropertyItem *item; - int a, value, totitem, icon= ICON_CHECKBOX_DEHLT; - int y= ui_menu_y(block) - MENU_ITEM_HEIGHT; - - prop= RNA_struct_find_property(ptr, propname); - if(prop) { - type= RNA_property_type(prop); - - if(type == PROP_BOOLEAN) { - if(RNA_property_boolean_get(ptr, prop)) - icon= ICON_CHECKBOX_HLT; - - return uiDefIconTextButR(block, TOG, 0, icon, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ptr, propname, 0, 0, 0, 0, 0, NULL); - } - else if(type == PROP_ENUM) { - RNA_property_enum_items(ptr, prop, &item, &totitem); - - value= 0; - for(a=0; a