diff options
author | Ton Roosendaal <ton@blender.org> | 2004-10-04 00:02:22 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-10-04 00:02:22 +0400 |
commit | 010200f9b552e13de5169069935ad666ca03377f (patch) | |
tree | 148b5579de55f33b459cb2ef92b5a09ca4ba6135 | |
parent | b7ac42a4c60307a6d95913bfb7a04cec55013ca6 (diff) |
Fix for new UI system and vertexpaint/faceselect/weightpaint/texturepaint
If backbuffer is in use for selection codes, the system switches back to
frontbuffer drawing temporally. Is easier solution now.
Next commit; fix for new 'zbuffer clipped selection', which also doesnt
work after using a pulldown or popup menu.
-rw-r--r-- | source/blender/include/BIF_interface.h | 1 | ||||
-rw-r--r-- | source/blender/include/interface.h | 9 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 13 | ||||
-rw-r--r-- | source/blender/src/interface.c | 40 | ||||
-rw-r--r-- | source/blender/src/interface_draw.c | 4 |
5 files changed, 46 insertions, 21 deletions
diff --git a/source/blender/include/BIF_interface.h b/source/blender/include/BIF_interface.h index 9f8afd76ea6..01fc74430e1 100644 --- a/source/blender/include/BIF_interface.h +++ b/source/blender/include/BIF_interface.h @@ -75,6 +75,7 @@ struct ScrArea; #define UI_BLOCK_NUMSELECT 16 #define UI_BLOCK_ENTER_OK 32 #define UI_BLOCK_NOSHADOW 64 +#define UI_BLOCK_FRONTBUFFER 128 /* block->flag bits 12-15 are identical to but->flag bits */ diff --git a/source/blender/include/interface.h b/source/blender/include/interface.h index 281e2e4be10..baa5e0d7418 100644 --- a/source/blender/include/interface.h +++ b/source/blender/include/interface.h @@ -41,8 +41,6 @@ #define UI_MAX_NAME_STR 64 #define UI_ARRAY 29 - - /* uiBut->flag */ #define UI_SELECT 1 #define UI_MOUSE_OVER 2 @@ -51,10 +49,6 @@ /* warn: rest of uiBut->flag in BIF_interface.c */ -/* block->frontbuf: (only internal here). this signals something was drawn, for flush */ -#define UI_HAS_DRAWN 1 - - /* internal panel drawing defines */ #define PNL_GRID 4 #define PNL_DIST 8 @@ -186,7 +180,8 @@ struct uiBlock { int afterval, flag; void *curfont; - short autofill, win, winq, direction, dt, frontbuf, auto_open, pad; //frontbuf see below + short autofill, win, winq, direction, dt; + short needflush, auto_open, in_use, pad; //flush see below void *overdraw; float xofs, yofs; // offset to parent button diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 47d158476dd..1c1e83932a1 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -1476,7 +1476,10 @@ static void view3d_panel_object(short cntrl) // VIEW3D_HANDLER_OBJECT if(uiNewPanel(curarea, block, "Transform Properties", "View3d", 10, 230, 318, 204)==0) return; - if((G.f & (G_VERTEXPAINT|G_TEXTUREPAINT))==0) { + if(G.f & (G_VERTEXPAINT|G_FACESELECT|G_TEXTUREPAINT|G_WEIGHTPAINT)) { + uiBlockSetFlag(block, UI_BLOCK_FRONTBUFFER); // force old style frontbuffer draw + } + else { uiDefBut(block, TEX, B_IDNAME, "OB: ", 10,180,140,20, ob->id.name+2, 0.0, 19.0, 0, 0, ""); uiDefIDPoinBut(block, test_obpoin_but, B_OBJECTPANELPARENT, "Par:", 160, 180, 140, 20, &ob->parent, "Parent Object"); } @@ -1532,6 +1535,10 @@ static void view3d_panel_background(short cntrl) // VIEW3D_HANDLER_BACKGROUND uiSetPanelHandler(VIEW3D_HANDLER_BACKGROUND); // for close and esc if(uiNewPanel(curarea, block, "Background Image", "View3d", 340, 10, 318, 204)==0) return; + if(G.f & (G_VERTEXPAINT|G_FACESELECT|G_TEXTUREPAINT|G_WEIGHTPAINT)) { + uiBlockSetFlag(block, UI_BLOCK_FRONTBUFFER); // force old style frontbuffer draw + } + if(vd->flag & V3D_DISPBGPIC) { if(vd->bgpic==0) { vd->bgpic= MEM_callocN(sizeof(BGpic), "bgpic"); @@ -1623,6 +1630,10 @@ static void view3d_panel_properties(short cntrl) // VIEW3D_HANDLER_SETTINGS uiSetPanelHandler(VIEW3D_HANDLER_PROPERTIES); // for close and esc if(uiNewPanel(curarea, block, "View Properties", "View3d", 340, 10, 318, 204)==0) return; + if(G.f & (G_VERTEXPAINT|G_FACESELECT|G_TEXTUREPAINT|G_WEIGHTPAINT)) { + uiBlockSetFlag(block, UI_BLOCK_FRONTBUFFER); // force old style frontbuffer draw + } + uiDefBut(block, LABEL, 1, "Grid:", 10, 180, 150, 19, NULL, 0.0, 0.0, 0, 0, ""); uiDefButF(block, NUM, REDRAWVIEW3D, "Spacing:", 10, 160, 140, 19, &vd->grid, 0.001, 100.0, 10, 0, "Set the distance between grid lines"); uiDefButS(block, NUM, REDRAWVIEW3D, "Lines:", 10, 136, 140, 19, &vd->gridlines, 0.0, 100.0, 100, 0, "Set the number of grid lines"); diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index f96ccd6f6cd..91d4334a81d 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -316,8 +316,16 @@ void ui_block_flush_back(uiBlock *block) int minx, miny, sizex, sizey; /* note; this routine also has to work for block loop */ - if(block->frontbuf==0) return; + if(block->needflush==0) return; + /* exception, when we cannot use backbuffer for draw... */ + if(block->flag & UI_BLOCK_FRONTBUFFER) { + glFlush(); + glDrawBuffer(GL_BACK); + block->needflush= 0; + return; + } + /* copy pixels works on window coords, so we move to window space */ ui_graphics_to_window(block->win, &block->flush.xmin, &block->flush.ymin); @@ -346,7 +354,7 @@ void ui_block_flush_back(uiBlock *block) markdirty_win_back(block->win); } - block->frontbuf= 0; + block->needflush= 0; } /* merge info for live updates in frontbuf */ @@ -354,13 +362,17 @@ void ui_block_set_flush(uiBlock *block, uiBut *but) { /* clear signal */ if(but==NULL) { - block->frontbuf= 0; + block->needflush= 0; block->flush.xmin= 0.0; block->flush.xmax= 0.0; } else { - if(block->frontbuf==0) { + /* exception, when we cannot use backbuffer for draw... */ + if(block->flag & UI_BLOCK_FRONTBUFFER) { + glDrawBuffer(GL_FRONT); + } + else if(block->needflush==0) { /* first rect */ block->flush.xmin= but->x1; block->flush.xmax= but->x2; @@ -374,7 +386,8 @@ void ui_block_set_flush(uiBlock *block, uiBut *but) if(block->flush.ymin > but->y1) block->flush.ymin= but->y1; if(block->flush.ymax < but->y2) block->flush.ymax= but->y2; } - block->frontbuf= UI_HAS_DRAWN; + + block->needflush= 1; } } @@ -3421,20 +3434,23 @@ int uiDoBlocks(ListBase *lb, int event) if( block->flag & UI_BLOCK_LOOP) { block->overdraw= ui_begin_overdraw((int)block->minx-1, (int)block->miny-6, (int)block->maxx+6, (int)block->maxy+1); } + block->in_use= 1; // is always a menu uiDrawBlock(block); block->flag &= ~UI_BLOCK_REDRAW; } - + + block->in_use= 1; // bit awkward, but now we can detect if frontbuf flush should be set retval= ui_do_block(block, &uevent); + block->in_use= 0; if(retval==UI_EXIT_LOOP) break; /* now a new block could be created for menus, this is inserted in the beginning of a list */ /* is there a flush cached? */ - if(block->frontbuf == UI_HAS_DRAWN) { + if(block->needflush) { ui_flush_overdraw(block->overdraw); - block->frontbuf= 0; + block->needflush= 0; } /* to make sure the matrix of the panel works for menus too */ @@ -3460,17 +3476,19 @@ int uiDoBlocks(ListBase *lb, int event) uiDrawBlock(block); block->flag &= ~UI_BLOCK_REDRAW; ui_flush_overdraw(block->overdraw); - block->frontbuf= 0; + block->needflush= 0; } uevent.event= extern_qread(&uevent.val); 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); + block->in_use= 0; - if(block->frontbuf == UI_HAS_DRAWN) { // flush now, maybe new menu was opened + if(block->needflush) { // flush now, maybe new menu was opened ui_flush_overdraw(block->overdraw); - block->frontbuf= 0; + block->needflush= 0; } if(retval & UI_RETURN) { diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c index ea16229074c..3ef7d802730 100644 --- a/source/blender/src/interface_draw.c +++ b/source/blender/src/interface_draw.c @@ -1715,10 +1715,10 @@ void ui_draw_but(uiBut *but) double value; float x1, x2, y1, y2, fac; - if(but==0) return; + if(but==NULL) return; /* signal for flush buttons and menus */ - ui_block_set_flush(but->block, but); + if(but->block->in_use) ui_block_set_flush(but->block, but); switch (but->type) { |