2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-27 21:01:53 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-05-25 21:31:27 +08:00
|
|
|
using osu.Game.Overlays;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
2024-03-07 13:20:46 +08:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-11-06 17:28:22 +08:00
|
|
|
namespace osu.Game.Screens.Edit.Components.Menus
|
2017-09-27 21:01:53 +08:00
|
|
|
{
|
2022-05-25 21:20:33 +08:00
|
|
|
public partial class EditorScreenSwitcherControl : OsuTabControl<EditorScreenMode>
|
2017-09-27 21:01:53 +08:00
|
|
|
{
|
2022-05-25 21:20:33 +08:00
|
|
|
public EditorScreenSwitcherControl()
|
2017-09-27 21:01:53 +08:00
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.X;
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-27 21:01:53 +08:00
|
|
|
TabContainer.RelativeSizeAxes &= ~Axes.X;
|
|
|
|
TabContainer.AutoSizeAxes = Axes.X;
|
2024-03-07 13:20:46 +08:00
|
|
|
TabContainer.Spacing = Vector2.Zero;
|
2017-09-27 21:01:53 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-27 21:01:53 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2022-05-25 21:31:27 +08:00
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2017-09-27 21:01:53 +08:00
|
|
|
{
|
2022-05-25 21:31:27 +08:00
|
|
|
AccentColour = colourProvider.Light3;
|
|
|
|
|
|
|
|
AddInternal(new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = colourProvider.Background2,
|
|
|
|
});
|
2017-09-27 21:01:53 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2023-01-12 23:07:54 +08:00
|
|
|
protected override Dropdown<EditorScreenMode> CreateDropdown() => null!;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-27 21:01:53 +08:00
|
|
|
protected override TabItem<EditorScreenMode> CreateTabItem(EditorScreenMode value) => new TabItem(value);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-29 19:02:55 +08:00
|
|
|
private partial class TabItem : OsuTabItem
|
2017-09-27 21:01:53 +08:00
|
|
|
{
|
2024-03-07 13:20:46 +08:00
|
|
|
private readonly Box background;
|
|
|
|
private Color4 backgroundIdleColour;
|
|
|
|
private Color4 backgroundHoverColour;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-27 21:01:53 +08:00
|
|
|
public TabItem(EditorScreenMode value)
|
|
|
|
: base(value)
|
|
|
|
{
|
2024-03-07 13:20:46 +08:00
|
|
|
Text.Margin = new MarginPadding(10);
|
2017-09-27 21:01:53 +08:00
|
|
|
Text.Anchor = Anchor.CentreLeft;
|
|
|
|
Text.Origin = Anchor.CentreLeft;
|
2022-05-25 21:31:27 +08:00
|
|
|
|
|
|
|
Text.Font = OsuFont.TorusAlternate;
|
|
|
|
|
2024-03-07 13:20:46 +08:00
|
|
|
Add(background = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Depth = float.MaxValue,
|
|
|
|
});
|
|
|
|
|
2022-05-25 21:31:27 +08:00
|
|
|
Bar.Expire();
|
|
|
|
}
|
|
|
|
|
2024-03-07 13:20:46 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
{
|
|
|
|
backgroundIdleColour = colourProvider.Background2;
|
|
|
|
backgroundHoverColour = colourProvider.Background1;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
background.Colour = backgroundIdleColour;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void FadeHovered()
|
2017-09-27 21:01:53 +08:00
|
|
|
{
|
2024-03-07 13:20:46 +08:00
|
|
|
base.FadeHovered();
|
|
|
|
background.FadeColour(backgroundHoverColour, TRANSITION_LENGTH, Easing.OutQuint);
|
2017-09-27 21:01:53 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2024-03-07 13:20:46 +08:00
|
|
|
protected override void FadeUnhovered()
|
2017-09-27 21:01:53 +08:00
|
|
|
{
|
2024-03-07 13:20:46 +08:00
|
|
|
base.FadeUnhovered();
|
|
|
|
background.FadeColour(backgroundIdleColour, TRANSITION_LENGTH, Easing.OutQuint);
|
2017-09-27 21:01:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|