Use OverlayScrollContainer for overlays

This commit is contained in:
Andrei Zavatski
2020-04-13 12:23:28 +03:00
parent 9dfca4a374
commit b741e359cd
8 changed files with 27 additions and 18 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -19,7 +20,7 @@ namespace osu.Game.Graphics.Containers
private Drawable expandableHeader, fixedHeader, footer, headerBackground;
private readonly OsuScrollContainer scrollContainer;
private readonly Container headerBackgroundContainer;
private readonly FlowContainer<T> scrollContentContainer;
private FlowContainer<T> scrollContentContainer;
protected override Container<T> Content => scrollContentContainer;
@ -125,20 +126,26 @@ namespace osu.Game.Graphics.Containers
public SectionsContainer()
{
AddInternal(scrollContainer = new OsuScrollContainer
AddRangeInternal(new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Masking = true,
ScrollbarVisible = false,
Children = new Drawable[] { scrollContentContainer = CreateScrollContentContainer() }
});
AddInternal(headerBackgroundContainer = new Container
{
RelativeSizeAxes = Axes.X
scrollContainer = CreateScrollContainer().With(s =>
{
s.RelativeSizeAxes = Axes.Both;
s.Masking = true;
s.ScrollbarVisible = false;
s.Children = new Drawable[] { scrollContentContainer = CreateScrollContentContainer() };
}),
headerBackgroundContainer = new Container
{
RelativeSizeAxes = Axes.X
}
});
originalSectionsMargin = scrollContentContainer.Margin;
}
[NotNull]
protected virtual OsuScrollContainer CreateScrollContainer() => new OsuScrollContainer();
public void ScrollTo(Drawable section) => scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(section) - (FixedHeader?.BoundingBox.Height ?? 0));
public void ScrollToTop() => scrollContainer.ScrollTo(0);