for button popups, dont close unless you click or press escape, this would often close when dragging a button value (or when using a tablet I am told)

This commit is contained in:
Campbell Barton 2007-12-11 23:05:10 +00:00
parent 5e3f4c20bb
commit 6dc52c893f
14 changed files with 39 additions and 37 deletions

@ -188,7 +188,7 @@ void uiGetMouse(int win, short *adr);
void uiComposeLinks(uiBlock *block);
void uiSetButLock(int val, char *lockstr);
void uiClearButLock(void);
int uiDoBlocks(struct ListBase *lb, int event);
int uiDoBlocks(struct ListBase *lb, int event, int movemouse_quit);
void uiSetCurFont(uiBlock *block, int index);
void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small);
void uiFreeBlock(uiBlock *block);

@ -730,7 +730,7 @@ void BPY_spacescript_do_pywin_event( SpaceScript * sc, unsigned short event,
if (val) {
if (uiDoBlocks( &curarea->uiblocks, event ) != UI_NOTHING) event = 0;
if (uiDoBlocks( &curarea->uiblocks, event, 1 ) != UI_NOTHING) event = 0;
if (event == UI_BUT_EVENT) {
/* check that event is in free range for script button events;
@ -1117,7 +1117,7 @@ static PyObject *Method_UIBlock( PyObject * self, PyObject * args )
/* Done clearing events */
uiBoundsBlock(uiblock, 5);
uiDoBlocks(&listb, 0);
uiDoBlocks(&listb, 0, 1);
}
uiFreeBlocks(&listb);
uiblock = NULL;

@ -2807,6 +2807,7 @@ static void draw_sculpt_depths(View3D *v3d)
static void draw_viewport_fps(ScrArea *sa);
void drawview3dspace(ScrArea *sa, void *spacedata)
{
View3D *v3d= spacedata;
@ -3288,11 +3289,12 @@ static void draw_viewport_fps(ScrArea *sa)
{
float fps;
char printable[16];
printable[0] = '\0';
if (lredrawtime == redrawtime)
return;
printable[0] = '\0';
fps = (float)(1.0/(lredrawtime-redrawtime));
/* is this more then half a frame behind? */

@ -2668,7 +2668,7 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
data= get_action_context(&datatype);
if (val) {
if ( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
if ( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
/* swap mouse buttons based on user preference */
if (U.flag & USER_LMOUSESELECT) {

@ -859,7 +859,7 @@ void winqreadimaselspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(val) {
if( event!=RETKEY && event!=PADENTER)
if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
switch(event) {

@ -1717,7 +1717,7 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if (!snla) return;
if(val) {
if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
/* swap mouse buttons based on user preference */
if (U.flag & USER_LMOUSESELECT) {

@ -2073,7 +2073,7 @@ static int node_uiDoBlocks(ScrArea *sa, short event)
((struct Link *)block)->next= NULL;
lb->first= lb->last= block;
retval= uiDoBlocks(lb, event);
retval= uiDoBlocks(lb, event, 1);
((struct Link *)block)->prev= prev;
((struct Link *)block)->next= next;

@ -531,7 +531,7 @@ static void scrarea_dispatch_header_events(ScrArea *sa)
while(bwin_qread(sa->headwin, &evt)) {
if(evt.val) {
if( uiDoBlocks(&curarea->uiblocks, evt.event)!=UI_NOTHING ) evt.event= 0;
if( uiDoBlocks(&curarea->uiblocks, evt.event, 1)!=UI_NOTHING ) evt.event= 0;
switch(evt.event) {
case UI_BUT_EVENT:

@ -123,7 +123,7 @@ void winqreadsoundspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(val) {
if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
/* swap mouse buttons based on user preference */
if (U.flag & USER_LMOUSESELECT) {

@ -836,7 +836,7 @@ void winqreadtimespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(val) {
if( uiDoBlocks(&sa->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&sa->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
/* swap mouse buttons based on user preference */
if (U.flag & USER_LMOUSESELECT) {

@ -1812,7 +1812,7 @@ void winqreadfilespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(val) {
if( event!=RETKEY && event!=PADENTER)
if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
switch(event) {

@ -1304,7 +1304,7 @@ static int ui_do_but_MENU(uiBut *but)
for(bt= block->buttons.first; bt; bt= bt->next) bt->win= block->win;
bwin_getsinglematrix(block->win, block->winmat);
event= uiDoBlocks(&listb, 0);
event= uiDoBlocks(&listb, 0, 1);
menudata_free(md);
@ -2351,7 +2351,7 @@ static int ui_do_but_ICONROW(uiBut *but)
this is needs better implementation */
block->win= G.curscreen->mainwin;
uiDoBlocks(&listb, 0);
uiDoBlocks(&listb, 0, 1);
but->flag &= ~UI_SELECT;
ui_check_but(but);
@ -2424,7 +2424,7 @@ static int ui_do_but_ICONTEXTROW(uiBut *but)
uiBoundsBlock(block, 3);
uiDoBlocks(&listb, 0);
uiDoBlocks(&listb, 0, 1);
menudata_free(md);
@ -3302,7 +3302,7 @@ static int ui_do_but_COL(uiBut *but)
for(bt= block->buttons.first; bt; bt= bt->next) bt->win= block->win;
bwin_getsinglematrix(block->win, block->winmat);
event= uiDoBlocks(&listb, 0);
event= uiDoBlocks(&listb, 0, 1);
if(but->pointype==CHA) ui_set_but_vectorf(but, colstore);
@ -4306,7 +4306,7 @@ int uiIsMenu(int *x, int *y, int *sizex, int *sizey)
* UI_CONT don't pass event to other ui's
* UI_RETURN something happened, return, swallow event
*/
static int ui_do_block(uiBlock *block, uiEvent *uevent)
static int ui_do_block(uiBlock *block, uiEvent *uevent, int movemouse_quit)
{
uiBut *but, *bt;
int butevent, event, retval=UI_NOTHING, count, act=0;
@ -4793,7 +4793,7 @@ 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(inside==0) {
if(inside==0 && movemouse_quit) {
uiBlock *tblock= NULL;
/* check for all parent rects, enables arrowkeys to be used */
@ -4935,7 +4935,7 @@ static void ui_do_but_tip(uiBut *buttip)
}
/* returns UI_NOTHING, if nothing happened */
int uiDoBlocks(ListBase *lb, int event)
int uiDoBlocks(ListBase *lb, int event, int movemouse_quit)
{
/* return when: firstblock != BLOCK_LOOP
*
@ -4990,7 +4990,7 @@ int uiDoBlocks(ListBase *lb, int event)
}
block->in_use= 1; // bit awkward, but now we can detect if frontbuf flush should be set
retval |= ui_do_block(block, &uevent); /* we 'or' because 2nd loop can return to here, and we we want 'out' to return */
retval |= ui_do_block(block, &uevent, movemouse_quit); /* we 'or' because 2nd loop can return to here, and we we want 'out' to return */
block->in_use= 0;
if(retval & UI_EXIT_LOOP) break;
@ -5034,7 +5034,7 @@ int uiDoBlocks(ListBase *lb, int event)
if(uevent.event) {
block->in_use= 1; // bit awkward, but now we can detect if frontbuf flush should be set
retval= ui_do_block(block, &uevent);
retval= ui_do_block(block, &uevent, movemouse_quit);
block->in_use= 0;
if(block->needflush) { // flush (old menu) now, maybe new menu was opened
@ -6530,7 +6530,7 @@ short pupmenu(char *instr)
uiBoundsBlock(block, 1);
event= uiDoBlocks(&listb, 0);
event= uiDoBlocks(&listb, 0, 1);
/* calculate last selected */
if(event & UI_RETURN_OK) {
@ -6688,7 +6688,7 @@ short pupmenu_col(char *instr, int maxrow)
uiBoundsBlock(block, 1);
event= uiDoBlocks(&listb, 0);
event= uiDoBlocks(&listb, 0, 1);
menudata_free(md);

@ -1173,7 +1173,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(val) {
if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
if(event==UI_BUT_EVENT) do_butspace(val); /* temporal, view3d deserves own queue? */
@ -2761,7 +2761,7 @@ static void winqreadipospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(sa->win==0) return;
if(val) {
if( uiDoBlocks(&sa->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&sa->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
/* swap mouse buttons based on user preference */
if (U.flag & USER_LMOUSESELECT) {
@ -4136,7 +4136,7 @@ static void winqreadinfospace(ScrArea *sa, void *spacedata, BWinEvent *evt)
short val= evt->val;
if(val) {
if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
switch(event) {
case UI_BUT_EVENT:
@ -4255,7 +4255,7 @@ static void winqreadbutspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(val) {
if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
switch(event) {
case UI_BUT_EVENT:
@ -4510,7 +4510,7 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(curarea->win==0) return;
if(val) {
if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
/* swap mouse buttons based on user preference */
if (U.flag & USER_LMOUSESELECT) {
@ -4969,7 +4969,7 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(val==0) return;
if(uiDoBlocks(&sa->uiblocks, event)!=UI_NOTHING ) event= 0;
if(uiDoBlocks(&sa->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
if (U.flag & USER_LMOUSESELECT) {
if (event == LEFTMOUSE) {
@ -5354,7 +5354,7 @@ static void winqreadoopsspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(val==0) return;
if( uiDoBlocks(&sa->uiblocks, event)!=UI_NOTHING ) event= 0;
if( uiDoBlocks(&sa->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
if (U.flag & USER_NONUMPAD) {
event= convert_for_nonumpad(event);

@ -288,7 +288,7 @@ short button(short *var, short min, short max, char *str)
uiBoundsBlock(block, 5);
ret= uiDoBlocks(&listb, 0);
ret= uiDoBlocks(&listb, 0, 0);
if(ret==UI_RETURN_OK) return 1;
return 0;
@ -322,7 +322,7 @@ short sbutton(char *var, float min, float max, char *str)
uiBoundsBlock(block, 5);
mainqenter_ext(BUT_ACTIVATE, 32766, 0); /* note, button id '32766' is asking for errors some day! */
ret= uiDoBlocks(&listb, 0);
ret= uiDoBlocks(&listb, 0, 0);
if(ret==UI_RETURN_OK) return 1;
return 0;
@ -356,7 +356,7 @@ short fbutton(float *var, float min, float max, float a1, float a2, char *str)
uiBoundsBlock(block, 2);
ret= uiDoBlocks(&listb, 0);
ret= uiDoBlocks(&listb, 0, 0);
if(ret==UI_RETURN_OK) return 1;
return 0;
@ -416,7 +416,7 @@ int movetolayer_buts(unsigned int *lay, char *title)
uiBoundsBlock(block, 2);
ret= uiDoBlocks(&listb, 0);
ret= uiDoBlocks(&listb, 0, 0);
if(ret==UI_RETURN_OK) return 1;
return 0;
@ -466,7 +466,7 @@ int movetolayer_short_buts(short *lay, char *title)
uiBoundsBlock(block, 2);
ret= uiDoBlocks(&listb, 0);
ret= uiDoBlocks(&listb, 0, 0);
if(ret==UI_RETURN_OK) return 1;
return 0;
@ -603,7 +603,7 @@ int do_clever_numbuts(char *name, int tot, int winevent)
uiBoundsBlock(block, 5);
event= uiDoBlocks(&listb, 0);
event= uiDoBlocks(&listb, 0, 0);
areawinset(curarea->win);
@ -2219,7 +2219,7 @@ void toolbox_n(void)
}
uiBoundsBlock(block, 2);
event= uiDoBlocks(&tb_listb, 0);
event= uiDoBlocks(&tb_listb, 0, 0);
/* free all dynamic entries... */
BLI_freelistN(&storage);