mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Add transition to dropdown chevrons
This commit is contained in:
parent
4c2ae07eba
commit
58e236a247
@ -163,7 +163,7 @@ namespace osu.Game.Collections
|
|||||||
public CollectionDropdownHeader()
|
public CollectionDropdownHeader()
|
||||||
{
|
{
|
||||||
Height = 25;
|
Height = 25;
|
||||||
Icon.Size = new Vector2(16);
|
Chevron.Size = new Vector2(16);
|
||||||
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 8, Right = 4 };
|
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 8, Right = 4 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,12 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected override DropdownMenu CreateMenu() => new OsuDropdownMenu();
|
protected override DropdownMenu CreateMenu() => new OsuDropdownMenu();
|
||||||
|
|
||||||
|
public OsuDropdown()
|
||||||
|
{
|
||||||
|
if (Header is OsuDropdownHeader osuHeader)
|
||||||
|
osuHeader.Dropdown = this;
|
||||||
|
}
|
||||||
|
|
||||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||||
{
|
{
|
||||||
if (e.Repeat) return false;
|
if (e.Repeat) return false;
|
||||||
@ -307,7 +313,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
set => Text.Text = value;
|
set => Text.Text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly SpriteIcon Icon;
|
protected readonly SpriteIcon Chevron;
|
||||||
|
|
||||||
|
public OsuDropdown<T>? Dropdown { get; set; }
|
||||||
|
|
||||||
public OsuDropdownHeader()
|
public OsuDropdownHeader()
|
||||||
{
|
{
|
||||||
@ -341,7 +349,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
},
|
},
|
||||||
Icon = new SpriteIcon
|
Chevron = new SpriteIcon
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.ChevronDown,
|
Icon = FontAwesome.Solid.ChevronDown,
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
@ -365,6 +373,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
if (Dropdown != null)
|
||||||
|
Dropdown.Menu.StateChanged += _ => updateChevron();
|
||||||
|
|
||||||
SearchBar.State.ValueChanged += _ => updateColour();
|
SearchBar.State.ValueChanged += _ => updateColour();
|
||||||
Enabled.BindValueChanged(_ => updateColour());
|
Enabled.BindValueChanged(_ => updateColour());
|
||||||
updateColour();
|
updateColour();
|
||||||
@ -392,16 +403,22 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
if (SearchBar.State.Value == Visibility.Visible)
|
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;
|
Background.Colour = unhoveredColour;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Icon.Colour = Color4.White;
|
Chevron.Colour = Color4.White;
|
||||||
Background.Colour = hovered ? hoveredColour : unhoveredColour;
|
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
|
protected override DropdownSearchBar CreateSearchBar() => new OsuDropdownSearchBar
|
||||||
{
|
{
|
||||||
Padding = new MarginPadding { Right = 26 },
|
Padding = new MarginPadding { Right = 26 },
|
||||||
|
@ -53,8 +53,8 @@ namespace osu.Game.Overlays.Music
|
|||||||
{
|
{
|
||||||
CornerRadius = 5;
|
CornerRadius = 5;
|
||||||
Height = 30;
|
Height = 30;
|
||||||
Icon.Size = new Vector2(14);
|
Chevron.Size = new Vector2(14);
|
||||||
Icon.Margin = new MarginPadding(0);
|
Chevron.Margin = new MarginPadding(0);
|
||||||
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 10, Right = 10 };
|
Foreground.Padding = new MarginPadding { Top = 4, Bottom = 4, Left = 10, Right = 10 };
|
||||||
EdgeEffect = new EdgeEffectParameters
|
EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
|
@ -200,7 +200,7 @@ namespace osu.Game.Overlays.Rankings
|
|||||||
Text.Font = OsuFont.GetFont(size: 15);
|
Text.Font = OsuFont.GetFont(size: 15);
|
||||||
Text.Padding = new MarginPadding { Vertical = 1.5f }; // osu-web line-height difference compensation
|
Text.Padding = new MarginPadding { Vertical = 1.5f }; // osu-web line-height difference compensation
|
||||||
Foreground.Padding = new MarginPadding { Horizontal = 10, Vertical = 15 };
|
Foreground.Padding = new MarginPadding { Horizontal = 10, Vertical = 15 };
|
||||||
Margin = Icon.Margin = new MarginPadding(0);
|
Margin = Chevron.Margin = new MarginPadding(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
Loading…
Reference in New Issue
Block a user