osu/osu.Game/Overlays/OverlayHeader.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
3.5 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.
2020-01-15 19:41:22 +00:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
2019-12-31 15:12:03 +00:00
public abstract partial class OverlayHeader : Container
{
public OverlayTitle Title { get; }
private float contentSidePadding;
/// <summary>
/// Horizontal padding of the header content.
/// </summary>
protected float ContentSidePadding
{
get => contentSidePadding;
set
{
contentSidePadding = value;
content.Padding = new MarginPadding
{
Horizontal = value
};
}
}
2020-04-16 09:07:38 +00:00
private readonly Box titleBackground;
private readonly Container content;
2020-01-20 05:52:03 +00:00
protected readonly FillFlowContainer HeaderInfo;
protected OverlayHeader()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Add(new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new[]
{
HeaderInfo = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Depth = -float.MaxValue,
2020-01-27 13:45:10 +00:00
Children = new[]
{
CreateBackground(),
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
titleBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Gray,
},
content = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = Title = CreateTitle().With(title =>
{
title.Anchor = Anchor.CentreLeft;
title.Origin = Anchor.CentreLeft;
}),
}
}
},
}
},
CreateContent()
}
});
ContentSidePadding = WaveOverlayContainer.HORIZONTAL_PADDING;
}
2020-01-15 19:41:22 +00:00
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
2020-01-15 19:41:22 +00:00
{
titleBackground.Colour = colourProvider.Dark5;
2020-01-15 19:41:22 +00:00
}
protected virtual Drawable CreateContent() => Empty();
protected virtual Drawable CreateBackground() => Empty();
protected abstract OverlayTitle CreateTitle();
}
}