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