2021-03-15 17:37:46 +08:00
|
|
|
// 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.Drawing;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2021-03-16 13:45:21 +08:00
|
|
|
using osu.Framework.Bindables;
|
2021-03-15 17:37:46 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Input.Handlers.Tablet;
|
|
|
|
using osu.Framework.Platform;
|
2021-03-16 15:24:08 +08:00
|
|
|
using osu.Game.Overlays;
|
2021-03-15 17:37:46 +08:00
|
|
|
using osu.Game.Overlays.Settings.Sections.Input;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Settings
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class TestSceneTabletSettings : OsuTestScene
|
|
|
|
{
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(GameHost host)
|
|
|
|
{
|
2021-03-16 13:45:21 +08:00
|
|
|
var tabletHandler = new TestTabletHandler();
|
2021-03-15 17:37:46 +08:00
|
|
|
|
|
|
|
tabletHandler.AreaOffset.Value = new Size(10, 10);
|
|
|
|
tabletHandler.AreaSize.Value = new Size(100, 80);
|
|
|
|
|
|
|
|
AddRange(new Drawable[]
|
|
|
|
{
|
2021-03-16 15:24:08 +08:00
|
|
|
new TabletSettings(tabletHandler)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.None,
|
|
|
|
Width = SettingsPanel.WIDTH,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
}
|
2021-03-15 17:37:46 +08:00
|
|
|
});
|
2021-03-16 13:45:21 +08:00
|
|
|
|
|
|
|
AddStep("Test with wide tablet", () => tabletHandler.SetTabletSize(new Size(160, 100)));
|
|
|
|
AddStep("Test with square tablet", () => tabletHandler.SetTabletSize(new Size(300, 300)));
|
|
|
|
AddStep("Test with tall tablet", () => tabletHandler.SetTabletSize(new Size(100, 300)));
|
|
|
|
AddStep("Test with very tall tablet", () => tabletHandler.SetTabletSize(new Size(100, 700)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public class TestTabletHandler : ITabletHandler
|
|
|
|
{
|
|
|
|
private readonly Bindable<Size> tabletSize = new Bindable<Size>();
|
|
|
|
|
|
|
|
public BindableSize AreaOffset { get; } = new BindableSize();
|
|
|
|
public BindableSize AreaSize { get; } = new BindableSize();
|
|
|
|
public IBindable<Size> TabletSize => tabletSize;
|
2021-03-16 15:23:46 +08:00
|
|
|
public string DeviceName => "test tablet T-421";
|
2021-03-16 13:45:21 +08:00
|
|
|
public BindableBool Enabled { get; } = new BindableBool(true);
|
|
|
|
|
|
|
|
public void SetTabletSize(Size size) => tabletSize.Value = size;
|
2021-03-15 17:37:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|