From 010f6258705e86c47ad208c519362daa80e6c346 Mon Sep 17 00:00:00 2001 From: Gagah Pangeran Rosfatiputra Date: Thu, 6 May 2021 17:05:41 +0700 Subject: [PATCH] use derived component in OsuMarkdownFencedCodeBlock --- .../Markdown/OsuMarkdownFencedCodeBlock.cs | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/osu.Game/Graphics/Containers/Markdown/OsuMarkdownFencedCodeBlock.cs b/osu.Game/Graphics/Containers/Markdown/OsuMarkdownFencedCodeBlock.cs index ddd88dd915..0d67849060 100644 --- a/osu.Game/Graphics/Containers/Markdown/OsuMarkdownFencedCodeBlock.cs +++ b/osu.Game/Graphics/Containers/Markdown/OsuMarkdownFencedCodeBlock.cs @@ -12,33 +12,34 @@ namespace osu.Game.Graphics.Containers.Markdown { public class OsuMarkdownFencedCodeBlock : MarkdownFencedCodeBlock { - private Box background; - private MarkdownTextFlowContainer textFlow; - + // TODO : change to monospace font for this component public OsuMarkdownFencedCodeBlock(FencedCodeBlock fencedCodeBlock) : base(fencedCodeBlock) { } - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - // TODO : Change to monospace font to match with osu-web - background.Colour = colourProvider.Background6; - textFlow.Colour = colourProvider.Light1; - } + protected override Drawable CreateBackground() => new CodeBlockBackground(); - protected override Drawable CreateBackground() + public override MarkdownTextFlowContainer CreateTextFlow() => new CodeBlockTextFlowContainer(); + + private class CodeBlockBackground : Box { - return background = new Box + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) { - RelativeSizeAxes = Axes.Both, - }; + RelativeSizeAxes = Axes.Both; + Colour = colourProvider.Background6; + } } - public override MarkdownTextFlowContainer CreateTextFlow() + private class CodeBlockTextFlowContainer : OsuMarkdownTextFlowContainer { - return textFlow = base.CreateTextFlow(); + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + Colour = colourProvider.Light1; + Margin = new MarginPadding(10); + } } } }