mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Refresh nub/slider appearance and use overlay theming
This commit is contained in:
parent
79d9aa7383
commit
a10a7e7903
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
@ -12,13 +13,16 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class Nub : CircularContainer, IHasCurrentValue<bool>, IHasAccentColour
|
||||
{
|
||||
public const float COLLAPSED_SIZE = 20;
|
||||
public const float EXPANDED_SIZE = 40;
|
||||
public const float HEIGHT = 15;
|
||||
|
||||
public const float COLLAPSED_SIZE = 30;
|
||||
public const float EXPANDED_SIZE = 50;
|
||||
|
||||
private const float border_width = 3;
|
||||
|
||||
@ -29,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Box fill;
|
||||
|
||||
Size = new Vector2(COLLAPSED_SIZE, 12);
|
||||
Size = new Vector2(COLLAPSED_SIZE, HEIGHT);
|
||||
|
||||
BorderColour = Color4.White;
|
||||
BorderThickness = border_width;
|
||||
@ -53,12 +57,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load([CanBeNull] OverlayColourProvider colourProvider, OsuColour colours)
|
||||
{
|
||||
AccentColour = colours.Pink;
|
||||
GlowingAccentColour = colours.PinkLighter;
|
||||
GlowColour = colours.PinkDarker;
|
||||
AccentColour = colourProvider?.Highlight1 ?? colours.Pink;
|
||||
GlowingAccentColour = colourProvider?.Highlight1.Lighten(0.2f) ?? colours.PinkLighter;
|
||||
GlowColour = colourProvider?.Dark3 ?? colours.PinkDarker;
|
||||
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
@ -96,9 +100,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
this.ResizeTo(new Vector2(EXPANDED_SIZE, 12), animate_in_duration, Easing.OutQuint);
|
||||
this.ResizeTo(new Vector2(EXPANDED_SIZE, HEIGHT), animate_in_duration, Easing.OutQuint);
|
||||
else
|
||||
this.ResizeTo(new Vector2(COLLAPSED_SIZE, 12), animate_out_duration, Easing.OutQuint);
|
||||
this.ResizeTo(new Vector2(COLLAPSED_SIZE, HEIGHT), animate_out_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,13 @@
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using JetBrains.Annotations;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
@ -16,6 +18,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@ -52,34 +55,63 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
accentColour = value;
|
||||
leftBox.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Colour4 backgroundColour;
|
||||
|
||||
public Color4 BackgroundColour
|
||||
{
|
||||
get => backgroundColour;
|
||||
set
|
||||
{
|
||||
backgroundColour = value;
|
||||
rightBox.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
public OsuSliderBar()
|
||||
{
|
||||
Height = 12;
|
||||
RangePadding = 20;
|
||||
Height = Nub.HEIGHT;
|
||||
RangePadding = Nub.EXPANDED_SIZE / 2;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
leftBox = new Box
|
||||
new Container
|
||||
{
|
||||
Height = 2,
|
||||
EdgeSmoothness = new Vector2(0, 0.5f),
|
||||
Position = new Vector2(2, 0),
|
||||
RelativeSizeAxes = Axes.None,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
rightBox = new Box
|
||||
{
|
||||
Height = 2,
|
||||
EdgeSmoothness = new Vector2(0, 0.5f),
|
||||
Position = new Vector2(-2, 0),
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Alpha = 0.5f,
|
||||
Padding = new MarginPadding { Horizontal = 2 },
|
||||
Child = new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Masking = true,
|
||||
CornerRadius = 5f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
leftBox = new Box
|
||||
{
|
||||
Height = 5,
|
||||
EdgeSmoothness = new Vector2(0, 0.5f),
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
rightBox = new Box
|
||||
{
|
||||
Height = 5,
|
||||
EdgeSmoothness = new Vector2(0, 0.5f),
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
nubContainer = new Container
|
||||
{
|
||||
@ -89,6 +121,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativePositionAxes = Axes.X,
|
||||
Expanded = true,
|
||||
Current = { Value = true }
|
||||
},
|
||||
},
|
||||
new HoverClickSounds()
|
||||
@ -97,11 +130,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Current.DisabledChanged += disabled => { Alpha = disabled ? 0.3f : 1; };
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, OsuColour colours)
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(AudioManager audio, [CanBeNull] OverlayColourProvider colourProvider, OsuColour colours)
|
||||
{
|
||||
sample = audio.Samples.Get(@"UI/notch-tick");
|
||||
AccentColour = colours.Pink;
|
||||
AccentColour = colourProvider?.Highlight1 ?? colours.Pink;
|
||||
BackgroundColour = colourProvider?.Background5 ?? colours.Pink.Opacity(0.5f);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -129,18 +163,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
Nub.Current.Value = true;
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
Nub.Current.Value = false;
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override void OnUserChange(T value)
|
||||
{
|
||||
base.OnUserChange(value);
|
||||
|
Loading…
Reference in New Issue
Block a user