Improve HeaderText highlight and spacing logic

This commit is contained in:
TheWildTree 2020-03-04 18:20:55 +01:00
parent 276a90fb84
commit 06642dc7ff
1 changed files with 12 additions and 8 deletions

View File

@ -70,7 +70,14 @@ private void load()
protected abstract Drawable[] CreateAdditionalContent(TModel item);
protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? string.Empty, HighlightedColumn(), GradeColumns());
protected override Drawable CreateHeader(int index, TableColumn column)
{
var title = column?.Header ?? string.Empty;
var isHighlighted = HighlightedColumn() == title;
var isGrade = GradeColumns().Contains(title);
return new HeaderText(title, isHighlighted) { Margin = new MarginPadding { Vertical = 5, Horizontal = isGrade ? 20 : 10 } };
}
protected abstract Country GetCountry(TModel item);
@ -105,23 +112,20 @@ private void load()
private class HeaderText : OsuSpriteText
{
private readonly string highlighted;
private readonly bool isHighlighted;
public HeaderText(string text, string highlighted, IEnumerable<string> gradeColumns)
public HeaderText(string text, bool isHighlighted)
{
this.highlighted = highlighted;
this.isHighlighted = isHighlighted;
Text = text;
Font = OsuFont.GetFont(size: 12);
var isGrade = gradeColumns.Contains(text);
Margin = new MarginPadding { Vertical = 5, Horizontal = isGrade ? 20 : 10 };
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
if (Text != highlighted)
if (isHighlighted)
Colour = colourProvider.Foreground1;
}
}