2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 04:59:30 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-09-30 09:45:27 +00:00
|
|
|
|
|
2016-10-13 14:57:05 +00:00
|
|
|
|
using System;
|
2017-03-04 18:42:37 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-09-30 09:45:27 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-12-01 05:22:29 +00:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2016-09-30 09:45:27 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2016-12-01 05:22:29 +00:00
|
|
|
|
using osu.Framework.Input;
|
2016-10-13 14:57:05 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2016-12-01 05:22:29 +00:00
|
|
|
|
using OpenTK;
|
2017-06-20 05:54:23 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2016-09-30 09:45:27 +00:00
|
|
|
|
|
2016-12-01 05:22:29 +00:00
|
|
|
|
namespace osu.Game.Overlays.Toolbar
|
2016-09-30 09:45:27 +00:00
|
|
|
|
{
|
2016-12-01 07:05:54 +00:00
|
|
|
|
public class Toolbar : OverlayContainer
|
2016-09-30 09:45:27 +00:00
|
|
|
|
{
|
2017-02-08 11:14:17 +00:00
|
|
|
|
public const float HEIGHT = 40;
|
2017-02-10 07:26:43 +00:00
|
|
|
|
public const float TOOLTIP_HEIGHT = 30;
|
2016-10-04 08:15:03 +00:00
|
|
|
|
|
|
|
|
|
public Action OnHome;
|
|
|
|
|
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly ToolbarUserArea userArea;
|
2016-09-30 09:45:27 +00:00
|
|
|
|
|
2017-04-18 06:34:53 +00:00
|
|
|
|
protected override bool BlockPassThroughMouse => false;
|
2017-02-09 03:46:53 +00:00
|
|
|
|
|
2017-03-09 06:52:40 +00:00
|
|
|
|
private const double transition_time = 500;
|
2016-11-30 04:50:30 +00:00
|
|
|
|
|
|
|
|
|
private const float alpha_hovering = 0.8f;
|
|
|
|
|
private const float alpha_normal = 0.6f;
|
|
|
|
|
|
2016-11-01 14:24:14 +00:00
|
|
|
|
public Toolbar()
|
2016-09-30 09:45:27 +00:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-01-30 14:24:30 +00:00
|
|
|
|
new ToolbarBackground(),
|
2017-03-01 18:33:01 +00:00
|
|
|
|
new FillFlowContainer
|
2016-10-03 11:39:32 +00:00
|
|
|
|
{
|
2017-03-04 10:00:17 +00:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2016-10-03 11:39:32 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2016-10-22 09:05:46 +00:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
2016-10-04 10:41:18 +00:00
|
|
|
|
Children = new Drawable[]
|
2016-10-03 11:39:32 +00:00
|
|
|
|
{
|
2016-12-02 09:43:01 +00:00
|
|
|
|
new ToolbarSettingsButton(),
|
2017-03-07 01:59:19 +00:00
|
|
|
|
new ToolbarHomeButton
|
2016-10-04 08:15:03 +00:00
|
|
|
|
{
|
2016-11-04 03:27:43 +00:00
|
|
|
|
Action = () => OnHome?.Invoke()
|
2016-10-04 08:15:03 +00:00
|
|
|
|
},
|
2017-04-21 07:11:24 +00:00
|
|
|
|
new ToolbarModeSelector()
|
2016-10-03 11:39:32 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2017-03-16 08:38:36 +00:00
|
|
|
|
new FillFlowContainer
|
2016-10-03 11:39:32 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
2017-03-04 10:00:17 +00:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2016-10-03 11:39:32 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2016-10-22 09:05:46 +00:00
|
|
|
|
AutoSizeAxes = Axes.X,
|
2017-01-31 07:59:38 +00:00
|
|
|
|
Children = new Drawable[]
|
2016-10-03 11:39:32 +00:00
|
|
|
|
{
|
2017-08-24 11:18:47 +00:00
|
|
|
|
new ToolbarDirectButton(),
|
2017-04-19 10:54:03 +00:00
|
|
|
|
new ToolbarChatButton(),
|
2017-08-16 15:00:30 +00:00
|
|
|
|
new ToolbarSocialButton(),
|
2016-12-02 09:43:01 +00:00
|
|
|
|
new ToolbarMusicButton(),
|
2017-12-30 18:47:50 +00:00
|
|
|
|
//new ToolbarButton
|
|
|
|
|
//{
|
|
|
|
|
// Icon = FontAwesome.fa_search
|
|
|
|
|
//},
|
2017-02-08 10:53:50 +00:00
|
|
|
|
userArea = new ToolbarUserArea(),
|
2017-02-10 07:26:43 +00:00
|
|
|
|
new ToolbarNotificationButton(),
|
2016-10-03 11:39:32 +00:00
|
|
|
|
}
|
2016-09-30 09:45:27 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2016-11-01 14:24:14 +00:00
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2017-01-30 13:00:23 +00:00
|
|
|
|
Size = new Vector2(1, HEIGHT);
|
2016-11-01 14:24:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-30 14:24:30 +00:00
|
|
|
|
public class ToolbarBackground : Container
|
|
|
|
|
{
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly Box solidBackground;
|
|
|
|
|
private readonly Box gradientBackground;
|
2017-01-30 14:24:30 +00:00
|
|
|
|
|
|
|
|
|
public ToolbarBackground()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
solidBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = OsuColour.Gray(0.1f),
|
|
|
|
|
Alpha = alpha_normal,
|
|
|
|
|
},
|
|
|
|
|
gradientBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Height = 90,
|
2017-07-23 05:30:50 +00:00
|
|
|
|
Colour = ColourInfo.GradientVertical(
|
2017-01-30 14:24:30 +00:00
|
|
|
|
OsuColour.Gray(0.1f).Opacity(0.5f), OsuColour.Gray(0.1f).Opacity(0)),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
2017-07-22 18:50:25 +00:00
|
|
|
|
solidBackground.FadeTo(alpha_hovering, transition_time, Easing.OutQuint);
|
|
|
|
|
gradientBackground.FadeIn(transition_time, Easing.OutQuint);
|
2017-01-30 14:24:30 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
2017-07-22 18:50:25 +00:00
|
|
|
|
solidBackground.FadeTo(alpha_normal, transition_time, Easing.OutQuint);
|
|
|
|
|
gradientBackground.FadeOut(transition_time, Easing.OutQuint);
|
2017-01-30 14:24:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-30 13:53:50 +00:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
2017-07-22 18:50:25 +00:00
|
|
|
|
this.MoveToY(0, transition_time, Easing.OutQuint);
|
|
|
|
|
this.FadeIn(transition_time / 2, Easing.OutQuint);
|
2017-01-30 13:53:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2017-02-08 10:53:50 +00:00
|
|
|
|
userArea?.LoginOverlay.Hide();
|
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
this.MoveToY(-DrawSize.Y, transition_time, Easing.OutQuint);
|
2017-07-14 16:18:12 +00:00
|
|
|
|
this.FadeOut(transition_time);
|
2017-01-30 13:53:50 +00:00
|
|
|
|
}
|
2016-09-30 09:45:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|