Fix initally-disabled OsuAnimatedButton colour fading

This commit is contained in:
Dan Balasescu
2021-12-24 11:42:41 +09:00
parent 03d159d723
commit c8073000c5

View File

@ -38,6 +38,9 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
[Resolved]
private OsuColour colours { get; set; }
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
private readonly Container content; private readonly Container content;
@ -73,17 +76,25 @@ namespace osu.Game.Graphics.UserInterface
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load()
{ {
if (AutoSizeAxes != Axes.None) if (AutoSizeAxes != Axes.None)
{ {
content.RelativeSizeAxes = (Axes.Both & ~AutoSizeAxes); content.RelativeSizeAxes = (Axes.Both & ~AutoSizeAxes);
content.AutoSizeAxes = AutoSizeAxes; content.AutoSizeAxes = AutoSizeAxes;
} }
Enabled.BindValueChanged(enabled => this.FadeColour(enabled.NewValue ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true);
} }
protected override void LoadComplete()
{
base.LoadComplete();
Colour = enablementColour;
Enabled.BindValueChanged(_ => this.FadeColour(enablementColour, 200, Easing.OutQuint));
}
private Color4 enablementColour => Enabled.Value ? Color4.White : colours.Gray9;
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
hover.FadeIn(500, Easing.OutQuint); hover.FadeIn(500, Easing.OutQuint);