From 4f884e21b2ca05fb13f7e675d81f3a07c14f3a67 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 28 Feb 2012 20:46:55 +0000 Subject: [PATCH] Add solid background behind text in search menu. This fixes the issue of text being hard to read due to (e.g.) black text on a dark icon. Example: http://www.pasteall.org/pic/show.php?id=27401 Reviewed by Brecht: http://codereview.appspot.com/5699098/ --- .../editors/interface/interface_widgets.c | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 8f5c08236cf..419f13254e6 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -3276,20 +3276,16 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state) { - rcti trect = *rect; + rcti trect = *rect, bg_rect; float font_dims[2] = {0.0f, 0.0f}; uiWidgetType *wt= widget_type(UI_WTYPE_MENU_ITEM); + unsigned char bg_col[3]; wt->state(wt, state); wt->draw(&wt->wcol, rect, 0, 0); widget_draw_preview(iconid, 1.0f, rect); - if (state == UI_ACTIVE) - glColor3ubv((unsigned char*)wt->wcol.text); - else - glColor3ubv((unsigned char*)wt->wcol.text_sel); - BLF_width_and_height(fstyle->uifont_id, name, &font_dims[0], &font_dims[1]); /* text rect */ @@ -3300,5 +3296,23 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int if(trect.xmax > rect->xmax - PREVIEW_PAD) trect.xmax = rect->xmax - PREVIEW_PAD; + bg_rect = trect; + bg_rect.xmin = rect->xmin + PREVIEW_PAD; + bg_rect.ymin = rect->ymin + PREVIEW_PAD; + bg_rect.xmax += PREVIEW_PAD / 2; + bg_rect.ymax += PREVIEW_PAD / 2; + + if(bg_rect.xmax > rect->xmax - PREVIEW_PAD) + bg_rect.xmax = rect->xmax - PREVIEW_PAD; + + UI_GetThemeColor3ubv(TH_BUTBACK, bg_col); + glColor3ubv(bg_col); + glRecti(bg_rect.xmin, bg_rect.ymin, bg_rect.xmax, bg_rect.ymax); + + if (state == UI_ACTIVE) + glColor3ubv((unsigned char*)wt->wcol.text); + else + glColor3ubv((unsigned char*)wt->wcol.text_sel); + uiStyleFontDraw(fstyle, &trect, name); }