use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class ListListeners method listTextListListener.
public static EventListener listTextListListener(final DialogSceneComposer dialogSceneComposer) {
var simList = (DialogSceneComposerModel.SimList) dialogSceneComposer.simActor;
var textField = new TextField("", skin, "scene");
textField.setFocusTraversal(false);
var draggableTextList = new DraggableTextList(true, skin, "scene-unchecked");
draggableTextList.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogSceneComposer.events.listList(draggableTextList.getTexts());
}
});
var scrollPane = new ScrollPane(draggableTextList, skin, "scene");
scrollPane.setFadeScrollBars(false);
scrollPane.addListener(scrollFocusListener);
var popTableClickListener = new PopTableClickListener(skin) {
{
popTable.key(Keys.ESCAPE, popTable::hide);
popTable.setAutomaticallyResized(true);
textField.addListener(ibeamListener);
textField.addListener(new TextTooltip("The text to add to the list.", tooltipManager, skin, "scene"));
textField.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Input.Keys.ENTER || keycode == Keys.NUMPAD_ENTER) {
addItem(textField.getText());
return true;
} else {
return false;
}
}
});
}
@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("List Entries:\n(Drag to change order)", skin, "scene-label-colored");
label.setAlignment(Align.center);
popTable.add(label).colspan(2);
popTable.row();
draggableTextList.clearChildren();
draggableTextList.addAllTexts(simList.list);
popTable.add(scrollPane).colspan(2).minHeight(150).growX();
popTable.row();
label = new Label("Add New Item:", skin, "scene-label-colored");
popTable.add(label).colspan(2).padTop(10);
popTable.row();
textField.setText("");
popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
var textButton = new Button(skin, "scene-plus");
popTable.add(textButton);
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
addItem(textField.getText());
}
});
dialogSceneComposer.getStage().setKeyboardFocus(textField);
dialogSceneComposer.getStage().setScrollFocus(scrollPane);
}
public void addItem(String item) {
draggableTextList.addText(item);
dialogSceneComposer.events.listList(draggableTextList.getTexts());
update();
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class ProgressBarListeners method progressBarOrientationListener.
public static EventListener progressBarOrientationListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simProgressBar = (DialogSceneComposerModel.SimProgressBar) 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("Orientation:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var draggableTextList = new DraggableTextList(true, skin, "scene");
draggableTextList.setDraggable(false);
draggableTextList.addAllTexts("Horizontal", "Vertical");
draggableTextList.setSelected(simProgressBar.vertical ? 1 : 0);
popTable.add(draggableTextList);
draggableTextList.addListener(handListener);
draggableTextList.addListener(new TextTooltip("The orientation of the ProgressBar.", tooltipManager, skin, "scene"));
draggableTextList.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.progressBarVertical(draggableTextList.getSelectedIndex() == 1);
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class ProgressBarListeners method progressBarRoundListener.
public static EventListener progressBarRoundListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simProgressBar = (DialogSceneComposerModel.SimProgressBar) 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("Round:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simProgressBar.round ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simProgressBar.round);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the ProgressBar inner positions are rounded to integer.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.progressBarRound(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class ProgressBarListeners method progressBarAnimationListener.
public static EventListener progressBarAnimationListener(final DialogSceneComposer dialogSceneComposer) {
var simProgressBar = (DialogSceneComposerModel.SimProgressBar) dialogSceneComposer.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 table = new Table();
popTable.add(table);
table.defaults().spaceRight(5);
var textButton = new TextButton("Animate Interpolation", skin, "scene-med");
table.add(textButton).uniformX().fillX().colspan(2);
textButton.addListener(handListener);
textButton.addListener(GeneralListeners.interpolationListener(dialogSceneComposer, selection -> dialogSceneComposer.events.progressBarAnimateInterpolation(selection)));
table.row();
textButton = new TextButton("Visual Interpolation", skin, "scene-med");
table.add(textButton).uniformX().fillX().colspan(2);
textButton.addListener(handListener);
textButton.addListener(GeneralListeners.interpolationListener(dialogSceneComposer, selection -> dialogSceneComposer.events.progressBarVisualInterpolation(selection)));
table.row();
var label = new Label("Animation Duration:", skin, "scene-label-colored");
table.add(label).right();
var durationSpinner = new Spinner(simProgressBar.animationDuration, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
durationSpinner.setMinimum(0);
table.add(durationSpinner).left();
durationSpinner.getTextField().addListener(ibeamListener);
durationSpinner.getButtonMinus().addListener(handListener);
durationSpinner.getButtonPlus().addListener(handListener);
durationSpinner.addListener(new TextTooltip("The animation duration of the ProgressBar as the value changes.", tooltipManager, skin, "scene"));
durationSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogSceneComposer.events.progressBarAnimationDuration((float) durationSpinner.getValue());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class TextFieldListeners method textFieldMessageTextListener.
public static EventListener textFieldMessageTextListener(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("Message Text:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
textField.setText(simTextField.messageText);
popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
textField.addListener(ibeamListener);
textField.addListener(new TextTooltip("The message inside the field when nothing is inputted and the field does not have focus.", tooltipManager, skin, "scene"));
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogSceneComposer.events.textFieldMessageText(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;
}
Aggregations