osu/osu.Game/Graphics/UserInterface/OsuTextBox.cs

52 lines
1.5 KiB
C#
Raw Normal View History

// 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 11:29:04 +00:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
2017-01-30 11:29:04 +00:00
using OpenTK.Graphics;
namespace osu.Game.Graphics.UserInterface
{
public class OsuTextBox : TextBox
{
2017-01-31 10:40:02 +00:00
protected override Color4 BackgroundUnfocused => Color4.Black.Opacity(0.5f);
protected override Color4 BackgroundFocused => OsuColour.Gray(0.3f).Opacity(0.8f);
protected override Color4 BackgroundCommit => BorderColour;
2017-01-31 10:40:02 +00:00
2017-02-08 02:19:58 +00:00
protected override float LeftRightPadding => 10;
2017-01-30 11:29:04 +00:00
public OsuTextBox()
{
Height = 40;
2017-02-08 02:19:58 +00:00
TextContainer.Height = 0.5f;
2017-01-30 11:29:04 +00:00
CornerRadius = 5;
}
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
BorderColour = colour.Yellow;
}
protected override bool OnFocus(InputState state)
{
BorderThickness = 3;
return base.OnFocus(state);
}
protected override void OnFocusLost(InputState state)
{
BorderThickness = 0;
base.OnFocusLost(state);
}
2017-02-08 02:19:58 +00:00
protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), TextSize = CalculatedTextSize };
2017-01-30 11:29:04 +00:00
}
}