1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00
osu-lazer/osu.Game/Overlays/OverlayHeader.cs
Andrei Zavatski 647c83e6c8 Add ability to not create content for headers
Rather than creating an empty container
2019-12-26 21:21:15 +03:00

75 lines
2.6 KiB
C#

// 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.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays
{
public abstract class OverlayHeader : Container
{
protected readonly OverlayHeaderTabControl TabControl;
private const float cover_height = 150;
private const float cover_info_height = 75;
protected OverlayHeader()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddRange(new[]
{
new Container
{
RelativeSizeAxes = Axes.X,
Height = cover_height,
Masking = true,
Child = CreateBackground()
},
new Container
{
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN },
Y = cover_height,
Height = cover_info_height,
RelativeSizeAxes = Axes.X,
Anchor = Anchor.TopLeft,
Origin = Anchor.BottomLeft,
Depth = -float.MaxValue,
Children = new Drawable[]
{
CreateTitle().With(t => t.X = -ScreenTitle.ICON_WIDTH),
TabControl = new OverlayHeaderTabControl
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = cover_info_height - 30,
Margin = new MarginPadding { Left = -UserProfileOverlay.CONTENT_X_MARGIN },
Padding = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }
}
}
}
});
if (CreateContent != null)
{
Add(new Container
{
Margin = new MarginPadding { Top = cover_height },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = CreateContent
});
};
}
protected abstract Drawable CreateBackground();
protected virtual Drawable CreateContent => null;
protected abstract ScreenTitle CreateTitle();
}
}