1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Fix tab dropdown receiving accent colour too early

This commit is contained in:
Bartłomiej Dach 2021-10-17 13:31:49 +02:00
parent ef03787fe0
commit 61127a389c
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -22,22 +22,34 @@ namespace osu.Game.Graphics.UserInterface
{
accentColour = value;
if (Menu is OsuDropdownMenu dropdownMenu)
{
dropdownMenu.HoverColour = value;
dropdownMenu.SelectionColour = value.Opacity(0.5f);
}
if (Header is OsuTabDropdownHeader tabDropdownHeader)
tabDropdownHeader.AccentColour = value;
if (IsLoaded)
propagateAccentColour();
}
}
private void propagateAccentColour()
{
if (Menu is OsuDropdownMenu dropdownMenu)
{
dropdownMenu.HoverColour = accentColour;
dropdownMenu.SelectionColour = accentColour.Opacity(0.5f);
}
if (Header is OsuTabDropdownHeader tabDropdownHeader)
tabDropdownHeader.AccentColour = accentColour;
}
public OsuTabDropdown()
{
RelativeSizeAxes = Axes.X;
}
protected override void LoadComplete()
{
base.LoadComplete();
propagateAccentColour();
}
protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu();
protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader
@ -80,7 +92,7 @@ namespace osu.Game.Graphics.UserInterface
{
accentColour = value;
BackgroundColourHover = value;
Foreground.Colour = value;
updateColour();
}
}
@ -116,15 +128,20 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(HoverEvent e)
{
Foreground.Colour = BackgroundColour;
updateColour();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
Foreground.Colour = BackgroundColourHover;
updateColour();
base.OnHoverLost(e);
}
private void updateColour()
{
Foreground.Colour = IsHovered ? BackgroundColour : BackgroundColourHover;
}
}
}
}