Fix [#21516] UI artifacts in array modifier
authorMatt Ebb <matt@mke3.net>
Tue, 6 Apr 2010 07:02:16 +0000 (07:02 +0000)
committerMatt Ebb <matt@mke3.net>
Tue, 6 Apr 2010 07:02:16 +0000 (07:02 +0000)
Modify the glClearColor used to draw disabled buttons, when creating a ROUNDBOX
ui element. Made a convenience function and rippled it though, too.

18 files changed:
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/resources.c
source/blender/editors/screen/area.c
source/blender/editors/space_action/space_action.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_console/space_console.c
source/blender/editors/space_info/space_info.c
source/blender/editors/space_logic/space_logic.c
source/blender/editors/space_nla/space_nla.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_script/space_script.c
source/blender/editors/space_sound/space_sound.c
source/blender/editors/space_text/space_text.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_view3d/view3d_draw.c

index 13f5eb8..b40fa85 100644 (file)
@@ -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);
 
index 1267a1c..77958b3 100644 (file)
@@ -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);
index af99021..dac689c 100644 (file)
@@ -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;
                        
index b22ef5b..e2bd8fc 100644 (file)
@@ -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)
index 61aa7a6..a248de2 100644 (file)
@@ -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) */
index 7e02454..41ae660 100644 (file)
@@ -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);
index 66068a4..352f513 100644 (file)
@@ -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) */
index 97e1403..1b81916 100644 (file)
@@ -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);
index 6c172c1..5245c53 100644 (file)
@@ -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);
 }
 
index e15d68b..5a969be 100644 (file)
@@ -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) */
index 46fec40..64933e3 100644 (file)
@@ -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);
index a1432cc..2dfc327 100644 (file)
@@ -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);
index 6350872..1c86eb4 100644 (file)
@@ -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);
index 3629c98..9fb1d1a 100644 (file)
@@ -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);
index 8c84002..174d686 100644 (file)
@@ -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);
index e4f488f..2e78a50 100644 (file)
@@ -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);
index 31b76e6..1460d08 100644 (file)
@@ -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);
index 3fd355f..e2b5797 100644 (file)
@@ -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 */