2019-05-20 09:02:13 +00:00
|
|
|
|
// 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;
|
2019-05-20 09:02:13 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-12-26 19:09:06 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osuTK.Graphics;
|
2019-05-20 09:02:13 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2019-12-31 15:12:03 +00:00
|
|
|
|
public abstract partial class OverlayHeader : Container
|
2019-05-20 09:02:13 +00:00
|
|
|
|
{
|
2020-09-03 06:46:56 +00:00
|
|
|
|
public OverlayTitle Title { get; }
|
|
|
|
|
|
2020-07-21 17:02:22 +00:00
|
|
|
|
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
|
|
|
|
|
2019-12-26 19:09:06 +00:00
|
|
|
|
private readonly Box titleBackground;
|
2020-07-21 17:02:22 +00:00
|
|
|
|
private readonly Container content;
|
2019-12-26 19:09:06 +00:00
|
|
|
|
|
2020-01-20 05:52:03 +00:00
|
|
|
|
protected readonly FillFlowContainer HeaderInfo;
|
2019-12-26 19:09:06 +00:00
|
|
|
|
|
2020-01-24 09:33:34 +00:00
|
|
|
|
protected OverlayHeader()
|
2019-05-20 09:02:13 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
2019-12-27 04:15:55 +00:00
|
|
|
|
Add(new FillFlowContainer
|
2019-05-20 09:02:13 +00:00
|
|
|
|
{
|
2019-12-26 19:09:06 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
2019-12-27 04:15:55 +00:00
|
|
|
|
Children = new[]
|
2019-05-20 09:02:13 +00:00
|
|
|
|
{
|
2020-01-03 20:22:19 +00:00
|
|
|
|
HeaderInfo = new FillFlowContainer
|
2019-12-26 19:09:06 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2020-01-03 20:22:19 +00:00
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Depth = -float.MaxValue,
|
2020-01-27 13:45:10 +00:00
|
|
|
|
Children = new[]
|
2019-12-26 19:09:06 +00:00
|
|
|
|
{
|
2020-01-27 12:36:19 +00:00
|
|
|
|
CreateBackground(),
|
2020-01-03 20:22:19 +00:00
|
|
|
|
new Container
|
2019-12-26 19:09:06 +00:00
|
|
|
|
{
|
2020-01-03 20:22:19 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
2019-12-26 19:09:06 +00:00
|
|
|
|
{
|
2020-01-03 20:22:19 +00:00
|
|
|
|
titleBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Gray,
|
|
|
|
|
},
|
2020-07-21 17:02:22 +00:00
|
|
|
|
content = new Container
|
2020-01-03 20:22:19 +00:00
|
|
|
|
{
|
2020-02-03 08:09:46 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2023-01-13 20:50:12 +00:00
|
|
|
|
Child = Title = CreateTitle().With(title =>
|
2020-02-03 08:09:46 +00:00
|
|
|
|
{
|
2023-01-13 20:50:12 +00:00
|
|
|
|
title.Anchor = Anchor.CentreLeft;
|
|
|
|
|
title.Origin = Anchor.CentreLeft;
|
|
|
|
|
}),
|
2020-02-03 08:09:46 +00:00
|
|
|
|
}
|
2020-01-03 20:22:19 +00:00
|
|
|
|
}
|
2019-12-26 19:09:06 +00:00
|
|
|
|
},
|
2019-05-20 09:02:13 +00:00
|
|
|
|
}
|
2019-12-27 04:15:55 +00:00
|
|
|
|
},
|
|
|
|
|
CreateContent()
|
2019-12-26 18:21:15 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2020-07-21 17:02:22 +00:00
|
|
|
|
|
2023-04-03 00:12:27 +00:00
|
|
|
|
ContentSidePadding = WaveOverlayContainer.HORIZONTAL_PADDING;
|
2019-05-20 09:02:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-15 19:41:22 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
2020-01-24 09:33:34 +00:00
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2020-01-15 19:41:22 +00:00
|
|
|
|
{
|
2020-01-24 09:33:34 +00:00
|
|
|
|
titleBackground.Colour = colourProvider.Dark5;
|
2020-01-15 19:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-03 08:09:46 +00:00
|
|
|
|
protected virtual Drawable CreateContent() => Empty();
|
|
|
|
|
|
|
|
|
|
protected virtual Drawable CreateBackground() => Empty();
|
2019-05-20 09:02:13 +00:00
|
|
|
|
|
2020-03-24 21:08:20 +00:00
|
|
|
|
protected abstract OverlayTitle CreateTitle();
|
2019-05-20 09:02:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|