WIP commit for new system to draw widgets and use themes or styles.

Not really interesting stuff to see in code now, the current 
structure will change quite a lot, this to make it hook up well
to the existing system.

What works quite well is a new full opengl vector method to draw 
scalable and pixel-aligned anti-aliased buttons.

http://download.blender.org/institute/rt3.jpg
http://download.blender.org/institute/rt4.jpg
This commit is contained in:
2009-03-25 16:58:42 +00:00
parent a26a3f423f
commit 2e48c4059a
7 changed files with 1076 additions and 19 deletions

View File

@@ -86,6 +86,7 @@ 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 */

View File

@@ -450,8 +450,8 @@ void uiRoundRectFakeAA(float minx, float miny, float maxx, float maxy, float rad
/* get the colour and divide up the alpha */
glGetFloatv(GL_CURRENT_COLOR, color);
alpha = color[3];
color[3]= alpha/(float)passes;
alpha = 1; //color[3];
color[3]= 0.5*alpha/(float)passes;
glColor4fv(color);
/* set the 'jitter amount' */
@@ -630,7 +630,7 @@ void uiEmboss(float x1, float y1, float x2, float y2, int sel)
/* icons have been standardized... and this call draws in untransformed coordinates */
#define ICON_HEIGHT 16.0f
static void ui_draw_icon(uiBut *but, BIFIconID icon, int blend)
void ui_draw_icon(uiBut *but, BIFIconID icon, int blend)
{
float xs=0, ys=0, aspect, height;
@@ -929,8 +929,8 @@ static void round_button_flat(int colorid, float asp, float x1, float y1, float
int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
/* emboss */
glColor4f(1.0f, 1.0f, 1.0f, 0.08f);
uiRoundRectFakeAA(x1+1, y1-1, x2, y2-1, rad, asp);
//glColor4f(1.0f, 1.0f, 1.0f, 0.08f);
//uiRoundRectFakeAA(x1+1, y1-1, x2, y2-1, rad, asp);
/* colour shading */
if(flag & UI_SELECT) {
@@ -2205,7 +2205,7 @@ static void ui_draw_pulldown_round(int type, int colorid, float asp, float x1, f
#define BUT_TEXT_NORMAL 0
#define BUT_TEXT_SUNKEN 1
static void ui_draw_text(uiBut *but, float x, float y, int sunken)
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;
@@ -2270,7 +2270,7 @@ static void ui_draw_text(uiBut *but, float x, float y, int sunken)
}
/* draws text and icons for buttons */
static void ui_draw_text_icon(uiBut *but)
void ui_draw_text_icon(uiBut *but)
{
float x, y;
short t, pos, ch;
@@ -3243,11 +3243,12 @@ void ui_draw_but(ARegion *ar, uiBut *but)
if(but==NULL) return;
/* XXX 2.50 no frontbuffer drawing allowed */
#if 0
/* signal for frontbuf flush buttons and menus, not when normal drawing */
if(but->block->in_use) ui_block_set_flush(but->block, but);
#endif
if(but->block->flag & UI_BLOCK_2_50) {
extern void ui_draw_but_new(ARegion *ar, uiBut *but); // XXX
ui_draw_but_new(ar, but);
return;
}
switch (but->type) {

View File

@@ -55,7 +55,7 @@ struct wmWindow;
#define UI_MOUSE_OVER 2
#define UI_ACTIVE 4
#define UI_HAS_ICON 8
/* warn: rest of uiBut->flag in BIF_interface.c */
/* warn: rest of uiBut->flag in UI_interface.h */
/* internal panel drawing defines */
#define PNL_GRID 4
@@ -334,6 +334,9 @@ 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);
/* interface_handlers.c */
extern void ui_button_active_cancel(const struct bContext *C, uiBut *but);

View File

@@ -846,6 +846,9 @@ void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x,
if(x) *x= layout->x;
if(y) *y= layout->y;
/* XXX temp, migration flag for drawing code */
uiBlockSetFlag(block, UI_BLOCK_2_50);
}
void ui_layout_free(uiLayout *layout)

File diff suppressed because it is too large Load Diff

View File

@@ -146,6 +146,7 @@ static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar)
{
ListBase *keymap;
// ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy);
/* own keymap */
@@ -171,13 +172,15 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar)
/* swapbuffers indicator */
fac= BLI_frand();
glColor3f(fac, fac, fac);
glRecti(20, 2, 30, 12);
glRecti(20, v2d->cur.ymin+2, 30, v2d->cur.ymin+12);
/* panels */
if(sbuts->mainb == CONTEXT_SCENE)
buttons_scene(C, ar);
else if(sbuts->mainb == CONTEXT_OBJECT)
buttons_object(C, ar);
else
drawnewstuff();
if(sbuts->align)
if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb || sbuts->tabo!=sbuts->tab[sbuts->mainb])

View File

@@ -209,10 +209,10 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
* fixed it). - zr (2001!)
*/
if (swin->winrct.xmax >= win->sizex)
swin->winrct.xmax= win->sizex-1;
if (swin->winrct.ymax >= win->sizey)
swin->winrct.ymax= win->sizey-1;
if (swin->winrct.xmax > win->sizex)
swin->winrct.xmax= win->sizex;
if (swin->winrct.ymax > win->sizey)
swin->winrct.ymax= win->sizey;
/* extra service */
wmSubWindowSet(win, swinid);