Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions osu.Framework.Tests/Visual/Testing/TestSceneStepButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public TestSceneStepButton()
CallStack = new StackTrace()
},
new StepSlider<int>(nameof(StepSlider<int>), 0, 10, 5),
new StepColourPicker(nameof(StepColourPicker), Colour4.AliceBlue),
}
};
}
Expand Down
69 changes: 69 additions & 0 deletions osu.Framework/Testing/Drawables/Steps/StepColourPicker.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
11 changes: 11 additions & 0 deletions osu.Framework/Testing/TestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,17 @@ protected void AddSliderStep<T>([NotNull] string description, T min, T max, T st
});
}

protected void AddColourPickerStep([NotNull] string description, Colour4 initial, Action<Colour4> valueChanged)
{
schedule(() =>
{
StepsContainer.Add(new StepColourPicker(description, initial)
{
ValueChanged = valueChanged,
});
});
}

protected void AddAssert([NotNull] string description, [NotNull] Func<bool> assert, [CanBeNull] string extendedDescription = null)
{
AddStep(new AssertButton
Expand Down
Loading