1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:07:25 +08:00

Use existing PageTabControl for layout

This commit is contained in:
Andrei Zavatski 2019-08-12 13:16:57 +03:00
parent fc521ac93b
commit ba49a4c2da

View File

@ -8,25 +8,24 @@ using osu.Framework.Graphics.Containers;
using osuTK;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
using osu.Framework.Extensions;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using osuTK.Graphics;
using osu.Framework.Input.Events;
using osu.Framework.Graphics.Colour;
using osu.Framework.Input.Events;
namespace osu.Game.Overlays.BeatmapSet
{
public class LeaderboardScopeSelector : TabControl<BeatmapLeaderboardScope>
public class LeaderboardScopeSelector : PageTabControl<BeatmapLeaderboardScope>
{
protected override bool AddAllItemsIfEnum => false;
protected override Dropdown<BeatmapLeaderboardScope> CreateDropdown() => null;
protected override TabItem<BeatmapLeaderboardScope> CreateTabItem(BeatmapLeaderboardScope value) => new ScopeSelectorTabItem(value);
public LeaderboardScopeSelector()
{
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
AddItem(BeatmapLeaderboardScope.Global);
@ -42,57 +41,31 @@ namespace osu.Game.Overlays.BeatmapSet
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(20, 0),
};
private class ScopeSelectorTabItem : TabItem<BeatmapLeaderboardScope>
private class ScopeSelectorTabItem : PageTabItem
{
private const float transition_duration = 100;
private readonly Box box;
protected readonly OsuSpriteText Text;
public ScopeSelectorTabItem(BeatmapLeaderboardScope value)
: base(value)
{
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
Text = new OsuSpriteText
{
Margin = new MarginPadding { Bottom = 8 },
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
Text = value.GetDescription(),
Font = OsuFont.GetFont(weight: FontWeight.Regular),
},
box = new Box
{
RelativeSizeAxes = Axes.X,
Height = 5,
Scale = new Vector2(1f, 0f),
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
},
new HoverClickSounds()
};
Text.Font = OsuFont.GetFont(size: 16);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
box.Colour = colours.Blue;
BoxColour = colours.Blue;
}
protected override bool OnHover(HoverEvent e)
{
Text.FadeColour(Color4.LightSkyBlue);
Text.FadeColour(BoxColour);
return base.OnHover(e);
}
@ -103,18 +76,6 @@ namespace osu.Game.Overlays.BeatmapSet
Text.FadeColour(Color4.White);
}
protected override void OnActivated()
{
box.ScaleTo(new Vector2(1f), transition_duration);
Text.Font = Text.Font.With(weight: FontWeight.Black);
}
protected override void OnDeactivated()
{
box.ScaleTo(new Vector2(1f, 0f), transition_duration);
Text.Font = Text.Font.With(weight: FontWeight.Regular);
}
}
private class Line : GridContainer