[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44532] trunk/blender/source/blender/ editors/interface/interface_widgets.c: Add solid background behind text in search menu.

Nicholas Bishop nicholasbishop at gmail.com
Tue Feb 28 21:46:57 CET 2012


Revision: 44532
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44532
Author:   nicholasbishop
Date:     2012-02-28 20:46:55 +0000 (Tue, 28 Feb 2012)
Log Message:
-----------
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/

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_widgets.c

Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c	2012-02-28 20:13:33 UTC (rev 44531)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c	2012-02-28 20:46:55 UTC (rev 44532)
@@ -3276,20 +3276,16 @@
 
 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 @@
 	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-blender-cvs mailing list