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
This commit is contained in:
Campbell Barton 2019-04-24 11:37:36 +10:00
parent 411b5f3b10
commit 4312b47e83
Notes: blender-bot 2023-02-14 09:44:56 +01:00
Referenced by issue #63845, Region window tabs selection issues
Referenced by issue #63822, Sidebar tabs active area deadzone
4 changed files with 40 additions and 3 deletions

View File

@ -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 */

View File

@ -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);

View File

@ -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;

View File

@ -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;
}