use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class ImageTextButtonListeners method imageTextButtonPaddingListener.
public static EventListener imageTextButtonPaddingListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simImageTextButton = (DialogSceneComposerModel.SimImageTextButton) 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 padLeft = popTable.findActor("pad-left");
Spinner padRight = popTable.findActor("pad-right");
Spinner padTop = popTable.findActor("pad-top");
Spinner padBottom = popTable.findActor("pad-bottom");
events.imageTextButtonPadding((float) padLeft.getValue(), (float) padRight.getValue(), (float) padTop.getValue(), (float) padBottom.getValue());
}
};
var label = new Label("Padding:", skin, "scene-label-colored");
popTable.add(label).colspan(2);
popTable.row();
popTable.defaults().right().spaceRight(5);
label = new Label("Left:", skin, "scene-label-colored");
popTable.add(label);
var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-left");
spinner.setValue(simImageTextButton.padLeft);
popTable.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 contents.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
popTable.row();
label = new Label("Right:", skin, "scene-label-colored");
popTable.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-right");
spinner.setValue(simImageTextButton.padRight);
popTable.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 contents.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
popTable.row();
label = new Label("Top:", skin, "scene-label-colored");
popTable.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-top");
spinner.setValue(simImageTextButton.padTop);
popTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding on the top of the contents.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
popTable.row();
label = new Label("Bottom:", skin, "scene-label-colored");
popTable.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-bottom");
spinner.setValue(simImageTextButton.padBottom);
popTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding on the bottom of the contents.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class ProgressBarListeners method progressBarNameListener.
public static EventListener progressBarNameListener(final DialogSceneComposer dialogSceneComposer) {
var simList = (DialogSceneComposerModel.SimProgressBar) 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("Name:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
textField.setText(simList.name);
popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
textField.addListener(ibeamListener);
textField.addListener(new TextTooltip("The name of the ProgressBar to allow for convenient searching via Group#findActor().", tooltipManager, skin, "scene"));
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogSceneComposer.events.progressBarName(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 ProgressBarListeners method progressBarValueSettingsListener.
public static EventListener progressBarValueSettingsListener(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 table = new Table();
popTable.add(table);
var label = new Label("Value:", skin, "scene-label-colored");
table.add(label);
var valueSpinner = new Spinner(simProgressBar.value, simProgressBar.increment, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
valueSpinner.setMinimum(simProgressBar.minimum);
valueSpinner.setMaximum(simProgressBar.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 ProgressBar.", tooltipManager, skin, "scene"));
valueSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.progressBarValue((float) valueSpinner.getValue());
}
});
table.row();
label = new Label("Minimum:", skin, "scene-label-colored");
table.add(label);
var minimumSpinner = new Spinner(simProgressBar.minimum, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
minimumSpinner.setMaximum(simProgressBar.maximum);
var maximumSpinner = new Spinner(simProgressBar.maximum, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
maximumSpinner.setMinimum(simProgressBar.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 ProgressBar.", tooltipManager, skin, "scene"));
minimumSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.progressBarMinimum((float) minimumSpinner.getValue());
if (valueSpinner.getValue() < minimumSpinner.getValue()) {
valueSpinner.setValue(simProgressBar.minimum);
}
maximumSpinner.setMinimum(simProgressBar.minimum);
}
});
table.row();
label = new Label("Maximum:", skin, "scene-label-colored");
table.add(label);
maximumSpinner.setValue(simProgressBar.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 ProgressBar.", tooltipManager, skin, "scene"));
maximumSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.progressBarMaximum((float) maximumSpinner.getValue());
if (valueSpinner.getValue() > maximumSpinner.getValue()) {
valueSpinner.setValue(simProgressBar.maximum);
}
minimumSpinner.setMaximum(simProgressBar.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(simProgressBar.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 ProgressBar.", tooltipManager, skin, "scene"));
incrementSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.progressBarIncrement((float) incrementSpinner.getValue());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class ProgressBarListeners method progressBarDisabledListener.
public static EventListener progressBarDisabledListener(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("Disabled:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simProgressBar.disabled ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simProgressBar.disabled);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the ProgressBar is disabled initially.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.progressBarDisabled(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class SelectBoxListeners method selectBoxScrollingListener.
public static EventListener selectBoxScrollingListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simSelectBox = (DialogSceneComposerModel.SimSelectBox) 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("Scrolling Disabled:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simSelectBox.scrollingDisabled ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simSelectBox.scrollingDisabled);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the SelectBox scrolling is diabled", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.selectBoxScrollingDisabled(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
Aggregations