From e5eec27e9574037e13287b11438c044d8cc1c0da Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jan 2021 14:44:47 +0900 Subject: [PATCH] Simplify selected section resolution --- osu.Game/Graphics/Containers/SectionsContainer.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 6607193cc6..cae2dd7e37 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -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 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(); } }