mirror of
https://github.com/ppy/osu.git
synced 2025-03-18 02:47:19 +08:00
Use rounded buttons in tablet rotation preset settings
This commit is contained in:
parent
b30dd2d4ed
commit
ff382259ca
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Handlers.Tablet;
|
||||
@ -21,6 +22,9 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
private TestTabletHandler tabletHandler;
|
||||
private TabletSettings settings;
|
||||
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -8,16 +9,24 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Handlers.Tablet;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
internal class RotationPresetButtons : FillFlowContainer
|
||||
internal class RotationPresetButtons : CompositeDrawable
|
||||
{
|
||||
public new MarginPadding Padding
|
||||
{
|
||||
get => base.Padding;
|
||||
set => base.Padding = value;
|
||||
}
|
||||
|
||||
private readonly ITabletHandler tabletHandler;
|
||||
|
||||
private Bindable<float> rotation;
|
||||
private readonly RotationButton[] rotationPresets = new RotationButton[preset_count];
|
||||
|
||||
private const int preset_count = 4;
|
||||
private const int height = 50;
|
||||
|
||||
public RotationPresetButtons(ITabletHandler tabletHandler)
|
||||
@ -27,18 +36,39 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = height;
|
||||
|
||||
for (int i = 0; i < 360; i += 90)
|
||||
IEnumerable<Dimension> createColumns(int count)
|
||||
{
|
||||
var presetRotation = i;
|
||||
|
||||
Add(new RotationButton(i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = height,
|
||||
Width = 0.25f,
|
||||
Text = $@"{presetRotation}º",
|
||||
Action = () => tabletHandler.Rotation.Value = presetRotation,
|
||||
});
|
||||
if (i > 0)
|
||||
yield return new Dimension(GridSizeMode.Absolute, 10);
|
||||
|
||||
yield return new Dimension();
|
||||
}
|
||||
}
|
||||
|
||||
GridContainer grid;
|
||||
|
||||
InternalChild = grid = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColumnDimensions = createColumns(preset_count).ToArray()
|
||||
};
|
||||
|
||||
grid.Content = new[] { new Drawable[preset_count * 2 - 1] };
|
||||
|
||||
for (int i = 0; i < preset_count; i++)
|
||||
{
|
||||
var rotationValue = i * 90;
|
||||
|
||||
var rotationPreset = new RotationButton(rotationValue)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Height = 1,
|
||||
Text = $@"{rotationValue}º",
|
||||
Action = () => tabletHandler.Rotation.Value = rotationValue,
|
||||
};
|
||||
grid.Content[0][2 * i] = rotationPresets[i] = rotationPreset;
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,16 +79,19 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
rotation = tabletHandler.Rotation.GetBoundCopy();
|
||||
rotation.BindValueChanged(val =>
|
||||
{
|
||||
foreach (var b in Children.OfType<RotationButton>())
|
||||
foreach (var b in rotationPresets)
|
||||
b.IsSelected = b.Preset == val.NewValue;
|
||||
}, true);
|
||||
}
|
||||
|
||||
public class RotationButton : TriangleButton
|
||||
public class RotationButton : RoundedButton
|
||||
{
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
public readonly int Preset;
|
||||
|
||||
public RotationButton(int preset)
|
||||
@ -91,18 +124,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
|
||||
private void updateColour()
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
BackgroundColour = colours.BlueDark;
|
||||
Triangles.ColourDark = colours.BlueDarker;
|
||||
Triangles.ColourLight = colours.Blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
BackgroundColour = colours.Gray4;
|
||||
Triangles.ColourDark = colours.Gray5;
|
||||
Triangles.ColourLight = colours.Gray6;
|
||||
}
|
||||
BackgroundColour = isSelected ? colours.Blue3 : colourProvider.Background3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user