From 5a89ba10404ca14bf81240302a1899cdf58442c7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 8 Feb 2017 11:19:58 +0900 Subject: [PATCH] Make OsuTextBox use OsuSpriteText. --- osu.Game/Graphics/UserInterface/OsuTextBox.cs | 7 ++++++- osu.Game/Screens/Select/SearchTextBox.cs | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTextBox.cs b/osu.Game/Graphics/UserInterface/OsuTextBox.cs index ae1b1f7a18..0590c0e79b 100644 --- a/osu.Game/Graphics/UserInterface/OsuTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTextBox.cs @@ -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 diff --git a/osu.Game/Screens/Select/SearchTextBox.cs b/osu.Game/Screens/Select/SearchTextBox.cs index 39f9fd0f80..b8ba491f8f 100644 --- a/osu.Game/Screens/Select/SearchTextBox.cs +++ b/osu.Game/Screens/Select/SearchTextBox.cs @@ -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))