1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 00:42:55 +08:00

Merge pull request #9023 from Fukashi13/sections-container-fix

Fix overlay section display highlighting wrong section
This commit is contained in:
Dan Balasescu 2020-05-18 19:49:28 +09:00 committed by GitHub
commit 490b6dbd7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -189,23 +189,18 @@ namespace osu.Game.Graphics.Containers
headerBackgroundContainer.Height = (ExpandableHeader?.LayoutSize.Y ?? 0) + (FixedHeader?.LayoutSize.Y ?? 0);
headerBackgroundContainer.Y = ExpandableHeader?.Y ?? 0;
T bestMatch = null;
float minDiff = float.MaxValue;
float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0;
Func<T, float> diff = section => scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset;
foreach (var section in Children)
if (scrollContainer.IsScrolledToEnd())
{
float diff = Math.Abs(scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset);
if (diff < minDiff)
{
minDiff = diff;
bestMatch = section;
}
SelectedSection.Value = Children.LastOrDefault();
}
else
{
SelectedSection.Value = Children.TakeWhile(section => diff(section) <= 0).LastOrDefault()
?? Children.FirstOrDefault();
}
if (bestMatch != null)
SelectedSection.Value = bestMatch;
}
}