2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
2021-06-12 15:34:02 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-06-12 15:34:02 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-06-12 15:34:02 +00:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings
|
|
|
|
|
{
|
|
|
|
|
public class SettingsTextBox : SettingsItem<string>
|
|
|
|
|
{
|
2021-06-12 16:37:31 +00:00
|
|
|
|
protected override Drawable CreateControl() => new TextBox
|
2018-11-14 21:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2019-11-14 05:19:55 +00:00
|
|
|
|
CommitOnFocusLost = true,
|
2018-11-14 21:29:11 +00:00
|
|
|
|
};
|
2021-06-12 15:34:02 +00:00
|
|
|
|
|
2021-06-12 16:37:31 +00:00
|
|
|
|
public class TextBox : OsuTextBox
|
2021-06-12 15:34:02 +00: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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|