Bugfix from own testing:

In outliner, the icons sometimes were drawing too large or too small.
Same happened in NLA, Action, Image window etc. And it happened
for "International fonts" when set to use 'texture drawing'.

Reason: the API call for setting icon size BIF_icon_set_aspect() was not
used consistantly. Sometimes it was set, sometimes not. And even worse,
for every icon drawn in UI buttons, the icon lookup had to be done twice
because of the aspect function.

Solved it by removing this call, and adding a new function:
BIF_icon_draw_aspect()
The old BIF_icon_draw() call now draws with aspect 1.0 always. The icons
code already had optimal checking for changed sizes, zo a change in aspect
won't result in much cpu overhead. Plus it saves calling icons lookup code,
which will make it all a bit faster.

Andrea: I've added this aspect function a long while ago, I think you also
like it better how it is now? Please check!
This commit is contained in:
2006-06-29 09:44:08 +00:00
parent e5b3fb85e4
commit 5dac88dc58
11 changed files with 61 additions and 94 deletions

View File

@@ -48,9 +48,10 @@ struct Material;
void BIF_icons_init(int first_dyn_id);
int BIF_icon_get_width(int icon_id);
int BIF_icon_get_height(int icon_id);
void BIF_icon_set_aspect(int icon_id, float aspect);
void BIF_icon_draw(float x, float y, int icon_id);
void BIF_icon_draw_blended(float x, float y, int icon_id, int colorid, int shade);
void BIF_icon_draw_aspect(float x, float y, int icon_id, float aspect);
void BIF_icon_draw_aspect_blended(float x, float y, int icon_id, float aspect, int shade);
void BIF_icons_free();
void BIF_icons_free_drawinfo(void *drawinfo);

View File

@@ -788,8 +788,8 @@ static void draw_keylist(gla2DDrawInfo *di, int totvert, BezTriple **blist, floa
gla2DDrawTranslatePt(di, blist[v]->vec[1][0], ypos, &sc_x, &sc_y);
// draw_key_but(sc_x-5, sc_y-6, 13, 13, (blist[v]->f2 & 1));
if(blist[v]->f2 & 1) BIF_icon_draw_blended(sc_x-7, sc_y-6, ICON_SPACE2, TH_HEADER, 0);
else BIF_icon_draw_blended(sc_x-7, sc_y-6, ICON_SPACE3, TH_HEADER, 0);
if(blist[v]->f2 & 1) BIF_icon_draw_aspect(sc_x-7, sc_y-6, ICON_SPACE2, 1.0f);
else BIF_icon_draw_aspect(sc_x-7, sc_y-6, ICON_SPACE3, 1.0f);
}
}

View File

@@ -674,16 +674,16 @@ static void draw_image_view_icon(void)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if(G.sima->flag & SI_STICKYUVS) {
BIF_icon_draw(xPos, 5.0, ICON_STICKY2_UVS);
BIF_icon_draw_aspect(xPos, 5.0, ICON_STICKY2_UVS, 1.0f);
xPos = 25.0;
}
else if(!(G.sima->flag & SI_LOCALSTICKY)) {
BIF_icon_draw(xPos, 5.0, ICON_STICKY_UVS);
BIF_icon_draw_aspect(xPos, 5.0, ICON_STICKY_UVS, 1.0f);
xPos = 25.0;
}
if(G.sima->flag & SI_SELACTFACE) {
BIF_icon_draw(xPos, 5.0, ICON_DRAW_UVFACES);
BIF_icon_draw_aspect(xPos, 5.0, ICON_DRAW_UVFACES, 1.0f);
}
glBlendFunc(GL_ONE, GL_ZERO);

View File

@@ -132,9 +132,9 @@ static void draw_nla_channels(void)
if(ob->nlastrips.first && ob->action) {
glEnable(GL_BLEND);
if(ob->nlaflag & OB_NLA_OVERRIDE)
BIF_icon_draw_blended(x+5, y-8, ICON_NLA, TH_HEADER, 0);
BIF_icon_draw(x+5, y-8, ICON_NLA);
else
BIF_icon_draw_blended(x+5, y-8, ICON_ACTION, TH_HEADER, 0);
BIF_icon_draw(x+5, y-8, ICON_ACTION);
glDisable(GL_BLEND);
}
y-=NLACHANNELHEIGHT+NLACHANNELSKIP;
@@ -156,7 +156,7 @@ static void draw_nla_channels(void)
if(strip->flag & ACTSTRIP_ACTIVE) break;
if(strip==NULL) {
glEnable(GL_BLEND);
BIF_icon_draw_blended(x, y-8, ICON_DOT, TH_BACK, 0);
BIF_icon_draw(x, y-8, ICON_DOT);
glDisable(GL_BLEND);
}
@@ -180,7 +180,7 @@ static void draw_nla_channels(void)
if(strip->flag & ACTSTRIP_ACTIVE) {
glEnable(GL_BLEND);
BIF_icon_draw_blended(x+16, y-8, ICON_DOT, TH_BACK, 0);
BIF_icon_draw(x+16, y-8, ICON_DOT);
glDisable(GL_BLEND);
}
}

View File

@@ -1473,31 +1473,28 @@ static void node_draw_basis(ScrArea *sa, SpaceNode *snode, bNode *node)
icon_id= ICON_MATERIAL_DEHLT;
iconofs-= 18.0f;
glEnable(GL_BLEND);
BIF_icon_set_aspect(icon_id, snode->aspect);
BIF_icon_draw_blended(iconofs, rct->ymax-NODE_DY+2, icon_id, 0, -60);
BIF_icon_draw_aspect_blended(iconofs, rct->ymax-NODE_DY+2, icon_id, snode->aspect, -60);
glDisable(GL_BLEND);
}
if(node->type == NODE_GROUP) {
iconofs-= 18.0f;
glEnable(GL_BLEND);
BIF_icon_set_aspect(ICON_NODE, snode->aspect);
if(node->id->lib) {
glPixelTransferf(GL_GREEN_SCALE, 0.7f);
glPixelTransferf(GL_BLUE_SCALE, 0.3f);
BIF_icon_draw(iconofs, rct->ymax-NODE_DY+2, ICON_NODE);
BIF_icon_draw_aspect(iconofs, rct->ymax-NODE_DY+2, ICON_NODE, snode->aspect);
glPixelTransferf(GL_GREEN_SCALE, 1.0f);
glPixelTransferf(GL_BLUE_SCALE, 1.0f);
}
else {
BIF_icon_draw_blended(iconofs, rct->ymax-NODE_DY+2, ICON_NODE, 0, -60);
BIF_icon_draw_aspect_blended(iconofs, rct->ymax-NODE_DY+2, ICON_NODE, snode->aspect, -60);
}
glDisable(GL_BLEND);
}
if(node->typeinfo->flag & NODE_OPTIONS) {
iconofs-= 18.0f;
glEnable(GL_BLEND);
BIF_icon_set_aspect(ICON_BUTS, snode->aspect);
BIF_icon_draw_blended(iconofs, rct->ymax-NODE_DY+2, ICON_BUTS, 0, -60);
BIF_icon_draw_aspect_blended(iconofs, rct->ymax-NODE_DY+2, ICON_BUTS, snode->aspect, -60);
glDisable(GL_BLEND);
}
{ /* always hide/reveil unused sockets */
@@ -1509,8 +1506,7 @@ static void node_draw_basis(ScrArea *sa, SpaceNode *snode, bNode *node)
else
shade= -90;
glEnable(GL_BLEND);
BIF_icon_set_aspect(ICON_PLUS, snode->aspect);
BIF_icon_draw_blended(iconofs, rct->ymax-NODE_DY+2, ICON_PLUS, 0, shade);
BIF_icon_draw_aspect_blended(iconofs, rct->ymax-NODE_DY+2, ICON_PLUS, snode->aspect, shade);
glDisable(GL_BLEND);
}

View File

@@ -136,9 +136,9 @@ static void draw_marker(TimeMarker *marker)
/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
if(marker->flag & SELECT)
BIF_icon_draw_blended(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER_HLT, TH_BACK, 0);
BIF_icon_draw(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER_HLT);
else
BIF_icon_draw_blended(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER, TH_BACK, 0);
BIF_icon_draw(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER);
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);

View File

@@ -3564,25 +3564,6 @@ void draw_area_emboss(ScrArea *sa)
sdrawline(0, 0, 0, sa->winy);
glDisable( GL_BLEND );
/* for test */
if(FALSE && sa->spacetype==SPACE_VIEW3D) {
cpack(0xA0A0A0);
uiSetRoundBox(31);
uiRoundBoxEmboss(5.0, 5.0, 25.0, 100.0, 8.0, 0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
BIF_icon_draw(8.0, 10.0, ICON_MATERIAL_HLT);
BIF_icon_draw(8.0, 30.0, ICON_IPO_HLT);
BIF_icon_draw(8.0, 50.0, ICON_HOME);
BIF_icon_draw(8.0, 70.0, ICON_BORDERMOVE);
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
}
}

View File

@@ -204,9 +204,6 @@ static void ui_draw_icon(uiBut *but, BIFIconID icon)
ys= (but->y1+but->y2- height)/2.0;
}
/* aspect for the icon has to be stored */
BIF_icon_set_aspect(icon, aspect);
glEnable(GL_BLEND);
/* calculate blend color */
@@ -215,7 +212,7 @@ static void ui_draw_icon(uiBut *but, BIFIconID icon)
else if(but->flag & UI_ACTIVE);
else blend= -60;
}
BIF_icon_draw_blended(xs, ys, icon, but->themecol, blend);
BIF_icon_draw_aspect_blended(xs, ys, icon, aspect, blend);
glDisable(GL_BLEND);

View File

@@ -772,32 +772,36 @@ static void icon_set_image(ID *id, DrawInfo *di)
}
}
void BIF_icon_draw(float x, float y, int icon_id)
void BIF_icon_draw_aspect(float x, float y, int icon_id, float aspect)
{
Icon *icon = NULL;
DrawInfo *di = NULL;
icon = BKE_icon_get(icon_id);
if (!icon) {
printf("BIF_icon_draw: Internal error, no icon for icon ID: %d\n", icon_id);
printf("BIF_icon_set_aspect: Internal error, no icon for icon ID: %d\n", icon_id);
return;
}
di = (DrawInfo*)icon->drawinfo;
if (!di) {
di = icon_create_drawinfo();
icon->changed = 1;
icon->drawinfo = di;
icon->drawinfo_free = BIF_icons_free_drawinfo;
icon->drawinfo_free = BIF_icons_free_drawinfo;
}
di->aspect = aspect;
/* scale width and height according to aspect */
di->w = (int)(ICON_DEFAULT_HEIGHT/di->aspect + 0.5f);
di->h = (int)(ICON_DEFAULT_HEIGHT/di->aspect + 0.5f);
if (di->drawFunc) {
/* vector icons use the uiBlock transformation, they are not drawn
with untransformed coordinates like the other icons */
with untransformed coordinates like the other icons */
di->drawFunc(x, y, ICON_DEFAULT_HEIGHT, ICON_DEFAULT_HEIGHT, 1.0f);
}
else {
@@ -808,7 +812,7 @@ void BIF_icon_draw(float x, float y, int icon_id)
icon->changed = 0;
waitcursor(0);
}
if (!di->rect) return; /* something has gone wrong! */
ui_rasterpos_safe(x, y, di->aspect);
@@ -826,11 +830,11 @@ void BIF_icon_draw(float x, float y, int icon_id)
/* first allocate imbuf for scaling and copy preview into it */
ima = IMB_allocImBuf(di->rw, di->rh, 32, IB_rect, 0);
memcpy(ima->rect, di->rect, di->rw*di->rh*sizeof(unsigned int));
/* scale it */
IMB_scaleImBuf(ima, di->w, di->h);
glDrawPixels(di->w, di->h, GL_RGBA, GL_UNSIGNED_BYTE, ima->rect);
IMB_freeImBuf(ima);
}
else
@@ -838,8 +842,13 @@ void BIF_icon_draw(float x, float y, int icon_id)
}
}
void BIF_icon_draw(float x, float y, int icon_id)
{
BIF_icon_draw_aspect(x, y, icon_id, 1.0f);
}
void BIF_icon_draw_blended(float x, float y, int icon_id, int colorid, int shade)
void BIF_icon_draw_aspect_blended(float x, float y, int icon_id, float aspect, int shade)
{
if(shade < 0) {
@@ -847,36 +856,9 @@ void BIF_icon_draw_blended(float x, float y, int icon_id, int colorid, int shade
glPixelTransferf(GL_ALPHA_SCALE, r);
}
BIF_icon_draw(x, y, icon_id);
BIF_icon_draw_aspect(x, y, icon_id, aspect);
glPixelTransferf(GL_ALPHA_SCALE, 1.0);
}
void BIF_icon_set_aspect(int icon_id, float aspect)
{
Icon *icon = NULL;
DrawInfo *di = NULL;
icon = BKE_icon_get(icon_id);
if (!icon) {
printf("BIF_icon_set_aspect: Internal error, no icon for icon ID: %d\n", icon_id);
return;
}
di = (DrawInfo*)icon->drawinfo;
if (!di) {
di = icon_create_drawinfo();
icon->changed = 1;
icon->drawinfo = di;
icon->drawinfo_free = BIF_icons_free_drawinfo;
}
di->aspect = aspect;
/* scale width and height according to aspect */
di->w = (int)(ICON_DEFAULT_HEIGHT/di->aspect + 0.5f);
di->h = (int)(ICON_DEFAULT_HEIGHT/di->aspect + 0.5f);
if(shade < 0)
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
}

View File

@@ -1120,11 +1120,6 @@ void ui_draw_panel(uiBlock *block)
if(panel->control & UI_PNL_CLOSE) {
ui_draw_x_icon(block->minx+2+ofsx, block->maxy+5);
/*
if(block->aspect>1.1) glPixelZoom(1.0/block->aspect, 1.0/block->aspect);
BIF_icon_draw(block->minx+4, block->maxy+3, ICON_PANEL_CLOSE);
if(block->aspect>1.1) glPixelZoom(1.0, 1.0);
*/
ofsx= 22;
}

View File

@@ -637,6 +637,21 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
outliner_add_element(soops, &te->subtree, key->ipo, te, 0, 0);
}
break;
case ID_IP:
{
Ipo *ipo= (Ipo *)id;
IpoCurve *icu;
Object *lastadded= NULL;
for(icu= ipo->curve.first; icu; icu= icu->next) {
if(icu->driver && icu->driver->ob) {
if(lastadded!=icu->driver->ob) {
outliner_add_element(soops, &te->subtree, icu->driver->ob, te, TSE_LINKED_OB, 0);
lastadded= icu->driver->ob;
}
}
}
}
case ID_AC:
{
bAction *act= (bAction *)id;