use of com.ray3k.skincomposer.utils.IntPair in project skin-composer by raeleus.
the class TableListeners method tableSetCellsListener.
public static EventListener tableSetCellsListener(final DialogSceneComposerEvents events) {
var popTableClickListener = new PopTableClickListener(skin, "dark");
var popTable = popTableClickListener.getPopTable();
popTable.key(Keys.ESCAPE, popTable::hide);
var label = new Label("Erase contents\nand create\nnew cells:", skin, "scene-label");
label.setAlignment(Align.center);
popTable.add(label);
label.addListener(new TextTooltip("Sets the cells for this table. This will erase the existing contents.", tooltipManager, skin, "scene"));
popTable.row();
var table = new Table();
popTable.add(table);
table.pad(10).padTop(0);
var buttons = new Button[6][6];
for (int j = 0; j < 6; j++) {
table.row();
for (int i = 0; i < 6; i++) {
var textButton = new Button(skin, "scene-table");
textButton.setProgrammaticChangeEvents(false);
textButton.setUserObject(new IntPair(i, j));
table.add(textButton);
buttons[i][j] = textButton;
textButton.addListener(handListener);
textButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
popTable.hide();
var intPair = (IntPair) textButton.getUserObject();
events.tableSetCells(intPair.x + 1, intPair.y + 1);
}
});
textButton.addListener(new InputListener() {
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
var intPair = (IntPair) textButton.getUserObject();
for (int y1 = 0; y1 < 6; y1++) {
for (int x1 = 0; x1 < 6; x1++) {
buttons[x1][y1].setChecked(y1 <= intPair.y && x1 <= intPair.x);
}
}
textButton.setChecked(true);
}
});
}
}
table.setTouchable(Touchable.enabled);
table.addListener(new InputListener() {
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
for (int y1 = 0; y1 < 6; y1++) {
for (int x1 = 0; x1 < 6; x1++) {
buttons[x1][y1].setChecked(false);
}
}
}
});
return popTableClickListener;
}
use of com.ray3k.skincomposer.utils.IntPair in project skin-composer by raeleus.
the class DialogSceneComposer method rootAddTableListener.
private EventListener rootAddTableListener() {
var popTableClickListener = new PopTableClickListener(skin, "dark");
var popTable = popTableClickListener.getPopTable();
popTable.key(Keys.ESCAPE, popTable::hide);
var label = new Label("New Table:", skin, "scene-label");
popTable.add(label);
label.addListener(new TextTooltip("Creates a base Table and adds it directly to the stage. This will serve as the basis for the rest of your UI layout and will fill the entire screen.", tooltipManager, skin, "scene"));
popTable.row();
var table = new Table();
popTable.add(table);
table.pad(10).padTop(0);
var buttons = new Button[6][6];
for (int j = 0; j < 6; j++) {
table.row();
for (int i = 0; i < 6; i++) {
var textButton = new Button(skin, "scene-table");
textButton.setProgrammaticChangeEvents(false);
textButton.setUserObject(new IntPair(i, j));
table.add(textButton);
buttons[i][j] = textButton;
textButton.addListener(handListener);
textButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
popTable.hide();
var intPair = (IntPair) textButton.getUserObject();
events.rootAddTable(intPair.x + 1, intPair.y + 1);
}
});
textButton.addListener(new InputListener() {
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
var intPair = (IntPair) textButton.getUserObject();
for (int y1 = 0; y1 < 6; y1++) {
for (int x1 = 0; x1 < 6; x1++) {
buttons[x1][y1].setChecked(y1 <= intPair.y && x1 <= intPair.x);
}
}
textButton.setChecked(true);
}
});
}
}
table.setTouchable(Touchable.enabled);
table.addListener(new InputListener() {
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
for (int y1 = 0; y1 < 6; y1++) {
for (int x1 = 0; x1 < 6; x1++) {
buttons[x1][y1].setChecked(false);
}
}
}
});
return popTableClickListener;
}
Aggregations