diff options
author | Ton Roosendaal <ton@blender.org> | 2009-04-30 21:27:30 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-04-30 21:27:30 +0400 |
commit | d576ee99ed30c9ccd3768a4c3f35f03e3fa1f1e5 (patch) | |
tree | 6d4bfb3e47f22c8364dc77f26604c84105c5eada | |
parent | 3ee6c11e31dcebc0999e335818cc07520dff5389 (diff) |
2.5
Cleanup of conventions for icon placement in menus.
Old code only allowed 1 icon per menu, forcing to pass on the sublevel
menu icon with exception handling.
Now sublevel icons are drawn automatically, allowing to add an icon
before name too. (Check shift+a menu)
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 16 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 70 |
4 files changed, 47 insertions, 48 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 26042f70b4a..0e34b3702ed 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -110,7 +110,7 @@ typedef struct uiLayout uiLayout; /* but->flag */ #define UI_TEXT_LEFT 64 #define UI_ICON_LEFT 128 -#define UI_ICON_RIGHT 256 +#define UI_ICON_SUBMENU 256 /* control for button type block */ #define UI_MAKE_TOP 512 #define UI_MAKE_DOWN 1024 diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 8a1086386e1..fd082c34238 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2741,7 +2741,7 @@ uiBut *uiDefMenuSep(uiBlock *block) uiBut *uiDefMenuSub(uiBlock *block, uiBlockCreateFunc func, char *name) { int y= ui_menu_y(block) - MENU_ITEM_HEIGHT; - return uiDefIconTextBlockBut(block, func, NULL, ICON_RIGHTARROW_THIN, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ""); + 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) @@ -2991,7 +2991,7 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in but->flag|= UI_HAS_ICON; but->flag|= UI_ICON_LEFT; - but->flag|= UI_ICON_RIGHT; + but->flag|= UI_ICON_SUBMENU; but->menu_create_func= func; ui_check_but(but); @@ -3004,11 +3004,13 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, { uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); - but->icon= (BIFIconID) icon; + /* XXX temp, old menu calls pass on icon arrow, which is now UI_ICON_SUBMENU flag */ + if(icon!=ICON_RIGHTARROW_THIN) { + but->icon= (BIFIconID) icon; + but->flag|= UI_ICON_LEFT; + } but->flag|= UI_HAS_ICON; - - but->flag|= UI_ICON_LEFT; - but->flag|= UI_ICON_RIGHT; + but->flag|= UI_ICON_SUBMENU; but->block_create_func= func; ui_check_but(but); @@ -3025,7 +3027,7 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int but->flag|= UI_HAS_ICON; but->flag|= UI_ICON_LEFT; - but->flag|= UI_ICON_RIGHT; + but->flag|= UI_ICON_SUBMENU; but->block_create_func= func; ui_check_but(but); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 6ed02a38ca1..6a02e992390 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -887,9 +887,6 @@ void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func) menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu"); - if(!icon && layout->type == UI_LAYOUT_MENU) - icon= ICON_RIGHTARROW_THIN, - ui_item_name(&menuitem->item, name); menuitem->item.icon= icon; menuitem->item.type= ITEM_MENU; @@ -931,8 +928,6 @@ void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu"); - if(!icon && layout->type == UI_LAYOUT_MENU) - icon= ICON_RIGHTARROW_THIN; if(!name) name= ot->name; @@ -978,8 +973,6 @@ void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA * menuitem= MEM_callocN(sizeof(uiItemMenu), "uiItemMenu"); - if(!icon && layout->type == UI_LAYOUT_MENU) - icon= ICON_RIGHTARROW_THIN; if(!name) name= (char*)RNA_property_ui_name(prop); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index baf5486ac3a..f557b2e97a4 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -633,7 +633,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect) float xs=0, ys=0, aspect, height; /* this icon doesn't need draw... */ - if(icon==ICON_BLANK1) return; + if(icon==ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU)==0) return; /* we need aspect from block, for menus... these buttons are scaled in uiPositionBlock() */ aspect= but->block->aspect; @@ -650,45 +650,49 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect) else height= ICON_HEIGHT; - if(but->flag & UI_ICON_LEFT) { - if (but->type==BUT_TOGDUAL) { - if (but->drawstr[0]) { - xs= rect->xmin-1.0; - } else { - xs= (rect->xmin+rect->xmax- height)/2.0; + /* calculate blend color */ + if ELEM3(but->type, TOG, ROW, TOGN) { + if(but->flag & UI_SELECT); + else if(but->flag & UI_ACTIVE); + else blend= -60; + } + + glEnable(GL_BLEND); + + if(icon && icon!=ICON_BLANK1) { + if(but->flag & UI_ICON_LEFT) { + if (but->type==BUT_TOGDUAL) { + if (but->drawstr[0]) { + xs= rect->xmin-1.0; + } else { + xs= (rect->xmin+rect->xmax- height)/2.0; + } } - } - else if (but->block->flag & UI_BLOCK_LOOP) { - xs= rect->xmin+1.0; - } - else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) { - xs= rect->xmin+3.0; + else if (but->block->flag & UI_BLOCK_LOOP) { + xs= rect->xmin+1.0; + } + else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) { + xs= rect->xmin+3.0; + } + else { + xs= rect->xmin+4.0; + } + ys= (rect->ymin+rect->ymax- height)/2.0; } else { - xs= rect->xmin+4.0; + xs= (rect->xmin+rect->xmax- height)/2.0; + ys= (rect->ymin+rect->ymax- height)/2.0; } - ys= (rect->ymin+rect->ymax- height)/2.0; + + UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend); } - if(but->flag & UI_ICON_RIGHT) { + + if(but->flag & UI_ICON_SUBMENU) { xs= rect->xmax-17.0; ys= (rect->ymin+rect->ymax- height)/2.0; + + UI_icon_draw_aspect_blended(xs, ys, ICON_RIGHTARROW_THIN, aspect, blend); } - if (!((but->flag & UI_ICON_RIGHT) || (but->flag & UI_ICON_LEFT))) { - xs= (rect->xmin+rect->xmax- height)/2.0; - ys= (rect->ymin+rect->ymax- height)/2.0; - } - - glEnable(GL_BLEND); - - /* calculate blend color */ - if ELEM3(but->type, TOG, ROW, TOGN) { - if(but->flag & UI_SELECT); - else if(but->flag & UI_ACTIVE); - else blend= -60; - } - if (but->flag & UI_BUT_DISABLED) blend = -100; - - UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend); glDisable(GL_BLEND); } @@ -843,7 +847,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB /* If there's an icon too (made with uiDefIconTextBut) then draw the icon and offset the text label to accomodate it */ - if ( (but->flag & UI_HAS_ICON) && (but->flag & UI_ICON_LEFT) ) { + if (but->flag & UI_HAS_ICON) { widget_draw_icon(but, but->icon, 0, rect); rect->xmin += UI_icon_get_width(but->icon); |