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
1 changed files with 28 additions and 11 deletions

View File

@ -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;
}
}
}
}