1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:07:25 +08:00

Improve collapse/expand animations

Especially when on a screen resolution where it would start collapsed.
This commit is contained in:
Dean Herbert 2023-09-12 17:00:06 +09:00
parent 824416067e
commit e40eaa7377
2 changed files with 21 additions and 6 deletions

View File

@ -73,8 +73,6 @@ namespace osu.Game.Overlays.Mods
Origin = Anchor.BottomRight,
Anchor = Anchor.BottomRight,
AutoSizeAxes = Axes.X,
AutoSizeEasing = Easing.OutQuint,
AutoSizeDuration = transition_duration,
Height = ShearedButton.HEIGHT,
Shear = new Vector2(shear, 0),
CornerRadius = ShearedButton.CORNER_RADIUS,
@ -135,6 +133,7 @@ namespace osu.Game.Overlays.Mods
},
outerContent = new FillFlowContainer<VerticalAttributeDisplay>
{
Alpha = 0,
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
AutoSizeAxes = Axes.X,
@ -163,7 +162,6 @@ namespace osu.Game.Overlays.Mods
content.BorderColour = ColourInfo.GradientVertical(background.Colour, glowColour);
innerContent.BorderColour = ColourInfo.GradientVertical(innerBackground.Colour, glowColour);
BeatmapInfo.BindValueChanged(_ => updateValues());
mods.BindValueChanged(_ =>
{
modSettingChangeTracker?.Dispose();
@ -173,12 +171,20 @@ namespace osu.Game.Overlays.Mods
updateValues();
}, true);
Collapsed.BindValueChanged(_ => updateCollapsedState(), true);
FinishTransforms(true);
Collapsed.BindValueChanged(_ =>
{
// Only start autosize animations on first collapse toggle. This avoids an ugly initial presentation.
startAnimating();
updateCollapsedState();
});
BeatmapInfo.BindValueChanged(_ => updateValues(), true);
}
protected override bool OnHover(HoverEvent e)
{
startAnimating();
updateCollapsedState();
return true;
}
@ -193,12 +199,19 @@ namespace osu.Game.Overlays.Mods
protected override bool OnClick(ClickEvent e) => true;
private void startAnimating()
{
content.AutoSizeEasing = Easing.OutQuint;
content.AutoSizeDuration = transition_duration;
}
private void updateValues() => Scheduler.AddOnce(() =>
{
if (BeatmapInfo.Value == null)
return;
cancellationSource?.Cancel();
starDifficulty = difficultyCache.GetBindableDifficulty(BeatmapInfo.Value, (cancellationSource = new CancellationTokenSource()).Token);
starDifficulty.BindValueChanged(s =>
{

View File

@ -339,9 +339,11 @@ namespace osu.Game.Overlays.Mods
SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? Resources.Localisation.Web.CommonStrings.InputSearch : ModSelectOverlayStrings.TabToSearch;
if (modEffectPreviewPanel != null)
// only update preview panel's collapsed state after we are fully visible, to ensure all the buttons are where we expect them to be.
if (modEffectPreviewPanel != null && Alpha == 1)
{
float rightEdgeOfLastButton = footerButtonFlow.Last().ScreenSpaceDrawQuad.TopRight.X;
// this is cheating a bit; the 375 value is hardcoded based on how wide the expanded panel _generally_ is.
// due to the transition applied, the raw screenspace quad of the panel cannot be used, as it will trigger an ugly feedback cycle of expanding and collapsing.
float projectedLeftEdgeOfExpandedModEffectPreviewPanel = footerButtonFlow.ToScreenSpace(footerButtonFlow.DrawSize - new Vector2(375 + 70, 0)).X;