From 949e30c4b4d85ed4b50e04494fe20fd3f6143ab7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 6 May 2022 19:36:41 +0900 Subject: [PATCH] Remove auto-expansion of individual toolbox groups when parent expanding container expands --- osu.Game/Overlays/SettingsToolboxGroup.cs | 54 ++++++++--------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/osu.Game/Overlays/SettingsToolboxGroup.cs b/osu.Game/Overlays/SettingsToolboxGroup.cs index b9e5283a44..ca4864293c 100644 --- a/osu.Game/Overlays/SettingsToolboxGroup.cs +++ b/osu.Game/Overlays/SettingsToolboxGroup.cs @@ -135,60 +135,31 @@ protected override void Update() 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() { 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 => { // clearing transforms can break autosizing, see: https://github.com/ppy/osu-framework/issues/5064 if (v.NewValue != v.OldValue) content.ClearTransforms(); - if (v.NewValue) - 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); + Scheduler.AddOnce(updateExpandedState); }, true); - this.Delay(600).Schedule(updateActiveState); + this.Delay(600).Schedule(updateFadeState); } protected override bool OnHover(HoverEvent e) { - updateActiveState(); + updateFadeState(); return false; } protected override void OnHoverLost(HoverLostEvent e) { - updateActiveState(); + updateFadeState(); base.OnHoverLost(e); } @@ -198,9 +169,22 @@ private void load(OsuColour colours) 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 Content => content;