[Bf-blender-cvs] [2ffc3dfc093] master: Fix action zones getting out of sync with panel size

Campbell Barton noreply at git.blender.org
Tue Apr 23 22:17:25 CEST 2019


Commit: 2ffc3dfc0936f82a50eaf4b0dd0471965963fe6d
Author: Campbell Barton
Date:   Wed Apr 24 06:10:50 2019 +1000
Branches: master
https://developer.blender.org/rB2ffc3dfc0936f82a50eaf4b0dd0471965963fe6d

Fix action zones getting out of sync with panel size

Change to recent fix for T61554

===================================================================

M	source/blender/editors/screen/area.c
M	source/blender/editors/screen/screen_ops.c

===================================================================

diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index ab68b3cfcf8..5cd5153b060 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -901,65 +901,32 @@ static void fullscreen_azone_initialize(ScrArea *sa, ARegion *ar)
 #define AZONEPAD_ICON (0.45f * U.widget_unit)
 static void region_azone_edge(AZone *az, ARegion *ar)
 {
-  int clip_axis = -1;
   switch (az->edge) {
     case AE_TOP_TO_BOTTOMRIGHT:
       az->x1 = ar->winrct.xmin;
       az->y1 = ar->winrct.ymax - AZONEPAD_EDGE;
       az->x2 = ar->winrct.xmax;
       az->y2 = ar->winrct.ymax + AZONEPAD_EDGE;
-      if (ar->overlap) {
-        clip_axis = 0;
-      }
       break;
     case AE_BOTTOM_TO_TOPLEFT:
       az->x1 = ar->winrct.xmin;
       az->y1 = ar->winrct.ymin + AZONEPAD_EDGE;
       az->x2 = ar->winrct.xmax;
       az->y2 = ar->winrct.ymin - AZONEPAD_EDGE;
-      if (ar->overlap) {
-        clip_axis = 0;
-      }
       break;
     case AE_LEFT_TO_TOPRIGHT:
       az->x1 = ar->winrct.xmin - AZONEPAD_EDGE;
       az->y1 = ar->winrct.ymin;
       az->x2 = ar->winrct.xmin + AZONEPAD_EDGE;
       az->y2 = ar->winrct.ymax;
-      if (ar->overlap) {
-        clip_axis = 1;
-      }
       break;
     case AE_RIGHT_TO_TOPLEFT:
       az->x1 = ar->winrct.xmax + AZONEPAD_EDGE;
       az->y1 = ar->winrct.ymin;
       az->x2 = ar->winrct.xmax - AZONEPAD_EDGE;
       az->y2 = ar->winrct.ymax;
-      if (ar->overlap) {
-        clip_axis = 1;
-      }
       break;
   }
-
-  /* Constrain action zones to usable area of region.
-   * Needed so blank areas of the region are interactive and aciton zones don't get in the way. */
-  if (clip_axis == 0) {
-    az->x1 = max_ii(az->x1,
-                    (ar->winrct.xmin + UI_view2d_view_to_region_x(&ar->v2d, ar->v2d.tot.xmin)) -
-                        UI_REGION_OVERLAP_MARGIN);
-    az->x2 = min_ii(az->x2,
-                    (ar->winrct.xmin + UI_view2d_view_to_region_x(&ar->v2d, ar->v2d.tot.xmax)) +
-                        UI_REGION_OVERLAP_MARGIN);
-  }
-  else if (clip_axis == 1) {
-    az->y1 = max_ii(az->y1,
-                    (ar->winrct.ymin + UI_view2d_view_to_region_y(&ar->v2d, ar->v2d.tot.ymin)) -
-                        UI_REGION_OVERLAP_MARGIN);
-    az->y2 = min_ii(az->y2,
-                    (ar->winrct.ymin + UI_view2d_view_to_region_y(&ar->v2d, ar->v2d.tot.ymax)) +
-                        UI_REGION_OVERLAP_MARGIN);
-  }
-
   BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
 }
 
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 27fd7c37dee..8e7475ec511 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -723,12 +723,54 @@ static void fullscreen_click_rcti_init(
   BLI_rcti_init(rect, x, x + icon_size, y, y + icon_size);
 }
 
+static bool azone_clipped_rect_calc(const AZone *az, rcti *r_rect_clip)
+{
+  const ARegion *ar = az->ar;
+  *r_rect_clip = az->rect;
+  if (az->type == AZONE_REGION) {
+    if (ar->overlap && (ar->v2d.keeptot != V2D_KEEPTOT_STRICT)) {
+      /* A floating region to be resized, clip by the visible region. */
+      switch (az->edge) {
+        case AE_TOP_TO_BOTTOMRIGHT:
+        case AE_BOTTOM_TO_TOPLEFT: {
+          r_rect_clip->xmin = max_ii(
+              r_rect_clip->xmin,
+              (ar->winrct.xmin + UI_view2d_view_to_region_x(&ar->v2d, ar->v2d.tot.xmin)) -
+                  UI_REGION_OVERLAP_MARGIN);
+          r_rect_clip->xmax = min_ii(
+              r_rect_clip->xmax,
+              (ar->winrct.xmin + UI_view2d_view_to_region_x(&ar->v2d, ar->v2d.tot.xmax)) +
+                  UI_REGION_OVERLAP_MARGIN);
+          return true;
+        }
+        case AE_LEFT_TO_TOPRIGHT:
+        case AE_RIGHT_TO_TOPLEFT: {
+          r_rect_clip->ymin = max_ii(
+              r_rect_clip->ymin,
+              (ar->winrct.ymin + UI_view2d_view_to_region_y(&ar->v2d, ar->v2d.tot.ymin)) -
+                  UI_REGION_OVERLAP_MARGIN);
+          r_rect_clip->ymax = min_ii(
+              r_rect_clip->ymax,
+              (ar->winrct.ymin + UI_view2d_view_to_region_y(&ar->v2d, ar->v2d.tot.ymax)) +
+                  UI_REGION_OVERLAP_MARGIN);
+          return true;
+        }
+      }
+    }
+  }
+  return false;
+}
+
 static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const bool test_only)
 {
   AZone *az = NULL;
 
   for (az = sa->actionzones.first; az; az = az->next) {
-    if (BLI_rcti_isect_pt_v(&az->rect, xy)) {
+    rcti az_rect_clip;
+    if (BLI_rcti_isect_pt_v(&az->rect, xy) &&
+        /* Check clipping if this is clipped */
+        (!azone_clipped_rect_calc(az, &az_rect_clip) || BLI_rcti_isect_pt_v(&az_rect_clip, xy))) {
+
       if (az->type == AZONE_AREA) {
         break;
       }



More information about the Bf-blender-cvs mailing list