mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Make it possible to change colours before load()
This commit is contained in:
parent
bbd1a7059e
commit
44141a38b8
@ -17,10 +17,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
private const float button_size = 30;
|
||||
|
||||
private Color4? flashColour;
|
||||
/// <summary>
|
||||
/// The colour that should be flashed when the <see cref="IconButton"/> is clicked.
|
||||
/// </summary>
|
||||
public Color4 FlashColour;
|
||||
public Color4 FlashColour
|
||||
{
|
||||
get { return flashColour ?? Color4.White; }
|
||||
set { flashColour = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The icon colour. This does not affect <see cref="IconButton.Colour"/>.
|
||||
@ -31,6 +36,20 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set { icon.Colour = value; }
|
||||
}
|
||||
|
||||
private Color4? hoverColour;
|
||||
/// <summary>
|
||||
/// The background colour of the <see cref="IconButton"/> while it is hovered.
|
||||
/// </summary>
|
||||
public Color4 HoverColour
|
||||
{
|
||||
get { return hoverColour ?? Color4.White; }
|
||||
set
|
||||
{
|
||||
hoverColour = value;
|
||||
hover.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The icon.
|
||||
/// </summary>
|
||||
@ -58,16 +77,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set { content.Size = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The background colour of the <see cref="IconButton"/> while it is hovered.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Color4 HoverColour
|
||||
{
|
||||
get { return hover.Colour; }
|
||||
set { hover.Colour = value; }
|
||||
}
|
||||
|
||||
private readonly Container content;
|
||||
private readonly SpriteIcon icon;
|
||||
private readonly Box hover;
|
||||
@ -112,8 +121,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
HoverColour = colours.Yellow.Opacity(0.6f);
|
||||
FlashColour = colours.Yellow;
|
||||
if (hoverColour == null)
|
||||
hoverColour = colours.Yellow.Opacity(0.6f);
|
||||
|
||||
if (flashColour == null)
|
||||
flashColour = colours.Yellow;
|
||||
|
||||
Enabled.ValueChanged += enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user