mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:32:55 +08:00
Fix tab dropdown receiving accent colour too early
This commit is contained in:
parent
ef03787fe0
commit
61127a389c
@ -22,22 +22,34 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
accentColour = value;
|
accentColour = value;
|
||||||
|
|
||||||
if (Menu is OsuDropdownMenu dropdownMenu)
|
if (IsLoaded)
|
||||||
{
|
propagateAccentColour();
|
||||||
dropdownMenu.HoverColour = value;
|
|
||||||
dropdownMenu.SelectionColour = value.Opacity(0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Header is OsuTabDropdownHeader tabDropdownHeader)
|
|
||||||
tabDropdownHeader.AccentColour = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
public OsuTabDropdown()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
propagateAccentColour();
|
||||||
|
}
|
||||||
|
|
||||||
protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu();
|
protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu();
|
||||||
|
|
||||||
protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader
|
protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader
|
||||||
@ -80,7 +92,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
accentColour = value;
|
accentColour = value;
|
||||||
BackgroundColourHover = value;
|
BackgroundColourHover = value;
|
||||||
Foreground.Colour = value;
|
updateColour();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,15 +128,20 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
Foreground.Colour = BackgroundColour;
|
updateColour();
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
Foreground.Colour = BackgroundColourHover;
|
updateColour();
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateColour()
|
||||||
|
{
|
||||||
|
Foreground.Colour = IsHovered ? BackgroundColour : BackgroundColourHover;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user