2019-01-24 17:43:03 +09:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-07-20 13:05:19 +03:00
|
|
|
|
|
2018-07-25 18:38:50 +09:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-07-20 13:05:19 +03:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-09-08 19:51:31 +09:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-07-25 18:34:47 +09:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2018-07-24 09:46:24 +03:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-07-20 13:05:19 +03:00
|
|
|
|
|
2019-09-24 19:00:26 +09:00
|
|
|
|
namespace osu.Game.Graphics.UserInterfaceV2
|
2018-07-20 13:05:19 +03:00
|
|
|
|
{
|
2019-10-28 15:33:08 +09:00
|
|
|
|
public class LabelledTextBox : LabelledComponent<OsuTextBox, string>
|
2018-07-20 13:05:19 +03:00
|
|
|
|
{
|
2018-07-25 18:34:47 +09:00
|
|
|
|
public event TextBox.OnCommitHandler OnCommit;
|
2018-07-24 22:33:19 +03:00
|
|
|
|
|
2019-09-20 18:50:50 +09:00
|
|
|
|
public LabelledTextBox()
|
|
|
|
|
: base(false)
|
2018-07-20 13:05:19 +03:00
|
|
|
|
{
|
|
|
|
|
}
|
2018-07-24 22:33:19 +03:00
|
|
|
|
|
2019-09-20 18:50:50 +09:00
|
|
|
|
public bool ReadOnly
|
2018-07-20 13:05:19 +03:00
|
|
|
|
{
|
2019-09-20 18:50:50 +09:00
|
|
|
|
set => Component.ReadOnly = value;
|
2018-07-20 13:05:19 +03:00
|
|
|
|
}
|
2018-07-24 22:33:19 +03:00
|
|
|
|
|
2018-07-23 15:44:10 +03:00
|
|
|
|
public string PlaceholderText
|
2018-07-20 13:05:19 +03:00
|
|
|
|
{
|
2019-09-20 18:50:50 +09:00
|
|
|
|
set => Component.PlaceholderText = value;
|
2018-07-20 13:05:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-23 15:44:10 +03:00
|
|
|
|
public string Text
|
2018-07-20 13:05:19 +03:00
|
|
|
|
{
|
2019-09-20 18:50:50 +09:00
|
|
|
|
set => Component.Text = value;
|
2018-07-20 13:05:19 +03:00
|
|
|
|
}
|
2018-07-25 18:38:50 +09:00
|
|
|
|
|
2020-09-08 19:51:31 +09:00
|
|
|
|
public Container TabbableContentContainer
|
|
|
|
|
{
|
|
|
|
|
set => Component.TabbableContentContainer = value;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-25 18:38:50 +09:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2019-09-20 18:50:50 +09:00
|
|
|
|
Component.BorderColour = colours.Blue;
|
2018-07-25 18:38:50 +09:00
|
|
|
|
}
|
2019-09-20 18:50:50 +09:00
|
|
|
|
|
2020-09-24 18:18:50 +09:00
|
|
|
|
protected virtual OsuTextBox CreateTextBox() => new OsuTextBox
|
2019-09-20 18:50:50 +09:00
|
|
|
|
{
|
2020-09-25 14:25:24 +09:00
|
|
|
|
CommitOnFocusLost = true,
|
2019-09-20 18:50:50 +09:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
CornerRadius = CORNER_RADIUS,
|
2020-09-24 18:18:50 +09:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected override OsuTextBox CreateComponent() => CreateTextBox().With(t =>
|
|
|
|
|
{
|
|
|
|
|
t.OnCommit += (sender, newText) => OnCommit?.Invoke(sender, newText);
|
|
|
|
|
});
|
2018-07-20 13:05:19 +03:00
|
|
|
|
}
|
|
|
|
|
}
|