Hand labeler UI improvements (#40318)
* Populate and select label line edit on window open * Widen hand labeller UI * Add reset and clear buttons to hand labeler UI * Add window resizing fix from https://github.com/space-wizards/space-station-14/pull/40322 * xaml cleanup, button grouping
This commit is contained in:
@@ -16,6 +16,7 @@ namespace Content.Client.Labels.UI
|
||||
// TODO LineEdit Make this a bool on the LineEdit control
|
||||
|
||||
private string _label = string.Empty;
|
||||
private string _initialLabel = string.Empty;
|
||||
|
||||
public HandLabelerWindow()
|
||||
{
|
||||
@@ -25,6 +26,7 @@ namespace Content.Client.Labels.UI
|
||||
{
|
||||
_label = e.Text;
|
||||
OnLabelChanged?.Invoke(_label);
|
||||
UpdateButtons();
|
||||
};
|
||||
|
||||
LabelLineEdit.OnFocusEnter += _ => _focused = true;
|
||||
@@ -33,12 +35,14 @@ namespace Content.Client.Labels.UI
|
||||
_focused = false;
|
||||
LabelLineEdit.Text = _label;
|
||||
};
|
||||
ResetLabelButton.OnPressed += _ => LabelLineEdit.SetText(_initialLabel, true);
|
||||
ClearLabelButton.OnPressed += _ => LabelLineEdit.SetText("", true);
|
||||
}
|
||||
|
||||
protected override void Opened()
|
||||
{
|
||||
base.Opened();
|
||||
|
||||
|
||||
// Give the editor keyboard focus, since that's the only
|
||||
// thing the user will want to be doing with this UI
|
||||
LabelLineEdit.GrabKeyboardFocus();
|
||||
@@ -51,7 +55,25 @@ namespace Content.Client.Labels.UI
|
||||
|
||||
_label = label;
|
||||
if (!_focused)
|
||||
{
|
||||
LabelLineEdit.Text = label;
|
||||
UpdateButtons();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInitialLabelState()
|
||||
{
|
||||
LabelLineEdit.Text = _label;
|
||||
LabelLineEdit.CursorPosition = _label.Length;
|
||||
LabelLineEdit.SelectionStart = 0;
|
||||
_initialLabel = _label;
|
||||
UpdateButtons();
|
||||
}
|
||||
|
||||
public void UpdateButtons()
|
||||
{
|
||||
ResetLabelButton.Disabled = (LabelLineEdit.Text == _initialLabel);
|
||||
ClearLabelButton.Disabled = (LabelLineEdit.Text == "");
|
||||
}
|
||||
|
||||
public void SetMaxLabelLength(int maxLength)
|
||||
|
||||
Reference in New Issue
Block a user