Expose colours of IconButton

This commit is contained in:
smoogipoo
2017-10-10 17:20:23 +09:00
parent 9cb9151811
commit d7fb59ee0e

View File

@ -15,9 +15,10 @@ namespace osu.Game.Graphics.UserInterface
{ {
public class IconButton : OsuClickableContainer public class IconButton : OsuClickableContainer
{ {
private readonly SpriteIcon icon; private const float button_size = 30;
private readonly Box hover;
private readonly Container content; public Color4 FlashColour;
public Color4 NormalColour;
public FontAwesome Icon public FontAwesome Icon
{ {
@ -25,15 +26,28 @@ namespace osu.Game.Graphics.UserInterface
set { icon.Icon = value; } set { icon.Icon = value; }
} }
private const float button_size = 30;
private Color4 flashColour;
public Vector2 IconScale public Vector2 IconScale
{ {
get { return icon.Scale; } get { return icon.Scale; }
set { icon.Scale = value; } set { icon.Scale = value; }
} }
public Vector2 ButtonSize
{
get { return content.Size; }
set { content.Size = value; }
}
public Color4 HoverColour
{
get { return hover.Colour; }
set { hover.Colour = value; }
}
private readonly Container content;
private readonly SpriteIcon icon;
private readonly Box hover;
public IconButton() public IconButton()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
@ -45,7 +59,6 @@ namespace osu.Game.Graphics.UserInterface
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Size = new Vector2(button_size), Size = new Vector2(button_size),
CornerRadius = 5, CornerRadius = 5,
Masking = true, Masking = true,
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
@ -75,8 +88,8 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
hover.Colour = colours.Yellow.Opacity(0.6f); HoverColour = colours.Yellow.Opacity(0.6f);
flashColour = colours.Yellow; FlashColour = colours.Yellow;
Enabled.ValueChanged += enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint); Enabled.ValueChanged += enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint);
} }
@ -95,7 +108,7 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnClick(InputState state) protected override bool OnClick(InputState state)
{ {
hover.FlashColour(flashColour, 800, Easing.OutQuint); hover.FlashColour(FlashColour, 800, Easing.OutQuint);
return base.OnClick(state); return base.OnClick(state);
} }