2021-04-14 19:54:29 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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;
|
2023-07-14 14:17:24 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2021-04-14 19:54:29 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|
|
|
{
|
|
|
|
public partial class TopPointPiece : CompositeDrawable
|
|
|
|
{
|
2023-07-14 14:17:24 +08:00
|
|
|
protected readonly ControlPoint Point;
|
|
|
|
|
|
|
|
protected OsuSpriteText Label { get; private set; } = null!;
|
2021-04-14 19:54:29 +08:00
|
|
|
|
2024-03-14 04:08:00 +08:00
|
|
|
public const float WIDTH = 80;
|
2021-04-14 19:54:29 +08:00
|
|
|
|
|
|
|
public TopPointPiece(ControlPoint point)
|
|
|
|
{
|
2023-07-14 14:17:24 +08:00
|
|
|
Point = point;
|
2024-03-14 04:08:00 +08:00
|
|
|
Width = WIDTH;
|
2021-04-14 19:54:29 +08:00
|
|
|
Height = 16;
|
2023-07-14 14:17:24 +08:00
|
|
|
Margin = new MarginPadding { Vertical = 4 };
|
2021-04-14 19:54:29 +08:00
|
|
|
|
|
|
|
Origin = Anchor.TopCentre;
|
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
2023-07-14 14:17:24 +08:00
|
|
|
const float corner_radius = 4;
|
|
|
|
const float arrow_extension = 3;
|
|
|
|
const float triangle_portion = 15;
|
|
|
|
|
2021-04-14 19:54:29 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2023-07-14 14:17:24 +08:00
|
|
|
// This is a triangle, trust me.
|
|
|
|
// Doing it this way looks okay. Doing it using Triangle primitive is basically impossible.
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Colour = Point.GetRepresentingColour(colours),
|
|
|
|
X = -corner_radius,
|
|
|
|
Size = new Vector2(triangle_portion * arrow_extension, Height),
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = Height,
|
|
|
|
CornerExponent = 1.4f,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = Color4.White,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new Container
|
2021-04-14 19:54:29 +08:00
|
|
|
{
|
2023-07-14 14:17:24 +08:00
|
|
|
RelativeSizeAxes = Axes.Y,
|
2024-03-14 04:08:00 +08:00
|
|
|
Width = WIDTH - triangle_portion,
|
2023-07-14 14:17:24 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Colour = Point.GetRepresentingColour(colours),
|
|
|
|
Masking = true,
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
Child = new Box
|
|
|
|
{
|
|
|
|
Colour = Color4.White,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2021-04-14 19:54:29 +08:00
|
|
|
},
|
|
|
|
Label = new OsuSpriteText
|
|
|
|
{
|
2023-07-14 14:17:24 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2021-04-14 19:54:29 +08:00
|
|
|
Padding = new MarginPadding(3),
|
|
|
|
Font = OsuFont.Default.With(size: 14, weight: FontWeight.SemiBold),
|
|
|
|
Colour = colours.B5,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|