mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 17:53:53 +08: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
|
// 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
|
// 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 sectionOrContent = Math.Min(smallestSectionHeight / 2.0f, scrollContainer.DisplayableContent * 0.05f);
|
||||||
|
|
||||||
float scrollOffset = (FixedHeader?.LayoutSize.Y ?? 0) + scrollContainer.DisplayableContent * scroll_target_multiplier + sectionOrContent;
|
float scrollOffset = (FixedHeader?.LayoutSize.Y ?? 0) + scrollContainer.DisplayableContent * scroll_target_multiplier + sectionOrContent;
|
||||||
Func<T, float> diff = section => scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset;
|
Func<T, float> diff = section => scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset;
|
||||||
|
|
||||||
if (Precision.AlmostBigger(0, scrollContainer.Current))
|
if (Precision.AlmostBigger(0, scrollContainer.Current))
|
||||||
{
|
|
||||||
SelectedSection.Value = lastClickedSection as T ?? Children.FirstOrDefault();
|
SelectedSection.Value = lastClickedSection as T ?? Children.FirstOrDefault();
|
||||||
return;
|
else if (Precision.AlmostBigger(scrollContainer.Current, scrollContainer.ScrollableExtent))
|
||||||
}
|
|
||||||
|
|
||||||
if (Precision.AlmostBigger(scrollContainer.Current, scrollContainer.ScrollableExtent))
|
|
||||||
{
|
|
||||||
SelectedSection.Value = lastClickedSection as T ?? Children.LastOrDefault();
|
SelectedSection.Value = lastClickedSection as T ?? Children.LastOrDefault();
|
||||||
return;
|
else
|
||||||
}
|
SelectedSection.Value = Children.TakeWhile(section => diff(section) <= 0).LastOrDefault() ?? Children.FirstOrDefault();
|
||||||
|
|
||||||
SelectedSection.Value = Children.TakeWhile(section => diff(section) <= 0).LastOrDefault()
|
|
||||||
?? Children.FirstOrDefault();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user