diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-04-14 11:46:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-04-14 11:50:28 +0300 |
commit | e6d9d5dcc18f3ab55c31abc6bfb2010081538422 (patch) | |
tree | 99c6315d9612d81f4b9c34a72674bb702f64ceda /source/blender/editors/interface/interface_widgets.c | |
parent | 571646ebc175877225c26a3dcf8869691cf70ba7 (diff) |
UI: improve menu search with dimmed menu prefix
- Show dimmed text for the menu entries leading up to the menu item.
- Show icons between the menu text and menu item.
- Use unicode right pointing triangle instead of arrow.
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 88bc4c38fd3..86a5fd5dabb 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2315,7 +2315,8 @@ static void widget_draw_text(const uiFontStyle *fstyle, }, drawlen, &font_xofs, - &font_yofs); + &font_yofs, + NULL); if (but->menu_key != '\0') { char fixedbuf[128]; @@ -5267,8 +5268,13 @@ void ui_draw_tooltip_background(const uiStyle *UNUSED(style), uiBlock *UNUSED(bl /* helper call to draw a menu item without button */ /* state: UI_ACTIVE or 0 */ -void ui_draw_menu_item( - const uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state, bool use_sep) +void ui_draw_menu_item(const uiFontStyle *fstyle, + rcti *rect, + const char *name, + int iconid, + int state, + bool use_sep, + int *r_name_width) { uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM); rcti _rect = *rect; @@ -5318,13 +5324,22 @@ void ui_draw_menu_item( UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0'); } - UI_fontstyle_draw(fstyle, - rect, - drawstr, - wt->wcol.text, - &(struct uiFontStyleDraw_Params){ - .align = UI_STYLE_TEXT_LEFT, - }); + int xofs = 0, yofs = 0; + struct ResultBLF info; + UI_fontstyle_draw_ex(fstyle, + rect, + drawstr, + wt->wcol.text, + &(struct uiFontStyleDraw_Params){ + .align = UI_STYLE_TEXT_LEFT, + }, + BLF_DRAW_STR_DUMMY_MAX, + &xofs, + &yofs, + &info); + if (r_name_width != NULL) { + *r_name_width = xofs + info.width; + } } /* part text right aligned */ |