<DefaultWindow xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="{Loc 'hand-labeler-ui-header'}">
- <BoxContainer Orientation="Vertical" SeparationOverride="4" MinWidth="150">
+ Title="{Loc 'hand-labeler-ui-header'}"
+ SetWidth="400"
+ MinWidth="150">
+ <BoxContainer Orientation="Vertical" SeparationOverride="4">
<Label Name="CurrentTextLabel" Text="{Loc 'hand-labeler-current-text-label'}" />
<LineEdit Name="LabelLineEdit" />
+ <BoxContainer Orientation="Horizontal" Align="Center">
+ <Button Name="ResetLabelButton" Text="{Loc 'hand-labeler-ui-reset-label-text'}" StyleClasses="OpenRight" />
+ <Button Name="ClearLabelButton" Text="{Loc 'hand-labeler-ui-clear-label-text'}" StyleClasses="OpenLeft" />
+ </BoxContainer>
</BoxContainer>
</DefaultWindow>
// TODO LineEdit Make this a bool on the LineEdit control
private string _label = string.Empty;
+ private string _initialLabel = string.Empty;
public HandLabelerWindow()
{
{
_label = e.Text;
OnLabelChanged?.Invoke(_label);
+ UpdateButtons();
};
LabelLineEdit.OnFocusEnter += _ => _focused = true;
_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();
_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)
# The content of the label in the UI above the text entry input.
hand-labeler-current-text-label = Label:
+# The text on the button in the UI to reset the text entry input to the content it had when the UI was opened
+hand-labeler-ui-reset-label-text = Reset
+
+# The text on the button in the UI to clear the text entry input
+hand-labeler-ui-clear-label-text = Clear
+
# When the hand labeler applies a label successfully
hand-labeler-successfully-applied = Applied label successfully