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
1 changed files with 14 additions and 3 deletions

View File

@ -38,6 +38,9 @@ protected Color4 HoverColour
}
}
[Resolved]
private OsuColour colours { get; set; }
protected override Container<Drawable> Content => content;
private readonly Container content;
@ -73,17 +76,25 @@ public OsuAnimatedButton()
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load()
{
if (AutoSizeAxes != Axes.None)
{
content.RelativeSizeAxes = (Axes.Both & ~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)
{
hover.FadeIn(500, Easing.OutQuint);