2016-11-05 07:27:41 +08:00
|
|
|
|
using System;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-11-09 12:16:04 +08:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
2016-11-08 07:04:49 +08:00
|
|
|
|
using osu.Framework.Input;
|
2016-11-09 12:16:04 +08:00
|
|
|
|
using osu.Framework.Threading;
|
2016-11-08 07:04:49 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2016-11-05 07:27:41 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Options
|
|
|
|
|
{
|
2016-11-08 18:17:09 +08:00
|
|
|
|
public class OptionsSidebar : Container
|
2016-11-05 07:27:41 +08:00
|
|
|
|
{
|
2016-11-08 07:04:49 +08:00
|
|
|
|
private FlowContainer content;
|
2016-11-09 12:16:04 +08:00
|
|
|
|
internal const int default_width = 60, expanded_width = 200;
|
2016-11-08 17:33:31 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
2016-11-08 07:04:49 +08:00
|
|
|
|
|
2016-11-08 18:17:09 +08:00
|
|
|
|
public OptionsSidebar()
|
2016-11-05 07:27:41 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
2016-11-08 07:04:49 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2016-11-05 07:27:41 +08:00
|
|
|
|
{
|
2016-11-08 19:07:28 +08:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2016-11-08 18:16:39 +08:00
|
|
|
|
new SidebarScrollContainer
|
2016-11-05 07:27:41 +08:00
|
|
|
|
{
|
2016-11-08 18:16:39 +08:00
|
|
|
|
Children = new []
|
|
|
|
|
{
|
|
|
|
|
content = new FlowContainer
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Direction = FlowDirection.VerticalOnly
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-05 07:27:41 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-09 12:16:04 +08:00
|
|
|
|
private ScheduledDelegate expandEvent;
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
|
|
|
|
expandEvent = Scheduler.AddDelayed(() =>
|
|
|
|
|
{
|
|
|
|
|
expandEvent = null;
|
|
|
|
|
ResizeTo(new Vector2(expanded_width, Height), 150, EasingTypes.OutQuad);
|
|
|
|
|
}, 750);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
|
|
|
|
expandEvent?.Cancel();
|
|
|
|
|
ResizeTo(new Vector2(default_width, Height), 150, EasingTypes.OutQuad);
|
|
|
|
|
base.OnHoverLost(state);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-08 18:16:39 +08:00
|
|
|
|
private class SidebarScrollContainer : ScrollContainer
|
|
|
|
|
{
|
|
|
|
|
public SidebarScrollContainer()
|
|
|
|
|
{
|
|
|
|
|
Content.Anchor = Anchor.CentreLeft;
|
|
|
|
|
Content.Origin = Anchor.CentreLeft;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-05 07:27:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|