From d8d4bf66b3fdfd7367f347325d8a03f44b841fd7 Mon Sep 17 00:00:00 2001 From: Gagah Pangeran Rosfatiputra Date: Fri, 4 Jun 2021 11:09:20 +0700 Subject: [PATCH] create TocTitle in WikiSidebar --- osu.Game/Overlays/Wiki/WikiSidebar.cs | 34 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Wiki/WikiSidebar.cs b/osu.Game/Overlays/Wiki/WikiSidebar.cs index 0f4ae45650..aa521d4ff5 100644 --- a/osu.Game/Overlays/Wiki/WikiSidebar.cs +++ b/osu.Game/Overlays/Wiki/WikiSidebar.cs @@ -1,10 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers.Markdown; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Wiki @@ -39,13 +42,34 @@ public void AddToc(string title, MarkdownHeading heading, int level) switch (level) { case 2: - tableOfContents.Add(new OsuSpriteText - { - Text = title, - Font = OsuFont.GetFont(size: 15), - }); + tableOfContents.Add(new TocTitle(title)); break; } } + + private class TocTitle : OsuHoverContainer + { + private readonly OsuSpriteText spriteText; + + public TocTitle(string text) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Child = spriteText = new OsuSpriteText + { + Text = text, + Font = OsuFont.GetFont(size: 15), + }; + } + + protected override IEnumerable EffectTargets => new Drawable[] { spriteText }; + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + IdleColour = colourProvider.Light2; + HoverColour = colourProvider.Light1; + } + } } }