mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 14:33:01 +08:00
Use alternative hue slider nub design
This commit is contained in:
parent
434c048d87
commit
083e463afd
@ -3,6 +3,7 @@
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
@ -15,6 +16,10 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
public class OsuHSVColourPicker : HSVColourPicker
|
||||
{
|
||||
private const float spacing = 10;
|
||||
private const float corner_radius = 10;
|
||||
private const float control_border_thickness = 3;
|
||||
|
||||
protected override HueSelector CreateHueSelector() => new OsuHueSelector();
|
||||
protected override SaturationValueSelector CreateSaturationValueSelector() => new OsuSaturationValueSelector();
|
||||
|
||||
@ -23,37 +28,58 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
Background.Colour = colourProvider?.Dark5 ?? osuColour.GreySeafoamDark;
|
||||
|
||||
Content.Padding = new MarginPadding(10);
|
||||
Content.Spacing = new Vector2(0, 10);
|
||||
Content.Padding = new MarginPadding(spacing);
|
||||
Content.Spacing = new Vector2(0, spacing);
|
||||
}
|
||||
|
||||
private static EdgeEffectParameters createShadowParameters() => new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0, 1),
|
||||
Radius = 3,
|
||||
Colour = Colour4.Black.Opacity(0.3f)
|
||||
};
|
||||
|
||||
private class OsuHueSelector : HueSelector
|
||||
{
|
||||
public OsuHueSelector()
|
||||
{
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Bottom = 15
|
||||
};
|
||||
|
||||
SliderBar.CornerRadius = SliderBar.Height / 2;
|
||||
SliderBar.CornerRadius = corner_radius;
|
||||
SliderBar.Masking = true;
|
||||
}
|
||||
|
||||
protected override Drawable CreateSliderNub() => new SliderNub();
|
||||
protected override Drawable CreateSliderNub() => new SliderNub(this);
|
||||
|
||||
private class SliderNub : CompositeDrawable
|
||||
{
|
||||
public SliderNub()
|
||||
private readonly Bindable<float> hue;
|
||||
private readonly Box fill;
|
||||
|
||||
public SliderNub(OsuHueSelector osuHueSelector)
|
||||
{
|
||||
InternalChild = new Triangle
|
||||
hue = osuHueSelector.Hue.GetBoundCopy();
|
||||
|
||||
InternalChild = new CircularContainer
|
||||
{
|
||||
Width = 20,
|
||||
Height = 15,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
Height = 35,
|
||||
Width = 10,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Masking = true,
|
||||
BorderColour = Colour4.White,
|
||||
BorderThickness = control_border_thickness,
|
||||
EdgeEffect = createShadowParameters(),
|
||||
Child = fill = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
hue.BindValueChanged(h => fill.Colour = Colour4.FromHSV(h.NewValue, 1, 1), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +87,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
public OsuSaturationValueSelector()
|
||||
{
|
||||
SelectionArea.CornerRadius = 10;
|
||||
SelectionArea.CornerRadius = corner_radius;
|
||||
SelectionArea.Masking = true;
|
||||
// purposefully use hard non-AA'd masking to avoid edge artifacts.
|
||||
SelectionArea.MaskingSmoothness = 0;
|
||||
@ -82,14 +108,8 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
Size = new Vector2(20),
|
||||
Masking = true,
|
||||
BorderColour = Colour4.White,
|
||||
BorderThickness = 3,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0, 1),
|
||||
Radius = 3,
|
||||
Colour = Colour4.Black.Opacity(0.3f)
|
||||
},
|
||||
BorderThickness = control_border_thickness,
|
||||
EdgeEffect = createShadowParameters(),
|
||||
Child = previewBox = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
|
Loading…
Reference in New Issue
Block a user