diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 8828e017fd..44c29e313b 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -16,6 +16,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Mods; using osuTK; using System.Threading; +using osu.Framework.Input.Events; using osu.Game.Configuration; namespace osu.Game.Overlays.Mods @@ -39,6 +40,8 @@ namespace osu.Game.Overlays.Mods [Resolved] private Bindable> mods { get; set; } = null!; + public BindableBool Collapsed { get; } = new BindableBool(true); + private ModSettingChangeTracker? modSettingChangeTracker; [Resolved] @@ -47,10 +50,7 @@ namespace osu.Game.Overlays.Mods private CancellationTokenSource? cancellationSource; private IBindable starDifficulty = null!; - public BeatmapAttributesDisplay() - { - Collapsed.Value = true; - } + private const float transition_duration = 250; [BackgroundDependencyLoader] private void load() @@ -75,6 +75,7 @@ namespace osu.Game.Overlays.Mods } }); + RightContent.Alpha = 0; RightContent.AddRange(new Drawable[] { circleSizeDisplay = new VerticalAttributeDisplay("CS") { Shear = new Vector2(-shear, 0), }, @@ -98,6 +99,43 @@ namespace osu.Game.Overlays.Mods }, true); BeatmapInfo.BindValueChanged(_ => updateValues(), true); + + Collapsed.BindValueChanged(_ => + { + // Only start autosize animations on first collapse toggle. This avoids an ugly initial presentation. + startAnimating(); + updateCollapsedState(); + }); + + updateCollapsedState(); + } + + protected override bool OnHover(HoverEvent e) + { + startAnimating(); + updateCollapsedState(); + return true; + } + + protected override void OnHoverLost(HoverLostEvent e) + { + updateCollapsedState(); + base.OnHoverLost(e); + } + + protected override bool OnMouseDown(MouseDownEvent e) => true; + + protected override bool OnClick(ClickEvent e) => true; + + private void startAnimating() + { + Content.AutoSizeEasing = Easing.OutQuint; + Content.AutoSizeDuration = transition_duration; + } + + private void updateCollapsedState() + { + RightContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint); } private void updateValues() => Scheduler.AddOnce(() => diff --git a/osu.Game/Overlays/Mods/ModFooterInformationDisplay.cs b/osu.Game/Overlays/Mods/ModFooterInformationDisplay.cs index ca9c13e75f..b55717fc17 100644 --- a/osu.Game/Overlays/Mods/ModFooterInformationDisplay.cs +++ b/osu.Game/Overlays/Mods/ModFooterInformationDisplay.cs @@ -2,12 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input.Events; using osu.Game.Graphics.UserInterface; using osuTK; using osuTK.Graphics; @@ -20,8 +18,6 @@ namespace osu.Game.Overlays.Mods protected FillFlowContainer RightContent { get; private set; } = null!; protected Container Content { get; private set; } = null!; - public BindableBool Collapsed { get; } = new BindableBool(); - private Container innerContent = null!; protected Box MainBackground { get; private set; } = null!; @@ -30,8 +26,6 @@ namespace osu.Game.Overlays.Mods [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; - private const float transition_duration = 250; - [BackgroundDependencyLoader] private void load() { @@ -88,7 +82,6 @@ namespace osu.Game.Overlays.Mods }, RightContent = new FillFlowContainer { - Alpha = 0, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, AutoSizeAxes = Axes.X, @@ -111,43 +104,6 @@ namespace osu.Game.Overlays.Mods Content.BorderColour = ColourInfo.GradientVertical(MainBackground.Colour, glowColour); innerContent.BorderColour = ColourInfo.GradientVertical(FrontBackground.Colour, glowColour); - - Collapsed.BindValueChanged(_ => - { - // Only start autosize animations on first collapse toggle. This avoids an ugly initial presentation. - startAnimating(); - updateCollapsedState(); - }); - - updateCollapsedState(); - } - - protected override bool OnHover(HoverEvent e) - { - startAnimating(); - updateCollapsedState(); - return true; - } - - protected override void OnHoverLost(HoverLostEvent e) - { - updateCollapsedState(); - base.OnHoverLost(e); - } - - protected override bool OnMouseDown(MouseDownEvent e) => true; - - protected override bool OnClick(ClickEvent e) => true; - - private void startAnimating() - { - Content.AutoSizeEasing = Easing.OutQuint; - Content.AutoSizeDuration = transition_duration; - } - - private void updateCollapsedState() - { - RightContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint); } } }