1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 19:04:06 +08:00

Use OverlayColourProvider and fix font weight

This commit is contained in:
Dean Herbert 2022-01-04 18:14:42 +09:00
parent d10b8c79b3
commit 5a11ee7810
4 changed files with 24 additions and 31 deletions

View File

@ -2,13 +2,18 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface.PageSelector; using osu.Game.Graphics.UserInterface.PageSelector;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.UserInterface namespace osu.Game.Tests.Visual.UserInterface
{ {
public class TestScenePageSelector : OsuTestScene public class TestScenePageSelector : OsuTestScene
{ {
[Cached]
private OverlayColourProvider provider { get; } = new OverlayColourProvider(OverlayColourScheme.Green);
private readonly PageSelector pageSelector; private readonly PageSelector pageSelector;
public TestScenePageSelector() public TestScenePageSelector()

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Game.Overlays;
namespace osu.Game.Graphics.UserInterface.PageSelector namespace osu.Game.Graphics.UserInterface.PageSelector
{ {
@ -16,12 +17,10 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
protected const int DURATION = 200; protected const int DURATION = 200;
[Resolved] [Resolved]
protected OsuColour Colours { get; private set; } protected OverlayColourProvider ColourProvider { get; private set; }
protected Box Background; protected Box Background;
public CircularContainer CircularContent { get; private set; }
protected PageSelectorButton() protected PageSelectorButton()
{ {
AutoSizeAxes = Axes.X; AutoSizeAxes = Axes.X;
@ -31,7 +30,7 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Add(CircularContent = new CircularContainer Add(new CircularContainer
{ {
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,

View File

@ -4,7 +4,6 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface.PageSelector namespace osu.Game.Graphics.UserInterface.PageSelector
@ -35,14 +34,14 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
protected override Drawable CreateContent() => text = new OsuSpriteText protected override Drawable CreateContent() => text = new OsuSpriteText
{ {
Font = OsuFont.GetFont(size: 12), Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
Text = Page.ToString(), Text = Page.ToString(),
}; };
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Background.Colour = Colours.Lime; Background.Colour = ColourProvider.Highlight1;
Background.Alpha = 0; Background.Alpha = 0;
} }
@ -55,7 +54,7 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
private void onSelectedChanged(ValueChangedEvent<bool> selected) private void onSelectedChanged(ValueChangedEvent<bool> selected)
{ {
Background.FadeTo(selected.NewValue ? 1 : 0, DURATION, Easing.OutQuint); Background.FadeTo(selected.NewValue ? 1 : 0, DURATION, Easing.OutQuint);
text.FadeColour(selected.NewValue ? Colours.GreySeaFoamDarker : Colours.Lime, DURATION, Easing.OutQuint); text.FadeColour(selected.NewValue ? ColourProvider.Dark4 : ColourProvider.Light3, DURATION, Easing.OutQuint);
} }
protected override void UpdateHoverState() protected override void UpdateHoverState()
@ -63,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
if (selected.Value) if (selected.Value)
return; return;
text.FadeColour(IsHovered ? Colours.Lime.Lighten(20f) : Colours.Lime, DURATION, Easing.OutQuint); text.FadeColour(IsHovered ? ColourProvider.Light2 : ColourProvider.Light1, DURATION, Easing.OutQuint);
} }
} }
} }

View File

@ -2,31 +2,26 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Graphics.UserInterface.PageSelector namespace osu.Game.Graphics.UserInterface.PageSelector
{ {
public class PageSelectorPrevNextButton : PageSelectorButton public class PageSelectorPrevNextButton : PageSelectorButton
{ {
private readonly bool rightAligned;
private readonly string text; private readonly string text;
private Box fadeBox;
private SpriteIcon icon; private SpriteIcon icon;
private OsuSpriteText name; private OsuSpriteText name;
private readonly Anchor alignment;
public PageSelectorPrevNextButton(bool rightAligned, string text) public PageSelectorPrevNextButton(bool rightAligned, string text)
{ {
this.rightAligned = rightAligned;
this.text = text; this.text = text;
alignment = rightAligned ? Anchor.x0 : Anchor.x2;
} }
protected override Drawable CreateContent() => new Container protected override Drawable CreateContent() => new Container
@ -47,16 +42,16 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
name = new OsuSpriteText name = new OsuSpriteText
{ {
Font = OsuFont.GetFont(size: 12), Font = OsuFont.GetFont(size: 12),
Anchor = Anchor.Centre, Anchor = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
Origin = Anchor.Centre, Origin = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
Text = text.ToUpper(), Text = text.ToUpper(),
}, },
icon = new SpriteIcon icon = new SpriteIcon
{ {
Icon = alignment == Anchor.x2 ? FontAwesome.Solid.ChevronLeft : FontAwesome.Solid.ChevronRight, Icon = rightAligned ? FontAwesome.Solid.ChevronRight : FontAwesome.Solid.ChevronLeft,
Size = new Vector2(8), Size = new Vector2(8),
Anchor = Anchor.Centre, Anchor = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
Origin = Anchor.Centre, Origin = rightAligned ? Anchor.CentreLeft : Anchor.CentreRight,
}, },
} }
}, },
@ -66,23 +61,18 @@ namespace osu.Game.Graphics.UserInterface.PageSelector
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
Background.Colour = Colours.GreySeaFoamDark; Background.Colour = ColourProvider.Dark4;
name.Colour = icon.Colour = Colours.Lime; name.Colour = icon.Colour = ColourProvider.Light1;
} }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
CircularContent.Add(fadeBox = new Box Enabled.BindValueChanged(enabled => Background.FadeTo(enabled.NewValue ? 1 : 0.5f, DURATION), true);
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(100)
});
Enabled.BindValueChanged(enabled => fadeBox.FadeTo(enabled.NewValue ? 0 : 1, DURATION), true);
} }
protected override void UpdateHoverState() => Background.FadeColour(IsHovered ? Colours.GreySeaFoam : Colours.GreySeaFoamDark, DURATION, Easing.OutQuint); protected override void UpdateHoverState() =>
Background.FadeColour(IsHovered ? ColourProvider.Dark3 : ColourProvider.Dark4, DURATION, Easing.OutQuint);
} }
} }