diff --git a/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs index 869005d05c..8134cfb42d 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControlCheckbox.cs @@ -37,6 +37,8 @@ namespace osu.Game.Graphics.UserInterface text.Colour = AccentColour; icon.Colour = AccentColour; } + + updateFade(); } } @@ -48,39 +50,6 @@ namespace osu.Game.Graphics.UserInterface private const float transition_length = 500; - private void fadeIn() - { - box.FadeIn(transition_length, Easing.OutQuint); - text.FadeColour(Color4.White, transition_length, Easing.OutQuint); - } - - private void fadeOut() - { - box.FadeOut(transition_length, Easing.OutQuint); - text.FadeColour(AccentColour, transition_length, Easing.OutQuint); - } - - protected override bool OnHover(HoverEvent e) - { - fadeIn(); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - if (!Current.Value) - fadeOut(); - - base.OnHoverLost(e); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - if (accentColour == null) - AccentColour = colours.Blue; - } - public OsuTabControlCheckbox() { AutoSizeAxes = Axes.Both; @@ -115,19 +84,34 @@ namespace osu.Game.Graphics.UserInterface } }; - Current.ValueChanged += selected => - { - if (selected.NewValue) - { - fadeIn(); - icon.Icon = FontAwesome.Regular.CheckCircle; - } - else - { - fadeOut(); - icon.Icon = FontAwesome.Regular.Circle; - } - }; + Current.ValueChanged += selected => { icon.Icon = selected.NewValue ? FontAwesome.Regular.CheckCircle : FontAwesome.Regular.Circle; }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + if (accentColour == null) + AccentColour = colours.Blue; + } + + protected override bool OnHover(HoverEvent e) + { + updateFade(); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + if (!Current.Value) + updateFade(); + + base.OnHoverLost(e); + } + + private void updateFade() + { + box.FadeTo(IsHovered ? 1 : 0, transition_length, Easing.OutQuint); + text.FadeColour(IsHovered ? Color4.White : AccentColour, transition_length, Easing.OutQuint); } } }