1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 16:07:24 +08:00
osu-lazer/osu.Game/Overlays/Options/OptionsSidebar.cs

104 lines
3.1 KiB
C#
Raw Normal View History

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;
using osu.Framework.Input;
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
{
private FlowContainer content;
2016-11-08 17:33:31 +08:00
protected override Container<Drawable> Content => content;
2016-11-08 18:17:09 +08:00
public OptionsSidebar()
2016-11-05 07:27:41 +08:00
{
RelativeSizeAxes = Axes.Y;
InternalChildren = new Drawable[]
2016-11-05 07:27:41 +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-08 18:16:39 +08:00
private class SidebarScrollContainer : ScrollContainer
{
public SidebarScrollContainer()
{
Content.Anchor = Anchor.CentreLeft;
Content.Origin = Anchor.CentreLeft;
}
}
public class SidebarButton : Container
2016-11-05 07:27:41 +08:00
{
private TextAwesome drawableIcon;
private Box backgroundBox;
public Action Action;
2016-11-08 18:16:39 +08:00
public FontAwesome Icon
{
get { return drawableIcon.Icon; }
set { drawableIcon.Icon = value; }
}
2016-11-08 18:16:39 +08:00
public SidebarButton()
2016-11-05 07:27:41 +08:00
{
Size = new Vector2(60);
Children = new Drawable[]
{
backgroundBox = new Box
{
RelativeSizeAxes = Axes.Both,
BlendingMode = BlendingMode.Additive,
Colour = new Color4(60, 60, 60, 255),
Alpha = 0,
},
drawableIcon = new TextAwesome
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
};
2016-11-05 07:27:41 +08:00
}
2016-11-08 18:16:39 +08:00
protected override bool OnClick(InputState state)
2016-11-05 07:27:41 +08:00
{
Action?.Invoke();
backgroundBox.FlashColour(Color4.White, 400);
return true;
2016-11-05 07:27:41 +08:00
}
2016-11-08 18:16:39 +08:00
protected override bool OnHover(InputState state)
2016-11-05 07:27:41 +08:00
{
backgroundBox.FadeTo(0.4f, 200);
return true;
}
2016-11-08 18:16:39 +08:00
protected override void OnHoverLost(InputState state)
{
backgroundBox.FadeTo(0, 200);
2016-11-05 07:27:41 +08:00
}
}
}
}