Ensure the correct fade level is applied over all state changes

This commit is contained in:
Dean Herbert 2021-08-20 16:50:27 +09:00
parent 2e1df7bee4
commit cff7b1e98f

View File

@ -102,28 +102,20 @@ namespace osu.Game.Overlays.Settings
}); });
selectedSection = settingsPanel.CurrentSection.GetBoundCopy(); selectedSection = settingsPanel.CurrentSection.GetBoundCopy();
selectedSection.BindValueChanged(selected => selectedSection.BindValueChanged(_ => updateContentFade(), true);
{
if (selected.NewValue == this)
content.FadeIn(500, Easing.OutQuint);
else
content.FadeTo(0.25f, 500, Easing.OutQuint);
}, true);
} }
private bool isCurrentSection => selectedSection.Value == this; private bool isCurrentSection => selectedSection.Value == this;
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
if (!isCurrentSection) updateContentFade();
content.FadeTo(0.6f, 500, Easing.OutQuint);
return base.OnHover(e); return base.OnHover(e);
} }
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
if (!isCurrentSection) updateContentFade();
content.FadeTo(0.25f, 500, Easing.OutQuint);
base.OnHoverLost(e); base.OnHoverLost(e);
} }
@ -135,9 +127,19 @@ namespace osu.Game.Overlays.Settings
return base.OnClick(e); return base.OnClick(e);
} }
protected override bool ShouldBeConsideredForInput(Drawable child) protected override bool ShouldBeConsideredForInput(Drawable child) =>
// only the current section should accept input.
// this provides the behaviour of the first click scrolling the target section to the centre of the screen.
isCurrentSection;
private void updateContentFade()
{ {
return isCurrentSection; float targetFade = 1;
if (!isCurrentSection)
targetFade = IsHovered ? 0.6f : 0.25f;
content.FadeTo(targetFade, 500, Easing.OutQuint);
} }
} }
} }