Fix #113687: Asset shelf header overlaps labels without region overlap
If "Region Overlap" was disabled, the region coordinate calculations would end up placing the header on the bottom, taking space away from the main asset shelf region. This is because the header was abusing the `RGN_SPLIT_PREV` flag a bit, because it gave the desired behavior of hiding the regions together. This worked well because the regions wouldn't actually do the splitting when one used region overlap and the other not. But disabling region overlap would bring the splitting usually enabled with the `RGN_SPLIT_PREV` flag. This PR removes the `RGN_SPLIT_PREV` flag from the asset shelf header. Instead a new flag is introduced to only enable the behavior of `RGN_SPLIT_PREV` of hiding a region together with the previous one. So the header stays at the top of the region, and labels stay visible. The new flag is added to the `ARegion.alignment` flags, even though it's more related to behavior than alignment. However this is more convenient, and keeps it together with related flags.
This commit is contained in:
@@ -1704,5 +1704,21 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
const ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
|
||||
&sl->regionbase;
|
||||
LISTBASE_FOREACH (ARegion *, region, regionbase) {
|
||||
if (region->regiontype != RGN_TYPE_ASSET_SHELF_HEADER) {
|
||||
continue;
|
||||
}
|
||||
region->alignment &= ~RGN_SPLIT_PREV;
|
||||
region->alignment |= RGN_ALIGN_HIDE_WITH_PREV;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1714,7 +1714,7 @@ static void region_subwindow(ARegion *region)
|
||||
bool hidden = (region->flag & (RGN_FLAG_POLL_FAILED | RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) !=
|
||||
0;
|
||||
|
||||
if ((region->alignment & RGN_SPLIT_PREV) && region->prev) {
|
||||
if ((region->alignment & (RGN_SPLIT_PREV | RGN_ALIGN_HIDE_WITH_PREV)) && region->prev) {
|
||||
hidden = hidden || (region->prev->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL));
|
||||
}
|
||||
|
||||
|
||||
@@ -5507,7 +5507,9 @@ struct RegionAlphaInfo {
|
||||
float ED_region_blend_alpha(ARegion *region)
|
||||
{
|
||||
/* check parent too */
|
||||
if (region->regiontimer == nullptr && (region->alignment & RGN_SPLIT_PREV) && region->prev) {
|
||||
if (region->regiontimer == nullptr &&
|
||||
(region->alignment & (RGN_SPLIT_PREV | RGN_ALIGN_HIDE_WITH_PREV)) && region->prev)
|
||||
{
|
||||
region = region->prev;
|
||||
}
|
||||
|
||||
@@ -5582,7 +5584,7 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe
|
||||
}
|
||||
|
||||
if (region->next) {
|
||||
if (region->next->alignment & RGN_SPLIT_PREV) {
|
||||
if (region->next->alignment & (RGN_SPLIT_PREV | RGN_ALIGN_HIDE_WITH_PREV)) {
|
||||
rgi->child_region = region->next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ static SpaceLink *view3d_create(const ScrArea * /*area*/, const Scene *scene)
|
||||
region = MEM_cnew<ARegion>("asset shelf header for view3d");
|
||||
BLI_addtail(&v3d->regionbase, region);
|
||||
region->regiontype = RGN_TYPE_ASSET_SHELF_HEADER;
|
||||
region->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
|
||||
region->alignment = RGN_ALIGN_BOTTOM | RGN_ALIGN_HIDE_WITH_PREV;
|
||||
|
||||
/* tool shelf */
|
||||
region = MEM_cnew<ARegion>("toolshelf for view3d");
|
||||
|
||||
@@ -703,10 +703,16 @@ enum {
|
||||
/* Maximum 15. */
|
||||
|
||||
/* Flags start here. */
|
||||
/** Region is split into the previous one, they share the same space along a common edge.
|
||||
* Includes the #RGN_ALIGN_HIDE_WITH_PREV behavior. */
|
||||
RGN_SPLIT_PREV = 1 << 5,
|
||||
/** Always let scaling this region scale the previous region instead. Useful to let regions
|
||||
* appear like they are one (while having independent layout, scrolling, etc.). */
|
||||
RGN_SPLIT_SCALE_PREV = 1 << 6,
|
||||
/** Whenever the previous region is hidden, this region becomes invisible too. #RGN_FLAG_HIDDEN
|
||||
* should only be set for the previous region, not this. The evaluated visibility respecting this
|
||||
* flag can be queried via #ARegion.visible */
|
||||
RGN_ALIGN_HIDE_WITH_PREV = 1 << 7,
|
||||
};
|
||||
|
||||
/** Mask out flags so we can check the alignment. */
|
||||
|
||||
Reference in New Issue
Block a user