diff options
18 files changed, 57 insertions, 83 deletions
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 13f5eb86de2..b40fa8509b3 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -279,6 +279,9 @@ void UI_ColorPtrBlendShade3ubv(char *cp1, char *cp2, float fac, int offset); // get a 3 byte color, blended and shaded between two other char color pointers void UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, int offset); +// clear the openGL ClearColor using the input colorid +void UI_ThemeClearColor(int colorid); + // internal (blender) usage only, for init and set active void UI_SetTheme(int spacetype, int regionid); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 1267a1c1737..77958b3454b 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -749,6 +749,8 @@ void uiDrawBlock(const bContext *C, uiBlock *block) wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); + UI_ThemeClearColor(TH_BACK); + /* back */ if(block->flag & UI_BLOCK_LOOP) ui_draw_menu_back(&style, block, &rect); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index af990214686..dac689ca933 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2318,6 +2318,22 @@ static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int state, int rou } +static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) +{ + uiWidgetBase wtb; + + widget_init(&wtb); + + /* half rounded */ + round_box_edges(&wtb, roundboxalign, rect, 4.0f); + + widgetbase_draw(&wtb, wcol); + + /* store the box bg as gl clearcolor, to retrieve later when drawing semi-transparent rects + * over the top to indicate disabled buttons */ + glClearColor(wcol->inner[0]/255.0, wcol->inner[1]/255.0, wcol->inner[2]/255.0, 1.0); +} + static void widget_but(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { uiWidgetBase wtb; @@ -2384,10 +2400,11 @@ static void widget_disabled(rcti *rect) /* can't use theme TH_BACK or TH_PANEL... undefined */ glGetFloatv(GL_COLOR_CLEAR_VALUE, col); glColor4f(col[0], col[1], col[2], 0.5f); + /* need -1 and +1 to make it work right for aligned buttons, * but problem may be somewhere else? */ - glRectf(rect->xmin-1, rect->ymin, rect->xmax, rect->ymax+1); - + glRectf(rect->xmin-1, rect->ymin-1, rect->xmax, rect->ymax+1); + glDisable(GL_BLEND); } @@ -2504,6 +2521,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) break; case UI_WTYPE_BOX: + wt.custom= widget_box; wt.wcol_theme= &btheme->tui.wcol_box; break; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index b22ef5bbe52..e2bd8fc163e 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -944,6 +944,14 @@ void UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, in col[2] = b; } +void UI_ThemeClearColor(int colorid) +{ + float col[3]; + + UI_GetThemeColor3fv(colorid, col); + glClearColor(col[0], col[1], col[2], 0.0); +} + void UI_make_axis_color(char *src_col, char *dst_col, char axis) { switch(axis) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 61aa7a63da9..a248de22e68 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -340,9 +340,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) /* optional header info instead? */ if(ar->headerstr) { - float col[3]; - UI_GetThemeColor3fv(TH_HEADER, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_HEADER); glClear(GL_COLOR_BUFFER_BIT); UI_ThemeColor(TH_TEXT); @@ -1228,7 +1226,6 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex Panel *panel; View2D *v2d= &ar->v2d; View2DScrollers *scrollers; - float col[3]; int xco, yco, x, y, miny=0, w, em, header, triangle, open, newcontext= 0; if(contextnr >= 0) @@ -1334,14 +1331,9 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex } /* clear */ - if (ar->type->regionid == RGN_TYPE_PREVIEW) - UI_GetThemeColor3fv(TH_PREVIEW_BACK, col); - else - UI_GetThemeColor3fv(TH_BACK, col); - - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW)?TH_PREVIEW_BACK:TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + /* before setting the view */ if(vertical) { /* only allow scrolling in vertical direction */ @@ -1418,16 +1410,10 @@ void ED_region_header(const bContext *C, ARegion *ar) uiLayout *layout; HeaderType *ht; Header header = {0}; - float col[3]; int maxco, xco, yco; - /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); + /* clear */ + UI_ThemeClearColor((ED_screen_area_active(C))?TH_HEADER:TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); /* set view2d view matrix for scrolling (without scrollers) */ diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 7e02454254b..41ae6609b80 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -165,12 +165,10 @@ static void action_main_area_draw(const bContext *C, ARegion *ar) View2D *v2d= &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - float col[3]; short unit=0, flag=0; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(C, v2d); @@ -227,11 +225,9 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar) bAnimContext ac; View2D *v2d= &ar->v2d; View2DScrollers *scrollers; - float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(C, v2d); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 66068a4f23c..352f5131903 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -208,15 +208,9 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar) ED_region_header(C, ar); #else - float col[3]; - + /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(ED_screen_area_active(C)?TH_HEADER:TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); /* set view2d view matrix for scrolling (without scrollers) */ diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 97e1403e435..1b8191696f4 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -156,14 +156,12 @@ static void console_main_area_draw(const bContext *C, ARegion *ar) SpaceConsole *sc= CTX_wm_space_console(C); View2D *v2d= &ar->v2d; View2DScrollers *scrollers; - float col[3]; if((sc->type==CONSOLE_TYPE_PYTHON) && (sc->scrollback.first==NULL)) WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL); /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 1.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); console_update_rect(C, ar); diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 6c172c13138..5245c53fb01 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -111,11 +111,9 @@ static void info_main_area_init(wmWindowManager *wm, ARegion *ar) static void info_main_area_draw(const bContext *C, ARegion *ar) { - float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); } diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index e15d68b36a5..5a969be5916 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -244,11 +244,9 @@ static void logic_main_area_draw(const bContext *C, ARegion *ar) // SpaceLogic *slogic= CTX_wm_space_logic(C); View2D *v2d= &ar->v2d; View2DScrollers *scrollers; - float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(C, v2d); @@ -294,15 +292,8 @@ static void logic_header_area_init(wmWindowManager *wm, ARegion *ar) static void logic_header_area_draw(const bContext *C, ARegion *ar) { - float col[3]; - /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(ED_screen_area_active(C)?TH_HEADER:TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); /* set view2d view matrix for scrolling (without scrollers) */ diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 46fec4015ea..64933e3c11a 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -227,11 +227,9 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar) bAnimContext ac; View2D *v2d= &ar->v2d; View2DScrollers *scrollers; - float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(C, v2d); @@ -273,12 +271,10 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar) View2D *v2d= &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - float col[3]; short unit=0, flag=0; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(C, v2d); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index a1432cc0c1c..2dfc3273ec8 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1067,14 +1067,12 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) { - float col[3]; View2DScrollers *scrollers; SpaceNode *snode= CTX_wm_space_node(C); Scene *scene= CTX_data_scene(C); int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(C, v2d); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 63508725b05..1c86eb4df70 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -71,11 +71,9 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar) { View2D *v2d= &ar->v2d; View2DScrollers *scrollers; - float col[3]; /* clear */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); draw_outliner(C); diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 3629c980a25..9fb1d1a3f0b 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -140,11 +140,9 @@ static void script_main_area_draw(const bContext *C, ARegion *ar) /* draw entirely, view changes should be handled here */ SpaceScript *sscript= (SpaceScript*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; - float col[3]; - + /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(C, v2d); diff --git a/source/blender/editors/space_sound/space_sound.c b/source/blender/editors/space_sound/space_sound.c index 8c84002a625..174d686cf73 100644 --- a/source/blender/editors/space_sound/space_sound.c +++ b/source/blender/editors/space_sound/space_sound.c @@ -150,11 +150,9 @@ static void sound_main_area_draw(const bContext *C, ARegion *ar) /* draw entirely, view changes should be handled here */ // SpaceSound *ssound= (SpaceSound*)CTX_wm_space_data(C); View2D *v2d= &ar->v2d; - float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(C, v2d); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index e4f488fb5c1..2e78a502461 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -347,11 +347,9 @@ static void text_main_area_draw(const bContext *C, ARegion *ar) /* draw entirely, view changes should be handled here */ SpaceText *st= CTX_wm_space_text(C); //View2D *v2d= &ar->v2d; - float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); // UI_view2d_view_ortho(C, v2d); diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 31b76e6d5fa..1460d08b396 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -226,11 +226,9 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) View2DGrid *grid; View2DScrollers *scrollers; int unit, flag=0; - float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(C, v2d); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 3fd355f3c06..e2b579734d3 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1968,9 +1968,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, glClearColor(scene->world->horr, scene->world->horg, scene->world->horb, 0.0); } else { - float col[3]; - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); } glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); @@ -2182,7 +2180,6 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) Scene *sce; Base *base; Object *ob; - float col[3]; int retopo= 0, sculptparticle= 0; Object *obact = OBACT; char *grid_unit= NULL; @@ -2201,8 +2198,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } /* clear background */ - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); + UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /* setup view matrices */ |