2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-06-03 15:48:44 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
|
2019-07-26 18:29:06 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual
|
2019-06-03 15:48:44 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An abstract test case which exposes small cells arranged in a grid.
|
|
|
|
|
/// Useful for displaying multiple configurations of a tested component at a glance.
|
|
|
|
|
/// </summary>
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public abstract partial class OsuGridTestScene : OsuTestScene
|
2019-06-03 15:48:44 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly Drawable[,] cells;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The amount of rows in the grid.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected readonly int Rows;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The amount of columns in the grid.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected readonly int Cols;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a grid test case with the given dimensions.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected OsuGridTestScene(int rows, int cols)
|
|
|
|
|
{
|
|
|
|
|
Rows = rows;
|
|
|
|
|
Cols = cols;
|
|
|
|
|
|
|
|
|
|
GridContainer testContainer;
|
|
|
|
|
Add(testContainer = new GridContainer { RelativeSizeAxes = Axes.Both });
|
|
|
|
|
|
|
|
|
|
cells = new Drawable[rows, cols];
|
2019-11-11 20:05:36 +08:00
|
|
|
|
|
2019-06-03 15:48:44 +08:00
|
|
|
|
for (int r = 0; r < rows; r++)
|
2019-11-11 19:53:22 +08:00
|
|
|
|
{
|
|
|
|
|
for (int c = 0; c < cols; c++)
|
|
|
|
|
cells[r, c] = new Container { RelativeSizeAxes = Axes.Both };
|
|
|
|
|
}
|
2019-06-03 15:48:44 +08:00
|
|
|
|
|
|
|
|
|
testContainer.Content = cells.ToJagged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Container Cell(int index) => (Container)cells[index / Cols, index % Cols];
|
|
|
|
|
protected Container Cell(int row, int col) => (Container)cells[row, col];
|
|
|
|
|
}
|
|
|
|
|
}
|