From e923da1998fd792aeb85e7c89403634a7667e32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sat, 12 Nov 2016 12:30:12 +0100 Subject: [PATCH 1/3] Fix lastKnownScroll never being written to. --- osu.Game/Overlays/OptionsOverlay.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 3ad894e102..d29580adfa 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -67,8 +67,6 @@ namespace osu.Game.Overlays }, scrollContainer = new ScrollContainer { - ScrollbarOverlapsContent = false, - ScrollDraggerAnchor = Anchor.TopLeft, RelativeSizeAxes = Axes.Y, Width = width, Margin = new MarginPadding { Left = sidebar_width }, @@ -131,8 +129,11 @@ namespace osu.Game.Overlays protected override void Update() { base.Update(); + if (scrollContainer.Current != lastKnownScroll) { + lastKnownScroll = scrollContainer.Current; + for (int i = sections.Length - 1; i >= 0; i--) { var section = sections[i]; From 1c47773e0dac8fbd7f1d855fc59f88c03a044059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sat, 12 Nov 2016 13:08:34 +0100 Subject: [PATCH 2/3] Make sidebar behaviour feel a bit nicer. --- osu.Game/Overlays/OptionsOverlay.cs | 37 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index d29580adfa..6f79fedf88 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -22,6 +22,7 @@ using osu.Game.Overlays.Options.General; using osu.Game.Overlays.Options.Graphics; using osu.Game.Overlays.Options.Input; using osu.Game.Overlays.Options.Online; +using System; namespace osu.Game.Overlays { @@ -112,8 +113,7 @@ namespace osu.Game.Overlays { Selected = sections[0] == section, Section = section, - Action = () => scrollContainer.ScrollTo( - scrollContainer.GetChildYInContent(section) - scrollContainer.DrawSize.Y / 2), + Action = () => scrollContainer.ScrollIntoView(section), } ).ToArray() } @@ -130,26 +130,31 @@ namespace osu.Game.Overlays { base.Update(); - if (scrollContainer.Current != lastKnownScroll) + float currentScroll = scrollContainer.Current; + if (currentScroll != lastKnownScroll) { - lastKnownScroll = scrollContainer.Current; + lastKnownScroll = currentScroll; - for (int i = sections.Length - 1; i >= 0; i--) + OptionsSection bestCandidate = null; + float bestDistance = float.MaxValue; + + foreach (OptionsSection section in sections) { - var section = sections[i]; - float y = scrollContainer.GetChildYInContent(section) - scrollContainer.Current; - if (y <= scrollContainer.DrawSize.Y / 2 + 25) + float distance = Math.Abs(scrollContainer.GetChildYInContent(section) - currentScroll); + if (distance < bestDistance) { - var previous = sidebarButtons.SingleOrDefault(sb => sb.Selected); - var next = sidebarButtons.SingleOrDefault(sb => sb.Section == section); - if (next != null) - { - previous.Selected = false; - next.Selected = true; - } - break; + bestDistance = distance; + bestCandidate = section; } } + + var previous = sidebarButtons.SingleOrDefault(sb => sb.Selected); + var next = sidebarButtons.SingleOrDefault(sb => sb.Section == bestCandidate); + if (next != null) + { + previous.Selected = false; + next.Selected = true; + } } } From 6355c8bd45734dcf85a543104f004157514de7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sat, 12 Nov 2016 13:10:53 +0100 Subject: [PATCH 3/3] Hide scrolldragger in options. --- osu.Game/Overlays/OptionsOverlay.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 6f79fedf88..4066687bdf 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -68,6 +68,7 @@ namespace osu.Game.Overlays }, scrollContainer = new ScrollContainer { + ScrollDraggerVisible = false, RelativeSizeAxes = Axes.Y, Width = width, Margin = new MarginPadding { Left = sidebar_width },