diff options
author | Ton Roosendaal <ton@blender.org> | 2009-06-08 14:00:14 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-06-08 14:00:14 +0400 |
commit | ca6a8a233b653e4545427b00fe265566da924522 (patch) | |
tree | 1fef07ad3ac191f5c2ddba1f78f3da4054078457 /source/blender/editors | |
parent | 9d4ebe1088dd5f59b2a53d47eaed1d40ab5c0a3e (diff) |
2.5
Preview renders:
- Added proper button type (BUT_EXTRA) for preview buttons, to
handle drawing better. It now first draws an alpha mask, to
ensure the preview is correctly fitting inside the widget style.
It then draws the outline.
- Added protection for executing preview renders while regular
rendering, that's not going to work...
Diffstat (limited to 'source/blender/editors')
7 files changed, 67 insertions, 21 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index f7a0fccf12b..14394b124c3 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -193,6 +193,7 @@ typedef struct uiLayout uiLayout; #define OPTION (38<<9) #define OPTIONN (39<<9) #define SEARCH_MENU (40<<9) +#define BUT_EXTRA (41<<9) #define BUTTYPE (63<<9) /* Drawing diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 072bc5a6feb..bef01b5a454 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -665,13 +665,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block) /* widgets */ for(but= block->buttons.first; but; but= but->next) { ui_but_to_pixelrect(&rect, ar, block, but); - ui_draw_but(ar, &style, but, &rect); - - /* temp? roundbox defines size/location of preview, and ID type */ - if(but->type==ROUNDBOX) - if(block->drawextra) - block->drawextra(C, but->poin, &rect); - + ui_draw_but(C, ar, &style, but, &rect); } /* restore matrix */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 1cab28abc4e..18423434eef 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -403,7 +403,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); -extern void ui_draw_but(ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); +extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); /* theme color init */ struct ThemeUI; void ui_widget_color_init(struct ThemeUI *tui); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index df7d81b8806..911d10f74d7 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -51,8 +51,6 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "BIF_gl.h" - #include "ED_util.h" #include "ED_types.h" #include "ED_screen.h" diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1d44fc90ce9..020d442bfe6 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1321,8 +1321,8 @@ void uiTemplatePreview(uiLayout *layout, ID *id) col= uiLayoutColumn(row, 0); uiLayoutSetKeepAspect(col, 1); - uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, id, 0.0, 0.0, 0, 0, ""); - /* extra draw is tied to roundbox for now */ + + uiDefBut(block, BUT_EXTRA, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, id, 0.0, 0.0, 0, 0, ""); uiBlockSetDrawExtraFunc(block, ED_preview_draw); uiBlockSetHandleFunc(block, do_preview_buttons, NULL); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index e3f850ddfd4..cb4d30213ca 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -545,12 +545,20 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) /* backdrop non AA */ if(wtb->inner) { if(wcol->shaded==0) { + + /* this is to enable drawing zero alpha masks */ + if(wcol->inner[3]==0) + glDisable(GL_BLEND); + /* filled center, solid */ glColor4ubv(wcol->inner); glBegin(GL_POLYGON); for(a=0; a<wtb->totvert; a++) glVertex2fv(wtb->inner_v[a]); glEnd(); + + if(wcol->inner[3]==0) + glEnable(GL_BLEND); } else { char col1[4], col2[4]; @@ -1596,6 +1604,46 @@ static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int state, int rou widgetbase_draw(&wtb, wcol); } +static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect) +{ + uiWidgetBase wtb; + uiWidgetColors *wcol= &wt->wcol; + char col[4]; + + /* state copy! */ + wt->wcol= *(wt->wcol_theme); + + widget_init(&wtb); + + /* filled rect in back color, alpha 1 */ + UI_GetThemeColor4ubv(TH_BACK, col); + col[3]= 255; + glColor4ubv(col); + glRecti(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + + /* inner mask with alpha zero */ + wcol->inner[0]= wcol->inner[1]= wcol->inner[2]= wcol->inner[3]= 0; + wtb.outline= 0; + round_box_edges(&wtb, 15, rect, 5.0f); + widgetbase_draw(&wtb, wcol); + + if(but->block->drawextra) { + glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE); + glEnable(GL_BLEND); + + but->block->drawextra(C, but->poin, rect); + + glDisable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + /* outline */ + wtb.outline= 1; + wtb.inner= 0; + widgetbase_draw(&wtb, wcol); + +} + + static void widget_disabled(rcti *rect) { float col[4]; @@ -1774,7 +1822,7 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) } /* conversion from old to new buttons, so still messy */ -void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) +void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) { bTheme *btheme= U.themes.first; ThemeUI *tui= &btheme->tui; @@ -1864,6 +1912,10 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) case ROUNDBOX: wt= widget_type(UI_WTYPE_BOX); break; + + case BUT_EXTRA: + widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect); + break; // XXX four old button types case HSVCUBE: diff --git a/source/blender/editors/preview/previewrender.c b/source/blender/editors/preview/previewrender.c index 096282a0f58..56ec22a44b0 100644 --- a/source/blender/editors/preview/previewrender.c +++ b/source/blender/editors/preview/previewrender.c @@ -640,14 +640,8 @@ void ED_preview_draw(const bContext *C, void *idp, rcti *rect) if(rres.rectf) { if(rres.rectx==newx && rres.recty==newy) { - glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA); - glEnable(GL_BLEND); - glaDrawPixelsSafe(rect->xmin, rect->ymin, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_FLOAT, rres.rectf); ok= 1; - - glDisable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } } BLI_unlock_malloc_thread(); @@ -1083,8 +1077,15 @@ static void shader_preview_free(void *customdata) void ED_preview_shader_job(const bContext *C, void *owner, ID *id, int sizex, int sizey) { - wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner); - ShaderPreview *sp= MEM_callocN(sizeof(ShaderPreview), "shader preview"); + wmJob *steve; + ShaderPreview *sp; + + /* XXX ugly global still, but we can't do preview while rendering */ + if(G.rendering) + return; + + steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner); + sp= MEM_callocN(sizeof(ShaderPreview), "shader preview"); /* customdata for preview thread */ sp->scene= CTX_data_scene(C); |