2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-12-06 09:56:20 +00:00
|
|
|
|
|
2016-11-04 23:27:41 +00:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-11-07 23:04:49 +00:00
|
|
|
|
using osu.Framework.Input;
|
2016-11-09 04:16:04 +00:00
|
|
|
|
using osu.Framework.Threading;
|
2017-02-08 11:14:17 +00:00
|
|
|
|
using osu.Game.Overlays.Toolbar;
|
2016-11-04 23:27:41 +00:00
|
|
|
|
|
2017-05-15 01:55:29 +00:00
|
|
|
|
namespace osu.Game.Overlays.Settings
|
2016-11-04 23:27:41 +00:00
|
|
|
|
{
|
2017-01-31 10:58:38 +00:00
|
|
|
|
public class Sidebar : Container
|
2016-11-04 23:27:41 +00:00
|
|
|
|
{
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly FillFlowContainer content;
|
2017-02-08 11:14:17 +00:00
|
|
|
|
internal const float DEFAULT_WIDTH = ToolbarButton.WIDTH;
|
2017-02-07 07:15:45 +00:00
|
|
|
|
internal const int EXPANDED_WIDTH = 200;
|
2016-11-08 09:33:31 +00:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
2016-11-07 23:04:49 +00:00
|
|
|
|
|
2017-01-31 10:58:38 +00:00
|
|
|
|
public Sidebar()
|
2016-11-04 23:27:41 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
2016-11-07 23:04:49 +00:00
|
|
|
|
InternalChildren = new Drawable[]
|
2016-11-04 23:27:41 +00:00
|
|
|
|
{
|
2016-11-08 11:07:28 +00:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2016-11-08 10:16:39 +00:00
|
|
|
|
new SidebarScrollContainer
|
2016-11-04 23:27:41 +00:00
|
|
|
|
{
|
2016-11-08 10:16:39 +00:00
|
|
|
|
Children = new []
|
|
|
|
|
{
|
2017-03-01 18:33:01 +00:00
|
|
|
|
content = new FillFlowContainer
|
2016-11-08 10:16:39 +00:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-03-04 10:00:17 +00:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2016-11-08 10:16:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-04 23:27:41 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-09 04:16:04 +00:00
|
|
|
|
private ScheduledDelegate expandEvent;
|
2017-04-06 08:21:18 +00:00
|
|
|
|
|
2016-11-09 04:16:04 +00:00
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
|
|
|
|
expandEvent = Scheduler.AddDelayed(() =>
|
|
|
|
|
{
|
|
|
|
|
expandEvent = null;
|
2017-02-07 07:15:45 +00:00
|
|
|
|
ResizeTo(new Vector2(EXPANDED_WIDTH, Height), 150, EasingTypes.OutQuad);
|
2016-11-09 04:16:04 +00:00
|
|
|
|
}, 750);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-04-06 08:21:18 +00:00
|
|
|
|
|
2016-11-09 04:16:04 +00:00
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
|
|
|
|
expandEvent?.Cancel();
|
2017-02-07 07:15:45 +00:00
|
|
|
|
ResizeTo(new Vector2(DEFAULT_WIDTH, Height), 150, EasingTypes.OutQuad);
|
2016-11-09 04:16:04 +00:00
|
|
|
|
base.OnHoverLost(state);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-08 10:16:39 +00:00
|
|
|
|
private class SidebarScrollContainer : ScrollContainer
|
|
|
|
|
{
|
|
|
|
|
public SidebarScrollContainer()
|
|
|
|
|
{
|
|
|
|
|
Content.Anchor = Anchor.CentreLeft;
|
|
|
|
|
Content.Origin = Anchor.CentreLeft;
|
2017-02-18 13:29:20 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2016-11-08 10:16:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-04 23:27:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|