From d5dbaf726aee70fed7db9f4037e46078da3ad085 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 6 Oct 2003 10:33:01 +0000 Subject: [PATCH] - pulldowns and 'BLOCK' buttons now open automatic, when mouseover without moving for 0.25 second. Also works for sublevels in pulldowns. - removed hacks from mainloop, which caused setting the main window and active subwindow for each event (including mousemove). WARN: test for all OS's that no events get lost, and active window focus is OK. For OSX it works nicely - reduced load for uibuttons with 50%.... --- source/blender/src/editscreen.c | 9 +++--- source/blender/src/ghostwinlay.c | 4 +-- source/blender/src/interface.c | 50 ++++++++++++++++++++++---------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c index f975d404d88..e4cf4a2be82 100644 --- a/source/blender/src/editscreen.c +++ b/source/blender/src/editscreen.c @@ -918,7 +918,7 @@ static ScrArea *screen_find_area_for_pt(bScreen *sc, short *mval) void screenmain(void) { - int has_input= 1; + int has_input= 0; /* was one, why! (ton) */ int firsttime = 1; while (1) { @@ -934,7 +934,7 @@ void screenmain(void) event= screen_qread(&val, &ascii); } - window_make_active(mainwin); + //window_make_active(mainwin); (removed, ton) if (event==INPUTCHANGE) { has_input= val; @@ -977,7 +977,8 @@ void screenmain(void) areawinset(G.curscreen->winakt); set_cursor(choose_cursor(g_activearea)); } - } else { + } + else { if (g_activearea) { scrarea_queue_headredraw(g_activearea); } @@ -1087,7 +1088,7 @@ void screenmain(void) towin= 0; } } - + if (towin && event) { if (blenderqread(event, val)) addqueue_ext(G.curscreen->winakt, event, val, ascii); diff --git a/source/blender/src/ghostwinlay.c b/source/blender/src/ghostwinlay.c index b96878f3ff2..cf29efd71b8 100644 --- a/source/blender/src/ghostwinlay.c +++ b/source/blender/src/ghostwinlay.c @@ -391,10 +391,10 @@ static int event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) { GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy); win->lmouse[0]= cx; win->lmouse[1]= (win->size[1]-1) - cy; - + window_handle(win, MOUSEX, win->lmouse[0]); window_handle(win, MOUSEY, win->lmouse[1]); - + break; } case GHOST_kEventButtonDown: diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index f5b3aa95ffc..c91a39bebdc 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -68,6 +68,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_userdef_types.h" +#include "DNA_vec_types.h" #include "BKE_blender.h" #include "BKE_utildefines.h" @@ -211,7 +212,8 @@ struct uiBlock { short autofill, flag, win, winq, direction, dt, frontbuf; //frontbuf see below void *saveunder; - float xofs, yofs; // offset to parent button + float xofs, yofs; // offset to parent button + rctf parentrct; // for pulldowns, rect the mouse is allowed outside of menu (parent button) }; /* block->frontbuf: (only internal here), to nice localize the old global var uiFrontBuf */ @@ -2323,10 +2325,6 @@ void uiDrawMenuBox(float minx, float miny, float maxx, float maxy) fdrawline(minx+4, miny-4, maxx+4, miny-4); fdrawline(maxx+4, miny-4, maxx+4, maxy-4); - glColor4ub(0, 0, 0, 10); - fdrawline(minx+4, miny-5, maxx+5, miny-5); - fdrawline(maxx+5, miny-5, maxx+5, maxy-4); - glDisable(GL_BLEND); /* below */ @@ -2494,6 +2492,7 @@ static void ui_positionblock(uiBlock *block, uiBut *but) ui_graphics_to_window(block->win, &butrct.xmin, &butrct.ymin); ui_graphics_to_window(block->win, &butrct.xmax, &butrct.ymax); + block->parentrct= butrct; // will use that for pulldowns later if( butrct.xmin-xsize > 0.0) left= 1; if( butrct.xmax+xsize < G.curscreen->sizex) right= 1; @@ -4364,7 +4363,7 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent) /* filter some unwanted events */ if(uevent==0 || uevent->event==LEFTSHIFTKEY || uevent->event==RIGHTSHIFTKEY) return UI_NOTHING; - + if(block->flag & UI_BLOCK_ENTER_OK) { if(uevent->event == RETKEY && uevent->val) { // printf("qual: %d %d %d\n", uevent->qual, get_qual(), G.qual); @@ -4517,6 +4516,14 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent) but->flag &= ~UI_ACTIVE; if(but->type != LABEL && but->embossfunc != ui_emboss_N) ui_draw_but(but); } + else if(but->type==BLOCK ) { // automatic opens block button (pulldown) + int time; + for (time= 0; time<10; time++) { + if (anyqtest()) break; + else PIL_sleep_ms(20); + } + if(time==10) ui_do_button(block, but, uevent); + } if(but->flag & UI_ACTIVE) active= 1; } @@ -4576,16 +4583,24 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent) if((uevent->event==RETKEY || uevent->event==PADENTER) && uevent->val==1) return UI_RETURN_OK; /* check outside */ - if(block->direction==UI_RIGHT) count= 140; else count= 40; - if(uevent->mval[0]minx-count) return UI_RETURN_OUT; - - if(uevent->mval[1]miny-40) return UI_RETURN_OUT; - - if(block->direction==UI_LEFT) count= 140; else count= 40; - if(uevent->mval[0]>block->maxx+count) return UI_RETURN_OUT; - - if(uevent->mval[1]>block->maxy+40) return UI_RETURN_OUT; + if(block->parentrct.xmax != 0.0) { + /* strict check, and include the parent rect */ + if( BLI_in_rctf(&block->parentrct, (float)uevent->mval[0], (float)uevent->mval[1])==0) { + if(uevent->mval[0]minx-10) return UI_RETURN_OUT; + if(uevent->mval[1]miny-10) return UI_RETURN_OUT; + if(uevent->mval[0]>block->maxx+10) return UI_RETURN_OUT; + if(uevent->mval[1]>block->maxy+10) return UI_RETURN_OUT; + } + } + else { + /* for popups without parent button */ + if(uevent->mval[0]minx-40) return UI_RETURN_OUT; + if(uevent->mval[1]miny-40) return UI_RETURN_OUT; + + if(uevent->mval[0]>block->maxx+40) return UI_RETURN_OUT; + if(uevent->mval[1]>block->maxy+40) return UI_RETURN_OUT; + } } return retval; @@ -4729,6 +4744,9 @@ int uiDoBlocks(ListBase *lb, int event) int retval= UI_NOTHING, cont= 1, dopop=0; if(lb->first==0) return UI_NOTHING; + + /* for every pixel both x and y events are generated, overloads the system! */ + if(event==MOUSEX) return UI_NOTHING; UIbuttip= NULL; UIafterfunc= NULL; /* to prevent infinite loops, this shouldnt be a global! */ @@ -4796,7 +4814,7 @@ int uiDoBlocks(ListBase *lb, int event) if(block->flag & UI_BLOCK_REDRAW) { if( block->flag & UI_BLOCK_LOOP) { - block->saveunder= ui_bgnpupdraw((int)block->minx-1, (int)block->miny-4, (int)block->maxx+4, (int)block->maxy+1, 1); + block->saveunder= ui_bgnpupdraw((int)block->minx-1, (int)block->miny-6, (int)block->maxx+6, (int)block->maxy+1, 1); block->frontbuf= UI_HAS_DRAW_FRONT; } uiDrawBlock(block);