use container for main title and sub title table of contents

This commit is contained in:
Gagah Pangeran Rosfatiputra 2021-06-06 08:37:03 +07:00
parent 9f45a28623
commit 525c16419a
No known key found for this signature in database
GPG Key ID: 25F6F17FD29031E2

View File

@ -15,9 +15,9 @@ namespace osu.Game.Overlays.Wiki
{ {
private readonly FillFlowContainer content; private readonly FillFlowContainer content;
private FillFlowContainer lastItem; private Container lastMainTitle;
private FillFlowContainer lastSubsection; private Container lastSubTitle;
public WikiTableOfContents() public WikiTableOfContents()
{ {
@ -37,29 +37,26 @@ namespace osu.Game.Overlays.Wiki
if (subtitle) if (subtitle)
{ {
lastSubsection ??= new FillFlowContainer lastMainTitle.Margin = new MarginPadding(0);
if (lastSubTitle != null)
lastSubTitle.Margin = new MarginPadding(0);
content.Add(lastSubTitle = new Container
{ {
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Left = 10 }, Margin = new MarginPadding { Bottom = 10 },
}; Child = entry,
});
lastSubsection.Add(entry);
return; return;
} }
if (lastSubsection != null) lastSubTitle = null;
{
lastItem.Add(lastSubsection);
lastItem.Margin = new MarginPadding { Bottom = 10 };
lastSubsection = null;
}
content.Add(lastItem = new FillFlowContainer content.Add(lastMainTitle = new Container
{ {
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Bottom = 5 }, Margin = new MarginPadding { Bottom = 5 },
@ -92,6 +89,7 @@ namespace osu.Game.Overlays.Wiki
f.AutoSizeAxes = Axes.Y; f.AutoSizeAxes = Axes.Y;
}); });
Margin = new MarginPadding { Bottom = 2 }; Margin = new MarginPadding { Bottom = 2 };
Padding = new MarginPadding { Left = subtitle ? 10 : 0 };
} }
protected override IEnumerable<Drawable> EffectTargets => new Drawable[] { textFlow }; protected override IEnumerable<Drawable> EffectTargets => new Drawable[] { textFlow };