mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Simplify colour usage in GradientLine
This commit is contained in:
parent
4dd819c150
commit
b17d097a39
@ -8,7 +8,6 @@ using osuTK;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
@ -19,8 +18,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected Color4 LineColour
|
||||
{
|
||||
get => line.MainColour.Value;
|
||||
set => line.MainColour.Value = value;
|
||||
get => line.Colour;
|
||||
set => line.Colour = value;
|
||||
}
|
||||
|
||||
private readonly GradientLine line;
|
||||
@ -48,12 +47,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private class GradientLine : GridContainer
|
||||
{
|
||||
public readonly Bindable<Color4> MainColour = new Bindable<Color4>();
|
||||
|
||||
private readonly Box left;
|
||||
private readonly Box middle;
|
||||
private readonly Box right;
|
||||
|
||||
public GradientLine()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -70,34 +63,23 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
left = new Box
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(0), Color4.White)
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
middle = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
right = new Box
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.White.Opacity(0))
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
MainColour.BindValueChanged(onColourChanged, true);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
private void onColourChanged(ValueChangedEvent<Color4> colour)
|
||||
{
|
||||
left.Colour = ColourInfo.GradientHorizontal(colour.NewValue.Opacity(0), colour.NewValue);
|
||||
middle.Colour = colour.NewValue;
|
||||
right.Colour = ColourInfo.GradientHorizontal(colour.NewValue, colour.NewValue.Opacity(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user