2022-04-20 06:05:07 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-04-21 07:15:10 +00:00
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
using osu.Game.Graphics;
|
2022-04-20 06:05:07 +00:00
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A sheared overlay which provides a header and footer and basic animations.
|
|
|
|
/// Exposes <see cref="TopLevelContent"/>, <see cref="MainAreaContent"/> and <see cref="Footer"/> as valid targets for content.
|
|
|
|
/// </summary>
|
|
|
|
public abstract class ShearedOverlayContainer : OsuFocusedOverlayContainer
|
|
|
|
{
|
2022-04-20 07:28:52 +00:00
|
|
|
protected const float PADDING = 14;
|
|
|
|
|
2022-04-20 07:30:58 +00:00
|
|
|
public const float SHEAR = 0.2f;
|
|
|
|
|
2022-04-20 06:05:07 +00:00
|
|
|
[Cached]
|
|
|
|
protected readonly OverlayColourProvider ColourProvider;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The overlay's header.
|
|
|
|
/// </summary>
|
2022-04-20 06:50:57 +00:00
|
|
|
protected ShearedOverlayHeader Header { get; private set; }
|
2022-04-20 06:05:07 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The overlay's footer.
|
|
|
|
/// </summary>
|
|
|
|
protected Container Footer { get; private set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A container containing all content, including the header and footer.
|
|
|
|
/// May be used for overlay-wide animations.
|
|
|
|
/// </summary>
|
|
|
|
protected Container TopLevelContent { get; private set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A container for content that is to be displayed between the header and footer.
|
|
|
|
/// </summary>
|
|
|
|
protected Container MainAreaContent { get; private set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A container for content that is to be displayed inside the footer.
|
|
|
|
/// </summary>
|
|
|
|
protected Container FooterContent { get; private set; }
|
|
|
|
|
|
|
|
protected override bool StartHidden => true;
|
|
|
|
|
|
|
|
protected override bool BlockNonPositionalInput => true;
|
|
|
|
|
2022-05-04 20:17:40 +00:00
|
|
|
protected ShearedOverlayContainer(OverlayColourScheme colourScheme)
|
2022-04-20 06:05:07 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
2022-05-04 20:17:40 +00:00
|
|
|
ColourProvider = new OverlayColourProvider(colourScheme);
|
2022-04-20 06:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
const float footer_height = 50;
|
|
|
|
|
|
|
|
Child = TopLevelContent = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-04-20 06:50:57 +00:00
|
|
|
Header = new ShearedOverlayHeader
|
2022-04-20 06:05:07 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Depth = float.MinValue,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Close = Hide
|
|
|
|
},
|
|
|
|
MainAreaContent = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding
|
|
|
|
{
|
2022-04-20 06:50:57 +00:00
|
|
|
Top = ShearedOverlayHeader.HEIGHT,
|
2022-04-20 07:28:52 +00:00
|
|
|
Bottom = footer_height + PADDING,
|
2022-04-20 06:05:07 +00:00
|
|
|
}
|
|
|
|
},
|
2022-04-21 07:15:10 +00:00
|
|
|
Footer = new InputBlockingContainer
|
2022-04-20 06:05:07 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Depth = float.MinValue,
|
|
|
|
Height = footer_height,
|
2022-04-20 07:28:52 +00:00
|
|
|
Margin = new MarginPadding { Top = PADDING },
|
2022-04-20 06:05:07 +00:00
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = ColourProvider.Background5
|
|
|
|
},
|
|
|
|
FooterContent = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-21 07:15:10 +00:00
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
|
|
|
if (State.Value == Visibility.Visible)
|
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return base.OnClick(e);
|
|
|
|
}
|
|
|
|
|
2022-04-20 06:05:07 +00:00
|
|
|
protected override void PopIn()
|
|
|
|
{
|
|
|
|
const double fade_in_duration = 400;
|
|
|
|
|
|
|
|
base.PopIn();
|
|
|
|
this.FadeIn(fade_in_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
Header.MoveToY(0, fade_in_duration, Easing.OutQuint);
|
|
|
|
Footer.MoveToY(0, fade_in_duration, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
{
|
|
|
|
const double fade_out_duration = 500;
|
|
|
|
|
|
|
|
base.PopOut();
|
|
|
|
this.FadeOut(fade_out_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
Header.MoveToY(-Header.DrawHeight, fade_out_duration, Easing.OutQuint);
|
|
|
|
Footer.MoveToY(Footer.DrawHeight, fade_out_duration, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|