[Bf-blender-cvs] [9e850ad] master: template id previews: changes for consistency with icon views template

Ines Almeida noreply at git.blender.org
Mon Jun 1 21:40:45 CEST 2015


Commit: 9e850addae2e47976b1bbf4d14802edf8c182863
Author: Ines Almeida
Date:   Mon May 25 21:55:48 2015 +0100
Branches: master
https://developer.blender.org/rB9e850addae2e47976b1bbf4d14802edf8c182863

template id previews: changes for consistency with icon views template

- elongate the buttons to acomodate the icon without the label overlapping.
- removing the blue background
- adding a consistent margin all around the popup

===================================================================

M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_widgets.c

===================================================================

diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 19d660f..df27c4e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -187,7 +187,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
 	/* preview thumbnails */
 	if (template.prv_rows > 0 && template.prv_cols > 0) {
 		int w = 4 * U.widget_unit * template.prv_cols;
-		int h = 4 * U.widget_unit * template.prv_rows;
+		int h = ((int)(5.25f * U.widget_unit)) * template.prv_rows;
 		
 		/* fake button, it holds space for search items */
 		uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, NULL, 0, 0, 0, 0, NULL);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index b3ac22a..478d1b4 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -4112,15 +4112,20 @@ 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, bg_rect;
+	rcti trect = *rect;
+	const float text_size = 0.2f * BLI_rcti_size_y(rect);
 	float font_dims[2] = {0.0f, 0.0f};
 	uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
 	
+	/* drawing button background */
 	wt->state(wt, state);
 	wt->draw(&wt->wcol, rect, 0, 0);
 	
+	/* draw icon in rect above the space reserved for the label */
+	rect->ymin += text_size;
 	glEnable(GL_BLEND);
 	widget_draw_preview(iconid, 1.0f, rect);
+	glDisable(GL_BLEND);
 	
 	BLF_width_and_height(fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]);
 
@@ -4132,19 +4137,6 @@ 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 = rect->xmax - PREVIEW_PAD;
-	bg_rect.ymax += PREVIEW_PAD / 2;
-	
-	if (bg_rect.xmax > rect->xmax - PREVIEW_PAD)
-		bg_rect.xmax = rect->xmax - PREVIEW_PAD;
-
-	glColor4ubv((unsigned char *)wt->wcol_theme->inner_sel);
-	glRecti(bg_rect.xmin, bg_rect.ymin, bg_rect.xmax, bg_rect.ymax);
-	glDisable(GL_BLEND);
-
 	{
 		char drawstr[UI_MAX_DRAW_STR];
 		const float okwidth = (float)BLI_rcti_size_x(&trect);




More information about the Bf-blender-cvs mailing list