mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:42:55 +08:00
Merge pull request #13273 from gagahpangeran/inline-code-background
Add background colour for inline code markdown
This commit is contained in:
commit
56cdd8dcb6
@ -4,7 +4,9 @@
|
|||||||
using Markdig.Syntax.Inlines;
|
using Markdig.Syntax.Inlines;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Containers.Markdown;
|
using osu.Framework.Graphics.Containers.Markdown;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
|
||||||
@ -12,17 +14,50 @@ namespace osu.Game.Graphics.Containers.Markdown
|
|||||||
{
|
{
|
||||||
public class OsuMarkdownTextFlowContainer : MarkdownTextFlowContainer
|
public class OsuMarkdownTextFlowContainer : MarkdownTextFlowContainer
|
||||||
{
|
{
|
||||||
[Resolved]
|
|
||||||
private OverlayColourProvider colourProvider { get; set; }
|
|
||||||
|
|
||||||
protected override void AddLinkText(string text, LinkInline linkInline)
|
protected override void AddLinkText(string text, LinkInline linkInline)
|
||||||
=> AddDrawable(new OsuMarkdownLinkText(text, linkInline));
|
=> AddDrawable(new OsuMarkdownLinkText(text, linkInline));
|
||||||
|
|
||||||
// TODO : Add background (colour B6) and change font to monospace
|
// TODO : Change font to monospace
|
||||||
protected override void AddCodeInLine(CodeInline codeInline)
|
protected override void AddCodeInLine(CodeInline codeInline) => AddDrawable(new OsuMarkdownInlineCode
|
||||||
=> AddText(codeInline.Content, t => { t.Colour = colourProvider.Light1; });
|
{
|
||||||
|
Text = codeInline.Content
|
||||||
|
});
|
||||||
|
|
||||||
protected override SpriteText CreateEmphasisedSpriteText(bool bold, bool italic)
|
protected override SpriteText CreateEmphasisedSpriteText(bool bold, bool italic)
|
||||||
=> CreateSpriteText().With(t => t.Font = t.Font.With(weight: bold ? FontWeight.Bold : FontWeight.Regular, italics: italic));
|
=> CreateSpriteText().With(t => t.Font = t.Font.With(weight: bold ? FontWeight.Bold : FontWeight.Regular, italics: italic));
|
||||||
|
|
||||||
|
private class OsuMarkdownInlineCode : Container
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private IMarkdownTextComponent parentTextComponent { get; set; }
|
||||||
|
|
||||||
|
public string Text;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OverlayColourProvider colourProvider)
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
CornerRadius = 4;
|
||||||
|
Masking = true;
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colourProvider.Background6,
|
||||||
|
},
|
||||||
|
parentTextComponent.CreateSpriteText().With(t =>
|
||||||
|
{
|
||||||
|
t.Colour = colourProvider.Light1;
|
||||||
|
t.Text = Text;
|
||||||
|
t.Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Vertical = 1,
|
||||||
|
Horizontal = 4,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user