1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 09:07:22 +08:00

78 lines
2.5 KiB
C#
Raw Normal View History

// 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 18:56:20 +09:00
2016-11-04 19:27:41 -04:00
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;
2016-11-08 23:16:04 -05:00
using osu.Framework.Threading;
using osu.Game.Overlays.Toolbar;
2016-11-04 19:27:41 -04:00
namespace osu.Game.Overlays.Settings
2016-11-04 19:27:41 -04:00
{
2017-01-31 19:58:38 +09:00
public class Sidebar : Container
2016-11-04 19:27:41 -04:00
{
private readonly FillFlowContainer content;
internal const float DEFAULT_WIDTH = ToolbarButton.WIDTH;
2017-02-07 16:15:45 +09:00
internal const int EXPANDED_WIDTH = 200;
2016-11-08 18:33:31 +09:00
protected override Container<Drawable> Content => content;
2017-01-31 19:58:38 +09:00
public Sidebar()
2016-11-04 19:27:41 -04:00
{
RelativeSizeAxes = Axes.Y;
InternalChildren = new Drawable[]
2016-11-04 19:27:41 -04:00
{
new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
},
2016-11-08 19:16:39 +09:00
new SidebarScrollContainer
2016-11-04 19:27:41 -04:00
{
2016-11-08 19:16:39 +09:00
Children = new []
{
2017-03-01 19:33:01 +01:00
content = new FillFlowContainer
2016-11-08 19:16:39 +09:00
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
2017-03-04 11:00:17 +01:00
Direction = FillDirection.Vertical,
2016-11-08 19:16:39 +09:00
}
}
2016-11-04 19:27:41 -04:00
},
};
}
2016-11-08 23:16:04 -05:00
private ScheduledDelegate expandEvent;
2016-11-08 23:16:04 -05:00
protected override bool OnHover(InputState state)
{
expandEvent = Scheduler.AddDelayed(() =>
{
expandEvent = null;
2017-02-07 16:15:45 +09:00
ResizeTo(new Vector2(EXPANDED_WIDTH, Height), 150, EasingTypes.OutQuad);
2016-11-08 23:16:04 -05:00
}, 750);
return true;
}
2016-11-08 23:16:04 -05:00
protected override void OnHoverLost(InputState state)
{
expandEvent?.Cancel();
2017-02-07 16:15:45 +09:00
ResizeTo(new Vector2(DEFAULT_WIDTH, Height), 150, EasingTypes.OutQuad);
2016-11-08 23:16:04 -05:00
base.OnHoverLost(state);
}
2016-11-08 19:16:39 +09:00
private class SidebarScrollContainer : ScrollContainer
{
public SidebarScrollContainer()
{
Content.Anchor = Anchor.CentreLeft;
Content.Origin = Anchor.CentreLeft;
RelativeSizeAxes = Axes.Both;
2016-11-08 19:16:39 +09:00
}
}
2016-11-04 19:27:41 -04:00
}
}