mirror of https://github.com/ppy/osu
Fix tab dropdown receiving accent colour too early
This commit is contained in:
parent
ef03787fe0
commit
61127a389c
|
@ -22,22 +22,34 @@ public Color4 AccentColour
|
|||
{
|
||||
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 @@ public Color4 AccentColour
|
|||
{
|
||||
accentColour = value;
|
||||
BackgroundColourHover = value;
|
||||
Foreground.Colour = value;
|
||||
updateColour();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,15 +128,20 @@ public OsuTabDropdownHeader()
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue