Add drop shadows to main menu buttons.

This commit is contained in:
Dean Herbert
2016-11-30 14:38:45 +09:00
parent d65a275e32
commit 5101297f53
3 changed files with 33 additions and 3 deletions

View File

@ -2,7 +2,10 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.GameModes.Testing; using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Sprites;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using OpenTK.Graphics;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
@ -15,6 +18,11 @@ namespace osu.Desktop.VisualTests.Tests
{ {
base.Reset(); base.Reset();
Add(new Box
{
ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke),
RelativeSizeAxes = Framework.Graphics.Axes.Both,
});
Add(new ButtonSystem()); Add(new ButtonSystem());
} }
} }

View File

@ -19,7 +19,7 @@ namespace osu.Game.Screens.Menu
public class Button : Container, IStateful<ButtonState> public class Button : Container, IStateful<ButtonState>
{ {
private Container iconText; private Container iconText;
private Box box; private Container box;
private Color4 colour; private Color4 colour;
private TextAwesome icon; private TextAwesome icon;
private string internalName; private string internalName;
@ -51,15 +51,31 @@ namespace osu.Game.Screens.Menu
Children = new Drawable[] Children = new Drawable[]
{ {
box = new Box box = new Container
{ {
Masking = true,
EdgeEffect = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
Colour = new Color4(0, 0, 0, 0.2f),
Roundness = 5,
Radius = 8,
},
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Colour = colour, Colour = colour,
Scale = new Vector2(0, 1), Scale = new Vector2(0, 1),
Size = boxSize, Size = boxSize,
Shear = new Vector2(ButtonSystem.wedge_width / boxSize.Y, 0), Shear = new Vector2(ButtonSystem.wedge_width / boxSize.Y, 0),
Children = new Drawable[]
{
new Box
{
EdgeSmoothness = new Vector2(2, 0), EdgeSmoothness = new Vector2(2, 0),
RelativeSizeAxes = Axes.Both,
},
}
}, },
iconText = new Container iconText = new Container
{ {

View File

@ -1,6 +1,8 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using OpenTK; using OpenTK;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Screens.Menu namespace osu.Game.Screens.Menu
{ {
@ -15,6 +17,10 @@ namespace osu.Game.Screens.Menu
/// </summary> /// </summary>
public Drawable CentreTarget; public Drawable CentreTarget;
protected override IComparer<Drawable> DepthComparer => new ReverseDepthComparer();
protected override IEnumerable<Drawable> SortedChildren => base.SortedChildren.Reverse();
public override Anchor Origin => Anchor.Custom; public override Anchor Origin => Anchor.Custom;
public override Vector2 OriginPosition public override Vector2 OriginPosition