static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNUSED(alpha)) { bTheme *btheme = UI_GetTheme(); ThemeWireColor *cs = &btheme->tarm[index]; /* Draw three bands of color: One per color * x-----a-----b-----c * | N | S | A | * x-----a-----b-----c */ const int a = x + w / 3; const int b = x + w / 3 * 2; const int c = x + w; /* XXX: Include alpha into this... */ /* normal */ glColor3ubv((unsigned char *)cs->solid); glRecti(x, y, a, y + h); /* selected */ glColor3ubv((unsigned char *)cs->select); glRecti(a, y, b, y + h); /* active */ glColor3ubv((unsigned char *)cs->active); glRecti(b, y, c, y + h); }
static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back) { bTheme *btheme = UI_GetTheme(); uiWidgetColors wcol = btheme->tui.wcol_scroll; unsigned char col[4]; float rad; UI_ThemeColor(TH_BACK); glRecti(back->xmin, back->ymin, back->xmax, back->ymax); uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0); uiSetRoundBox(UI_CNR_ALL); rad = 0.4f * min_ii(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll)); UI_GetThemeColor3ubv(TH_HILITE, col); col[3] = 48; glColor4ubv(col); glEnable(GL_BLEND); uiRoundBox(st->txtscroll.xmin + 1, st->txtscroll.ymin, st->txtscroll.xmax - 1, st->txtscroll.ymax, rad); glDisable(GL_BLEND); }
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 = (icon->type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : 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 ... */ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, rgb, is_preview); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } } }
static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), short is_preview) { bTheme *btheme= UI_GetTheme(); Icon *icon = NULL; DrawInfo *di = NULL; IconImage *iimg; float fdraw_size= is_preview ? draw_size : (draw_size * UI_DPI_ICON_FAC); int w, h; icon = BKE_icon_get(icon_id); alpha *= btheme->tui.icon_alpha; if (icon==NULL) { if (G.f & 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, ICON_DEFAULT_HEIGHT, ICON_DEFAULT_HEIGHT, 1.0f); } else if(di->type == ICON_TYPE_TEXTURE) { 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); } else if(di->type == ICON_TYPE_BUFFER) { /* it is a builtin icon */ iimg= di->data.buffer.image; if(!iimg->rect) return; /* something has gone wrong! */ icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview); } 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); } } }
static void init_internal_icons(void) { bTheme *btheme= UI_GetTheme(); ImBuf *bbuf= NULL; int x, y, icontype; char iconfilestr[FILE_MAX]; if ((btheme!=NULL) && btheme->tui.iconfile[0]) { char *icondir= BLI_get_folder(BLENDER_DATAFILES, "icons"); if (icondir) { BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile); bbuf = IMB_loadiffname(iconfilestr, IB_rect); /* if the image is missing bbuf will just be NULL */ if(bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) { printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr); IMB_freeImBuf(bbuf); bbuf= NULL; } } else { printf("%s: 'icons' data path not found, continuing\n", __func__); } } if(bbuf==NULL) bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_blender_icons_png, datatoc_blender_icons_png_size, IB_rect, "<blender icons>"); if(bbuf) { /* free existing texture if any */ if(icongltex.id) { glDeleteTextures(1, &icongltex.id); icongltex.id= 0; } /* we only use a texture for cards with non-power of two */ if(GPU_non_power_of_two_support()) { glGenTextures(1, &icongltex.id); if(icongltex.id) { icongltex.w = bbuf->x; icongltex.h = bbuf->y; icongltex.invw = 1.0f/bbuf->x; icongltex.invh = 1.0f/bbuf->y; glBindTexture(GL_TEXTURE_2D, icongltex.id); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bbuf->x, bbuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, bbuf->rect); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBindTexture(GL_TEXTURE_2D, 0); if(glGetError() == GL_OUT_OF_MEMORY) { glDeleteTextures(1, &icongltex.id); icongltex.id= 0; } } } } if(icongltex.id) icontype= ICON_TYPE_TEXTURE; else icontype= ICON_TYPE_BUFFER; if(bbuf) { for (y=0; y<ICON_GRID_ROWS; y++) { for (x=0; x<ICON_GRID_COLS; x++) { def_internal_icon(bbuf, BIFICONID_FIRST + y*ICON_GRID_COLS + x, x*(ICON_GRID_W+ICON_GRID_MARGIN)+ICON_GRID_MARGIN, y*(ICON_GRID_H+ICON_GRID_MARGIN)+ICON_GRID_MARGIN, ICON_GRID_W, icontype); } } } def_internal_vicon(VICO_VIEW3D_VEC, vicon_view3d_draw); def_internal_vicon(VICO_EDIT_VEC, vicon_edit_draw); def_internal_vicon(VICO_EDITMODE_DEHLT, vicon_editmode_dehlt_draw); def_internal_vicon(VICO_EDITMODE_HLT, vicon_editmode_hlt_draw); def_internal_vicon(VICO_DISCLOSURE_TRI_RIGHT_VEC, vicon_disclosure_tri_right_draw); def_internal_vicon(VICO_DISCLOSURE_TRI_DOWN_VEC, vicon_disclosure_tri_down_draw); def_internal_vicon(VICO_MOVE_UP_VEC, vicon_move_up_draw); def_internal_vicon(VICO_MOVE_DOWN_VEC, vicon_move_down_draw); def_internal_vicon(VICO_X_VEC, vicon_x_draw); def_internal_vicon(VICO_SMALL_TRI_RIGHT_VEC, vicon_small_tri_right_draw); IMB_freeImBuf(bbuf); }