[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19584] branches/blender2.5/blender/source /blender/editors: 2.5
Ton Roosendaal
ton at blender.org
Tue Apr 7 19:08:26 CEST 2009
Revision: 19584
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19584
Author: ton
Date: 2009-04-07 19:08:26 +0200 (Tue, 07 Apr 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
branches/blender2.5/blender/source/blender/editors/interface/interface.c
branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
branches/blender2.5/blender/source/blender/editors/screen/area.c
Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-04-07 17:08:24 UTC (rev 19583)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-04-07 17:08:26 UTC (rev 19584)
@@ -87,7 +87,6 @@
#define UI_BLOCK_MOVEMOUSE_QUIT 128
#define UI_BLOCK_KEEP_OPEN 256
#define UI_BLOCK_POPUP 512
-#define UI_BLOCK_2_50 1024 /* XXX 2.5 migration flag */
/* uiPopupBlockHandle->menuretval */
#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-04-07 17:08:24 UTC (rev 19583)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-04-07 17:08:26 UTC (rev 19584)
@@ -666,9 +666,24 @@
if(block->drawextra) block->drawextra(C, block);
+ /* pixel space for AA widgets */
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ wmOrtho2(0.0f, ar->winx, 0.0f, ar->winy);
+
for(but= block->buttons.first; but; but= but->next)
ui_draw_but(ar, but);
+ /* restore matrix */
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+
ui_draw_links(block);
}
@@ -2311,12 +2326,8 @@
short slen;
if(type & BUTPOIN) { /* a pointer is required */
- if(poin==NULL) {
- /* if pointer is zero, button is removed and not drawn */
- UI_ThemeColor(block->themecol);
- glRects(x1, y1, x1+x2, y1+y2);
+ if(poin==NULL)
return NULL;
- }
}
but= MEM_callocN(sizeof(uiBut), "uiBut");
@@ -2326,6 +2337,7 @@
but->bit= type & BIT;
but->bitnr= type & 31;
but->icon = 0;
+ but->dt= block->dt;
BLI_addtail(&block->buttons, but);
@@ -2360,7 +2372,7 @@
but->lock= block->lock;
but->lockstr= block->lockstr;
- but->aspect= block->aspect;
+ but->aspect= 1.0f; //XXX block->aspect;
but->win= block->win;
but->block= block; // pointer back, used for frontbuffer status, and picker
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c 2009-04-07 17:08:24 UTC (rev 19583)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_draw.c 2009-04-07 17:08:26 UTC (rev 19584)
@@ -507,272 +507,9 @@
}
-/* ************** 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
static void ui_draw_but_CHARTAB(uiBut *but)
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h 2009-04-07 17:08:24 UTC (rev 19583)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h 2009-04-07 17:08:26 UTC (rev 19584)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list