示例#1
0
static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *rect, char dir)
{
	Panel *panel= block->panel;
	rcti hrect;
	int  pnl_icons;
	char *activename= panel->drawname[0]?panel->drawname:panel->panelname;
	
	/* + 0.001f to avoid flirting with float inaccuracy */
	if(panel->control & UI_PNL_CLOSE) pnl_icons=(panel->labelofs+2*PNL_ICON+5)/block->aspect + 0.001f;
	else pnl_icons= (panel->labelofs+PNL_ICON+5)/block->aspect + 0.001f;
	
	/* active tab */
	/* draw text label */
	UI_ThemeColor(TH_TITLE);
	
	hrect= *rect;
	if(dir == 'h') {
		hrect.xmin= rect->xmin+pnl_icons;
		uiStyleFontDraw(&style->paneltitle, &hrect, activename);
	}
	else {
		/* ignore 'pnl_icons', otherwise the text gets offset horizontally 
		 * + 0.001f to avoid flirting with float inaccuracy
		 */
		hrect.xmin= rect->xmin + (PNL_ICON+5)/block->aspect + 0.001f;
		uiStyleFontDrawRotated(&style->paneltitle, &hrect, activename);
	}
}
示例#2
0
static void file_draw_string(int sx, int sy, const char *string, float width, int height, short align)
{
	uiStyle *style = UI_GetStyle();
	uiFontStyle fs = style->widgetlabel;
	rcti rect;
	char fname[FILE_MAXFILE];

	fs.align = align;

	BLI_strncpy(fname, string, FILE_MAXFILE);
	file_shorten_string(fname, width + 1.0f, 0);

	/* no text clipping needed, uiStyleFontDraw does it but is a bit too strict (for buttons it works) */
	rect.xmin = sx;
	rect.xmax = (int)(sx + ceil(width + 4.0f));
	rect.ymin = sy - height;
	rect.ymax = sy;
	
	uiStyleFontDraw(&fs, &rect, fname);
}