use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class TreeListeners method nodeOptionsListener.
public static EventListener nodeOptionsListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simNode = (SimNode) 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();
popTable.pad(10);
var table = new Table();
popTable.add(table).space(5);
table.defaults().left().expandX();
var imageTextButton = new ImageTextButton("Expanded", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simNode.expanded);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Sets whether the children are expanded and visible.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.nodeExpanded(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Selectable", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simNode.selectable);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Sets whether this node can be selected.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.nodeSelectable(((ImageTextButton) actor).isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class TreeListeners method treeNameListener.
public static EventListener treeNameListener(final DialogSceneComposer dialogSceneComposer) {
var simTree = (SimTree) 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(simTree.name);
popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
textField.addListener(ibeamListener);
textField.addListener(new TextTooltip("The name of the Tree 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.treeName(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.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class TreeListeners method treeSpacingListener.
public static EventListener treeSpacingListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTree = (SimTree) 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 tableShown(Event event) {
var popTable = getPopTable();
popTable.clearChildren();
var table = new Table();
popTable.add(table);
table.defaults().right().spaceRight(5);
var label = new Label("Icon Space Left:", skin, "scene-label-colored");
table.add(label);
var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simTree.iconSpaceLeft);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The spacing on the left of the icon.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.treeIconSpaceLeft((float) ((Spinner) actor).getValue());
}
});
table.row();
label = new Label("Icon Space Right:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simTree.iconSpaceRight);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The spacing on the right of the icon.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.treeIconSpaceRight((float) ((Spinner) actor).getValue());
}
});
table.row();
label = new Label("Indent Spacing:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simTree.indentSpacing);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The indentation space for each indented node.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.treeIndentSpacing((float) ((Spinner) actor).getValue());
}
});
table.row();
label = new Label("Y Spacing:", skin, "scene-label-colored");
table.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setValue(simTree.ySpacing);
table.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The vertical spacing between each node.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.treeYSpacing((float) ((Spinner) actor).getValue());
}
});
}
};
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class CellListeners method cellMoveCellListener.
public static EventListener cellMoveCellListener(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 label = new Label("Move Cell", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var subTable = new Table();
popTable.add(subTable);
subTable.add();
var button = new Button(skin, "scene-move-up");
button.setDisabled(simCell.row == 0);
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Moves the current cell up.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellMoveCellUp();
popTable.hide();
}
});
subTable.add();
subTable.row();
button = new Button(skin, "scene-move-left");
button.setDisabled(simCell.column == 0);
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Moves the current cell left.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellMoveCellLeft();
popTable.hide();
}
});
subTable.add();
button = new Button(skin, "scene-move-right");
button.setDisabled(simCell.column == simTable.getColumns(simCell.row) - 1);
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Moves the current cell right.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellMoveCellRight();
popTable.hide();
}
});
subTable.row();
subTable.add();
button = new Button(skin, "scene-move-down");
button.setDisabled(simCell.row == simTable.getRows() - 1);
subTable.add(button);
button.addListener(handListener);
button.addListener(new TextTooltip("Moves the current cell down.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellMoveCellDown();
popTable.hide();
}
});
subTable.add();
popTable.row();
label = new Label("Move to New Row", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
subTable = new Table();
popTable.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 moves this cell to it.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellMoveToNewRowBelow();
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 moves this cell to it.", tooltipManager, skin, "scene"));
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellMoveToNewRowAbove();
popTable.hide();
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class CellListeners method cellAlignmentListener.
public static EventListener cellAlignmentListener(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 simCell = (DialogSceneComposerModel.SimCell) 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 cell to the top left.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAlignment(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 cell to the top center.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAlignment(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 cell to the top right.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAlignment(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 cell to the middle left.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAlignment(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 cell to the center.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAlignment(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 cell to the middle right.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAlignment(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 cell to the bottom left.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAlignment(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 cell to the bottom center.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAlignment(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 cell to the bottom right.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.cellAlignment(Align.bottomRight);
}
});
buttonGroup.add(imageTextButton);
switch(simCell.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;
}
Aggregations