1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 12:42:54 +08:00

Remove auto-expansion of individual toolbox groups when parent expanding container expands

This commit is contained in:
Dean Herbert 2022-05-06 19:36:41 +09:00
parent 09139ef9f4
commit 949e30c4b4

View File

@ -135,60 +135,31 @@ namespace osu.Game.Overlays
headerText.FadeTo(headerText.DrawWidth < DrawWidth ? 1 : 0, 150, Easing.OutQuint); headerText.FadeTo(headerText.DrawWidth < DrawWidth ? 1 : 0, 150, Easing.OutQuint);
} }
[Resolved(canBeNull: true)]
private IExpandingContainer expandingContainer { get; set; }
private bool expandedByContainer;
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
expandingContainer?.Expanded.BindValueChanged(containerExpanded =>
{
if (containerExpanded.NewValue && !Expanded.Value)
{
Expanded.Value = true;
expandedByContainer = true;
}
else if (!containerExpanded.NewValue && expandedByContainer)
{
Expanded.Value = false;
expandedByContainer = false;
}
updateActiveState();
}, true);
Expanded.BindValueChanged(v => Expanded.BindValueChanged(v =>
{ {
// clearing transforms can break autosizing, see: https://github.com/ppy/osu-framework/issues/5064 // clearing transforms can break autosizing, see: https://github.com/ppy/osu-framework/issues/5064
if (v.NewValue != v.OldValue) if (v.NewValue != v.OldValue)
content.ClearTransforms(); content.ClearTransforms();
if (v.NewValue) Scheduler.AddOnce(updateExpandedState);
content.AutoSizeAxes = Axes.Y;
else
{
content.AutoSizeAxes = Axes.None;
content.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
}
button.FadeColour(Expanded.Value ? expandedColour : Color4.White, 200, Easing.InOutQuint);
}, true); }, true);
this.Delay(600).Schedule(updateActiveState); this.Delay(600).Schedule(updateFadeState);
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
updateActiveState(); updateFadeState();
return false; return false;
} }
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
updateActiveState(); updateFadeState();
base.OnHoverLost(e); base.OnHoverLost(e);
} }
@ -198,9 +169,22 @@ namespace osu.Game.Overlays
expandedColour = colours.Yellow; expandedColour = colours.Yellow;
} }
private void updateActiveState() private void updateExpandedState()
{ {
this.FadeTo(IsHovered || expandingContainer?.Expanded.Value == true ? 1 : inactive_alpha, fade_duration, Easing.OutQuint); if (Expanded.Value)
content.AutoSizeAxes = Axes.Y;
else
{
content.AutoSizeAxes = Axes.None;
content.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
}
button.FadeColour(Expanded.Value ? expandedColour : Color4.White, 200, Easing.InOutQuint);
}
private void updateFadeState()
{
this.FadeTo(IsHovered ? 1 : inactive_alpha, fade_duration, Easing.OutQuint);
} }
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;