Screen: split ED_area_actionzone_find_xy
authorCampbell Barton <ideasman42@gmail.com>
Wed, 20 Jun 2018 13:32:46 +0000 (15:32 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 20 Jun 2018 13:34:20 +0000 (15:34 +0200)
Add ED_area_actionzone_refresh_xy which can tag redraw
find no longer changes changes to the action zone.

source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_intern.h
source/blender/editors/screen/screen_ops.c

index 615f47e51c3ee204fbecc6344b077f2d9bbc492b..3306003f18cfd57020cd5d1eaf87286fe6cc123f 100644 (file)
@@ -1106,7 +1106,7 @@ void ED_screen_set_subwinactive(bContext *C, const wmEvent *event)
                for (sa = scr->areabase.first; sa; sa = sa->next) {
                        if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax)
                                if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax)
-                                       if (NULL == ED_area_actionzone_find_xy(sa, &event->x))
+                                       if (NULL == ED_area_actionzone_refresh_xy(sa, &event->x))
                                                break;
                }
                if (sa) {
index cd12f30c3bb196a37bbf1a01feddd58131cacb8c..63d616e986e8474ab20e3e3016310a7389218bd0 100644 (file)
@@ -62,6 +62,7 @@ ScrEdge    *screen_find_active_scredge(bScreen *sc,
                                        const int mx, const int my);
 
 struct AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2]);
+struct AZone *ED_area_actionzone_refresh_xy(ScrArea *sa, const int xy[2]);
 
 /* screen_context.c */
 int ed_screen_context(
index d1510f60517335db157e6981a60f6a96c7fb25ce..a77307af1928d1074d97ef72cc443a6a969b25a7 100644 (file)
@@ -665,7 +665,7 @@ static void fullscreen_click_rcti_init(rcti *rect, const short x1, const short y
        BLI_rcti_init(rect, x, x + icon_size, y, y + icon_size);
 }
 
-AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2])
+static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const bool test_only)
 {
        AZone *az = NULL;
 
@@ -682,40 +682,49 @@ AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2])
                                break;
                        }
                        else if (az->type == AZONE_FULLSCREEN) {
-                               int mouse_radius, spot_radius, fadein_radius, fadeout_radius;
                                rcti click_rect;
-
                                fullscreen_click_rcti_init(&click_rect, az->x1, az->y1, az->x2, az->y2);
+                               const bool click_isect = BLI_rcti_isect_pt_v(&click_rect, xy);
 
-                               if (BLI_rcti_isect_pt_v(&click_rect, xy)) {
-                                       az->alpha = 1.0f;
+                               if (test_only) {
+                                       if (click_isect) {
+                                               break;
+                                       }
                                }
                                else {
-                                       mouse_radius = (xy[0] - az->x2) * (xy[0] - az->x2) + (xy[1] - az->y2) * (xy[1] - az->y2);
-                                       spot_radius = AZONESPOT * AZONESPOT;
-                                       fadein_radius = AZONEFADEIN * AZONEFADEIN;
-                                       fadeout_radius = AZONEFADEOUT * AZONEFADEOUT;
+                                       int mouse_radius, spot_radius, fadein_radius, fadeout_radius;
 
-                                       if (mouse_radius < spot_radius) {
+                                       fullscreen_click_rcti_init(&click_rect, az->x1, az->y1, az->x2, az->y2);
+                                       if (click_isect) {
                                                az->alpha = 1.0f;
                                        }
-                                       else if (mouse_radius < fadein_radius) {
-                                               az->alpha = 1.0f;
-                                       }
-                                       else if (mouse_radius < fadeout_radius) {
-                                               az->alpha = 1.0f - ((float)(mouse_radius - fadein_radius)) / ((float)(fadeout_radius - fadein_radius));
-                                       }
                                        else {
-                                               az->alpha = 0.0f;
+                                               mouse_radius = (xy[0] - az->x2) * (xy[0] - az->x2) + (xy[1] - az->y2) * (xy[1] - az->y2);
+                                               spot_radius = AZONESPOT * AZONESPOT;
+                                               fadein_radius = AZONEFADEIN * AZONEFADEIN;
+                                               fadeout_radius = AZONEFADEOUT * AZONEFADEOUT;
+
+                                               if (mouse_radius < spot_radius) {
+                                                       az->alpha = 1.0f;
+                                               }
+                                               else if (mouse_radius < fadein_radius) {
+                                                       az->alpha = 1.0f;
+                                               }
+                                               else if (mouse_radius < fadeout_radius) {
+                                                       az->alpha = 1.0f - ((float)(mouse_radius - fadein_radius)) / ((float)(fadeout_radius - fadein_radius));
+                                               }
+                                               else {
+                                                       az->alpha = 0.0f;
+                                               }
+
+                                               /* fade in/out but no click */
+                                               az = NULL;
                                        }
 
-                                       /* fade in/out but no click */
-                                       az = NULL;
+                                       /* XXX force redraw to show/hide the action zone */
+                                       ED_area_tag_redraw(sa);
+                                       break;
                                }
-
-                               /* XXX force redraw to show/hide the action zone */
-                               ED_area_tag_redraw(sa);
-                               break;
                        }
                }
        }
@@ -723,6 +732,15 @@ AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2])
        return az;
 }
 
+AZone *ED_area_actionzone_find_xy(ScrArea *sa, const int xy[2])
+{
+       return area_actionzone_refresh_xy(sa, xy, true);
+}
+
+AZone *ED_area_actionzone_refresh_xy(ScrArea *sa, const int xy[2])
+{
+       return area_actionzone_refresh_xy(sa, xy, false);
+}
 
 static void actionzone_exit(wmOperator *op)
 {