mirror of
https://github.com/ppy/osu
synced 2024-12-11 17:42:28 +00:00
Simplify selected section resolution
This commit is contained in:
parent
6d167b7865
commit
e5eec27e95
@ -215,23 +215,16 @@ namespace osu.Game.Graphics.Containers
|
||||
// plus 5% to fix floating point errors and to not have a section instantly unselect when scrolling upwards
|
||||
// but the 5% can't be bigger than our smallest section height, otherwise it won't get selected correctly
|
||||
float sectionOrContent = Math.Min(smallestSectionHeight / 2.0f, scrollContainer.DisplayableContent * 0.05f);
|
||||
|
||||
float scrollOffset = (FixedHeader?.LayoutSize.Y ?? 0) + scrollContainer.DisplayableContent * scroll_target_multiplier + sectionOrContent;
|
||||
Func<T, float> diff = section => scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset;
|
||||
|
||||
if (Precision.AlmostBigger(0, scrollContainer.Current))
|
||||
{
|
||||
SelectedSection.Value = lastClickedSection as T ?? Children.FirstOrDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Precision.AlmostBigger(scrollContainer.Current, scrollContainer.ScrollableExtent))
|
||||
{
|
||||
else if (Precision.AlmostBigger(scrollContainer.Current, scrollContainer.ScrollableExtent))
|
||||
SelectedSection.Value = lastClickedSection as T ?? Children.LastOrDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
SelectedSection.Value = Children.TakeWhile(section => diff(section) <= 0).LastOrDefault()
|
||||
?? Children.FirstOrDefault();
|
||||
else
|
||||
SelectedSection.Value = Children.TakeWhile(section => diff(section) <= 0).LastOrDefault() ?? Children.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user