From af03d883f168fbc3244fe7f51a4ad24307dbc4bb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 Nov 2017 19:01:30 +0900 Subject: [PATCH] Ensure overlay containers scroll to top when new information is presented --- osu.Game/Graphics/Containers/SectionsContainer.cs | 2 ++ osu.Game/Overlays/BeatmapSetOverlay.cs | 5 ++++- osu.Game/Overlays/UserProfileOverlay.cs | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 6e5c3c8183..1e2826189b 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -139,6 +139,8 @@ namespace osu.Game.Graphics.Containers public void ScrollTo(Drawable section) => scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(section) - (FixedHeader?.BoundingBox.Height ?? 0)); + public void ScrollToTop() => scrollContainer.ScrollTo(0); + private float lastKnownScroll; protected override void UpdateAfterChildren() { diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index ddd146bcb6..940ac433fc 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -30,6 +30,8 @@ namespace osu.Game.Overlays private APIAccess api; private RulesetStore rulesets; + private readonly ScrollContainer scroll; + // receive input outside our bounds so we can trigger a close event on ourselves. public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; @@ -61,7 +63,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, Colour = OsuColour.Gray(0.2f) }, - new ScrollContainer + scroll = new ScrollContainer { RelativeSizeAxes = Axes.Both, ScrollbarVisible = false, @@ -120,6 +122,7 @@ namespace osu.Game.Overlays { header.BeatmapSet = info.BeatmapSet = set; Show(); + scroll.ScrollTo(0); } } } diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index ce35f7e547..dd31a43290 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -164,6 +164,7 @@ namespace osu.Game.Overlays } Show(); + sectionsContainer.ScrollToTop(); } private void userLoadComplete(User user)