From c2edf0ec03b9ce18baf71139c31fb41dc33155b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 10 Oct 2023 18:50:57 +0900 Subject: [PATCH 1/2] Add button to randomise test scene background colour --- .../Testing/Drawables/TestBrowserToolbar.cs | 46 +++++++++++++++++-- osu.Framework/Testing/TestScene.cs | 26 +++++++++-- 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/osu.Framework/Testing/Drawables/TestBrowserToolbar.cs b/osu.Framework/Testing/Drawables/TestBrowserToolbar.cs index 9518d145fd..52de2567be 100644 --- a/osu.Framework/Testing/Drawables/TestBrowserToolbar.cs +++ b/osu.Framework/Testing/Drawables/TestBrowserToolbar.cs @@ -2,17 +2,22 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing.Drawables.Sections; +using osu.Framework.Utils; +using osuTK.Graphics; namespace osu.Framework.Testing.Drawables { internal partial class TestBrowserToolbar : CompositeDrawable { [BackgroundDependencyLoader] - private void load() + private void load(TestBrowser browser) { const float section_padding = 10; @@ -40,6 +45,7 @@ private void load() new Dimension(GridSizeMode.AutoSize), new Dimension(), new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), }, Content = new[] { @@ -51,7 +57,7 @@ private void load() { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, - Margin = new MarginPadding { Left = section_padding }, + Margin = new MarginPadding { Horizontal = section_padding }, Children = new Drawable[] { new Container //Backdrop of the record section @@ -64,9 +70,43 @@ private void load() Colour = FrameworkColour.GreenDarker, }, }, - new ToolbarRecordSection { RelativeSizeAxes = Axes.Y } + new ToolbarRecordSection { RelativeSizeAxes = Axes.Y }, } }, + new Container + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Margin = new MarginPadding { Left = section_padding }, + Children = new Drawable[] + { + new Container //Backdrop of the record section + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(-section_padding), + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = FrameworkColour.GreenDarker.Darken(0.5f), + }, + }, + new BasicButton + { + Text = "bg", + RelativeSizeAxes = Axes.Y, + Width = 40, + Action = () => browser.CurrentTest.ChangeBackgroundColour( + new ColourInfo + { + TopLeft = new Color4(RNG.NextSingle(1), RNG.NextSingle(1), RNG.NextSingle(1), 1), + TopRight = new Color4(RNG.NextSingle(1), RNG.NextSingle(1), RNG.NextSingle(1), 1), + BottomLeft = new Color4(RNG.NextSingle(1), RNG.NextSingle(1), RNG.NextSingle(1), 1), + BottomRight = new Color4(RNG.NextSingle(1), RNG.NextSingle(1), RNG.NextSingle(1), 1) + } + ) + }, + } + } } }, }, diff --git a/osu.Framework/Testing/TestScene.cs b/osu.Framework/Testing/TestScene.cs index b08ebe8876..a4c6e5576b 100644 --- a/osu.Framework/Testing/TestScene.cs +++ b/osu.Framework/Testing/TestScene.cs @@ -17,6 +17,7 @@ using osu.Framework.Extensions; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; @@ -58,6 +59,8 @@ public abstract partial class TestScene : Container private Task runTask; private ITestSceneTestRunner runner; + private readonly Box backgroundFill; + /// /// A nested game instance, if added via . /// @@ -166,11 +169,23 @@ protected TestScene() Bottom = padding, }, RelativeSizeAxes = Axes.Both, - Child = content = new DrawFrameRecordingContainer + Child = new Container { - Masking = true, - RelativeSizeAxes = Axes.Both - } + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + backgroundFill = new Box + { + Colour = Color4.Black, + RelativeSizeAxes = Axes.Both, + }, + content = new DrawFrameRecordingContainer + { + Masking = true, + RelativeSizeAxes = Axes.Both + } + } + }, }, } }); @@ -255,6 +270,9 @@ private void runNextStep(Action onCompletion, Action onError, Func backgroundFill.FadeColour(colour, 200, Easing.OutQuint); + public StepButton AddStep(string description, Action action) { var step = new SingleStepButton(addStepsAsSetupSteps) From a89c062610f0c2446b38a6b6d7d5c163987ec990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 10 Oct 2023 13:18:36 +0200 Subject: [PATCH 2/2] Fix comment --- osu.Framework/Testing/Drawables/TestBrowserToolbar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Framework/Testing/Drawables/TestBrowserToolbar.cs b/osu.Framework/Testing/Drawables/TestBrowserToolbar.cs index 52de2567be..6ba9d37c97 100644 --- a/osu.Framework/Testing/Drawables/TestBrowserToolbar.cs +++ b/osu.Framework/Testing/Drawables/TestBrowserToolbar.cs @@ -80,7 +80,7 @@ private void load(TestBrowser browser) Margin = new MarginPadding { Left = section_padding }, Children = new Drawable[] { - new Container //Backdrop of the record section + new Container //Backdrop of the bg section { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding(-section_padding),