From cd976bfd427da41eaccb81cb87596dcf87b9ba7f Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 6 Jul 2006 12:50:48 +0000 Subject: [PATCH] Bugfix #4628 Ancient issue in making screendumps in Blender. It used to support making dumps of popup menus, but that disappeared a while ago. However, when you press CTRL+F3 in a menu now, Blender hangs in some eternal loop in ghost. This commit fixes making menu screendumps (nice for docs!). - press CTRL+F3 *twice* for an exact copy of a menu. (first press exits menu, 2nd press opens filewindow) - note, it is ALT+CTRL+F3 in OSX - what is saved is only the topmost open level of a menu - full-screen dumps work too by holding SHIFT extra. --- source/blender/src/editscreen.c | 5 ++- source/blender/src/interface.c | 70 ++++++++++++++++----------------- source/blender/src/screendump.c | 18 +++++---- 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c index 429d803bcd4..7ae0bdfac5e 100644 --- a/source/blender/src/editscreen.c +++ b/source/blender/src/editscreen.c @@ -954,7 +954,10 @@ unsigned short extern_qread_ext(short *val, char *ascii) else if(event==INPUTCHANGE) ext_inputchange= *val; else if(event==MOUSEY || event==MOUSEX) ext_mousemove= 1; else if((G.qual & (LR_CTRLKEY|LR_ALTKEY)) && event==F3KEY) { - if(*val) BIF_screendump(0); + if(*val) { + BIF_screendump(0); + return ESCKEY; /* go out of menu, if that was set */ + } } return event; diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index bbe86e68186..ce980e96386 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -4201,8 +4201,38 @@ static void ui_but_prev_edittext(uiBlock *block) } } +/* ******************************************************* */ +/* nasty but safe way to store screendump rect */ +static int scr_x=0, scr_y=0, scr_sizex=0, scr_sizey=0; +static void ui_set_screendump_bbox(uiBlock *block) +{ + if(block) { + scr_x= block->minx; + scr_y= block->miny; + scr_sizex= block->maxx - block->minx; + scr_sizey= block->maxy - block->miny; + } + else { + scr_sizex= scr_sizey= 0; + } +} + +/* used for making screenshots for menus, called in screendump.c */ +int uiIsMenu(int *x, int *y, int *sizex, int *sizey) +{ + if(scr_sizex!=0 && scr_sizey!=0) { + *x= scr_x; + *y= scr_y; + *sizex= scr_sizex; + *sizey= scr_sizey; + return 1; + } + + return 0; +} +/* ******************************************************* */ /* return: * UI_NOTHING pass event to other ui's @@ -4232,6 +4262,7 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent) } ui_set_ftf_font(block->aspect); // sets just a pointer in ftf lib... the button dont have ftf handles + ui_set_screendump_bbox(block); // added this for panels in windows with buttons... // maybe speed optimize should require test @@ -4962,6 +4993,9 @@ int uiDoBlocks(ListBase *lb, int event) if(retval==UI_CONT || (retval & UI_RETURN_OK)) cont= 0; } + /* clears screendump boundbox, call before afterfunc! */ + ui_set_screendump_bbox(NULL); + /* afterfunc is used for fileloading too, so after this call, the blocks pointers are invalid */ if(retval & UI_RETURN_OK) { if(UIafterfunc) { @@ -4975,7 +5009,7 @@ int uiDoBlocks(ListBase *lb, int event) if(retval==UI_NOTHING && (uevent.event==MOUSEX || uevent.event==MOUSEY)) { if(U.flag & USER_TOOLTIPS) ui_do_but_tip(UIbuttip); } - + return retval; } @@ -5277,40 +5311,6 @@ uiBlock *uiGetBlock(char *name, ScrArea *sa) return NULL; } -#if 0 -/* used for making screenshots for menus, called in screendump.c */ -static int uiIsMenu(int *x, int *y, int *sizex, int *sizey) -{ - uiBlock *block= curarea->uiblocks.first; - int minx, miny, maxx, maxy; - - minx= 1<<30; - miny= 1<<30; - maxx= 0; - maxy= 0; - - while(block) { - if(block->flag & UI_BLOCK_LOOP) { - if(block->minx < minx) minx= (int)block->minx; - if(block->miny < miny) miny= (int)block->miny; - if(block->maxx > maxx) maxx= (int)block->maxx; - if(block->maxy > maxy) maxy= (int)block->maxy; - } - block= block->next; - } -printf("%d %d %d %d\n", minx, miny, maxx, maxy); - if(maxx!=0 && maxy!=0) { - *x= minx-10<0?0:minx; - *y= miny-10<0?0:miny; - *sizex= maxx-minx+10; - *sizey= maxy-miny+10; - return 1; - } - - return 0; -} -#endif - void ui_check_but(uiBut *but) { /* if something changed in the button */ diff --git a/source/blender/src/screendump.c b/source/blender/src/screendump.c index fc17d0a5759..2b40d8e7171 100644 --- a/source/blender/src/screendump.c +++ b/source/blender/src/screendump.c @@ -117,25 +117,27 @@ void write_screendump(char *name) /* get dump from frontbuffer */ void BIF_screendump(int fscreen) { - extern uiBut *UIbuttip; // interface.c + extern int uiIsMenu(int *x, int *y, int *sizex, int *sizey); + int ismenu; static int wasmenu= 0; int x=0, y=0; char imstr[64]; - if(wasmenu && UIbuttip==NULL) { + /* this sets dumpsx/y to zero if ismenu==0 */ + ismenu= uiIsMenu(&x, &y, &dumpsx, &dumpsy); + + if(wasmenu && !ismenu) { save_image_filesel_str(imstr); + strcat(imstr, " (Menu)"); activate_fileselect(FILE_SPECIAL, imstr, G.ima, write_screendump); wasmenu= 0; return; } - dumpsx= 0; - dumpsy= 0; - if(dumprect) MEM_freeN(dumprect); dumprect= NULL; - if(UIbuttip || (G.qual & LR_SHIFTKEY) || fscreen) { /* full screen */ + if((G.qual & LR_SHIFTKEY) || fscreen) { /* full screen */ x= 0; y= 0; @@ -144,7 +146,7 @@ void BIF_screendump(int fscreen) } else { - { /* a window */ + if(ismenu==0) { /* a window */ //int win= mywinget(); //bwin_getsuborigin(win, &x, &y); @@ -164,7 +166,7 @@ void BIF_screendump(int fscreen) glFinish(); glReadBuffer(GL_BACK); - if(UIbuttip==NULL) { + if(ismenu==0) { wasmenu= 0; save_image_filesel_str(imstr); activate_fileselect(FILE_SPECIAL, imstr, G.ima, write_screendump);