Bugfix from own testing:
authorTon Roosendaal <ton@blender.org>
Thu, 29 Jun 2006 09:44:08 +0000 (09:44 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 29 Jun 2006 09:44:08 +0000 (09:44 +0000)
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!

source/blender/include/BIF_interface_icons.h
source/blender/src/drawaction.c
source/blender/src/drawimage.c
source/blender/src/drawnla.c
source/blender/src/drawnode.c
source/blender/src/drawtime.c
source/blender/src/editscreen.c
source/blender/src/interface_draw.c
source/blender/src/interface_icons.c
source/blender/src/interface_panel.c
source/blender/src/outliner.c

index 1eb70c5185c66cd2a1232f63352c1ca0b967e135..45f00dfb5914b65be7adaacdbef379e82d090000 100644 (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);
 
index 0a4f52b617484bf68b9ec5e8e60fed455e41a3f9..a76db77ef2257f7ebcca200b55bd3f00d742b347 100644 (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);
 
                }
        }                       
index 7eb30880bdc13cc5e8faec6423726782770933aa..dcf880df300912f8f7d21d429bdd447238befe67 100644 (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); 
index 9232feb3d41f93c5e5e282e6c211b9f694477dea..9c66eae794bccb72f9f6b3db712c6c9297576a00 100644 (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);
                                        }
                                }
index 68fbe34e1db7cc8819b50f7007aeaf4ac88654ee..205aa815b961d09f507a38d92c6a7f3cf89d5d13 100644 (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);
        }
        
index 7ad6c492c5bc6e89481bc1c8c5ede7f098443ce2..11d38cba844e8892e0f6b934ef6b416081e00d69 100644 (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);            
index 40ab5735e08fbca9d417c399e78f8978175b089f..429d803bcd434b8250b0f9e598a72a3b87281595 100644 (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);
-       }
 }
 
 
index 4f799142769557a146a67f004cb2602c920b8d96..f42d16a6d5a608978361e97ce584b58a4cba4b53 100644 (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);
 
index 9d759b7aa6dd4ca17b1174c79d18cd79da0034f7..36c0e766bc6903e723f0869b4512ce0e4adc722f 100644 (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);
-
-       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;
+       BIF_icon_draw_aspect(x, y, icon_id, aspect);
 
-       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);
 }
 
index e61d80c6121fc7b428281eae63c7a81c9cdc97d2..36dca12ee67babba0c64e26096bdf591f8ce8731 100644 (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;
        }
 
index 152e88ef65793c53ee7931e3a13921e18620da43..f33a4996186812867dfe7bfa28686041073a36b8 100644 (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;