mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
Add colourPicker step drawable
This commit is contained in:
@@ -59,6 +59,7 @@ namespace osu.Framework.Tests.Visual.Testing
|
||||
CallStack = new StackTrace()
|
||||
},
|
||||
new StepSlider<int>(nameof(StepSlider<int>), 0, 10, 5),
|
||||
new StepColourPicker(nameof(StepColourPicker), Colour4.AliceBlue),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
69
osu.Framework/Testing/Drawables/Steps/StepColourPicker.cs
Normal file
69
osu.Framework/Testing/Drawables/Steps/StepColourPicker.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Framework.Testing.Drawables.Steps
|
||||
{
|
||||
public partial class StepColourPicker : CompositeDrawable
|
||||
{
|
||||
private const float scale_adjust = 0.5f;
|
||||
|
||||
public Action<Colour4>? ValueChanged { get; set; }
|
||||
|
||||
private readonly Bindable<Colour4> current;
|
||||
|
||||
public StepColourPicker(string description, Colour4 initialColour)
|
||||
{
|
||||
current = new Bindable<Colour4>(initialColour);
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = FrameworkColour.GreenDark,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Text = description,
|
||||
Padding = new MarginPadding(5),
|
||||
Font = FrameworkFont.Regular.With(size: 14),
|
||||
},
|
||||
new BasicColourPicker
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 1f / scale_adjust,
|
||||
Scale = new Vector2(scale_adjust),
|
||||
Current = current,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
current.BindValueChanged(v => ValueChanged?.Invoke(v.NewValue), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user