diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 4a54fb6038a..b0ae69ed8fb 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -1061,9 +1061,7 @@ static void region_azone_scrollbar_init(ScrArea *area, ARegion *region, AZScrollDirection direction) { - rcti scroller_vert = (direction == AZ_SCROLL_VERT) ? region->v2d.vert : region->v2d.hor; AZone *az = static_cast(MEM_callocN(sizeof(*az), __func__)); - float hide_width; BLI_addtail(&area->actionzones, az); az->type = AZONE_REGION_SCROLL; @@ -1072,20 +1070,13 @@ static void region_azone_scrollbar_init(ScrArea *area, if (direction == AZ_SCROLL_VERT) { az->region->v2d.alpha_vert = 0; - hide_width = V2D_SCROLL_HIDE_HEIGHT; } else if (direction == AZ_SCROLL_HOR) { az->region->v2d.alpha_hor = 0; - hide_width = V2D_SCROLL_HIDE_WIDTH; } - BLI_rcti_translate(&scroller_vert, region->winrct.xmin, region->winrct.ymin); - az->x1 = scroller_vert.xmin - ((direction == AZ_SCROLL_VERT) ? hide_width : 0); - az->y1 = scroller_vert.ymin - ((direction == AZ_SCROLL_HOR) ? hide_width : 0); - az->x2 = scroller_vert.xmax + ((direction == AZ_SCROLL_VERT) ? hide_width : 0); - az->y2 = scroller_vert.ymax + ((direction == AZ_SCROLL_HOR) ? hide_width : 0); - - BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); + /* No need to specify rect for scrollbar az. For intersection we'll test against the area around + * the region's scroller instead, in `area_actionzone_get_rect`. */ } static void region_azones_scrollbars_init(ScrArea *area, ARegion *region) @@ -3131,11 +3122,14 @@ void ED_region_panels_draw(const bContext *C, ARegion *region) /* scrollers */ bool use_mask = false; rcti mask; - if (region->runtime.category && (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_RIGHT)) + if (region->runtime.category && + (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_RIGHT) && + UI_panel_category_is_visible(region)) { use_mask = true; UI_view2d_mask_from_win(v2d, &mask); - mask.xmax -= UI_PANEL_CATEGORY_MARGIN_WIDTH; + mask.xmax -= round_fl_to_int(UI_view2d_scale_get_x(®ion->v2d) * + UI_PANEL_CATEGORY_MARGIN_WIDTH); } bool use_full_hide = false; if (region->overlap) { diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index cb6e2fbd119..ae1a0ad34c5 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -817,15 +817,35 @@ static bool azone_clipped_rect_calc(const AZone *az, rcti *r_rect_clip) return false; } +/* Return the azone's calculated rect. */ +static void area_actionzone_get_rect(AZone *az, rcti *rect) +{ + if (az->type == AZONE_REGION_SCROLL) { + /* For scroll azones use the area around the region's scrollbar location. */ + rcti scroller_vert = (az->direction == AZ_SCROLL_HOR) ? az->region->v2d.hor : + az->region->v2d.vert; + BLI_rcti_translate(&scroller_vert, az->region->winrct.xmin, az->region->winrct.ymin); + rect->xmin = scroller_vert.xmin - ((az->direction == AZ_SCROLL_VERT) ? V2D_SCROLL_HIDE_HEIGHT : 0); + rect->ymin = scroller_vert.ymin - + ((az->direction == AZ_SCROLL_HOR) ? V2D_SCROLL_HIDE_WIDTH : 0); + rect->xmax = scroller_vert.xmax + + ((az->direction == AZ_SCROLL_VERT) ? V2D_SCROLL_HIDE_HEIGHT : 0); + rect->ymax = scroller_vert.ymax + + ((az->direction == AZ_SCROLL_HOR) ? V2D_SCROLL_HIDE_WIDTH : 0); + } + else { + azone_clipped_rect_calc(az, rect); + } +} + static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const bool test_only) { AZone *az = NULL; for (az = area->actionzones.first; az; az = az->next) { - 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))) + rcti az_rect; + area_actionzone_get_rect(az, &az_rect); + if (BLI_rcti_isect_pt_v(&az_rect, xy)) { if (az->type == AZONE_AREA) { @@ -915,16 +935,14 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b float dist_fac = 0.0f, alpha = 0.0f; if (az->direction == AZ_SCROLL_HOR) { - float hide_width = (az->y2 - az->y1) / 2.0f; - dist_fac = BLI_rcti_length_y(&v2d->hor, local_xy[1]) / hide_width; + dist_fac = BLI_rcti_length_y(&v2d->hor, local_xy[1]) / V2D_SCROLL_HIDE_WIDTH; CLAMP(dist_fac, 0.0f, 1.0f); alpha = 1.0f - dist_fac; v2d->alpha_hor = alpha * 255; } else if (az->direction == AZ_SCROLL_VERT) { - float hide_width = (az->x2 - az->x1) / 2.0f; - dist_fac = BLI_rcti_length_x(&v2d->vert, local_xy[0]) / hide_width; + dist_fac = BLI_rcti_length_x(&v2d->vert, local_xy[0]) / V2D_SCROLL_HIDE_HEIGHT; CLAMP(dist_fac, 0.0f, 1.0f); alpha = 1.0f - dist_fac;