Fix action zones getting out of sync with panel size
Change to recent fix for T61554
This commit is contained in:
parent
211c5b4429
commit
2ffc3dfc09
Notes:
blender-bot
2023-02-14 11:18:07 +01:00
Referenced by issue #79937, Brush cursor (sculpt, vertexpaint, weightpaint) stuck/doesn't draw under transparent part of N-panel
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue