mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add a way to change the IconButton icon colour
This commit is contained in:
@ -27,13 +27,28 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
set { flashColour = value; }
|
set { flashColour = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Color4? iconColour;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The icon colour. This does not affect <see cref="IconButton.Colour"/>.
|
/// The icon colour. This does not affect <see cref="IconButton.Colour"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color4 IconColour
|
public Color4 IconColour
|
||||||
{
|
{
|
||||||
get { return icon.Colour; }
|
get { return iconColour ?? Color4.White; }
|
||||||
set { icon.Colour = value; }
|
set
|
||||||
|
{
|
||||||
|
iconColour = value;
|
||||||
|
icon.Colour = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color4? iconHoverColour;
|
||||||
|
/// <summary>
|
||||||
|
/// The icon colour while the <see cref="IconButton"/> is hovered.
|
||||||
|
/// </summary>
|
||||||
|
public Color4 IconHoverColour
|
||||||
|
{
|
||||||
|
get { return iconHoverColour ?? IconColour; }
|
||||||
|
set { iconHoverColour = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color4? hoverColour;
|
private Color4? hoverColour;
|
||||||
@ -133,12 +148,14 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override bool OnHover(InputState state)
|
protected override bool OnHover(InputState state)
|
||||||
{
|
{
|
||||||
hover.FadeIn(500, Easing.OutQuint);
|
hover.FadeIn(500, Easing.OutQuint);
|
||||||
|
icon.FadeColour(IconHoverColour, 500, Easing.OutQuint);
|
||||||
return base.OnHover(state);
|
return base.OnHover(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(InputState state)
|
protected override void OnHoverLost(InputState state)
|
||||||
{
|
{
|
||||||
hover.FadeOut(500, Easing.OutQuint);
|
hover.FadeOut(500, Easing.OutQuint);
|
||||||
|
icon.FadeColour(IconColour, 500, Easing.OutQuint);
|
||||||
base.OnHoverLost(state);
|
base.OnHoverLost(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,14 +25,18 @@ namespace osu.Game.Tests.Visual
|
|||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new NamedIconButton("No change", new IconButton()),
|
new NamedIconButton("No change", new IconButton()),
|
||||||
new NamedIconButton("Green colours", new IconButton
|
new NamedIconButton("Background colours", new IconButton
|
||||||
{
|
{
|
||||||
IconColour = Color4.LightGreen,
|
|
||||||
FlashColour = Color4.DarkGreen,
|
FlashColour = Color4.DarkGreen,
|
||||||
HoverColour = Color4.Green
|
HoverColour = Color4.Green,
|
||||||
}),
|
}),
|
||||||
new NamedIconButton("Full-width", new IconButton { ButtonSize = new Vector2(200, 30) }),
|
new NamedIconButton("Full-width", new IconButton { ButtonSize = new Vector2(200, 30) }),
|
||||||
new NamedIconButton("Unchanging size", new IconButton(), false)
|
new NamedIconButton("Unchanging size", new IconButton(), false),
|
||||||
|
new NamedIconButton("Icon colours", new IconButton
|
||||||
|
{
|
||||||
|
IconColour = Color4.Green,
|
||||||
|
IconHoverColour = Color4.Red
|
||||||
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user