1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

add OsuMarkdownTableCell

Reference :
d56352aeef/resources/assets/less/bem/osu-md.less (L254-L277)
This commit is contained in:
Gagah Pangeran Rosfatiputra 2021-04-28 10:53:00 +07:00
parent 736eace00a
commit 2252d308c8
No known key found for this signature in database
GPG Key ID: 25F6F17FD29031E2

View File

@ -0,0 +1,52 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using Markdig.Extensions.Tables;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers.Markdown;
using osu.Framework.Graphics.Shapes;
using osu.Game.Overlays;
namespace osu.Game.Graphics.Containers.Markdown
{
public class OsuMarkdownTableCell : MarkdownTableCell
{
private readonly bool isHeading;
public OsuMarkdownTableCell(TableCell cell, TableColumnDefinition definition, bool isHeading)
: base(cell, definition)
{
this.isHeading = isHeading;
Masking = false;
BorderThickness = 0;
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
var border = new Box
{
RelativeSizeAxes = Axes.X,
};
// TODO : Change font weight to 700 for heading
if (isHeading)
{
border.Colour = colourProvider.Background3;
border.Height = 2;
border.Anchor = Anchor.BottomLeft;
border.Origin = Anchor.BottomLeft;
}
else
{
border.Colour = colourProvider.Background4;
border.Height = 1;
border.Anchor = Anchor.TopLeft;
border.Origin = Anchor.TopLeft;
}
AddInternal(border);
}
}
}