1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 02:02:53 +08:00

Merge pull request #27516 from frenzibyte/editor-screen-selector

Change editor screen switcher control design and behaviour to act like a button
This commit is contained in:
Bartłomiej Dach 2024-03-07 11:04:18 +01:00 committed by GitHub
commit e99030c515
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 16 deletions

View File

@ -116,18 +116,18 @@ namespace osu.Game.Graphics.UserInterface
} }
} }
private const float transition_length = 500; protected const float TRANSITION_LENGTH = 500;
protected void FadeHovered() protected virtual void FadeHovered()
{ {
Bar.FadeIn(transition_length, Easing.OutQuint); Bar.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
Text.FadeColour(Color4.White, transition_length, Easing.OutQuint); Text.FadeColour(Color4.White, TRANSITION_LENGTH, Easing.OutQuint);
} }
protected void FadeUnhovered() protected virtual void FadeUnhovered()
{ {
Bar.FadeTo(IsHovered ? 1 : 0, transition_length, Easing.OutQuint); Bar.FadeTo(IsHovered ? 1 : 0, TRANSITION_LENGTH, Easing.OutQuint);
Text.FadeColour(IsHovered ? Color4.White : AccentColour, transition_length, Easing.OutQuint); Text.FadeColour(IsHovered ? Color4.White : AccentColour, TRANSITION_LENGTH, Easing.OutQuint);
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)

View File

@ -9,6 +9,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays; using osu.Game.Overlays;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Edit.Components.Menus namespace osu.Game.Screens.Edit.Components.Menus
{ {
@ -21,7 +22,7 @@ namespace osu.Game.Screens.Edit.Components.Menus
TabContainer.RelativeSizeAxes &= ~Axes.X; TabContainer.RelativeSizeAxes &= ~Axes.X;
TabContainer.AutoSizeAxes = Axes.X; TabContainer.AutoSizeAxes = Axes.X;
TabContainer.Padding = new MarginPadding(10); TabContainer.Spacing = Vector2.Zero;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -42,30 +43,51 @@ namespace osu.Game.Screens.Edit.Components.Menus
private partial class TabItem : OsuTabItem private partial class TabItem : OsuTabItem
{ {
private const float transition_length = 250; private readonly Box background;
private Color4 backgroundIdleColour;
private Color4 backgroundHoverColour;
public TabItem(EditorScreenMode value) public TabItem(EditorScreenMode value)
: base(value) : base(value)
{ {
Text.Margin = new MarginPadding(); Text.Margin = new MarginPadding(10);
Text.Anchor = Anchor.CentreLeft; Text.Anchor = Anchor.CentreLeft;
Text.Origin = Anchor.CentreLeft; Text.Origin = Anchor.CentreLeft;
Text.Font = OsuFont.TorusAlternate; Text.Font = OsuFont.TorusAlternate;
Add(background = new Box
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue,
});
Bar.Expire(); Bar.Expire();
} }
protected override void OnActivated() [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{ {
base.OnActivated(); backgroundIdleColour = colourProvider.Background2;
Bar.ScaleTo(new Vector2(1, 5), transition_length, Easing.OutQuint); backgroundHoverColour = colourProvider.Background1;
} }
protected override void OnDeactivated() protected override void LoadComplete()
{ {
base.OnDeactivated(); base.LoadComplete();
Bar.ScaleTo(Vector2.One, transition_length, Easing.OutQuint); background.Colour = backgroundIdleColour;
}
protected override void FadeHovered()
{
base.FadeHovered();
background.FadeColour(backgroundHoverColour, TRANSITION_LENGTH, Easing.OutQuint);
}
protected override void FadeUnhovered()
{
base.FadeUnhovered();
background.FadeColour(backgroundIdleColour, TRANSITION_LENGTH, Easing.OutQuint);
} }
} }
} }