[Bf-committers] Test of new tooltip appearance

Kenneth Styrberg bf-committers@blender.org
Sun, 23 May 2004 00:04:17 +0200


Hi,

I've been testing a new tooltip appearance. I've still only implemented 
it for Internal fonts so deselect international fonts to test. (It will 
break the other tooltips appearance)

The size is now fixed even if menus are zoomed in or out.


Comments?!

//styken



/cvsroot/bf-blender/blender/source/blender/src/interface.c
~ line:2834

static uiSaveUnder *ui_draw_but_tip(uiBut *but)
{
    uiSaveUnder *su;
    float x1, x2, y1, y2;
    short mouse[2];
    int xmin,xmax,ymin,ymax;

    uiGetMouse(mywinget(), mouse);

#ifdef INTERNATIONAL
    if(G.ui_international == TRUE) {
        float llx,lly,llz,urx,ury,urz;  //for FTF_GetBoundingBox()

        if(U.transopts & USER_TR_TOOLTIPS) {
            FTF_GetBoundingBox(but->tip, &llx,&lly,&llz,&urx,&ury,&urz, 
FTF_USE_GETTEXT | FTF_INPUT_UTF8);

            x1= (but->x1+but->x2)/2; x2= 10+x1+ 
but->aspect*FTF_GetStringWidth(but->tip, FTF_USE_GETTEXT | 
FTF_INPUT_UTF8);  //BMF_GetStringWidth(but->font, but->tip);
            y1= but->y1-(ury+FTF_GetSize())-16; y2= but->y1-8;
        } else {
            FTF_GetBoundingBox(but->tip, &llx,&lly,&llz,&urx,&ury,&urz, 
FTF_NO_TRANSCONV | FTF_INPUT_UTF8);

            x1= (but->x1+but->x2)/2; x2= 10+x1+ 
but->aspect*FTF_GetStringWidth(but->tip, FTF_NO_TRANSCONV | 
FTF_INPUT_UTF8);  //BMF_GetStringWidth(but->font, but->tip);
            y1= but->y1-(ury+FTF_GetSize())-16; y2= but->y1-8;
        }
    } else {

        BMF_GetBoundingBox(UIfont[0].medium, &xmin, &ymin, &xmax, &ymax);

        x1 = mouse[0];
        y1 = mouse[1];

    }
#else

    x1= (but->x1+but->x2)/2; x2= 10+x1+ 
but->aspect*BMF_GetStringWidth(but->font, but->tip);
      y1= but->y1-35; y2= but->y1-10;
#endif

    /* for pulldown menus it doesnt work */
    if(mywinget()==G.curscreen->mainwin);
    else {
       
        ui_graphics_to_window(mywinget(), &x1, &y1);
        y1 -= 32;
        x2 = 4 + x1 + BMF_GetStringWidth(UIfont[0].medium, but->tip);
        y2 = y1 + (ymax - ymin) + 1;
    }
   
    if(x2 > G.curscreen->sizex) {
        x1 -= x2-G.curscreen->sizex;
        x2= G.curscreen->sizex;
    }
    if(y1 < 0) {
        y1 += 32;
        y2 += 32;
    }

    // adjust tooltip heights
    if(mywinget()==G.curscreen->mainwin)
        y2 -= G.ui_international ? 4:1;        //tip is from pulldownmenu
    else if(curarea->win != mywinget())
        y2 -= G.ui_international ? 5:1;        //tip is from a windowheader

    su= ui_bgnpupdraw((int)(x1-1), (int)(y1-2), (int)(x2+4), 
(int)(y2+4), 0);

    glColor3ub(0,0,0);
    glRectf(x1-1, y1-1, x2+1, y2+1);

    glColor3ub(0xFF, 0xFF, 0xDD);
    glRectf(x1, y1, x2, y2);

    glColor3ub(0,0,0);
    glRasterPos2f(x1+3, y1+4);

    BIF_DrawString(UIfont[0].medium, but->tip, (U.transopts & 
USER_TR_TOOLTIPS));
    glFinish();        /* to show it in the frontbuffer */
    return su;
}