From ecc222c0438b55d062a6853d8efc20a5b91f171e Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 20 May 2017 07:20:46 +0800 Subject: [PATCH] Allow custom SectionsContainer. --- .../Graphics/Containers/SectionsContainer.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 65bb318008..d46292cd9a 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -16,7 +16,8 @@ namespace osu.Game.Graphics.Containers public class SectionsContainer : Container { private Drawable expandableHeader, fixedHeader; - private ScrollContainer scrollContainer; + private readonly ScrollContainer scrollContainer; + private readonly Container sectionsContainer; public Drawable ExpandableHeader { @@ -53,6 +54,13 @@ namespace osu.Game.Graphics.Containers public Bindable SelectedSection { get; } = new Bindable(); public void ScrollToSection(Drawable section) => scrollContainer.ScrollIntoView(section); + protected virtual Container CreateSectionsContainer() + => new FillFlowContainer + { + Direction = FillDirection.Vertical, + AutoSizeAxes = Axes.Both + }; + private List sections = new List(); public IEnumerable Sections { @@ -62,14 +70,14 @@ namespace osu.Game.Graphics.Containers if (value == sections) return; foreach (var section in sections) - scrollContainer.Remove(section); + sectionsContainer.Remove(section); sections = value.ToList(); if (sections.Count == 0) return; originalSectionMargin = sections[0].Margin; updateSectionMargin(); - scrollContainer.Add(sections); + sectionsContainer.Add(sections); SelectedSection.Value = sections[0]; } } @@ -87,9 +95,10 @@ namespace osu.Game.Graphics.Containers public SectionsContainer() { - Add(scrollContainer = new ScrollContainer + Add(scrollContainer = new ScrollContainer() { - RelativeSizeAxes = Axes.Both + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { sectionsContainer = CreateSectionsContainer() } }); }