use of com.ray3k.stripe.PopTable in project skin-composer by raeleus.
the class DialogSceneComposer method showExportDialog.
public PopTable showExportDialog() {
var root = new PopTable(skin);
root.setHideOnUnfocus(true);
root.setModal(true);
root.setKeepSizedWithinStage(true);
root.setKeepCenteredInWindow(true);
root.pad(20);
var label = new Label("Export", skin, "scene-title-bg");
label.setAlignment(Align.center);
root.add(label).growX().pad(10);
root.row();
var table = new Table();
root.add(table);
table.defaults().space(10f);
var textButton = new TextButton("Save JSON", skin, "scene-med");
table.add(textButton).fillX();
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
var file = desktopWorker.saveDialog("Export JSON...", projectData.getLastSceneComposerJson(), new String[] { "*.json" }, "JSON Files (*.json)");
if (file != null) {
events.exportTemplate(new FileHandle(file));
}
if (file != null) {
root.hide();
}
}
});
var horizontalGroup = new HorizontalGroup();
table.add(horizontalGroup).expandX().left();
label = new Label("A JSON file compatible with ", skin, "scene-label-colored");
horizontalGroup.addActor(label);
textButton = new TextButton("SceneComposerStageBuilder", skin, "scene-link");
horizontalGroup.addActor(textButton);
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Gdx.net.openURI("https://github.com/raeleus/stripe/blob/master/README.md");
}
});
table.row();
textButton = new TextButton("Save to JAVA", skin, "scene-med");
table.add(textButton).fillX();
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
var file = desktopWorker.saveDialog("Export Java...", projectData.getLastSceneComposerJson(), new String[] { "*.java" }, "Java Files (*.java)");
var fileHandle = new FileHandle(file);
if (file != null) {
if (!fileHandle.extension().equalsIgnoreCase("java"))
fileHandle = fileHandle.sibling(fileHandle.name() + ".java");
events.exportJava(fileHandle);
root.hide();
}
}
});
label = new Label("A file to be added directly into your project", skin, "scene-label-colored");
table.add(label).expandX().left();
table.row();
textButton = new TextButton("Copy to Clipboard", skin, "scene-med");
table.add(textButton).fillX();
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.exportClipboard();
root.hide();
}
});
label = new Label("A minimal version to be pasted into your existing code", skin, "scene-label-colored");
table.add(label).expandX().left();
root.show(getStage());
return root;
}
use of com.ray3k.stripe.PopTable in project skin-composer by raeleus.
the class DialogSceneComposer method populatePath.
public void populatePath() {
var root = pathTable;
root.clear();
var objects = new Array<DialogSceneComposerModel.SimActor>();
objects.add(simActor);
var object = simActor;
while (object != null) {
if (object.parent != null) {
object = object.parent;
objects.add(object);
} else {
object = null;
}
}
while (objects.size > 0) {
object = objects.pop();
var textButton = new TextButton(object.toString(), skin, object == simActor ? "scene-small-highlighted" : "scene-small");
textButton.setUserObject(object);
root.add(textButton);
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = (DialogSceneComposerModel.SimActor) textButton.getUserObject();
populateProperties();
model.updatePreview();
populatePath();
}
});
if (objects.size > 0) {
var image = new Image(skin, "scene-icon-path-seperator");
root.add(image);
}
}
var popTableClickListener = new PopTableClickListener(skin);
var popTable = popTableClickListener.getPopTable();
var popSubTable = new Table();
var scrollPane = new ScrollPane(popSubTable, skin, "scene");
popTable.add(scrollPane).grow();
if (simActor instanceof DialogSceneComposerModel.SimTable) {
var table = (DialogSceneComposerModel.SimTable) simActor;
if (table.cells.size > 0) {
var image = new Image(skin, "scene-icon-path-child-seperator");
root.add(image);
var textButton = new TextButton("Select Child", skin, "scene-small");
root.add(textButton);
textButton.addListener(handListener);
int row = 0;
for (var cell : table.cells) {
var textButton1 = new TextButton(cell.toString(), skin, "scene-small");
if (cell.row > row) {
popSubTable.row();
row++;
}
popSubTable.add(textButton1).colspan(cell.colSpan).fillX();
textButton1.addListener(handListener);
textButton1.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = cell;
populateProperties();
model.updatePreview();
populatePath();
popTable.hide();
}
});
}
textButton.addListener(popTableClickListener);
}
} else if (simActor instanceof SimSingleChild) {
var simSingleChild = (SimSingleChild) simActor;
if (simSingleChild.getChild() != null) {
var image = new Image(skin, "scene-icon-path-child-seperator");
root.add(image);
var textButton = new TextButton(simSingleChild.getChild().toString(), skin, "scene-small");
root.add(textButton);
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = simSingleChild.getChild();
populateProperties();
model.updatePreview();
populatePath();
}
});
}
} else if (simActor instanceof SimMultipleChildren) {
var simMultipleChildren = (SimMultipleChildren) simActor;
if (simMultipleChildren.getChildren().size > 0) {
var image = new Image(skin, "scene-icon-path-child-seperator");
root.add(image);
if (simMultipleChildren.getChildren().size == 1) {
var textButton = new TextButton(simMultipleChildren.getChildren().first().toString(), skin, "scene-small");
root.add(textButton);
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = simMultipleChildren.getChildren().first();
populateProperties();
model.updatePreview();
populatePath();
}
});
} else {
var textButton = new TextButton("Select Child", skin, "scene-small");
root.add(textButton);
textButton.addListener(handListener);
for (var child : simMultipleChildren.getChildren()) {
var textButton1 = new TextButton(child.toString(), skin, "scene-small");
popSubTable.add(textButton1).row();
textButton1.addListener(handListener);
textButton1.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = child;
populateProperties();
populatePath();
model.updatePreview();
popTable.hide();
}
});
}
textButton.addListener(popTableClickListener);
}
}
}
root.add().growX();
}
use of com.ray3k.stripe.PopTable in project skin-composer by raeleus.
the class ScrollPaneListeners method scrollPaneKnobsListener.
public static EventListener scrollPaneKnobsListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simScrollPane = (DialogSceneComposerModel.SimScrollPane) 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).left();
table.defaults().left().expandX();
var imageTextButton = new ImageTextButton("Variable Size Knobs", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.variableSizeKnobs);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Scroll knobs are sized based on getMaxX() or getMaxY()", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneVariableSizeKnobs(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Fade Scroll Bars", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.fadeScrollBars);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Scrollbars don't reduce the scrollable size and fade out if not used.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneFadeScrollBars(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("ScrollBarsVisible", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.scrollBarsVisible);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Shows or hides the scrollbars when Fade Scroll Bars is activated.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneScrollBarsVisible(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Scroll Bar Touch", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.scrollBarsOnTop);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Set whether scrollbars respond to mouse clicks.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneScrollBarTouch(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Scroll Bars On Top", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.scrollBarsOnTop);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Scrollbars don't reduce the scrollable size and fade out if not used.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneScrollBarsOnTop(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Force Horizontal Scroll", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.forceScrollX);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Forces the horizontal scroll bar to be enabled.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneForceScrollX(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Force Vertical Scroll", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.forceScrollY);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Forces the vertical scroll bar to be enabled.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneForceScrollY(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Horizontal Scrolling Disabled", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.scrollingDisabledX);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Horizontal Scrolling is disabled.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneScrollingDisabledX(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Vertical Scrolling Disabled", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.scrollingDisabledY);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Vertical scrolling is disabled.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneScrollingDisabledY(((ImageTextButton) actor).isChecked());
}
});
popTable.row();
table = new Table();
popTable.add(table);
table.defaults().space(5).fillX();
var label = new Label("Horizontal Scroll Position: ", skin, "scene-label-colored");
table.add(label);
var selectBox = new SelectBox<String>(skin, "scene");
selectBox.setItems("Top", "Bottom");
selectBox.setSelectedIndex(simScrollPane.scrollBarBottom ? 1 : 0);
table.add(selectBox);
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneScrollBarBottom(((SelectBox) actor).getSelectedIndex() == 1);
}
});
table.row();
label = new Label("Vertical Scroll Position: ", skin, "scene-label-colored");
table.add(label);
selectBox = new SelectBox<>(skin, "scene");
selectBox.setItems("Left", "Right");
selectBox.setSelectedIndex(simScrollPane.scrollBarRight ? 1 : 0);
table.add(selectBox);
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneScrollBarRight(((SelectBox) actor).getSelectedIndex() == 1);
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTable in project skin-composer by raeleus.
the class ScrollPaneListeners method scrollPaneScrollListener.
public static EventListener scrollPaneScrollListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simScrollPane = (DialogSceneComposerModel.SimScrollPane) 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().left().spaceRight(5);
var imageTextButton = new ImageTextButton("Clamp", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.clamp);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Prevents scrolling out of the widget's bounds when using flick Scroll.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneClamp(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Flick Scroll", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.flickScroll);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Allow users to scroll by flicking the contents of the ScrollPanel", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneFlickScroll(((ImageTextButton) actor).isChecked());
}
});
table.row();
var subTable = new Table();
table.add(subTable);
var label = new Label("Fling Time:", skin, "scene-label-colored");
subTable.add(label).space(5);
var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-left");
spinner.setValue(simScrollPane.flingTime);
subTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The amount of time in seconds that a fling will continue to scroll.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneFlingTime((float) ((Spinner) actor).getValue());
}
});
table.row();
imageTextButton = new ImageTextButton("Overscroll X", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.overScrollX);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("The widget can be scrolled passed the bounds horizontally and will snap back into place if flick scroll is enabled.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneOverScrollX(((ImageTextButton) actor).isChecked());
}
});
table.row();
imageTextButton = new ImageTextButton("Overscroll Y", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.overScrollY);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("The widget can be scrolled passed the bounds vertically and will snap back into place if flick scroll is enabled.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneOverScrollY(((ImageTextButton) actor).isChecked());
}
});
table.row();
subTable = new Table();
table.add(subTable);
label = new Label("Overscroll Distance:", skin, "scene-label-colored");
subTable.add(label).spaceRight(5);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-left");
spinner.setValue(simScrollPane.overScrollDistance);
subTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The distance in pixels that the user is allowed to scroll beyond the bounds if overscroll is enabled.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneOverScrollDistance((float) ((Spinner) actor).getValue());
}
});
subTable.row();
label = new Label("Overscroll Speed Min:", skin, "scene-label-colored");
subTable.add(label).spaceRight(5);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-left");
spinner.setValue(simScrollPane.overScrollSpeedMin);
subTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The minimum speed that scroll returns to the widget bounds when overscroll is enabled.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneOverScrollSpeedMin((float) ((Spinner) actor).getValue());
}
});
subTable.row();
label = new Label("Overscroll Speed Max:", skin, "scene-label-colored");
subTable.add(label).spaceRight(5);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-left");
spinner.setValue(simScrollPane.overScrollSpeedMax);
subTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The maximum speed that scroll returns to the widget bounds when overscroll is enabled.", tooltipManager, skin, "scene"));
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneOverScrollSpeedMax((float) ((Spinner) actor).getValue());
}
});
table.row();
imageTextButton = new ImageTextButton("Smooth Scrolling", skin, "scene-checkbox-colored");
imageTextButton.setChecked(simScrollPane.smoothScrolling);
table.add(imageTextButton);
imageTextButton.addListener(handListener);
imageTextButton.addListener(new TextTooltip("Scrolling is interpolated instead of jumping to position immediately.", tooltipManager, skin, "scene"));
imageTextButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.scrollPaneSmoothScrolling(((ImageTextButton) actor).isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTable 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;
}
Aggregations