2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2017-01-30 19:29:04 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2017-02-08 13:01:17 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-01-30 19:29:04 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.Input;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-01-30 19:29:04 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-01-30 19:29:04 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
|
|
|
|
public class OsuTextBox : TextBox
|
|
|
|
|
{
|
2017-01-31 18:40:02 +08:00
|
|
|
|
protected override Color4 BackgroundUnfocused => Color4.Black.Opacity(0.5f);
|
|
|
|
|
protected override Color4 BackgroundFocused => OsuColour.Gray(0.3f).Opacity(0.8f);
|
2017-01-31 19:10:26 +08:00
|
|
|
|
protected override Color4 BackgroundCommit => BorderColour;
|
2017-01-31 18:40:02 +08:00
|
|
|
|
|
2017-02-08 10:19:58 +08:00
|
|
|
|
protected override float LeftRightPadding => 10;
|
|
|
|
|
|
2017-02-08 13:01:17 +08:00
|
|
|
|
protected override SpriteText CreatePlaceholder() => new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = @"Exo2.0-MediumItalic",
|
|
|
|
|
Colour = new Color4(180, 180, 180, 255),
|
|
|
|
|
Margin = new MarginPadding { Left = 2 },
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-30 19:29:04 +08:00
|
|
|
|
public OsuTextBox()
|
|
|
|
|
{
|
|
|
|
|
Height = 40;
|
2017-02-08 10:19:58 +08:00
|
|
|
|
TextContainer.Height = 0.5f;
|
2017-01-30 19:29:04 +08:00
|
|
|
|
CornerRadius = 5;
|
2017-04-21 12:53:11 +08:00
|
|
|
|
|
|
|
|
|
Current.DisabledChanged += disabled =>
|
|
|
|
|
{
|
|
|
|
|
Alpha = disabled ? 0.3f : 1;
|
|
|
|
|
};
|
2017-01-30 19:29:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colour)
|
|
|
|
|
{
|
|
|
|
|
BorderColour = colour.Yellow;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-30 15:33:26 +08:00
|
|
|
|
protected override void OnFocus(InputState state)
|
2017-01-30 19:29:04 +08:00
|
|
|
|
{
|
|
|
|
|
BorderThickness = 3;
|
2017-05-30 15:33:26 +08:00
|
|
|
|
base.OnFocus(state);
|
2017-01-30 19:29:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnFocusLost(InputState state)
|
|
|
|
|
{
|
|
|
|
|
BorderThickness = 0;
|
|
|
|
|
|
|
|
|
|
base.OnFocusLost(state);
|
|
|
|
|
}
|
2017-02-08 10:19:58 +08:00
|
|
|
|
|
2017-02-08 11:41:23 +08:00
|
|
|
|
protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), TextSize = CalculatedTextSize };
|
2017-01-30 19:29:04 +08:00
|
|
|
|
}
|
|
|
|
|
}
|