mirror of https://github.com/ppy/osu
Use new placeholder logic.
This commit is contained in:
parent
84096b146e
commit
a6f02106a4
|
@ -3,6 +3,8 @@
|
|||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
@ -19,6 +21,13 @@ public class OsuTextBox : TextBox
|
|||
|
||||
protected override float LeftRightPadding => 10;
|
||||
|
||||
protected override SpriteText CreatePlaceholder() => new OsuSpriteText
|
||||
{
|
||||
Font = @"Exo2.0-MediumItalic",
|
||||
Colour = new Color4(180, 180, 180, 255),
|
||||
Margin = new MarginPadding { Left = 2 },
|
||||
};
|
||||
|
||||
public OsuTextBox()
|
||||
{
|
||||
Height = 40;
|
||||
|
|
|
@ -26,16 +26,16 @@ public Bindable<string> Bindable
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override string InternalText
|
||||
|
||||
public OptionTextBox()
|
||||
{
|
||||
get { return base.InternalText; }
|
||||
set
|
||||
{
|
||||
base.InternalText = value;
|
||||
if (bindable != null)
|
||||
bindable.Value = value;
|
||||
}
|
||||
OnChange += onChange;
|
||||
}
|
||||
|
||||
private void onChange(TextBox sender, bool newText)
|
||||
{
|
||||
if (bindable != null)
|
||||
bindable.Value = Text;
|
||||
}
|
||||
|
||||
private void bindableValueChanged(object sender, EventArgs e)
|
||||
|
|
|
@ -19,7 +19,7 @@ public class LoginOptions : OptionsSubsection, IOnlineComponent
|
|||
{
|
||||
private bool bounding = true;
|
||||
|
||||
protected override string Header => "Sign In";
|
||||
protected override string Header => "Account";
|
||||
|
||||
public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty;
|
||||
|
||||
|
@ -112,11 +112,13 @@ private void load(APIAccess api, OsuConfigManager config)
|
|||
{
|
||||
username = new OsuTextBox
|
||||
{
|
||||
PlaceholderText = "Username",
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = api?.Username ?? string.Empty
|
||||
},
|
||||
password = new OsuPasswordTextBox
|
||||
{
|
||||
PlaceholderText = "Password",
|
||||
RelativeSizeAxes = Axes.X
|
||||
},
|
||||
saveUsername = new OsuCheckbox
|
||||
|
|
|
@ -34,38 +34,11 @@ public bool HoldFocus
|
|||
}
|
||||
}
|
||||
|
||||
private SpriteText placeholder;
|
||||
|
||||
protected override string InternalText
|
||||
{
|
||||
get { return base.InternalText; }
|
||||
set
|
||||
{
|
||||
base.InternalText = value;
|
||||
if (placeholder != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
placeholder.Text = "type to search";
|
||||
else
|
||||
placeholder.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SearchTextBox()
|
||||
{
|
||||
Height = 35;
|
||||
Add(new Drawable[]
|
||||
{
|
||||
placeholder = new SpriteText
|
||||
{
|
||||
Font = @"Exo2.0-MediumItalic",
|
||||
Text = "type to search",
|
||||
Colour = new Color4(180, 180, 180, 255),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 10 },
|
||||
},
|
||||
new TextAwesome
|
||||
{
|
||||
Icon = FontAwesome.fa_search,
|
||||
|
@ -74,6 +47,8 @@ public SearchTextBox()
|
|||
Margin = new MarginPadding { Right = 10 },
|
||||
}
|
||||
});
|
||||
|
||||
PlaceholderText = "type to search";
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
|
Loading…
Reference in New Issue