Make OsuTextBox use OsuSpriteText.

This commit is contained in:
Dean Herbert 2017-02-08 11:19:58 +09:00
parent e720bed9e5
commit 5a89ba1040
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
2 changed files with 15 additions and 3 deletions

View File

@ -8,6 +8,7 @@
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using OpenTK.Graphics;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface
{
@ -17,10 +18,12 @@ public class OsuTextBox : TextBox
protected override Color4 BackgroundFocused => OsuColour.Gray(0.3f).Opacity(0.8f);
protected override Color4 BackgroundCommit => BorderColour;
protected override float LeftRightPadding => 10;
public OsuTextBox()
{
Height = 40;
TextContainer.Height = OsuSpriteText.FONT_SIZE / Height;
TextContainer.Height = 0.5f;
CornerRadius = 5;
}
@ -43,6 +46,8 @@ protected override void OnFocusLost(InputState state)
base.OnFocusLost(state);
}
protected override SpriteText GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString() };
}
public class OsuPasswordTextBox : OsuTextBox

View File

@ -12,10 +12,11 @@
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Select
{
public class SearchTextBox : TextBox
public class SearchTextBox : OsuTextBox
{
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);
protected override Color4 BackgroundFocused => new Color4(10, 10, 10, 255);
@ -54,7 +55,6 @@ protected override string InternalText
public SearchTextBox()
{
Height = 35;
TextContainer.Padding = new MarginPadding(5);
Add(new Drawable[]
{
placeholder = new SpriteText
@ -82,6 +82,13 @@ protected override void Update()
base.Update();
}
protected override bool OnFocus(InputState state)
{
var result = base.OnFocus(state);
BorderThickness = 0;
return result;
}
protected override void OnFocusLost(InputState state)
{
if (state.Keyboard.Keys.Any(key => key == Key.Escape))