use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class SliderListeners method sliderAnimationListener.
public static EventListener sliderAnimationListener(final DialogSceneComposer dialogSceneComposer) {
var simSlider = (DialogSceneComposerModel.SimSlider) dialogSceneComposer.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 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.sliderAnimateInterpolation(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.sliderVisualInterpolation(selection)));
table.row();
var label = new Label("Animation Duration:", skin, "scene-label-colored");
table.add(label).right();
var durationSpinner = new Spinner(simSlider.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 Slider as the value changes.", tooltipManager, skin, "scene"));
durationSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogSceneComposer.events.sliderAnimationDuration((float) durationSpinner.getValue());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class SliderListeners method sliderValueSettingsListener.
public static EventListener sliderValueSettingsListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simSlider = (DialogSceneComposerModel.SimSlider) 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 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);
var label = new Label("Value:", skin, "scene-label-colored");
table.add(label);
var valueSpinner = new Spinner(simSlider.value, simSlider.increment, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
valueSpinner.setMinimum(simSlider.minimum);
valueSpinner.setMaximum(simSlider.maximum);
table.add(valueSpinner).width(100).uniformX();
valueSpinner.getTextField().addListener(ibeamListener);
valueSpinner.getButtonMinus().addListener(handListener);
valueSpinner.getButtonPlus().addListener(handListener);
valueSpinner.addListener(new TextTooltip("The value of the Slider.", tooltipManager, skin, "scene"));
valueSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.sliderValue((float) valueSpinner.getValue());
}
});
table.row();
label = new Label("Minimum:", skin, "scene-label-colored");
table.add(label);
var minimumSpinner = new Spinner(simSlider.minimum, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
minimumSpinner.setMaximum(simSlider.maximum);
var maximumSpinner = new Spinner(simSlider.maximum, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
maximumSpinner.setMinimum(simSlider.minimum);
table.add(minimumSpinner).uniformX().fillX();
minimumSpinner.getTextField().addListener(ibeamListener);
minimumSpinner.getButtonMinus().addListener(handListener);
minimumSpinner.getButtonPlus().addListener(handListener);
minimumSpinner.addListener(new TextTooltip("The minimum value of the Slider.", tooltipManager, skin, "scene"));
minimumSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.sliderMinimum((float) minimumSpinner.getValue());
if (valueSpinner.getValue() < minimumSpinner.getValue()) {
valueSpinner.setValue(simSlider.minimum);
}
maximumSpinner.setMinimum(simSlider.minimum);
}
});
table.row();
label = new Label("Maximum:", skin, "scene-label-colored");
table.add(label);
maximumSpinner.setValue(simSlider.maximum);
table.add(maximumSpinner).uniformX().fillX();
maximumSpinner.getTextField().addListener(ibeamListener);
maximumSpinner.getButtonMinus().addListener(handListener);
maximumSpinner.getButtonPlus().addListener(handListener);
maximumSpinner.addListener(new TextTooltip("The maximum value of the Slider.", tooltipManager, skin, "scene"));
maximumSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.sliderMaximum((float) maximumSpinner.getValue());
if (valueSpinner.getValue() > maximumSpinner.getValue()) {
valueSpinner.setValue(simSlider.maximum);
}
minimumSpinner.setMaximum(simSlider.maximum);
}
});
table.row();
label = new Label("Increment:", skin, "scene-label-colored");
table.add(label);
var incrementSpinner = new Spinner(0, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
incrementSpinner.setValue(simSlider.increment);
incrementSpinner.setMinimum(.0000000001);
table.add(incrementSpinner).uniformX().fillX();
incrementSpinner.getTextField().addListener(ibeamListener);
incrementSpinner.getButtonMinus().addListener(handListener);
incrementSpinner.getButtonPlus().addListener(handListener);
incrementSpinner.addListener(new TextTooltip("The increment value of the Slider.", tooltipManager, skin, "scene"));
incrementSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.sliderIncrement((float) incrementSpinner.getValue());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class SliderListeners method sliderRoundListener.
public static EventListener sliderRoundListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simSlider = (DialogSceneComposerModel.SimSlider) 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(simSlider.round ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simSlider.round);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the Slider 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.sliderRound(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class TextAreaListeners method textAreaTextListener.
public static EventListener textAreaTextListener(final DialogSceneComposer dialogSceneComposer) {
var simTextArea = (DialogSceneComposerModel.SimTextArea) 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(simTextArea.text);
popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
textField.addListener(ibeamListener);
textField.addListener(new TextTooltip("The default text inside the TextArea.", tooltipManager, skin, "scene"));
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogSceneComposer.events.textAreaText(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.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class CellListeners method cellPaddingSpacingListener.
public static EventListener cellPaddingSpacingListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simCell = (DialogSceneComposerModel.SimCell) 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 clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var changeListener = new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Spinner paddingLeftSpinner = popTable.findActor("padding-left");
Spinner paddingRightSpinner = popTable.findActor("padding-right");
Spinner paddingTopSpinner = popTable.findActor("padding-top");
Spinner paddingBottomSpinner = popTable.findActor("padding-bottom");
Spinner spacingLeftSpinner = popTable.findActor("spacing-left");
Spinner spacingRightSpinner = popTable.findActor("spacing-right");
Spinner spacingTopSpinner = popTable.findActor("spacing-top");
Spinner spacingBottomSpinner = popTable.findActor("spacing-bottom");
Button paddingLinkButton = popTable.findActor("padding-link");
Button spacingLinkButton = popTable.findActor("spacing-link");
if (paddingLinkButton.isChecked() && actor instanceof Spinner) {
var val = (float) ((Spinner) actor).getValue();
paddingLeftSpinner.setValue(val);
paddingRightSpinner.setValue(val);
paddingTopSpinner.setValue(val);
paddingBottomSpinner.setValue(val);
}
if (spacingLinkButton.isChecked() && actor instanceof Spinner) {
var val = (float) ((Spinner) actor).getValue();
spacingLeftSpinner.setValue(val);
spacingRightSpinner.setValue(val);
spacingTopSpinner.setValue(val);
spacingBottomSpinner.setValue(val);
}
var paddingLeft = (float) paddingLeftSpinner.getValue();
var paddingRight = (float) paddingRightSpinner.getValue();
var paddingTop = (float) paddingTopSpinner.getValue();
var paddingBottom = (float) paddingBottomSpinner.getValue();
var spacingLeft = (float) spacingLeftSpinner.getValue();
var spacingRight = (float) spacingRightSpinner.getValue();
var spacingTop = (float) spacingTopSpinner.getValue();
var spacingBottom = (float) spacingBottomSpinner.getValue();
events.cellPaddingSpacing(paddingLeft, paddingRight, paddingTop, paddingBottom, spacingLeft, spacingRight, spacingTop, spacingBottom);
}
};
var table = new Table();
popTable.add(table);
var label = new Label("Padding:", skin, "scene-label-colored");
table.add(label).colspan(2);
table.row();
table.defaults().right().spaceRight(5);
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(simCell.padLeft);
spinner.setName("padding-left");
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding to the left of the cell. Stacks with other cell padding.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
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(simCell.padRight);
spinner.setName("padding-right");
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding to the right of the cell. Stacks with other cell padding.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
table.row();
label = new Label("Top:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simCell.padTop);
spinner.setName("padding-top");
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding to the top of the cell. Stacks with other cell padding.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
table.row();
label = new Label("Bottom:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simCell.padBottom);
spinner.setName("padding-bottom");
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding to the bottom of the cell. Stacks with other cell padding.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
table.row();
var button = new Button(skin, "scene-link");
button.setName("padding-link");
table.add(button).right().colspan(2);
button.addListener(Main.handListener);
button.addListener(changeListener);
button.addListener(new TextTooltip("Click to modify all padding values at once.", tooltipManager, skin, "scene"));
var image = new Image(skin, "scene-menu-divider");
popTable.add(image).space(10).growY();
table = new Table();
popTable.add(table);
label = new Label("Spacing:", skin, "scene-label-colored");
table.add(label).colspan(2);
table.row();
table.defaults().right().spaceRight(5);
label = new Label("Left:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simCell.spaceLeft);
spinner.setName("spacing-left");
spinner.setMinimum(0);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The spacing to the left of the cell. Does not stack with other cell spacing.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
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(simCell.spaceRight);
spinner.setName("spacing-right");
spinner.setMinimum(0);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The spacing to the right of the cell. Does not stack with other cell spacing.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
table.row();
label = new Label("Top:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simCell.spaceTop);
spinner.setName("spacing-top");
spinner.setMinimum(0);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The spacing to the top of the cell. Does not stack with other cell spacing.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
table.row();
label = new Label("Bottom:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simCell.spaceBottom);
spinner.setName("spacing-bottom");
spinner.setMinimum(0);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The spacing to the bottom of the cell. Does not stack with other cell spacing.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
table.row();
button = new Button(skin, "scene-link");
button.setName("spacing-link");
table.add(button).right().colspan(2);
button.addListener(Main.handListener);
button.addListener(changeListener);
button.addListener(new TextTooltip("Click to modify all spacing values at once.", tooltipManager, skin, "scene"));
}
};
popTableClickListener.update();
return popTableClickListener;
}
Aggregations