Merge pull request #1509 from peppy/overlay-scroll-to-top

Ensure overlay containers scroll to top when new information is presented
This commit is contained in:
Dan Balasescu 2017-11-15 19:26:26 +09:00 committed by GitHub
commit 9549b85a00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -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 ScrollTo(Drawable section) => scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(section) - (FixedHeader?.BoundingBox.Height ?? 0));
public void ScrollToTop() => scrollContainer.ScrollTo(0);
private float lastKnownScroll; private float lastKnownScroll;
protected override void UpdateAfterChildren() protected override void UpdateAfterChildren()
{ {

View File

@ -30,6 +30,8 @@ namespace osu.Game.Overlays
private APIAccess api; private APIAccess api;
private RulesetStore rulesets; private RulesetStore rulesets;
private readonly ScrollContainer scroll;
// receive input outside our bounds so we can trigger a close event on ourselves. // receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
@ -61,7 +63,7 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f) Colour = OsuColour.Gray(0.2f)
}, },
new ScrollContainer scroll = new ScrollContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false, ScrollbarVisible = false,
@ -120,6 +122,7 @@ namespace osu.Game.Overlays
{ {
header.BeatmapSet = info.BeatmapSet = set; header.BeatmapSet = info.BeatmapSet = set;
Show(); Show();
scroll.ScrollTo(0);
} }
} }
} }

View File

@ -164,6 +164,7 @@ namespace osu.Game.Overlays
} }
Show(); Show();
sectionsContainer.ScrollToTop();
} }
private void userLoadComplete(User user) private void userLoadComplete(User user)