[Bf-codereview] Improve readability of search menu text (issue 5699098)
NicholasBishop at gmail.com
NicholasBishop at gmail.com
Tue Feb 28 03:39:12 CET 2012
Reviewers: bf-codereview_blender.org,
Description:
The search menu used for selecting brushes (as well as brush textures in
sculpt mode) draws text directly over preview icons. Depending on what
the icon is, this can make the text very hard to read.
This patch adds a solid background between the icon and text. Example:
http://www.pasteall.org/pic/show.php?id=27401
It could probably be further improved aesthetically, but at least it is
readable with this.
Please review this at http://codereview.appspot.com/5699098/
Affected files:
source/blender/editors/interface/interface_widgets.c
Index: source/blender/editors/interface/interface_widgets.c
===================================================================
--- source/blender/editors/interface/interface_widgets.c (revision 44497)
+++ source/blender/editors/interface/interface_widgets.c (working copy)
@@ -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);
}
More information about the Bf-codereview
mailing list