mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Explicitly implement tooltips on date drawables to avoid "convert to auto-property" inspections
This commit is contained in:
parent
da7ff4b160
commit
69c23a2371
@ -142,13 +142,11 @@ namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
|
||||
private class Date : CompositeDrawable, IHasCustomTooltip<DateTimeOffset>
|
||||
{
|
||||
public ITooltip<DateTimeOffset> GetCustomTooltip() => new DateTooltip();
|
||||
|
||||
public DateTimeOffset TooltipContent { get; }
|
||||
private readonly DateTimeOffset date;
|
||||
|
||||
public Date(DateTimeOffset date)
|
||||
{
|
||||
TooltipContent = date;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -172,7 +170,7 @@ namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
Origin = Anchor.TopRight,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold), // using Bold since there is no 800 weight alternative
|
||||
Colour = colourProvider.Light1,
|
||||
Text = $"{TooltipContent:dd}"
|
||||
Text = $"{date:dd}"
|
||||
},
|
||||
new TextFlowContainer(f =>
|
||||
{
|
||||
@ -183,11 +181,15 @@ namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Text = $"{TooltipContent:MMM yyyy}"
|
||||
Text = $"{date:MMM yyyy}"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ITooltip<DateTimeOffset> IHasCustomTooltip<DateTimeOffset>.GetCustomTooltip() => new DateTooltip();
|
||||
|
||||
DateTimeOffset IHasCustomTooltip<DateTimeOffset>.TooltipContent => date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,13 +69,11 @@ namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
|
||||
private class Date : CompositeDrawable, IHasCustomTooltip<DateTimeOffset>
|
||||
{
|
||||
public ITooltip<DateTimeOffset> GetCustomTooltip() => new DateTooltip();
|
||||
|
||||
public DateTimeOffset TooltipContent { get; }
|
||||
private readonly DateTimeOffset date;
|
||||
|
||||
public Date(DateTimeOffset date)
|
||||
{
|
||||
TooltipContent = date;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -98,16 +96,20 @@ namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
Margin = new MarginPadding { Vertical = 5 }
|
||||
};
|
||||
|
||||
textFlow.AddText($"{TooltipContent:dd}", t =>
|
||||
textFlow.AddText($"{date:dd}", t =>
|
||||
{
|
||||
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold);
|
||||
});
|
||||
|
||||
textFlow.AddText($"{TooltipContent: MMM}", t =>
|
||||
textFlow.AddText($"{date: MMM}", t =>
|
||||
{
|
||||
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular);
|
||||
});
|
||||
}
|
||||
|
||||
ITooltip<DateTimeOffset> IHasCustomTooltip<DateTimeOffset>.GetCustomTooltip() => new DateTooltip();
|
||||
|
||||
DateTimeOffset IHasCustomTooltip<DateTimeOffset>.TooltipContent => date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,13 +125,11 @@ namespace osu.Game.Overlays.News
|
||||
|
||||
private class DateContainer : CircularContainer, IHasCustomTooltip<DateTimeOffset>
|
||||
{
|
||||
public ITooltip<DateTimeOffset> GetCustomTooltip() => new DateTooltip();
|
||||
|
||||
public DateTimeOffset TooltipContent { get; }
|
||||
private readonly DateTimeOffset date;
|
||||
|
||||
public DateContainer(DateTimeOffset date)
|
||||
{
|
||||
TooltipContent = date;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -148,7 +146,7 @@ namespace osu.Game.Overlays.News
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = TooltipContent.ToString("d MMM yyyy").ToUpper(),
|
||||
Text = date.ToString("d MMM yyyy").ToUpper(),
|
||||
Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold),
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
@ -160,6 +158,10 @@ namespace osu.Game.Overlays.News
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e) => true; // Protects the NewsCard from clicks while hovering DateContainer
|
||||
|
||||
ITooltip<DateTimeOffset> IHasCustomTooltip<DateTimeOffset>.GetCustomTooltip() => new DateTooltip();
|
||||
|
||||
DateTimeOffset IHasCustomTooltip<DateTimeOffset>.TooltipContent => date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user