diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index ddfb0d36ce1..77bd2d5b572 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -930,13 +930,41 @@ static void fullscreen_azone_init(ScrArea *area, ARegion *region) BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } +/** + * Return true if the background color alpha is close to fully transparent. That is, a value of + * less than 50 on a [0-255] scale (rather arbitrary threshold). Assumes the region uses #TH_BACK + * for its background. + */ +static bool region_background_is_transparent(const ScrArea *area, const ARegion *region) +{ + /* Ensure the right theme is active, may not be the case on startup, for example. */ + bThemeState theme_state; + UI_Theme_Store(&theme_state); + UI_SetTheme(area->spacetype, region->regiontype); + + uchar back[4]; + UI_GetThemeColor4ubv(TH_BACK, back); + + UI_Theme_Restore(&theme_state); + + return back[3] < 50; +} + #define AZONEPAD_EDGE (0.1f * U.widget_unit) #define AZONEPAD_ICON (0.45f * U.widget_unit) -static void region_azone_edge(AZone *az, ARegion *region) +static void region_azone_edge(const ScrArea *area, AZone *az, const ARegion *region) { - /* If region is overlapped (transparent background), move #AZone to content. - * Note this is an arbitrary amount that matches nicely with numbers elsewhere. */ - int overlap_padding = (region->overlap) ? int(0.4f * U.widget_unit) : 0; + /* If there is no visible region background, users typically expect the #AZone to be closer to + * the content, so move it a bit. */ + const int overlap_padding = + /* Header-like regions are usually thin and there's not much padding around them, + * applying an offset would make the edge overlap buttons.*/ + (!RGN_TYPE_IS_HEADER_ANY(region->regiontype) && + /* Is the region background transparent? */ + region->overlap && region_background_is_transparent(area, region)) ? + /* Note that this is an arbitrary amount that matches nicely with numbers elsewhere. */ + int(0.4f * U.widget_unit) : + 0; switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: @@ -1053,7 +1081,7 @@ static void region_azone_edge_init(ScrArea *area, region_azone_tab_plus(area, az, region); } else { - region_azone_edge(az, region); + region_azone_edge(area, az, region); } }