use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class CellListeners method cellAddCellListener.
public static EventListener cellAddCellListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simCell = (DialogSceneComposerModel.SimCell) simActor;
var simTable = (SimTable) simActor.parent;
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("New Cell", skin, "scene-label-colored");
table.add(label);
table.row();
var subTable = new Table();
table.add(subTable);
subTable.add();
var button = new Button(skin, "scene-add-up");
button.setDisabled(simCell.row == 0);
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new cell at the end of the row above.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAddCellAbove();
popTable.hide();
}
});
subTable.add();
subTable.row();
button = new Button(skin, "scene-add-left");
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new cell to the left of the current one.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAddCellToLeft();
popTable.hide();
}
});
subTable.add();
button = new Button(skin, "scene-add-right");
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new cell to the right of the current one.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAddCellToRight();
popTable.hide();
}
});
subTable.row();
subTable.add();
button = new Button(skin, "scene-add-down");
button.setDisabled(simCell.row == simTable.getRows() - 1);
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new cell at the end of the row below.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAddCellBelow();
popTable.hide();
}
});
subTable.add();
table.row();
label = new Label("New Row", skin, "scene-label-colored");
table.add(label);
table.row();
subTable = new Table();
table.add(subTable);
button = new Button(skin, "scene-add-down-row");
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new row below and adds a cell to it.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAddRowBelow();
popTable.hide();
}
});
button = new Button(skin, "scene-add-up-row");
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new row above and adds a cell to it.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAddRowAbove();
popTable.hide();
}
});
var image = new Image(skin, "scene-menu-divider");
popTable.add(image).space(10).growY();
table = new Table();
popTable.add(table);
label = new Label("Duplicate Cell", skin, "scene-label-colored");
table.add(label);
table.row();
subTable = new Table();
table.add(subTable);
subTable.add();
button = new Button(skin, "scene-duplicate-up");
subTable.add(button);
button.setDisabled(simCell.row == 0);
button.addListener(handListener);
button.addListener(new TextTooltip("Duplicates the cell to the row above.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellDuplicateCellAbove();
popTable.hide();
}
});
subTable.add();
subTable.row();
button = new Button(skin, "scene-duplicate-left");
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new cell to the left of the current one.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellDuplicateCellLeft();
popTable.hide();
}
});
subTable.add();
button = new Button(skin, "scene-duplicate-right");
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new cell to the right of the current one.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellDuplicateCellRight();
popTable.hide();
}
});
subTable.row();
subTable.add();
button = new Button(skin, "scene-duplicate-down");
subTable.add(button);
button.setDisabled(simCell.row == simTable.getRows() - 1);
button.addListener(handListener);
button.addListener(new TextTooltip("Duplicates the cell to the row below.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellDuplicateCellBelow();
popTable.hide();
}
});
subTable.add();
table.row();
label = new Label("Dup. to New Row", skin, "scene-label-colored");
table.add(label);
table.row();
subTable = new Table();
table.add(subTable);
button = new Button(skin, "scene-duplicate-down-row");
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new row below and adds a cell to it.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellDuplicateCellNewRowBelow();
popTable.hide();
}
});
button = new Button(skin, "scene-duplicate-up-row");
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Creates a new row below and adds a cell to it.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellDuplicateCellNewRowAbove();
popTable.hide();
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class ContainerListeners method containerPaddingListener.
public static EventListener containerPaddingListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simContainer = (DialogSceneComposerModel.SimContainer) 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 paddingLeft = popTable.findActor("padding-left");
Spinner paddingRight = popTable.findActor("padding-right");
Spinner paddingTop = popTable.findActor("padding-top");
Spinner paddingBottom = popTable.findActor("padding-bottom");
events.containerPadding((float) paddingLeft.getValue(), (float) paddingRight.getValue(), (float) paddingTop.getValue(), (float) paddingBottom.getValue());
}
};
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(simContainer.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 on the left of the container.", 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(simContainer.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 on the right of the container.", 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(simContainer.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 on the top of the container.", 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(simContainer.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 on the bottom of the container.", 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 ContainerListeners method containerSizeListener.
public static EventListener containerSizeListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simContainer = (DialogSceneComposerModel.SimContainer) 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 changeListener = new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Spinner minimumWidth = popTable.findActor("minimum-width");
Spinner minimumHeight = popTable.findActor("minimum-height");
Spinner maximumWidth = popTable.findActor("maximum-width");
Spinner maximumHeight = popTable.findActor("maximum-height");
Spinner preferredWidth = popTable.findActor("preferred-width");
Spinner preferredHeight = popTable.findActor("preferred-height");
events.containerSize((float) minimumWidth.getValue(), (float) minimumHeight.getValue(), (float) maximumWidth.getValue(), (float) maximumHeight.getValue(), (float) preferredWidth.getValue(), (float) preferredHeight.getValue());
}
};
var label = new Label("Minimum:", skin, "scene-label-colored");
table.add(label).colspan(2);
table.row();
table.defaults().right().spaceRight(5);
label = new Label("Width:", skin, "scene-label-colored");
table.add(label);
var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("minimum-width");
spinner.setValue(simContainer.minWidth);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The minimum width of the contents of the container.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
table.row();
label = new Label("Height:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("minimum-height");
spinner.setValue(simContainer.minHeight);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The minimum height of the contents of the container.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
var image = new Image(skin, "scene-menu-divider");
popTable.add(image).space(10).growY();
table = new Table();
popTable.add(table);
label = new Label("Maximum:", skin, "scene-label-colored");
table.add(label).colspan(2);
table.row();
table.defaults().right().spaceRight(5);
label = new Label("Width:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("maximum-width");
spinner.setValue(simContainer.maxWidth);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The maximum width of the contents of the container.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
table.row();
label = new Label("Height:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("maximum-height");
spinner.setValue(simContainer.maxHeight);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The maximum height of the contents of the container.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
image = new Image(skin, "scene-menu-divider");
popTable.add(image).space(10).growY();
table = new Table();
popTable.add(table);
label = new Label("Preferred:", skin, "scene-label-colored");
table.add(label).colspan(2);
table.row();
table.defaults().right().spaceRight(5);
label = new Label("Width:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("preferred-width");
spinner.setValue(simContainer.preferredWidth);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The preferred width of the contents of the container.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
table.row();
label = new Label("Height:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("preferred-height");
spinner.setValue(simContainer.preferredHeight);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The preferred height of the contents of the container.", 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 ContainerListeners method containerAlignmentListener.
public static EventListener containerAlignmentListener(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 simContainer = (DialogSceneComposerModel.SimContainer) 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 container to the top left.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.containerAlignment(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 container to the top center.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.containerAlignment(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 container to the top right.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.containerAlignment(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 container to the middle left.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.containerAlignment(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 container to the center.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.containerAlignment(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 container to the middle right.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.containerAlignment(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 container to the bottom left.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.containerAlignment(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 container to the bottom center.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.containerAlignment(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 container to the bottom right.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.containerAlignment(Align.bottomRight);
}
});
buttonGroup.add(imageTextButton);
switch(simContainer.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.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class ButtonListeners method buttonDisabledListener.
public static EventListener buttonDisabledListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simButton = (DialogSceneComposerModel.SimButton) 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(simButton.disabled ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simButton.disabled);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the button 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.buttonDisabled(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
Aggregations