1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 10:32:55 +08:00
osu-lazer/osu.Game/Graphics/UserInterface/GradientLineTabControl.cs

76 lines
2.2 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2019-09-12 10:26:10 +08:00
// See the LICENCE file in the repository root for full licence text.
2022-06-17 15:37:17 +08:00
#nullable disable
2019-09-12 10:26:10 +08:00
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osuTK;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
using osu.Framework.Graphics.Colour;
namespace osu.Game.Graphics.UserInterface
{
2019-09-13 12:59:06 +08:00
public abstract class GradientLineTabControl<TModel> : PageTabControl<TModel>
2019-09-12 10:26:10 +08:00
{
protected Color4 LineColour
{
2019-09-12 22:17:57 +08:00
get => line.Colour;
set => line.Colour = value;
2019-09-12 10:26:10 +08:00
}
private readonly GradientLine line;
2019-09-13 12:59:06 +08:00
protected GradientLineTabControl()
2019-09-12 10:26:10 +08:00
{
RelativeSizeAxes = Axes.X;
AddInternal(line = new GradientLine
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
});
}
2019-09-13 12:59:06 +08:00
protected override Dropdown<TModel> CreateDropdown() => null;
2019-09-12 10:26:10 +08:00
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(20, 0),
};
private class GradientLine : GridContainer
{
public GradientLine()
{
RelativeSizeAxes = Axes.X;
Size = new Vector2(0.8f, 1f);
2019-09-12 10:26:10 +08:00
Content = new[]
{
new Drawable[]
{
2019-09-12 22:17:57 +08:00
new Box
2019-09-12 10:26:10 +08:00
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientHorizontal(Color4.Transparent, Colour)
2019-09-12 10:26:10 +08:00
},
2019-09-12 22:17:57 +08:00
new Box
2019-09-12 10:26:10 +08:00
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientHorizontal(Colour, Color4.Transparent)
2019-09-12 10:26:10 +08:00
},
}
};
}
}
}
}