2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-06-12 23:34:02 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-06-12 23:34:02 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-06-12 23:34:02 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings
|
|
|
|
|
{
|
|
|
|
|
public class SettingsTextBox : SettingsItem<string>
|
|
|
|
|
{
|
2021-06-12 23:37:01 +08:00
|
|
|
|
protected override Drawable CreateControl() => new OsuSettingsTextBox
|
2018-11-15 05:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2019-11-14 13:19:55 +08:00
|
|
|
|
CommitOnFocusLost = true,
|
2018-11-15 05:29:11 +08:00
|
|
|
|
};
|
2021-06-12 23:34:02 +08:00
|
|
|
|
|
2021-06-12 23:37:01 +08:00
|
|
|
|
public class OsuSettingsTextBox : OsuTextBox
|
2021-06-12 23:34:02 +08:00
|
|
|
|
{
|
|
|
|
|
private const float border_thickness = 3;
|
|
|
|
|
|
|
|
|
|
private Color4 borderColourFocused;
|
|
|
|
|
private Color4 borderColourUnfocused;
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colour)
|
|
|
|
|
{
|
|
|
|
|
borderColourUnfocused = colour.Gray4.Opacity(0.5f);
|
|
|
|
|
borderColourFocused = BorderColour;
|
|
|
|
|
|
|
|
|
|
updateBorder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnFocus(FocusEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnFocus(e);
|
|
|
|
|
|
|
|
|
|
updateBorder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnFocusLost(FocusLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnFocusLost(e);
|
|
|
|
|
|
|
|
|
|
updateBorder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateBorder()
|
|
|
|
|
{
|
|
|
|
|
BorderThickness = border_thickness;
|
|
|
|
|
BorderColour = HasFocus ? borderColourFocused : borderColourUnfocused;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-12 23:37:01 +08:00
|
|
|
|
public class OsuSettingsNumberBox : OsuSettingsTextBox
|
2021-06-12 23:34:02 +08:00
|
|
|
|
{
|
|
|
|
|
protected override bool CanAddCharacter(char character) => char.IsNumber(character);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|