1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 12:43:06 +08:00
osu-lazer/osu.Game/Overlays/Settings/SettingsSection.cs

95 lines
3.0 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
2018-11-20 15:51:59 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics.Sprites;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Settings
{
public abstract class SettingsSection : Container, IHasFilterableChildren
{
protected FillFlowContainer FlowContent;
protected override Container<Drawable> Content => FlowContent;
public abstract IconUsage Icon { get; }
2018-04-13 17:19:50 +08:00
public abstract string Header { get; }
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
2019-11-21 05:26:39 +08:00
public virtual IEnumerable<string> FilterTerms => new[] { Header };
2018-04-13 17:19:50 +08:00
private const int header_size = 26;
private const int header_margin = 25;
private const int border_size = 2;
public bool MatchingFilter
{
set => this.FadeTo(value ? 1 : 0);
2018-04-13 17:19:50 +08:00
}
2019-03-28 23:29:07 +08:00
public bool FilteringActive { get; set; }
2018-04-13 17:19:50 +08:00
protected SettingsSection()
{
Margin = new MarginPadding { Top = 20 };
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
FlowContent = new FillFlowContainer
{
Margin = new MarginPadding
{
Top = header_size + header_margin
},
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 30),
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AddRangeInternal(new Drawable[]
{
new Box
{
Colour = new Color4(0, 0, 0, 255),
RelativeSizeAxes = Axes.X,
Height = border_size,
},
new Container
{
Padding = new MarginPadding
{
Top = 20 + border_size,
Bottom = 10,
},
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
2018-04-13 17:19:50 +08:00
{
new OsuSpriteText
{
Font = OsuFont.GetFont(size: header_size),
2018-04-13 17:19:50 +08:00
Text = Header,
Colour = colours.Yellow,
Margin = new MarginPadding { Left = SettingsPanel.CONTENT_MARGINS, Right = SettingsPanel.CONTENT_MARGINS }
2018-04-13 17:19:50 +08:00
},
FlowContent
}
},
});
}
}
}