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 | |
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')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 24 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 263 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 40 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 144 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 2 |
8 files changed, 160 insertions, 324 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d15ef90eee8..cb5c2da477f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -87,7 +87,6 @@ typedef struct uiPopupBlockHandle uiPopupBlockHandle; #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 */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 6a763ce64be..e548bbd76ca 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -666,9 +666,24 @@ void uiDrawBlock(const bContext *C, uiBlock *block) 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 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short 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 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short but->bit= type & BIT; but->bitnr= type & 31; but->icon = 0; + but->dt= block->dt; BLI_addtail(&block->buttons, but); @@ -2360,7 +2372,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short 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 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 diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index ff9e099e676..e5f803dec33 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -40,7 +40,42 @@ struct uiHandleButtonData; struct wmEvent; struct wmWindow; -/* general defines */ +/* ****************** general defines ************** */ + +/* visual types for drawing */ +/* for time being separated from functional types */ +typedef enum { + /* standard set */ + UI_WTYPE_TOGGLE, + UI_WTYPE_OPTION, + UI_WTYPE_RADIO, + UI_WTYPE_NUMBER, + UI_WTYPE_SLIDER, + UI_WTYPE_EXEC, + + /* strings */ + UI_WTYPE_NAME, + UI_WTYPE_NAME_LINK, + UI_WTYPE_POINTER_LINK, + UI_WTYPE_FILENAME, + + /* menus */ + UI_WTYPE_MENU_RADIO, + UI_WTYPE_MENU_POINTER_LINK, + + UI_WTYPE_PULLDOWN, + UI_WTYPE_MENU_ITEM, + UI_WTYPE_MENU_BACK, + + /* specials */ + UI_WTYPE_ICON, + UI_WTYPE_SWATCH, + UI_WTYPE_RGB_PICKER, + UI_WTYPE_NORMAL + +} uiWidgetTypeEnum; + + #define UI_MAX_DRAW_STR 400 #define UI_MAX_NAME_STR 64 @@ -338,9 +373,6 @@ extern void gl_round_box(int mode, float minx, float miny, float maxx, float max extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight); -void ui_draw_icon(uiBut *but, BIFIconID icon, int blend); -void ui_draw_text(uiBut *but, float x, float y, int sunken); - void ui_draw_but_COLORBAND(uiBut *but); void ui_draw_but_NORMAL(uiBut *but); void ui_draw_but_CURVE(ARegion *ar, uiBut *but); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 31eab12021c..61ae8c6b139 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -940,9 +940,6 @@ void uiRegionPanelLayout(const bContext *C, ARegion *ar, int vertical, char *con if(pt->draw && (!pt->poll || pt->poll(C))) { block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS, UI_HELV); - /* XXX temp, migration flag for drawing code */ - uiBlockSetFlag(block, UI_BLOCK_2_50); - w= (ar->type->minsizex)? ar->type->minsizex-22: UI_PANEL_WIDTH-22; if(uiNewPanel(C, ar, block, pt->name, pt->name, x, y, w, 0)) { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index ded1baa7747..788d31e699a 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -930,10 +930,9 @@ static void ui_draw_panel_style(ARegion *ar, uiBlock *block) void ui_draw_panel(ARegion *ar, uiBlock *block) { - if(block->flag & UI_BLOCK_2_50) - ui_draw_panel_style(ar, block); - else - ui_draw_panel_old(ar, block); + ui_draw_panel_style(ar, block); + + if(0) ui_draw_panel_old(ar, block); // XXX } /* ------------ panel alignment ---------------- */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c9b6fe9794c..cabebf19e3a 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -117,39 +117,6 @@ typedef struct uiWidgetBase { } uiWidgetBase; - -typedef enum { - /* standard set */ - UI_WTYPE_TOGGLE, - UI_WTYPE_OPTION, - UI_WTYPE_RADIO, - UI_WTYPE_NUMBER, - UI_WTYPE_SLIDER, - UI_WTYPE_EXEC, - - /* strings */ - UI_WTYPE_NAME, - UI_WTYPE_NAME_LINK, - UI_WTYPE_POINTER_LINK, - UI_WTYPE_FILENAME, - - /* menus */ - UI_WTYPE_MENU_RADIO, - UI_WTYPE_MENU_POINTER_LINK, - - UI_WTYPE_PULLDOWN, - UI_WTYPE_MENU_ITEM, - UI_WTYPE_MENU_BACK, - - /* specials */ - UI_WTYPE_ICON, - UI_WTYPE_SWATCH, - UI_WTYPE_RGB_PICKER, - UI_WTYPE_NORMAL - -} uiWidgetTypeEnum; - - /* uiWidgetType: for time being only for visual appearance, later, a handling callback can be added too */ @@ -662,6 +629,77 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) /* *********************** text/icon ************************************** */ + +/* icons have been standardized... and this call draws in untransformed coordinates */ +#define ICON_HEIGHT 16.0f + +static void widget_draw_icon(uiBut *but, BIFIconID icon, int blend, rcti *rect) +{ + 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= rect->xmin-1.0; + } else { + xs= (rect->xmin+rect->xmax- height)/2.0; + } + } + else if (but->block->flag & UI_BLOCK_LOOP) { + xs= rect->xmin+1.0; + } + else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) { + xs= rect->xmin+3.0; + } + else { + xs= rect->xmin+4.0; + } + ys= (rect->ymin+rect->ymax- height)/2.0; + } + if(but->flag & UI_ICON_RIGHT) { + xs= rect->xmax-17.0; + ys= (rect->ymin+rect->ymax- height)/2.0; + } + if (!((but->flag & UI_ICON_RIGHT) || (but->flag & UI_ICON_LEFT))) { + xs= (rect->xmin+rect->xmax- height)/2.0; + ys= (rect->ymin+rect->ymax- 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); +} + + + static void widget_draw_text(uiBut *but, float x, float y) { int transopts; @@ -705,7 +743,7 @@ static void widget_draw_text_icon(uiBut *but, rcti *rect, float *col) /* check for button text label */ if (but->type == ICONTEXTROW) { - ui_draw_icon(but, (BIFIconID) (but->icon+but->iconadd), 0); + widget_draw_icon(but, (BIFIconID) (but->icon+but->iconadd), 0, rect); } else { @@ -763,7 +801,7 @@ static void widget_draw_text_icon(uiBut *but, rcti *rect, float *col) else if(but->pointype==INT) dualset= BTST( *(((int *)but->poin)+1), but->bitnr); - ui_draw_icon(but, ICON_DOT, dualset?0:-100); + widget_draw_icon(but, ICON_DOT, dualset?0:-100, rect); } if(but->drawstr[0]!=0) { @@ -773,7 +811,7 @@ static void widget_draw_text_icon(uiBut *but, rcti *rect, float *col) if ( (but->flag & UI_HAS_ICON) && (but->flag & UI_ICON_LEFT) ) { - ui_draw_icon(but, but->icon, 0); + widget_draw_icon(but, but->icon, 0, rect); if(but->editstr || (but->flag & UI_TEXT_LEFT)) x= rect->xmin + but->aspect*UI_icon_get_width(but->icon)+5.0; else x= (rect->xmin+rect->xmax-but->strwidth+1)/2.0; @@ -797,7 +835,7 @@ static void widget_draw_text_icon(uiBut *but, rcti *rect, float *col) } /* 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); + widget_draw_icon(but, (BIFIconID) (but->icon+but->iconadd), 0, rect); } } } @@ -1413,7 +1451,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int ro recttemp.ymax-= delta; /* half rounded */ - round_box_edges(&wtb, roundboxalign, &recttemp, 4.0f); + round_box_edges(&wtb, 15, &recttemp, 4.0f); /* decoration */ if(state & UI_SELECT) { @@ -1627,17 +1665,37 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) return 15; } +static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBut *but) +{ + uiBlock *block= but->block; + float gx, gy; + float getsizex, getsizey; + + getsizex= ar->winx; + getsizey= ar->winy; + + gx= but->x1 + (block->panel?block->panel->ofsx:0.0f); + gy= but->y1 + (block->panel?block->panel->ofsy:0.0f); + + rect->xmin= floor(getsizex*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); + rect->ymin= floor(getsizey*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); + + gx= but->x2 + (block->panel?block->panel->ofsx:0.0f); + gy= but->y2 + (block->panel?block->panel->ofsy:0.0f); + + rect->xmax= floor(getsizex*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); + rect->ymax= floor(getsizey*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); +} + + /* conversion from old to new buttons, so still messy */ void ui_draw_but(ARegion *ar, uiBut *but) { uiWidgetType *wt= NULL; rcti rect; - /* XXX project later */ - rect.xmin= but->x1; - rect.xmax= but->x2; - rect.ymin= but->y1; - rect.ymax= but->y2; + /* project */ + ui_but_to_pixelrect(&rect, ar, but); /* handle menus seperately */ if(but->dt==UI_EMBOSSP) { diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 5c481652db1..17e5155d6cb 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -646,6 +646,8 @@ void ED_region_init(bContext *C, ARegion *ar) /* refresh can be called before window opened */ region_subwindow(CTX_wm_manager(C), CTX_wm_window(C), ar); + ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1; + ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1; } |