1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Add transition to dropdown chevrons

This commit is contained in:
Salman Ahmed 2024-07-08 08:48:52 +03:00
parent 4c2ae07eba
commit 58e236a247
4 changed files with 25 additions and 8 deletions

View File

@ -163,7 +163,7 @@ namespace osu.Game.Collections
public CollectionDropdownHeader()
{
Height = 25;
Icon.Size = new Vector2(16);
Chevron.Size = new Vector2(16);
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 8, Right = 4 };
}
}

View File

@ -30,6 +30,12 @@ namespace osu.Game.Graphics.UserInterface
protected override DropdownMenu CreateMenu() => new OsuDropdownMenu();
public OsuDropdown()
{
if (Header is OsuDropdownHeader osuHeader)
osuHeader.Dropdown = this;
}
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat) return false;
@ -307,7 +313,9 @@ namespace osu.Game.Graphics.UserInterface
set => Text.Text = value;
}
protected readonly SpriteIcon Icon;
protected readonly SpriteIcon Chevron;
public OsuDropdown<T>? Dropdown { get; set; }
public OsuDropdownHeader()
{
@ -341,7 +349,7 @@ namespace osu.Game.Graphics.UserInterface
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X,
},
Icon = new SpriteIcon
Chevron = new SpriteIcon
{
Icon = FontAwesome.Solid.ChevronDown,
Anchor = Anchor.CentreRight,
@ -365,6 +373,9 @@ namespace osu.Game.Graphics.UserInterface
{
base.LoadComplete();
if (Dropdown != null)
Dropdown.Menu.StateChanged += _ => updateChevron();
SearchBar.State.ValueChanged += _ => updateColour();
Enabled.BindValueChanged(_ => updateColour());
updateColour();
@ -392,16 +403,22 @@ namespace osu.Game.Graphics.UserInterface
if (SearchBar.State.Value == Visibility.Visible)
{
Icon.Colour = hovered ? hoveredColour.Lighten(0.5f) : Colour4.White;
Chevron.Colour = hovered ? hoveredColour.Lighten(0.5f) : Colour4.White;
Background.Colour = unhoveredColour;
}
else
{
Icon.Colour = Color4.White;
Chevron.Colour = Color4.White;
Background.Colour = hovered ? hoveredColour : unhoveredColour;
}
}
private void updateChevron()
{
bool open = Dropdown?.Menu.State == MenuState.Open;
Chevron.ScaleTo(open ? new Vector2(1f, -1f) : Vector2.One, 300, Easing.OutQuint);
}
protected override DropdownSearchBar CreateSearchBar() => new OsuDropdownSearchBar
{
Padding = new MarginPadding { Right = 26 },

View File

@ -53,8 +53,8 @@ namespace osu.Game.Overlays.Music
{
CornerRadius = 5;
Height = 30;
Icon.Size = new Vector2(14);
Icon.Margin = new MarginPadding(0);
Chevron.Size = new Vector2(14);
Chevron.Margin = new MarginPadding(0);
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 10, Right = 10 };
EdgeEffect = new EdgeEffectParameters
{

View File

@ -200,7 +200,7 @@ namespace osu.Game.Overlays.Rankings
Text.Font = OsuFont.GetFont(size: 15);
Text.Padding = new MarginPadding { Vertical = 1.5f }; // osu-web line-height difference compensation
Foreground.Padding = new MarginPadding { Horizontal = 10, Vertical = 15 };
Margin = Icon.Margin = new MarginPadding(0);
Margin = Chevron.Margin = new MarginPadding(0);
}
[BackgroundDependencyLoader]