1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00
osu-lazer/osu.Game/Graphics/UserInterface/GradientLineTabControl.cs

85 lines
2.6 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.
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, 1.5f);
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(mode: GridSizeMode.Relative, size: 0.4f),
new Dimension(),
};
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, Color4.White)
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,
},
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.White, Color4.Transparent)
2019-09-12 10:26:10 +08:00
},
}
};
}
}
}
}