1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-27 02:50:00 +08:00

Fix form dropdown open animation not being smooth (#36358)

Preview:


https://github.com/user-attachments/assets/07cb58b7-5980-4fed-bb4c-2443ba1e9635
This commit is contained in:
Salman Alshamrani
2026-01-16 12:54:12 -05:00
committed by GitHub
Unverified
parent a6489cd758
commit b5a989d31e
@@ -40,6 +40,8 @@ namespace osu.Game.Graphics.UserInterfaceV2
private FormDropdownHeader header = null!;
private const float header_menu_spacing = 5;
[BackgroundDependencyLoader]
private void load()
{
@@ -47,6 +49,10 @@ namespace osu.Game.Graphics.UserInterfaceV2
header.Caption = Caption;
header.HintText = HintText;
// there's bottom margin applied inside the header to give spacing between the header and the menu.
// however when the menu is closed the extra spacing remains present. to remove it, apply negative bottom padding here.
Margin = new MarginPadding { Bottom = -header_menu_spacing };
}
protected override void LoadComplete()
@@ -145,6 +151,8 @@ namespace osu.Game.Graphics.UserInterfaceV2
Masking = true;
CornerRadius = 5;
Margin = new MarginPadding { Bottom = header_menu_spacing };
Foreground.Padding = new MarginPadding(9);
Foreground.Children = new Drawable[]
{
@@ -278,11 +286,26 @@ namespace osu.Game.Graphics.UserInterfaceV2
private void load(OverlayColourProvider colourProvider)
{
ItemsContainer.Padding = new MarginPadding(9);
Margin = new MarginPadding { Top = 5 };
MaskingContainer.BorderThickness = 2;
MaskingContainer.BorderColour = colourProvider.Highlight1;
}
protected override void AnimateOpen()
{
base.AnimateOpen();
// there's negative bottom margin applied on the whole dropdown control to remove extra spacing when the menu is closed.
// however, when the menu is open, we want spacing between the menu and the next control below it. therefore apply bottom margin here.
// we use a transform to keep the open animation smooth while margin is adjusted.
this.TransformTo(nameof(Margin), new MarginPadding { Bottom = header_menu_spacing }, 300, Easing.OutQuint);
}
protected override void AnimateClose()
{
base.AnimateClose();
this.TransformTo(nameof(Margin), new MarginPadding { Bottom = 0 }, 300, Easing.OutQuint);
}
}
}