2021-04-27 17:01:32 +08:00
|
|
|
|
// 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.Syntax;
|
|
|
|
|
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
|
|
|
|
|
{
|
2024-02-18 07:00:55 +08:00
|
|
|
|
public partial class OsuMarkdownCodeBlock : MarkdownCodeBlock
|
2021-04-27 17:01:32 +08:00
|
|
|
|
{
|
2021-05-06 18:05:41 +08:00
|
|
|
|
// TODO : change to monospace font for this component
|
2024-02-18 07:00:55 +08:00
|
|
|
|
public OsuMarkdownCodeBlock(CodeBlock codeBlock)
|
|
|
|
|
: base(codeBlock)
|
2021-04-27 17:01:32 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 18:05:41 +08:00
|
|
|
|
protected override Drawable CreateBackground() => new CodeBlockBackground();
|
2021-04-27 17:01:32 +08:00
|
|
|
|
|
2021-05-06 18:05:41 +08:00
|
|
|
|
public override MarkdownTextFlowContainer CreateTextFlow() => new CodeBlockTextFlowContainer();
|
|
|
|
|
|
|
|
|
|
private partial class CodeBlockBackground : Box
|
2021-04-27 17:01:32 +08:00
|
|
|
|
{
|
2021-05-06 18:05:41 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2021-04-27 17:01:32 +08:00
|
|
|
|
{
|
2021-05-06 18:05:41 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
Colour = colourProvider.Background6;
|
|
|
|
|
}
|
2021-04-27 17:01:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 18:05:41 +08:00
|
|
|
|
private partial class CodeBlockTextFlowContainer : OsuMarkdownTextFlowContainer
|
2021-04-27 17:01:32 +08:00
|
|
|
|
{
|
2021-05-06 18:05:41 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
Colour = colourProvider.Light1;
|
|
|
|
|
Margin = new MarginPadding(10);
|
|
|
|
|
}
|
2021-04-27 17:01:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|