コード例 #1
0
static void ui_id_icon_render(bContext *C, ID *id, const bool big)
{
	PreviewImage *pi = BKE_previewimg_get(id);

	if (pi) {
		if (big)
			ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_PREVIEW);  /* bigger preview size */
		else
			ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_ICON);     /* icon size */
	}
}
コード例 #2
0
static void ui_id_brush_render(bContext *C, ID *id)
{
	PreviewImage *pi = BKE_previewimg_get(id); 
	enum eIconSizes i;
	
	if (!pi)
		return;
	
	for (i = 0; i < NUM_ICON_SIZES; i++) {
		/* check if rect needs to be created; changed
		 * only set by dynamic icons */
		if ((pi->changed[i] || !pi->rect[i])) {
			icon_set_image(C, id, pi, i);
			pi->changed[i] = 0;
		}
	}
}
コード例 #3
0
static void ui_id_icon_render(bContext *C, ID *id, int big)
{
	PreviewImage *pi = BKE_previewimg_get(id); 
	
	if (pi) {			
		if ((pi->changed[0] ||!pi->rect[0])) /* changed only ever set by dynamic icons */
		{
			/* create the rect if necessary */				
			
			icon_set_image(C, id, pi, ICON_SIZE_ICON);		/* icon size */
			if (big)
				icon_set_image(C, id, pi, ICON_SIZE_PREVIEW);	/* bigger preview size */
			
			pi->changed[0] = 0;
		}
	}
}
コード例 #4
0
void BKE_icon_changed(int id)
{
	Icon *icon = NULL;
	
	if (!id || G.background) return;

	icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(id));
	
	if (icon) {
		PreviewImage *prv = BKE_previewimg_get((ID *)icon->obj);

		/* all previews changed */
		if (prv) {
			int i;
			for (i = 0; i < NUM_ICON_SIZES; ++i) {
				prv->changed[i] = 1;
				prv->changed_timestamp[i]++;
			}
		}
	}
}
コード例 #5
0
static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, const float rgb[3],
                           enum eIconSizes size, int draw_size, const bool UNUSED(nocreate), const bool is_preview)
{
	bTheme *btheme = UI_GetTheme();
	Icon *icon = NULL;
	DrawInfo *di = NULL;
	IconImage *iimg;
	const float fdraw_size = (float)draw_size;
	int w, h;
	
	icon = BKE_icon_get(icon_id);
	alpha *= btheme->tui.icon_alpha;
	
	if (icon == NULL) {
		if (G.debug & G_DEBUG)
			printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
		return;
	}

	di = (DrawInfo *)icon->drawinfo;
	
	if (!di) {
		di = icon_create_drawinfo();
	
		icon->drawinfo = di;
		icon->drawinfo_free = UI_icons_free_drawinfo;
	}
	
	/* scale width and height according to aspect */
	w = (int)(fdraw_size / aspect + 0.5f);
	h = (int)(fdraw_size / aspect + 0.5f);
	
	if (di->type == ICON_TYPE_VECTOR) {
		/* vector icons use the uiBlock transformation, they are not drawn
		 * with untransformed coordinates like the other icons */
		di->data.vector.func((int)x, (int)y, w, h, 1.0f);
	}
	else if (di->type == ICON_TYPE_TEXTURE) {
		/* texture image use premul alpha for correct scaling */
		glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
		icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y,
		                  di->data.texture.w, di->data.texture.h, alpha, rgb);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}
	else if (di->type == ICON_TYPE_BUFFER) {
		/* it is a builtin icon */
		iimg = di->data.buffer.image;
#ifndef WITH_HEADLESS
		icon_verify_datatoc(iimg);
#endif
		if (!iimg->rect) return;  /* something has gone wrong! */

		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}
	else if (di->type == ICON_TYPE_PREVIEW) {
		PreviewImage *pi = BKE_previewimg_get((ID *)icon->obj);

		if (pi) {
			/* no create icon on this level in code */
			if (!pi->rect[size]) return;  /* something has gone wrong! */
			
			/* preview images use premul alpha ... */
			glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
			icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], 1.0f, NULL, is_preview);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		}
	}
}