From e390d70b707c97909404b8f596dc2908a66605b4 Mon Sep 17 00:00:00 2001 From: Fukashi13 <48766178+Fukashi13@users.noreply.github.com> Date: Thu, 14 May 2020 14:33:12 +0200 Subject: [PATCH 1/4] bestMatch changes on entering section with screen top border --- osu.Game/Graphics/Containers/SectionsContainer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index a3125614aa..8b866c8d21 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -189,15 +189,15 @@ 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; + T bestMatch = Children.FirstOrDefault(); + float minDiff = float.MinValue; float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0; foreach (var section in Children) { - float diff = Math.Abs(scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset); + float diff = scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset; - if (diff < minDiff) + if ((minDiff < diff) & (diff < 0)) { minDiff = diff; bestMatch = section; From 097fcfd9ad35832a190a9bee0f7bfd14f33aa146 Mon Sep 17 00:00:00 2001 From: Fukashi13 <48766178+Fukashi13@users.noreply.github.com> Date: Fri, 15 May 2020 00:06:58 +0200 Subject: [PATCH 2/4] Update osu.Game/Graphics/Containers/SectionsContainer.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartłomiej Dach --- osu.Game/Graphics/Containers/SectionsContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 8b866c8d21..5192a7ddea 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -197,7 +197,7 @@ namespace osu.Game.Graphics.Containers { float diff = scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset; - if ((minDiff < diff) & (diff < 0)) + if (minDiff < diff && diff < 0) { minDiff = diff; bestMatch = section; From c55eb8335135359ee20ee7a3900392b35981b6da Mon Sep 17 00:00:00 2001 From: Fukashi13 <48766178+Fukashi13@users.noreply.github.com> Date: Fri, 15 May 2020 14:03:45 +0200 Subject: [PATCH 3/4] last section gets selected when scrolling to bottom of list --- .../Graphics/Containers/SectionsContainer.cs | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 5192a7ddea..b9ed9b90fc 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -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 = Children.FirstOrDefault(); - float minDiff = float.MinValue; float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0; + Func diff = section => scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset; - foreach (var section in Children) + if (scrollContainer.IsScrolledToEnd()) { - float diff = scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset; - - if (minDiff < diff && diff < 0) - { - 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; } } From 6416ace70d07f8a5d67bfd469ee93e73f1af5266 Mon Sep 17 00:00:00 2001 From: Fukashi13 <48766178+Fukashi13@users.noreply.github.com> Date: Fri, 15 May 2020 14:31:05 +0200 Subject: [PATCH 4/4] fixed indent --- osu.Game/Graphics/Containers/SectionsContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index b9ed9b90fc..d739f56828 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -199,7 +199,7 @@ namespace osu.Game.Graphics.Containers else { SelectedSection.Value = Children.TakeWhile(section => diff(section) <= 0).LastOrDefault() - ?? Children.FirstOrDefault(); + ?? Children.FirstOrDefault(); } } }