1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:47:28 +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);
Text.FadeColour(Color4.White, transition_length, Easing.OutQuint);
Bar.FadeIn(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);
Text.FadeColour(IsHovered ? Color4.White : AccentColour, transition_length, Easing.OutQuint);
Bar.FadeTo(IsHovered ? 1 : 0, TRANSITION_LENGTH, Easing.OutQuint);
Text.FadeColour(IsHovered ? Color4.White : AccentColour, TRANSITION_LENGTH, Easing.OutQuint);
}
protected override bool OnHover(HoverEvent e)

View File

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