diff options
author | Ton Roosendaal <ton@blender.org> | 2009-04-07 21:08:26 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-04-07 21:08:26 +0400 |
commit | 654a30aa2d9feb455e5fa6a856bee8ab6a0eca85 (patch) | |
tree | 0223182c27365d23608e4f41d9e18a16ef0ed29c /source/blender/editors/interface/interface_draw.c | |
parent | 7c74d1dfa36376ebd5757d990af0ce6813130100 (diff) |
2.5
- Widgets now draw projected themselves, putting window/region matrix
on 1:1 pixelspace. This allows zoomable buttons, but crispy.
- Note: text in smaller buttons dont get clipped correct now, WIP
- Fixed error with button types in some menus.
- removed temp UI_2_50 define hack.
Diffstat (limited to 'source/blender/editors/interface/interface_draw.c')
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 263 |
1 files changed, 0 insertions, 263 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index e623a906f16..fc3808a6608 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -507,271 +507,8 @@ void uiEmboss(float x1, float y1, float x2, float y2, int sel) } -/* ************** GENERIC ICON DRAW, NO THEME HERE ************* */ - -/* icons have been standardized... and this call draws in untransformed coordinates */ -#define ICON_HEIGHT 16.0f - -void ui_draw_icon(uiBut *but, BIFIconID icon, int blend) -{ - float xs=0, ys=0, aspect, height; - - /* this icon doesn't need draw... */ - if(icon==ICON_BLANK1) return; - - /* we need aspect from block, for menus... these buttons are scaled in uiPositionBlock() */ - aspect= but->block->aspect; - if(aspect != but->aspect) { - /* prevent scaling up icon in pupmenu */ - if (aspect < 1.0f) { - height= ICON_HEIGHT; - aspect = 1.0f; - - } - else - height= ICON_HEIGHT/aspect; - } - else - height= ICON_HEIGHT; - - if(but->flag & UI_ICON_LEFT) { - if (but->type==BUT_TOGDUAL) { - if (but->drawstr[0]) { - xs= but->x1-1.0; - } else { - xs= (but->x1+but->x2- height)/2.0; - } - } - else if (but->block->flag & UI_BLOCK_LOOP) { - xs= but->x1+1.0; - } - else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) { - xs= but->x1+3.0; - } - else { - xs= but->x1+4.0; - } - ys= (but->y1+but->y2- height)/2.0; - } - if(but->flag & UI_ICON_RIGHT) { - xs= but->x2-17.0; - ys= (but->y1+but->y2- height)/2.0; - } - if (!((but->flag & UI_ICON_RIGHT) || (but->flag & UI_ICON_LEFT))) { - xs= (but->x1+but->x2- height)/2.0; - ys= (but->y1+but->y2- height)/2.0; - } - - glEnable(GL_BLEND); - - /* calculate blend color */ - if ELEM3(but->type, TOG, ROW, TOGN) { - if(but->flag & UI_SELECT); - else if(but->flag & UI_ACTIVE); - else blend= -60; - } - if (but->flag & UI_BUT_DISABLED) blend = -100; - - UI_icon_draw_aspect_blended(xs, ys, icon, aspect, blend); - - glDisable(GL_BLEND); -} - - - - /* ************** TEXT AND ICON DRAWING FUNCTIONS ************* */ -#define BUT_TEXT_NORMAL 0 -#define BUT_TEXT_SUNKEN 1 - -void ui_draw_text(uiBut *but, float x, float y, int sunken) -{ - int alpha_offs= (but->flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0; - int transopts; - int len; - float ypos = (sunken==BUT_TEXT_SUNKEN) ? (y-1) : y; - char *cpoin; - - if(but->type==LABEL && but->hardmin!=0.0) { - UI_ThemeColor(TH_BUT_TEXT_HI); - } - else if(but->dt==UI_EMBOSSP) { - if((but->flag & UI_ACTIVE) && but->type!=LABEL) { // LABEL = title in pulldowns - UI_ThemeColorShadeAlpha(TH_MENU_TEXT_HI, 0, alpha_offs); - } else { - UI_ThemeColorShadeAlpha(TH_MENU_TEXT, 0, alpha_offs); - } - } - else { - if(but->flag & UI_SELECT) { - UI_ThemeColorShadeAlpha(TH_BUT_TEXT_HI, 0, alpha_offs); - } else { - UI_ThemeColorShadeAlpha(TH_BUT_TEXT, 0, alpha_offs); - } - } - - if (sunken == BUT_TEXT_SUNKEN) { - float curcol[4]; - - glGetFloatv(GL_CURRENT_COLOR, curcol); /* returns four components: r,g,b,a */ - - /* only draw embossed text if the text color is darker than 0.5 mid-grey */ - if ((curcol[0] + curcol[1] + curcol[2]) * 0.3f < 0.5f) - glColor4f(0.6f, 0.6f, 0.6f, 0.3f); - else - return; - } - - ui_rasterpos_safe(x, ypos, but->aspect); - if(but->type==IDPOIN) transopts= 0; // no translation, of course! - else transopts= ui_translate_buttons(); - - /* cut string in 2 parts */ - cpoin= strchr(but->drawstr, '|'); - if(cpoin) *cpoin= 0; - -#ifdef INTERNATIONAL - if (but->type == FTPREVIEW) - FTF_DrawNewFontString (but->drawstr+but->ofs, FTF_INPUT_UTF8); - else - UI_DrawString(but->font, but->drawstr+but->ofs, transopts); -#else - UI_DrawString(but->font, but->drawstr+but->ofs, transopts); -#endif - - /* part text right aligned */ - if(cpoin) { - len= UI_GetStringWidth(but->font, cpoin+1, ui_translate_buttons()); - ui_rasterpos_safe( but->x2 - len*but->aspect-3, ypos, but->aspect); - UI_DrawString(but->font, cpoin+1, ui_translate_buttons()); - *cpoin= '|'; - } -} - -/* draws text and icons for buttons */ -void ui_draw_text_icon(uiBut *but) -{ - float x, y; - short t, pos, ch; - short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw; - - /* check for button text label */ - if (but->type == ICONTEXTROW) { - ui_draw_icon(but, (BIFIconID) (but->icon+but->iconadd), 0); - } - else { - - /* text button selection and cursor */ - if(but->editstr && but->pos != -1) { - - if ((but->selend - but->selsta) > 0) { - /* text button selection */ - selsta_tmp = but->selsta + strlen(but->str); - selend_tmp = but->selend + strlen(but->str); - - if(but->drawstr[0]!=0) { - ch= but->drawstr[selsta_tmp]; - but->drawstr[selsta_tmp]= 0; - - selsta_draw = but->aspect*UI_GetStringWidth(but->font, but->drawstr+but->ofs, ui_translate_buttons()) + 3; - - but->drawstr[selsta_tmp]= ch; - - - ch= but->drawstr[selend_tmp]; - but->drawstr[selend_tmp]= 0; - - selwidth_draw = but->aspect*UI_GetStringWidth(but->font, but->drawstr+but->ofs, ui_translate_buttons()) + 3; - - but->drawstr[selend_tmp]= ch; - - UI_ThemeColor(TH_BUT_TEXTFIELD_HI); - glRects(but->x1+selsta_draw+1, but->y1+2, but->x1+selwidth_draw+1, but->y2-2); - } - } else { - /* text cursor */ - pos= but->pos+strlen(but->str); - if(pos >= but->ofs) { - if(but->drawstr[0]!=0) { - ch= but->drawstr[pos]; - but->drawstr[pos]= 0; - - t= but->aspect*UI_GetStringWidth(but->font, but->drawstr+but->ofs, ui_translate_buttons()) + 3; - - but->drawstr[pos]= ch; - } - else t= 3; - - glColor3ub(255,0,0); - glRects(but->x1+t, but->y1+2, but->x1+t+2, but->y2-2); - } - } - } - - if(but->type==BUT_TOGDUAL) { - int dualset= 0; - if(but->pointype==SHO) - dualset= BTST( *(((short *)but->poin)+1), but->bitnr); - else if(but->pointype==INT) - dualset= BTST( *(((int *)but->poin)+1), but->bitnr); - - ui_draw_icon(but, ICON_DOT, dualset?0:-100); - } - - if(but->drawstr[0]!=0) { - int tog3= 0; - - /* If there's an icon too (made with uiDefIconTextBut) then draw the icon - and offset the text label to accomodate it */ - - if ( (but->flag & UI_HAS_ICON) && (but->flag & UI_ICON_LEFT) ) - { - ui_draw_icon(but, but->icon, 0); - - if(but->editstr || (but->flag & UI_TEXT_LEFT)) x= but->x1 + but->aspect*UI_icon_get_width(but->icon)+5.0; - else x= (but->x1+but->x2-but->strwidth+1)/2.0; - } - else - { - if(but->editstr || (but->flag & UI_TEXT_LEFT)) - x= but->x1+4.0; - else if ELEM3(but->type, TOG, TOGN, TOG3) - x= but->x1+18.0; /* offset for checkmark */ - else - x= (but->x1+but->x2-but->strwidth+1)/2.0; - } - - /* tog3 button exception; draws with glColor! */ - if(but->type==TOG3 && (but->flag & UI_SELECT)) { - - if( but->pointype==CHA ) { - if( BTST( *(but->poin+2), but->bitnr )) tog3= 1; - } - else if( but->pointype ==SHO ) { - short *sp= (short *)but->poin; - if( BTST( sp[1], but->bitnr )) tog3= 1; - } - -// ui_tog3_invert(but->x1,but->y1,but->x2,but->y2, tog3); - if (tog3) glColor3ub(255, 255, 0); - } - - /* position and draw */ - y = (but->y1+but->y2- 9.0)/2.0; - - if (ELEM(but->type, LABEL, PULLDOWN) && !(but->flag & UI_ACTIVE)) - ui_draw_text(but, x, y, BUT_TEXT_SUNKEN); - - ui_draw_text(but, x, y, BUT_TEXT_NORMAL); - - } - /* if there's no text label, then check to see if there's an icon only and draw it */ - else if( but->flag & UI_HAS_ICON ) { - ui_draw_icon(but, (BIFIconID) (but->icon+but->iconadd), 0); - } - } -} #if 0 #ifdef INTERNATIONAL |