UI: Improve region resize edge detection for transparent regions #109753

Merged
Julian Eisel merged 4 commits from JulianEisel/blender:temp-region-resize-edge-offset-fix into main 2023-07-10 12:53:48 +02:00
1 changed files with 11 additions and 10 deletions
Showing only changes of commit d322993d50 - Show all commits

View File

@ -932,8 +932,8 @@ static void fullscreen_azone_init(ScrArea *area, ARegion *region)
/**
* 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 (arbitrary/eyeballed threshold). Assumes the region uses
* #TH_BACK for its background.
* less than 50 on a [0-255] scale (rather arbitrary threshold). Assumes the region uses #TH_BACK
* for its background.
*/
static bool region_back_is_barely_visible(const ScrArea *area, const ARegion *region)
JulianEisel marked this conversation as resolved Outdated

Naming: region_back_is_barely_visible reads a bit strangely, something may be invisible because of it's size/placement.

region_background_is_transparent the doc-string can note that a threshold is used. Or the name could be expanded to include that but I don't think it's necessary.

Naming: `region_back_is_barely_visible` reads a bit strangely, something may be invisible because of it's size/placement. `region_background_is_transparent` the doc-string can note that a threshold is used. Or the name could be expanded to include that but I don't think it's necessary.
{
@ -955,14 +955,15 @@ static bool region_back_is_barely_visible(const ScrArea *area, const ARegion *re
static void region_azone_edge(const ScrArea *area, AZone *az, const ARegion *region)
{
/* If there is no visible region background, users typically expect the #AZone to be closer to
* the content, so move it a bit. Headers-like regions are usually thin and there's not much
* padding around them, so don't touch the #AZone there (also avoids mouse hover conflicts with
* actual contents).
* Note that this is an arbitrary amount that matches nicely with numbers elsewhere. */
const int overlap_padding = (region->overlap && region_back_is_barely_visible(area, region) &&
!RGN_TYPE_IS_HEADER_ANY(region->regiontype)) ?
int(0.4f * U.widget_unit) :
0;
* the content, so move it a bit. */
const int overlap_padding =
(region->overlap && region_back_is_barely_visible(area, region) &&
/* 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)) ?
JulianEisel marked this conversation as resolved Outdated

picky would check !RGN_TYPE_IS_HEADER_ANY(region->regiontype) before region_back_is_barely_visible as UI_Theme_Store / UI_Theme_Restore is heavier than this check.

*picky* would check `!RGN_TYPE_IS_HEADER_ANY(region->regiontype)` before `region_back_is_barely_visible` as `UI_Theme_Store` / `UI_Theme_Restore` is heavier than this check.
/* 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: