use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class TextFieldListeners method textFieldPasswordListener.
public static EventListener textFieldPasswordListener(final DialogSceneComposer dialogSceneComposer) {
var simTextField = (DialogSceneComposerModel.SimTextField) dialogSceneComposer.simActor;
var textField = new TextField("", skin, "scene");
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
dialogSceneComposer.getStage().setKeyboardFocus(textField);
textField.setSelection(0, textField.getText().length());
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Password Character:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
textField.setText(Character.toString(simTextField.passwordCharacter));
textField.setMaxLength(1);
popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
textField.addListener(ibeamListener);
textField.addListener(new TextTooltip("The character used to obscure text when password mode is enabled.", tooltipManager, skin, "scene"));
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (textField.getText().length() > 0) {
dialogSceneComposer.events.textFieldPasswordCharacter(textField.getText().charAt(0));
} else {
dialogSceneComposer.events.textFieldPasswordCharacter('*');
}
}
});
textField.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Input.Keys.ENTER || keycode == Keys.NUMPAD_ENTER) {
popTable.hide();
return true;
} else {
return false;
}
}
});
popTable.row();
label = new Label("Password Mode:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simTextField.passwordMode ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simTextField.passwordMode);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether password mode is enabled for the TextField.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
dialogSceneComposer.events.textFieldPasswordMode(textButton.isChecked());
}
});
dialogSceneComposer.getStage().setKeyboardFocus(textField);
textField.setSelection(0, textField.getText().length());
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class TextFieldListeners method textFieldFocusTraversalListener.
public static EventListener textFieldFocusTraversalListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTextField = (DialogSceneComposerModel.SimTextField) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Focus Traversal:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simTextField.focusTraversal ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simTextField.focusTraversal);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the text field allows for the use of focus traversal keys.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.textFieldFocusTraversal(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class TextFieldListeners method textFieldAlignmentListener.
public static EventListener textFieldAlignmentListener(final DialogSceneComposerEvents events, final SimActor simActor) {
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var simTextField = (DialogSceneComposerModel.SimTextField) simActor;
var popTable = getPopTable();
popTable.clearChildren();
var table = new Table();
popTable.add(table);
var label = new Label("Alignment:", skin, "scene-label-colored");
table.add(label).colspan(3);
table.row();
table.defaults().space(10).left().uniformX();
var buttonGroup = new ButtonGroup<ImageTextButton>();
var imageTextButton = new ImageTextButton("Top-Left", skin, "scene-checkbox-colored");
var topLeft = imageTextButton;
imageTextButton.setProgrammaticChangeEvents(false);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Align the contents of the TextField to the top left.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldAlignment(Align.topLeft);
}
});
buttonGroup.add(imageTextButton);
imageTextButton = new ImageTextButton("Top", skin, "scene-checkbox-colored");
var top = imageTextButton;
imageTextButton.setProgrammaticChangeEvents(false);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Align the contents of the TextField to the top center.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldAlignment(Align.top);
}
});
buttonGroup.add(imageTextButton);
imageTextButton = new ImageTextButton("Top-Right", skin, "scene-checkbox-colored");
var topRight = imageTextButton;
imageTextButton.setProgrammaticChangeEvents(false);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Align the contents of the TextField to the top right.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldAlignment(Align.topRight);
}
});
buttonGroup.add(imageTextButton);
table.row();
imageTextButton = new ImageTextButton("Left", skin, "scene-checkbox-colored");
var left = imageTextButton;
imageTextButton.setProgrammaticChangeEvents(false);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Align the contents of the TextField to the middle left.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldAlignment(Align.left);
}
});
buttonGroup.add(imageTextButton);
imageTextButton = new ImageTextButton("Center", skin, "scene-checkbox-colored");
var center = imageTextButton;
imageTextButton.setProgrammaticChangeEvents(false);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Align the contents of the TextField to the center.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldAlignment(Align.center);
}
});
buttonGroup.add(imageTextButton);
imageTextButton = new ImageTextButton("Right", skin, "scene-checkbox-colored");
var right = imageTextButton;
imageTextButton.setProgrammaticChangeEvents(false);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Align the contents of the TextField to the middle right.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldAlignment(Align.right);
}
});
buttonGroup.add(imageTextButton);
table.row();
imageTextButton = new ImageTextButton("Bottom-Left", skin, "scene-checkbox-colored");
var bottomLeft = imageTextButton;
imageTextButton.setProgrammaticChangeEvents(false);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Align the contents of the TextField to the bottom left.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldAlignment(Align.bottomLeft);
}
});
buttonGroup.add(imageTextButton);
imageTextButton = new ImageTextButton("Bottom", skin, "scene-checkbox-colored");
var bottom = imageTextButton;
imageTextButton.setProgrammaticChangeEvents(false);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Align the contents of the TextField to the bottom center.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldAlignment(Align.bottom);
}
});
buttonGroup.add(imageTextButton);
imageTextButton = new ImageTextButton("Bottom-Right", skin, "scene-checkbox-colored");
var bottomRight = imageTextButton;
imageTextButton.setProgrammaticChangeEvents(false);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Align the contents of the TextField to the bottom right.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldAlignment(Align.bottomRight);
}
});
buttonGroup.add(imageTextButton);
switch(simTextField.alignment) {
case Align.topLeft:
topLeft.setChecked(true);
break;
case Align.top:
top.setChecked(true);
break;
case Align.topRight:
topRight.setChecked(true);
break;
case Align.right:
right.setChecked(true);
break;
case Align.bottomRight:
bottomRight.setChecked(true);
break;
case Align.bottom:
bottom.setChecked(true);
break;
case Align.bottomLeft:
bottomLeft.setChecked(true);
break;
case Align.left:
left.setChecked(true);
break;
case Align.center:
center.setChecked(true);
break;
}
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class TextFieldListeners method textFieldTextListener.
public static EventListener textFieldTextListener(final DialogSceneComposer dialogSceneComposer) {
var simTextField = (DialogSceneComposerModel.SimTextField) dialogSceneComposer.simActor;
var textField = new TextField("", skin, "scene");
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
dialogSceneComposer.getStage().setKeyboardFocus(textField);
textField.setSelection(0, textField.getText().length());
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Text:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
textField.setText(simTextField.text);
popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
textField.addListener(ibeamListener);
textField.addListener(new TextTooltip("The default text inside the TextField.", tooltipManager, skin, "scene"));
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogSceneComposer.events.textFieldText(textField.getText());
}
});
textField.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Input.Keys.ENTER || keycode == Keys.NUMPAD_ENTER) {
popTable.hide();
return true;
} else {
return false;
}
}
});
dialogSceneComposer.getStage().setKeyboardFocus(textField);
textField.setSelection(0, textField.getText().length());
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class TreeListeners method treePaddingListener.
public static EventListener treePaddingListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTree = (SimTree) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ENTER, popTable::hide);
getPopTable().key(Keys.NUMPAD_ENTER, popTable::hide);
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void tableShown(Event event) {
var popTable = getPopTable();
popTable.clearChildren();
var table = new Table();
popTable.add(table);
table.defaults().right().spaceRight(5);
var label = new Label("Left:", skin, "scene-label-colored");
table.add(label);
var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simTree.padLeft);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding on the left of the Tree.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.treePadLeft((float) ((Spinner) actor).getValue());
}
});
table.row();
label = new Label("Right:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simTree.padRight);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding on the right of the Tree.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.treePadLeft((float) ((Spinner) actor).getValue());
}
});
}
};
return popTableClickListener;
}
Aggregations