mirror of https://github.com/ppy/osu
Make OsuTextBox use OsuSpriteText.
This commit is contained in:
parent
e720bed9e5
commit
5a89ba1040
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue