Fix action zones not drawing properly while sculpting, due to recent bugfix.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 15 May 2013 17:59:55 +0000 (17:59 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 15 May 2013 17:59:55 +0000 (17:59 +0000)
Partial redraw doesn't work so well with these, now I've changed the action
zones to just draw as part of regions instead of as a special overdraw done
at the end, which fits better with partial redraw by avoiding any special
exceptions.

source/blender/editors/include/ED_screen.h
source/blender/editors/screen/area.c
source/blender/windowmanager/intern/wm_draw.c

index 3dc5ec0ebce5a07ff02ee28cadf1fe979ccd7fce..f1be219242e70900717d6546ab4dedcc6cab9e97 100644 (file)
@@ -74,8 +74,6 @@ void  ED_region_visible_rect(struct ARegion *ar, struct rcti *rect);
 void    ED_spacetypes_keymap(struct wmKeyConfig *keyconf);
 int     ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *block, int yco);
 int     ED_area_header_standardbuttons(const struct bContext *C, struct uiBlock *block, int yco);
-void    ED_area_overdraw(struct bContext *C);
-void    ED_area_overdraw_flush(struct ScrArea *sa, struct ARegion *ar);
 
 
 /* areas */
index 82ba0568823e6097f8a5850f836afb30f5c24f95..9196fdc19808a49871694a200d0195179e989d18 100644 (file)
@@ -149,25 +149,6 @@ void ED_area_do_refresh(bContext *C, ScrArea *sa)
        sa->do_refresh = FALSE;
 }
 
-/* based on screen region draw tags, set draw tags in azones, and future region tabs etc */
-/* only exported for WM */
-void ED_area_overdraw_flush(ScrArea *sa, ARegion *ar)
-{
-       AZone *az;
-       
-       for (az = sa->actionzones.first; az; az = az->next) {
-               int xs, ys;
-               
-               xs = (az->x1 + az->x2) / 2;
-               ys = (az->y1 + az->y2) / 2;
-
-               /* test if inside */
-               if (BLI_rcti_isect_pt(&ar->winrct, xs, ys)) {
-                       az->do_draw = TRUE;
-               }
-       }
-}
-
 /**
  * \brief Corner widgets use for dragging and splitting the view.
  */
@@ -347,49 +328,50 @@ static void region_draw_azone_tria(AZone *az)
        glDisable(GL_BLEND);
 }
 
-/* only exported for WM */
-void ED_area_overdraw(bContext *C)
+static void region_draw_azones(ScrArea *sa, ARegion *ar)
 {
-       wmWindow *win = CTX_wm_window(C);
-       bScreen *screen = CTX_wm_screen(C);
-       ScrArea *sa;
-       
-       /* Draw AZones, in screenspace */
-       wmSubWindowSet(win, screen->mainwin);
+       AZone *az;
+
+       if (!sa)
+               return;
 
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+       glPushMatrix();
+       glTranslatef(-ar->winrct.xmin, -ar->winrct.ymin, 0.0f);
        
-       for (sa = screen->areabase.first; sa; sa = sa->next) {
-               AZone *az;
-               for (az = sa->actionzones.first; az; az = az->next) {
-                       if (az->do_draw) {
-                               if (az->type == AZONE_AREA) {
-                                       area_draw_azone(az->x1, az->y1, az->x2, az->y2);
-                               }
-                               else if (az->type == AZONE_REGION) {
-                                       
-                                       if (az->ar) {
-                                               /* only display tab or icons when the region is hidden */
-                                               if (az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) {
-                                                       if (G.debug_value == 3)
-                                                               region_draw_azone_icon(az);
-                                                       else if (G.debug_value == 2)
-                                                               region_draw_azone_tria(az);
-                                                       else if (G.debug_value == 1)
-                                                               region_draw_azone_tab(az);
-                                                       else
-                                                               region_draw_azone_tab_plus(az);
-                                               }
+       for (az = sa->actionzones.first; az; az = az->next) {
+               /* test if action zone is over this region */
+               rcti azrct;
+               BLI_rcti_init(&azrct, az->x1, az->x2, az->y1, az->y2);
+
+               if (BLI_rcti_isect(&ar->drawrct, &azrct, NULL)) {
+                       if (az->type == AZONE_AREA) {
+                               area_draw_azone(az->x1, az->y1, az->x2, az->y2);
+                       }
+                       else if (az->type == AZONE_REGION) {
+                               
+                               if (az->ar) {
+                                       /* only display tab or icons when the region is hidden */
+                                       if (az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) {
+                                               if (G.debug_value == 3)
+                                                       region_draw_azone_icon(az);
+                                               else if (G.debug_value == 2)
+                                                       region_draw_azone_tria(az);
+                                               else if (G.debug_value == 1)
+                                                       region_draw_azone_tab(az);
+                                               else
+                                                       region_draw_azone_tab_plus(az);
                                        }
                                }
-                               
-                               az->do_draw = FALSE;
                        }
                }
        }
+
+       glPopMatrix();
+
        glDisable(GL_BLEND);
-       
 }
 
 /* only exported for WM */
@@ -454,6 +436,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
 
        ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
 
+       region_draw_azones(sa, ar);
+
        /* for debugging unneeded area redraws and partial redraw */
 #if 0
        glEnable(GL_BLEND);
index 438004b5d76fe4acfffea7099e3ce510bf74ea3c..3e9dc0f10c8734188ca98f75c4823aa3138549dc 100644 (file)
@@ -167,7 +167,6 @@ static void wm_method_draw_full(bContext *C, wmWindow *win)
                                CTX_wm_region_set(C, ar);
                                ED_region_do_draw(C, ar);
                                wm_paintcursor_draw(C, ar);
-                               ED_area_overdraw_flush(sa, ar);
                                CTX_wm_region_set(C, NULL);
                        }
                }
@@ -177,7 +176,6 @@ static void wm_method_draw_full(bContext *C, wmWindow *win)
        }
 
        ED_screen_draw(win);
-       ED_area_overdraw(C);
 
        /* draw overlapping regions */
        for (ar = screen->regionbase.first; ar; ar = ar->next) {
@@ -282,7 +280,6 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
                                        CTX_wm_region_set(C, ar);
                                        ED_region_do_draw(C, ar);
                                        wm_paintcursor_draw(C, ar);
-                                       ED_area_overdraw_flush(sa, ar);
                                        CTX_wm_region_set(C, NULL);
 
                                        if (exchange)
@@ -293,7 +290,6 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
                                                CTX_wm_region_set(C, ar);
                                                ED_region_do_draw(C, ar);
                                                wm_paintcursor_draw(C, ar);
-                                               ED_area_overdraw_flush(sa, ar);
                                                CTX_wm_region_set(C, NULL);
 
                                                ar->swap = WIN_BOTH_OK;
@@ -328,8 +324,6 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
                        screen->swap = WIN_BOTH_OK;
        }
 
-       ED_area_overdraw(C);
-
        /* draw marked overlapping regions */
        for (ar = screen->regionbase.first; ar; ar = ar->next) {
                if (ar->swinid && ar->do_draw) {
@@ -621,7 +615,6 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
                                if (ar->overlap == 0) {
                                        CTX_wm_region_set(C, ar);
                                        ED_region_do_draw(C, ar);
-                                       ED_area_overdraw_flush(sa, ar);
                                        CTX_wm_region_set(C, NULL);
                                        copytex = 1;
                                }
@@ -634,7 +627,6 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
 
        if (copytex) {
                wmSubWindowSet(win, screen->mainwin);
-               ED_area_overdraw(C);
 
                wm_triple_copy_textures(win, triple);
        }