[Bf-blender-cvs] [4312b47e83a] master: Fix T63822: Sidebar tabs active area dead-zone #2

Campbell Barton noreply at git.blender.org
Wed Apr 24 04:06:23 CEST 2019


Commit: 4312b47e83aaa7d54e67e53774ca85140c3a0931
Author: Campbell Barton
Date:   Wed Apr 24 11:37:36 2019 +1000
Branches: master
https://developer.blender.org/rB4312b47e83aaa7d54e67e53774ca85140c3a0931

Fix T63822: Sidebar tabs active area dead-zone #2

Take the entire gutter used for panel tabs into account.

Introduced in recent fix for T61554

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

M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/screen/area_query.c

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

diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 00771142553..543b2a5781f 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -413,6 +413,9 @@ bool ED_region_overlap_isect_xy_with_margin(const ARegion *ar,
                                             const int event_xy[2],
                                             const int margin);
 
+bool ED_region_panel_category_gutter_calc_rect(const ARegion *ar, rcti *r_ar_gutter);
+bool ED_region_panel_category_gutter_isect_xy(const ARegion *ar, const int event_xy[2]);
+
 bool ED_region_contains_xy(const struct ARegion *ar, const int event_xy[2]);
 
 /* interface_region_hud.c */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 3b77146b70e..d6cfe7aea1f 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1622,7 +1622,7 @@ void UI_panels_scale(struct ARegion *ar, float new_width);
 void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y);
 int UI_panel_size_y(const struct Panel *pa);
 
-bool UI_panel_category_is_visible(struct ARegion *ar);
+bool UI_panel_category_is_visible(const struct ARegion *ar);
 void UI_panel_category_add(struct ARegion *ar, const char *name);
 struct PanelCategoryDyn *UI_panel_category_find(struct ARegion *ar, const char *idname);
 struct PanelCategoryStack *UI_panel_category_active_find(struct ARegion *ar, const char *idname);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 7117115a0a1..ae28c09b7e2 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1757,7 +1757,7 @@ static void ui_handle_panel_header(
   }
 }
 
-bool UI_panel_category_is_visible(ARegion *ar)
+bool UI_panel_category_is_visible(const ARegion *ar)
 {
   /* more than one */
   return ar->panels_category.first && ar->panels_category.first != ar->panels_category.last;
diff --git a/source/blender/editors/screen/area_query.c b/source/blender/editors/screen/area_query.c
index 4d33567316f..420d70e63fb 100644
--- a/source/blender/editors/screen/area_query.c
+++ b/source/blender/editors/screen/area_query.c
@@ -24,6 +24,7 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
+#include "BLI_math_base.h"
 
 #include "RNA_types.h"
 
@@ -62,6 +63,35 @@ bool ED_region_overlap_isect_xy(const ARegion *ar, const int event_xy[2])
           ED_region_overlap_isect_y(ar, event_xy[1]));
 }
 
+bool ED_region_panel_category_gutter_calc_rect(const ARegion *ar, rcti *r_ar_gutter)
+{
+  *r_ar_gutter = ar->winrct;
+  if (UI_panel_category_is_visible(ar)) {
+    const int category_tabs_width = round_fl_to_int(UI_view2d_scale_get_x(&ar->v2d) *
+                                                    UI_PANEL_CATEGORY_MARGIN_WIDTH);
+    if (ar->alignment == RGN_ALIGN_LEFT) {
+      r_ar_gutter->xmax = r_ar_gutter->xmin + category_tabs_width;
+    }
+    else if (ar->alignment == RGN_ALIGN_RIGHT) {
+      r_ar_gutter->xmin = r_ar_gutter->xmax - category_tabs_width;
+    }
+    else {
+      BLI_assert(!"Unsupported alignment");
+    }
+    return true;
+  }
+  return false;
+}
+
+bool ED_region_panel_category_gutter_isect_xy(const ARegion *ar, const int event_xy[2])
+{
+  rcti ar_gutter;
+  if (ED_region_panel_category_gutter_calc_rect(ar, &ar_gutter)) {
+    return BLI_rcti_isect_pt_v(&ar_gutter, event_xy);
+  }
+  return false;
+}
+
 bool ED_region_overlap_isect_x_with_margin(const ARegion *ar, const int event_x, const int margin)
 {
   BLI_assert(ar->overlap);
@@ -121,11 +151,15 @@ bool ED_region_contains_xy(const ARegion *ar, const int event_xy[2])
           }
         }
         else if (ELEM(ar->alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
-          if (!ED_region_overlap_isect_y_with_margin(ar, event_xy[1], overlap_margin)) {
+          if (ED_region_panel_category_gutter_isect_xy(ar, event_xy)) {
+            /* pass */
+          }
+          else if (!ED_region_overlap_isect_y_with_margin(ar, event_xy[1], overlap_margin)) {
             return false;
           }
         }
         else {
+          /* No panel categories for horizontal regions currently. */
           if (!ED_region_overlap_isect_xy_with_margin(ar, event_xy, overlap_margin)) {
             return false;
           }



More information about the Bf-blender-cvs mailing list