From 6465a72060ab9cf3b7515bc288f56576b415bd1f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 Apr 2021 16:23:26 +0900 Subject: [PATCH] Add bubbled word class for use in attribute rows --- .../RowAttributes/AttributeBubbledWord.cs | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 osu.Game/Screens/Edit/Timing/RowAttributes/AttributeBubbledWord.cs diff --git a/osu.Game/Screens/Edit/Timing/RowAttributes/AttributeBubbledWord.cs b/osu.Game/Screens/Edit/Timing/RowAttributes/AttributeBubbledWord.cs new file mode 100644 index 0000000000..3e956cbe92 --- /dev/null +++ b/osu.Game/Screens/Edit/Timing/RowAttributes/AttributeBubbledWord.cs @@ -0,0 +1,71 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Overlays; + +namespace osu.Game.Screens.Edit.Timing.RowAttributes +{ + public class AttributeBubbledWord : CompositeDrawable + { + private readonly ControlPoint controlPoint; + + private OsuSpriteText textDrawable; + + private string text; + + public string Text + { + get => text; + set + { + if (value == text) + return; + + text = value; + if (textDrawable != null) + textDrawable.Text = text; + } + } + + public AttributeBubbledWord(ControlPoint controlPoint) + { + this.controlPoint = controlPoint; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, OverlayColourProvider overlayColours) + { + AutoSizeAxes = Axes.X; + + Anchor = Anchor.CentreLeft; + Origin = Anchor.CentreLeft; + + Height = 12; + + InternalChildren = new Drawable[] + { + new Circle + { + Colour = controlPoint.GetRepresentingColour(colours), + RelativeSizeAxes = Axes.Both, + }, + textDrawable = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Padding = new MarginPadding(3), + Font = OsuFont.Default.With(weight: FontWeight.SemiBold, size: 12), + Text = text, + Colour = colours.Gray0 + }, + }; + } + } +}