mirror of
https://github.com/osukey/osukey.git
synced 2025-05-04 21:27:22 +09:00
Allow custom SectionsContainer.
This commit is contained in:
parent
473441dfd4
commit
ecc222c043
@ -16,7 +16,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
public class SectionsContainer : Container
|
public class SectionsContainer : Container
|
||||||
{
|
{
|
||||||
private Drawable expandableHeader, fixedHeader;
|
private Drawable expandableHeader, fixedHeader;
|
||||||
private ScrollContainer scrollContainer;
|
private readonly ScrollContainer scrollContainer;
|
||||||
|
private readonly Container<Drawable> sectionsContainer;
|
||||||
|
|
||||||
public Drawable ExpandableHeader
|
public Drawable ExpandableHeader
|
||||||
{
|
{
|
||||||
@ -53,6 +54,13 @@ namespace osu.Game.Graphics.Containers
|
|||||||
public Bindable<Drawable> SelectedSection { get; } = new Bindable<Drawable>();
|
public Bindable<Drawable> SelectedSection { get; } = new Bindable<Drawable>();
|
||||||
public void ScrollToSection(Drawable section) => scrollContainer.ScrollIntoView(section);
|
public void ScrollToSection(Drawable section) => scrollContainer.ScrollIntoView(section);
|
||||||
|
|
||||||
|
protected virtual Container<Drawable> CreateSectionsContainer()
|
||||||
|
=> new FillFlowContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
AutoSizeAxes = Axes.Both
|
||||||
|
};
|
||||||
|
|
||||||
private List<Drawable> sections = new List<Drawable>();
|
private List<Drawable> sections = new List<Drawable>();
|
||||||
public IEnumerable<Drawable> Sections
|
public IEnumerable<Drawable> Sections
|
||||||
{
|
{
|
||||||
@ -62,14 +70,14 @@ namespace osu.Game.Graphics.Containers
|
|||||||
if (value == sections) return;
|
if (value == sections) return;
|
||||||
|
|
||||||
foreach (var section in sections)
|
foreach (var section in sections)
|
||||||
scrollContainer.Remove(section);
|
sectionsContainer.Remove(section);
|
||||||
|
|
||||||
sections = value.ToList();
|
sections = value.ToList();
|
||||||
if (sections.Count == 0) return;
|
if (sections.Count == 0) return;
|
||||||
|
|
||||||
originalSectionMargin = sections[0].Margin;
|
originalSectionMargin = sections[0].Margin;
|
||||||
updateSectionMargin();
|
updateSectionMargin();
|
||||||
scrollContainer.Add(sections);
|
sectionsContainer.Add(sections);
|
||||||
SelectedSection.Value = sections[0];
|
SelectedSection.Value = sections[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,9 +95,10 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
public SectionsContainer()
|
public SectionsContainer()
|
||||||
{
|
{
|
||||||
Add(scrollContainer = new ScrollContainer
|
Add(scrollContainer = new ScrollContainer()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[] { sectionsContainer = CreateSectionsContainer() }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user