use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project libgdx by libgdx.
the class Benchmark3DTest method create.
@Override
public void create() {
super.create();
GLProfiler.enable();
randomizeLights();
cam.position.set(10, 10, 10);
cam.lookAt(0, 0, 0);
cam.update();
showAxes = true;
lighting = true;
vertexCountLabel = new Label("Vertices: 999", skin);
vertexCountLabel.setPosition(0, fpsLabel.getTop());
hud.addActor(vertexCountLabel);
textureBindsLabel = new Label("Texture bindings: 999", skin);
textureBindsLabel.setPosition(0, vertexCountLabel.getTop());
hud.addActor(textureBindsLabel);
shaderSwitchesLabel = new Label("Shader switches: 999", skin);
shaderSwitchesLabel.setPosition(0, textureBindsLabel.getTop());
hud.addActor(shaderSwitchesLabel);
drawCallsLabel = new Label("Draw calls: 999", skin);
drawCallsLabel.setPosition(0, shaderSwitchesLabel.getTop());
hud.addActor(drawCallsLabel);
glCallsLabel = new Label("GL calls: 999", skin);
glCallsLabel.setPosition(0, drawCallsLabel.getTop());
hud.addActor(glCallsLabel);
lightsLabel = new Label("Lights: 999", skin);
lightsLabel.setPosition(0, glCallsLabel.getTop());
hud.addActor(lightsLabel);
lightingCheckBox = new CheckBox("Lighting", skin);
lightingCheckBox.setChecked(lighting);
lightingCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
lighting = lightingCheckBox.isChecked();
}
});
lightingCheckBox.setPosition(hudWidth - lightingCheckBox.getWidth(), gridCheckBox.getTop());
hud.addActor(lightingCheckBox);
lightsCheckBox = new CheckBox("Randomize lights", skin);
lightsCheckBox.setChecked(false);
lightsCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
lightsCheckBox.setChecked(false);
randomizeLights();
}
});
lightsCheckBox.setPosition(hudWidth - lightsCheckBox.getWidth(), lightingCheckBox.getTop());
hud.addActor(lightsCheckBox);
moveCheckBox.remove();
rotateCheckBox.remove();
}
use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project skin-composer by raeleus.
the class RootTable method refreshPreview.
public void refreshPreview() {
if (previewTable != null) {
previewTable.clear();
previewTable.setBackground("white");
previewTable.setColor((Color) previewProperties.get("bgcolor"));
for (BitmapFont font : previewFonts) {
font.dispose();
}
if (classSelectBox.getSelectedIndex() >= 0 && classSelectBox.getSelectedIndex() < Main.BASIC_CLASSES.length) {
StyleData styleData = getSelectedStyle();
Class clazz = Main.BASIC_CLASSES[classSelectBox.getSelectedIndex()];
if (!styleData.hasMandatoryFields()) {
Label label;
if (clazz.equals(SelectBox.class)) {
label = new Label("Please fill all mandatory fields\n(Highlighted on the left)\n\nscrollStyle and listStyle\nmust already be defined", getSkin());
} else if (clazz.equals(TextTooltip.class)) {
label = new Label("Please fill all mandatory fields\n(Highlighted on the left)\n\nlabel must already be defined", getSkin());
} else {
label = new Label("Please fill all mandatory fields\n(Highlighted on the left)", getSkin());
}
label.setAlignment(Align.center);
previewTable.add(label);
} else if (styleData.hasAllNullFields()) {
Label label;
label = new Label("All fields are empty!\nEmpty classes are not exported\nAdd style properties in the menu to the left", getSkin());
label.setAlignment(Align.center);
previewTable.add(label);
} else {
Actor widget = null;
if (clazz.equals(Button.class)) {
Button.ButtonStyle style = createPreviewStyle(Button.ButtonStyle.class, styleData);
widget = new Button(style);
((Button) widget).setDisabled((boolean) previewProperties.get("disabled"));
widget.addListener(main.getHandListener());
} else if (clazz.equals(CheckBox.class)) {
CheckBox.CheckBoxStyle style = createPreviewStyle(CheckBox.CheckBoxStyle.class, styleData);
widget = new CheckBox("", style);
((CheckBox) widget).setDisabled((boolean) previewProperties.get("disabled"));
((CheckBox) widget).setText((String) previewProperties.get("text"));
widget.addListener(main.getHandListener());
} else if (clazz.equals(ImageButton.class)) {
ImageButtonStyle style = createPreviewStyle(ImageButtonStyle.class, styleData);
widget = new ImageButton(style);
((ImageButton) widget).setDisabled((boolean) previewProperties.get("disabled"));
widget.addListener(main.getHandListener());
} else if (clazz.equals(ImageTextButton.class)) {
ImageTextButton.ImageTextButtonStyle style = createPreviewStyle(ImageTextButton.ImageTextButtonStyle.class, styleData);
widget = new ImageTextButton("", style);
((ImageTextButton) widget).setDisabled((boolean) previewProperties.get("disabled"));
((ImageTextButton) widget).setText((String) previewProperties.get("text"));
widget.addListener(main.getHandListener());
} else if (clazz.equals(Label.class)) {
LabelStyle style = createPreviewStyle(LabelStyle.class, styleData);
widget = new Label("", style);
((Label) widget).setText((String) previewProperties.get("text"));
} else if (clazz.equals(List.class)) {
ListStyle style = createPreviewStyle(ListStyle.class, styleData);
widget = new List(style);
Array<String> items = new Array<>(((String) previewProperties.get("text")).split("\\n"));
((List) widget).setItems(items);
widget.addListener(main.getHandListener());
} else if (clazz.equals(ProgressBar.class)) {
ProgressBar.ProgressBarStyle style = createPreviewStyle(ProgressBar.ProgressBarStyle.class, styleData);
widget = new ProgressBar((float) (double) previewProperties.get("minimum"), (float) (double) previewProperties.get("maximum"), (float) (double) previewProperties.get("increment"), (boolean) previewProperties.get("orientation"), style);
((ProgressBar) widget).setValue((float) (double) previewProperties.get("value"));
((ProgressBar) widget).setDisabled((boolean) previewProperties.get("disabled"));
} else if (clazz.equals(ScrollPane.class)) {
ScrollPaneStyle style = createPreviewStyle(ScrollPaneStyle.class, styleData);
Label label = new Label("", getSkin());
widget = new ScrollPane(label, style);
((ScrollPane) widget).setScrollbarsOnTop((boolean) previewProperties.get("scrollbarsOnTop"));
((ScrollPane) widget).setScrollBarPositions((boolean) previewProperties.get("hScrollBarPosition"), (boolean) previewProperties.get("vScrollBarPosition"));
((ScrollPane) widget).setScrollingDisabled((boolean) previewProperties.get("hScrollDisabled"), (boolean) previewProperties.get("vScrollDisabled"));
((ScrollPane) widget).setForceScroll((boolean) previewProperties.get("forceHscroll"), (boolean) previewProperties.get("forceVscroll"));
((ScrollPane) widget).setVariableSizeKnobs((boolean) previewProperties.get("variableSizeKnobs"));
((ScrollPane) widget).setOverscroll((boolean) previewProperties.get("hOverscroll"), (boolean) previewProperties.get("vOverscroll"));
((ScrollPane) widget).setFadeScrollBars((boolean) previewProperties.get("fadeScroll"));
((ScrollPane) widget).setSmoothScrolling((boolean) previewProperties.get("smoothScroll"));
((ScrollPane) widget).setFlickScroll((boolean) previewProperties.get("flickScroll"));
((ScrollPane) widget).setClamp((boolean) previewProperties.get("clamp"));
label.setText((String) previewProperties.get("text"));
} else if (clazz.equals(SelectBox.class)) {
SelectBox.SelectBoxStyle style = createPreviewStyle(SelectBox.SelectBoxStyle.class, styleData);
widget = new SelectBox(style);
((SelectBox) widget).setDisabled((boolean) previewProperties.get("disabled"));
Array<String> items = new Array<>(((String) previewProperties.get("text")).split("\\n"));
((SelectBox) widget).setItems(items);
widget.addListener(main.getHandListener());
((SelectBox) widget).getList().addListener(main.getHandListener());
} else if (clazz.equals(Slider.class)) {
Slider.SliderStyle style = createPreviewStyle(Slider.SliderStyle.class, styleData);
widget = new Slider((float) (double) previewProperties.get("minimum"), (float) (double) previewProperties.get("maximum"), (float) (double) previewProperties.get("increment"), (boolean) previewProperties.get("orientation"), style);
((Slider) widget).setDisabled((boolean) previewProperties.get("disabled"));
widget.addListener(main.getHandListener());
} else if (clazz.equals(SplitPane.class)) {
SplitPane.SplitPaneStyle style = createPreviewStyle(SplitPane.SplitPaneStyle.class, styleData);
Label label1 = new Label("", getSkin());
Label label2 = new Label("", getSkin());
widget = new SplitPane(label1, label2, (boolean) previewProperties.get("orientation"), style);
label1.setText((String) previewProperties.get("text"));
label2.setText((String) previewProperties.get("text"));
if ((boolean) previewProperties.get("orientation")) {
widget.addListener(vSplitPaneDragListener);
widget.addListener(vSplitPaneInputListener);
} else {
widget.addListener(hSplitPaneDragListener);
widget.addListener(hSplitPaneInputListener);
}
} else if (clazz.equals(TextButton.class)) {
TextButtonStyle style = createPreviewStyle(TextButtonStyle.class, styleData);
widget = new TextButton("", style);
((TextButton) widget).setDisabled((boolean) previewProperties.get("disabled"));
((TextButton) widget).setText((String) previewProperties.get("text"));
widget.addListener(main.getHandListener());
} else if (clazz.equals(TextField.class)) {
TextFieldStyle style = createPreviewStyle(TextFieldStyle.class, styleData);
widget = new TextField("", style);
((TextField) widget).setFocusTraversal(false);
((TextField) widget).setDisabled((boolean) previewProperties.get("disabled"));
((TextField) widget).setPasswordMode((boolean) previewProperties.get("passwordMode"));
((TextField) widget).setAlignment((int) previewProperties.get("alignment"));
((TextField) widget).setText((String) previewProperties.get("text"));
((TextField) widget).setMessageText((String) previewProperties.get("message"));
String string = (String) previewProperties.get("password");
if (string.length() > 0) {
((TextField) widget).setPasswordCharacter(string.charAt(0));
}
widget.addListener(main.getIbeamListener());
} else if (clazz.equals(TextTooltip.class)) {
TextTooltip.TextTooltipStyle style = createPreviewStyle(TextTooltip.TextTooltipStyle.class, styleData);
TooltipManager manager = new TooltipManager();
manager.animations = false;
manager.initialTime = 0.0f;
manager.resetTime = 0.0f;
manager.subsequentTime = 0.0f;
manager.hideAll();
manager.instant();
TextTooltip toolTip = new TextTooltip((String) previewProperties.get("text"), manager, style);
widget = new Label("Hover over me", getSkin());
widget.addListener(toolTip);
} else if (clazz.equals(Touchpad.class)) {
Touchpad.TouchpadStyle style = createPreviewStyle(Touchpad.TouchpadStyle.class, styleData);
widget = new Touchpad(0, style);
widget.addListener(main.getHandListener());
} else if (clazz.equals(Tree.class)) {
Tree.TreeStyle style = createPreviewStyle(Tree.TreeStyle.class, styleData);
widget = new Tree(style);
String[] lines = { "this", "is", "a", "test" };
Tree.Node parentNode = null;
for (String line : lines) {
Label label = new Label(line, getSkin());
Tree.Node node = new Tree.Node(label);
if (parentNode == null) {
((Tree) widget).add(node);
} else {
parentNode.add(node);
}
parentNode = node;
}
widget.addListener(main.getHandListener());
} else if (clazz.equals(Window.class)) {
Window.WindowStyle style = createPreviewStyle(Window.WindowStyle.class, styleData);
if (style.stageBackground != null) {
previewTable.setBackground(style.stageBackground);
previewTable.setColor(Color.WHITE);
style.stageBackground = null;
}
Label sampleText = new Label("", getSkin());
sampleText.setText((String) previewProperties.get("text"));
widget = new Window((String) previewProperties.get("title"), style);
((Window) widget).add(sampleText);
}
if (widget != null) {
switch((int) previewProperties.get("size")) {
case (0):
previewTable.add(widget).size(10.0f);
previewSizeSelectBox.setItems(DEFAULT_SIZES);
break;
case (1):
previewTable.add(widget);
previewSizeSelectBox.setItems(DEFAULT_SIZES);
break;
case (2):
previewTable.add(widget).size(200.0f);
previewSizeSelectBox.setItems(DEFAULT_SIZES);
break;
case (3):
previewTable.add(widget).growX();
previewSizeSelectBox.setItems(DEFAULT_SIZES);
break;
case (4):
previewTable.add(widget).growY();
previewSizeSelectBox.setItems(DEFAULT_SIZES);
break;
case (5):
previewTable.add(widget).grow();
previewSizeSelectBox.setItems(DEFAULT_SIZES);
break;
case (6):
Actor addWidget = widget;
TraversalTextField widthField = new TraversalTextField("", getSkin());
TraversalTextField heightField = new TraversalTextField("", getSkin());
widthField.setNextFocus(heightField);
heightField.setNextFocus(widthField);
Dialog dialog = new Dialog("Enter dimensions...", getSkin()) {
@Override
protected void result(Object object) {
if ((boolean) object) {
previewTable.add(addWidget).size(Integer.parseInt(widthField.getText()), Integer.parseInt(heightField.getText()));
Array<String> items = new Array<>(DEFAULT_SIZES);
items.add(widthField.getText() + "x" + heightField.getText());
previewProperties.put("sizeX", Integer.parseInt(widthField.getText()));
previewProperties.put("sizeY", Integer.parseInt(heightField.getText()));
previewSizeSelectBox.setItems(items);
previewSizeSelectBox.setSelectedIndex(7);
} else {
previewSizeSelectBox.setSelectedIndex(1);
}
}
};
dialog.getTitleTable().getCells().first().padLeft(5.0f);
dialog.text("Enter the preview dimensions: ");
dialog.getContentTable().getCells().first().pad(10.0f);
dialog.getContentTable().row();
Table sizeTable = new Table();
sizeTable.add(widthField).padLeft(10.0f);
sizeTable.add(new Label(" x ", getSkin()));
sizeTable.add(heightField).padRight(10.0f);
dialog.getContentTable().add(sizeTable);
dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
dialog.button("OK", true);
dialog.button("Cancel", false);
TextButton okButton = (TextButton) dialog.getButtonTable().getCells().first().getActor();
okButton.setDisabled(true);
okButton.addListener(main.getHandListener());
widthField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
okButton.setDisabled(!widthField.getText().matches("^\\d+$") || !heightField.getText().matches("^\\d+$"));
}
});
heightField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
okButton.setDisabled(!widthField.getText().matches("^\\d+$") || !heightField.getText().matches("^\\d+$"));
}
});
dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
dialog.key(Input.Keys.ESCAPE, false);
dialog.show(stage);
stage.setKeyboardFocus(widthField);
break;
case (7):
previewTable.add(widget).size((int) previewProperties.get("sizeX"), (int) previewProperties.get("sizeY"));
break;
}
}
}
} else {
CustomStyle customStyle = (CustomStyle) styleSelectBox.getSelected();
boolean showMessage = true;
if (customStyle.getProperties().size == 0) {
Label label = new Label("No style properties!\nEmpty classes are not exported\nAdd style properties in the menu to the left", getSkin());
label.setAlignment(0);
previewTable.add(label);
} else {
for (CustomProperty customProperty : customStyle.getProperties()) {
if (customProperty.getValue() != null && !(customProperty.getValue() instanceof String) || customProperty.getValue() != null && !((String) customProperty.getValue()).equals("")) {
showMessage = false;
break;
}
}
if (showMessage) {
Label label = new Label("All properties are empty!\nEmpty classes are not exported\nAdd style properties in the menu to the left", getSkin());
label.setAlignment(0);
previewTable.add(label);
}
}
if (!showMessage) {
HorizontalGroup horizontalGroup = new HorizontalGroup();
horizontalGroup.wrap();
// the following causes a crash. LibGDX bug.
// horizontalGroup.space(10.0f);
horizontalGroup.wrapSpace(10.0f);
horizontalGroup.setTouchable(Touchable.disabled);
previewTable.add(horizontalGroup).grow().pad(10.0f);
for (CustomProperty customProperty : customStyle.getProperties()) {
if (customProperty.getValue() != null) {
Container container = new Container();
container.pad(5.0f);
horizontalGroup.addActor(container);
switch(customProperty.getType()) {
case TEXT:
case RAW_TEXT:
Label labelText = new Label((String) customProperty.getValue(), getSkin());
container.setActor(labelText);
break;
case NUMBER:
Label labelNumber = new Label(Double.toString((double) customProperty.getValue()), getSkin());
container.setActor(labelNumber);
break;
case BOOL:
Label labelBoolean = new Label(Boolean.toString((boolean) customProperty.getValue()), getSkin());
container.setActor(labelBoolean);
break;
case COLOR:
ColorData colorData = null;
String colorName = (String) customProperty.getValue();
for (ColorData cd : main.getJsonData().getColors()) {
if (cd.getName().equals(colorName)) {
colorData = cd;
break;
}
}
if (colorData != null) {
Table colorTable = new Table(getSkin());
colorTable.setBackground("white");
colorTable.setColor(colorData.color);
colorTable.add().size(25.0f);
container.setActor(colorTable);
}
break;
case FONT:
BitmapFont font = null;
FontData fontData = null;
String fontName = (String) customProperty.getValue();
for (FontData fd : main.getJsonData().getFonts()) {
if (fd.getName().equals(fontName)) {
fontData = fd;
font = new BitmapFont(fd.file);
previewFonts.add(font);
break;
}
}
if (font != null) {
Label labelFont = new Label(fontData.getName(), new LabelStyle(font, Color.WHITE));
container.setActor(labelFont);
}
FreeTypeFontData freeTypeFontData = null;
for (FreeTypeFontData fd : main.getJsonData().getFreeTypeFonts()) {
if (fd.name.equals(fontName)) {
freeTypeFontData = fd;
break;
}
}
if (freeTypeFontData.bitmapFont != null) {
Label labelFont = new Label(freeTypeFontData.name, new LabelStyle(freeTypeFontData.bitmapFont, Color.WHITE));
container.setActor(labelFont);
}
break;
case DRAWABLE:
DrawableData drawable = null;
String drawableName = (String) customProperty.getValue();
for (DrawableData dd : main.getAtlasData().getDrawables()) {
if (dd.name.equals(drawableName)) {
drawable = dd;
break;
}
}
if (drawable != null) {
Image image = new Image(drawablePairs.get(drawable.name));
container.setActor(image);
}
break;
}
}
}
}
}
}
}
use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project skin-composer by raeleus.
the class RootTable method refreshPreviewProperties.
public void refreshPreviewProperties() {
if (previewPropertiesTable != null) {
previewPropertiesTable.clear();
previewProperties.clear();
Table t = new Table();
previewPropertiesTable.add(t).grow();
t.defaults().pad(3.0f);
if (previewBgColor == null) {
previewBgColor.set(Color.WHITE);
}
previewProperties.put("bgcolor", previewBgColor);
if (classSelectBox.getSelectedIndex() >= 0 && classSelectBox.getSelectedIndex() < Main.BASIC_CLASSES.length) {
t.add(new Label("Stage Color: ", getSkin())).right();
BrowseField browseField = new BrowseField(null, null, getSkin(), "color");
browseField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
main.getDialogFactory().showDialogColorPicker((Color) previewProperties.get("bgcolor"), new DialogColorPicker.ColorListener() {
@Override
public void selected(Color color) {
if (color != null) {
browseField.getTextButton().setText((int) (color.r * 255) + "," + (int) (color.g * 255) + "," + (int) (color.b * 255) + "," + (int) (color.a * 255));
previewProperties.put("bgcolor", color);
previewBgColor.set(color);
refreshPreview();
}
}
});
}
});
browseField.addListener(main.getHandListener());
t.add(browseField).growX();
browseField.getTextButton().setText((int) (previewBgColor.r * 255) + "," + (int) (previewBgColor.g * 255) + "," + (int) (previewBgColor.b * 255) + "," + (int) (previewBgColor.a * 255));
t.row();
t.add(new Label("Size: ", getSkin())).right();
previewSizeSelectBox = new SelectBox<>(getSkin());
previewSizeSelectBox.setItems(DEFAULT_SIZES);
previewSizeSelectBox.setSelectedIndex(1);
previewSizeSelectBox.addListener(main.getHandListener());
previewSizeSelectBox.getList().addListener(main.getHandListener());
t.add(previewSizeSelectBox).growX().minWidth(200.0f);
Class clazz = Main.BASIC_CLASSES[classSelectBox.getSelectedIndex()];
if (clazz.equals(Button.class)) {
t.row();
t.add(new Label("Disabled: ", getSkin())).right();
ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
disabledCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("disabled", disabledCheckBox.isChecked());
refreshPreview();
}
});
disabledCheckBox.addListener(main.getHandListener());
previewProperties.put("disabled", disabledCheckBox.isChecked());
t.add(disabledCheckBox).left();
} else if (clazz.equals(CheckBox.class)) {
t.row();
t.add(new Label("Disabled: ", getSkin())).right();
ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
disabledCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("disabled", disabledCheckBox.isChecked());
refreshPreview();
}
});
disabledCheckBox.addListener(main.getHandListener());
previewProperties.put("disabled", disabledCheckBox.isChecked());
t.add(disabledCheckBox).left();
t.row();
t.add(new Label("Text: ", getSkin())).right();
TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
previewTextField.setFocusTraversal(false);
previewTextField.addListener(main.getIbeamListener());
previewTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", previewTextField.getText());
refreshPreview();
}
});
previewProperties.put("text", previewTextField.getText());
t.add(previewTextField).growX();
} else if (clazz.equals(ImageButton.class)) {
t.row();
t.add(new Label("Disabled: ", getSkin())).right();
ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
disabledCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("disabled", disabledCheckBox.isChecked());
refreshPreview();
}
});
disabledCheckBox.addListener(main.getHandListener());
previewProperties.put("disabled", disabledCheckBox.isChecked());
t.add(disabledCheckBox).left();
} else if (clazz.equals(ImageTextButton.class)) {
t.row();
t.add(new Label("Disabled: ", getSkin())).right();
ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
disabledCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("disabled", disabledCheckBox.isChecked());
refreshPreview();
}
});
disabledCheckBox.addListener(main.getHandListener());
previewProperties.put("disabled", disabledCheckBox.isChecked());
t.add(disabledCheckBox).left();
t.row();
t.add(new Label("Text: ", getSkin())).right();
TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
previewTextField.setFocusTraversal(false);
previewTextField.addListener(main.getIbeamListener());
previewTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", previewTextField.getText());
refreshPreview();
}
});
previewProperties.put("text", previewTextField.getText());
t.add(previewTextField).growX();
} else if (clazz.equals(Label.class)) {
t.row();
t.add(new Label("Text: ", getSkin())).right();
TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
previewTextField.setFocusTraversal(false);
previewTextField.addListener(main.getIbeamListener());
previewTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", previewTextField.getText());
refreshPreview();
}
});
previewProperties.put("text", previewTextField.getText());
t.add(previewTextField).growX();
} else if (clazz.equals(List.class)) {
t.row();
t.add(new Label("List Items: ", getSkin())).right();
TextArea listItemsTextArea = new TextArea("Lorem ipsum\ndolor sit\namet, consectetur", getSkin());
listItemsTextArea.setFocusTraversal(false);
listItemsTextArea.setPrefRows(3);
listItemsTextArea.addListener(main.getIbeamListener());
listItemsTextArea.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", listItemsTextArea.getText());
refreshPreview();
}
});
previewProperties.put("text", listItemsTextArea.getText());
t.add(listItemsTextArea).growX();
} else if (clazz.equals(ProgressBar.class)) {
t.row();
t.add(new Label("Disabled: ", getSkin())).right();
ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
disabledCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("disabled", disabledCheckBox.isChecked());
refreshPreview();
}
});
disabledCheckBox.addListener(main.getHandListener());
previewProperties.put("disabled", disabledCheckBox.isChecked());
t.add(disabledCheckBox).left();
t.row();
t.add(new Label("Value: ", getSkin())).right();
Spinner valueSpinner = new Spinner(0.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
valueSpinner.getTextField().setFocusTraversal(false);
valueSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("value", valueSpinner.getValue());
refreshPreview();
}
});
valueSpinner.getButtonMinus().addListener(main.getHandListener());
valueSpinner.getButtonPlus().addListener(main.getHandListener());
valueSpinner.getTextField().addListener(main.getIbeamListener());
previewProperties.put("value", valueSpinner.getValue());
t.add(valueSpinner).growX();
t.row();
t.add(new Label("Minimum: ", getSkin())).right();
Spinner minimumSpinner = new Spinner(0.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
minimumSpinner.getTextField().setFocusTraversal(false);
minimumSpinner.getTextField().addListener(main.getIbeamListener());
minimumSpinner.getButtonMinus().addListener(main.getHandListener());
minimumSpinner.getButtonPlus().addListener(main.getHandListener());
previewProperties.put("minimum", minimumSpinner.getValue());
t.add(minimumSpinner).growX();
t.row();
t.add(new Label("Maximum: ", getSkin())).right();
Spinner maximumSpinner = new Spinner(100.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
maximumSpinner.getTextField().setFocusTraversal(false);
maximumSpinner.getTextField().addListener(main.getIbeamListener());
maximumSpinner.getButtonMinus().addListener(main.getHandListener());
maximumSpinner.getButtonPlus().addListener(main.getHandListener());
previewProperties.put("maximum", maximumSpinner.getValue());
t.add(maximumSpinner).growX();
minimumSpinner.setMaximum(maximumSpinner.getValue());
maximumSpinner.setMinimum(minimumSpinner.getValue());
minimumSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("minimum", minimumSpinner.getValue());
maximumSpinner.setMinimum(minimumSpinner.getValue());
refreshPreview();
}
});
maximumSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("maximum", maximumSpinner.getValue());
minimumSpinner.setMaximum(maximumSpinner.getValue());
refreshPreview();
}
});
t.row();
t.add(new Label("Increment: ", getSkin())).right();
Spinner incrementSpinner = new Spinner(1.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
incrementSpinner.getTextField().setFocusTraversal(false);
incrementSpinner.setMinimum(1);
incrementSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("increment", incrementSpinner.getValue());
refreshPreview();
}
});
incrementSpinner.getTextField().addListener(main.getIbeamListener());
incrementSpinner.getButtonMinus().addListener(main.getHandListener());
incrementSpinner.getButtonPlus().addListener(main.getHandListener());
previewProperties.put("increment", incrementSpinner.getValue());
t.add(incrementSpinner).growX();
t.row();
t.add(new Label("Orientation: ", getSkin())).right();
SelectBox<String> selectBox = new SelectBox<>(getSkin());
selectBox.setItems(new String[] { "Horizontal", "Vertical" });
if (getSelectedStyle().name.contains("vert")) {
previewProperties.put("orientation", true);
selectBox.setSelectedIndex(1);
} else {
previewProperties.put("orientation", false);
}
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
if (selectBox.getSelectedIndex() == 0) {
previewProperties.put("orientation", false);
} else {
previewProperties.put("orientation", true);
}
refreshPreview();
}
});
selectBox.addListener(main.getHandListener());
selectBox.getList().addListener(main.getHandListener());
t.add(selectBox).growX();
} else if (clazz.equals(ScrollPane.class)) {
t.row();
t.add(new Label("Scrollbars On Top: ", getSkin())).right();
ImageTextButton onTopCheckBox = new ImageTextButton("", getSkin(), "switch");
onTopCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("scrollbarsOnTop", onTopCheckBox.isChecked());
refreshPreview();
}
});
t.add(onTopCheckBox).left();
onTopCheckBox.addListener(main.getHandListener());
previewProperties.put("scrollbarsOnTop", onTopCheckBox.isChecked());
t.row();
t.add(new Label("H ScrollBar Position: ", getSkin())).right();
SelectBox<String> hScrollPosBox = new SelectBox<>(getSkin());
hScrollPosBox.setItems(new String[] { "Top", "Bottom" });
hScrollPosBox.setSelectedIndex(1);
hScrollPosBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
if (hScrollPosBox.getSelectedIndex() == 0) {
previewProperties.put("hScrollBarPosition", false);
} else {
previewProperties.put("hScrollBarPosition", true);
}
refreshPreview();
}
});
t.add(hScrollPosBox).growX();
hScrollPosBox.addListener(main.getHandListener());
hScrollPosBox.getList().addListener(main.getHandListener());
previewProperties.put("hScrollBarPosition", true);
t.row();
t.add(new Label("V ScrollBar Position: ", getSkin())).right();
SelectBox<String> vScrollPosBox = new SelectBox<>(getSkin());
vScrollPosBox.setItems(new String[] { "Left", "Right" });
vScrollPosBox.setSelectedIndex(1);
vScrollPosBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
if (vScrollPosBox.getSelectedIndex() == 0) {
previewProperties.put("vScrollBarPosition", false);
} else {
previewProperties.put("vScrollBarPosition", true);
}
refreshPreview();
}
});
t.add(vScrollPosBox).growX();
vScrollPosBox.addListener(main.getHandListener());
vScrollPosBox.getList().addListener(main.getHandListener());
previewProperties.put("vScrollBarPosition", true);
t.row();
t.add(new Label("H Scrolling Disabled: ", getSkin())).right();
ImageTextButton hScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
hScrollCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("hScrollDisabled", hScrollCheckBox.isChecked());
refreshPreview();
}
});
t.add(hScrollCheckBox).left();
hScrollCheckBox.addListener(main.getHandListener());
previewProperties.put("hScrollDisabled", hScrollCheckBox.isChecked());
t.row();
t.add(new Label("V Scrolling Disabled: ", getSkin())).right();
ImageTextButton vScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
vScrollCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("vScrollDisabled", vScrollCheckBox.isChecked());
refreshPreview();
}
});
t.add(vScrollCheckBox).left();
vScrollCheckBox.addListener(main.getHandListener());
previewProperties.put("vScrollDisabled", vScrollCheckBox.isChecked());
t.row();
t.add(new Label("Force H Scroll: ", getSkin())).right();
ImageTextButton forceHScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
forceHScrollCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("forceHscroll", forceHScrollCheckBox.isChecked());
refreshPreview();
}
});
t.add(forceHScrollCheckBox).left();
forceHScrollCheckBox.addListener(main.getHandListener());
previewProperties.put("forceHscroll", forceHScrollCheckBox.isChecked());
t.row();
t.add(new Label("Force V Scroll: ", getSkin())).right();
ImageTextButton forceVScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
forceVScrollCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("forceVscroll", forceVScrollCheckBox.isChecked());
refreshPreview();
}
});
t.add(forceVScrollCheckBox).left();
forceVScrollCheckBox.addListener(main.getHandListener());
previewProperties.put("forceVscroll", forceVScrollCheckBox.isChecked());
t.row();
t.add(new Label("Variable Size Knobs: ", getSkin())).right();
ImageTextButton variableSizeKnobsCheckBox = new ImageTextButton("", getSkin(), "switch");
variableSizeKnobsCheckBox.setChecked(true);
variableSizeKnobsCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("variableSizeKnobs", variableSizeKnobsCheckBox.isChecked());
refreshPreview();
}
});
t.add(variableSizeKnobsCheckBox).left();
variableSizeKnobsCheckBox.addListener(main.getHandListener());
previewProperties.put("variableSizeKnobs", variableSizeKnobsCheckBox.isChecked());
t.row();
t.add(new Label("H Overscroll: ", getSkin())).right();
ImageTextButton hOverscrollCheckBox = new ImageTextButton("", getSkin(), "switch");
hOverscrollCheckBox.setChecked(true);
hOverscrollCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("hOverscroll", hOverscrollCheckBox.isChecked());
refreshPreview();
}
});
t.add(hOverscrollCheckBox).left();
hOverscrollCheckBox.addListener(main.getHandListener());
previewProperties.put("hOverscroll", hOverscrollCheckBox.isChecked());
t.row();
t.add(new Label("V Overscroll: ", getSkin())).right();
ImageTextButton vOverscrollCheckBox = new ImageTextButton("", getSkin(), "switch");
vOverscrollCheckBox.setChecked(true);
vOverscrollCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("vOverscroll", vOverscrollCheckBox.isChecked());
refreshPreview();
}
});
t.add(vOverscrollCheckBox).left();
vOverscrollCheckBox.addListener(main.getHandListener());
previewProperties.put("vOverscroll", vOverscrollCheckBox.isChecked());
t.row();
t.add(new Label("Fade Scroll Bars: ", getSkin())).right();
ImageTextButton fadeScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
fadeScrollCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("fadeScroll", fadeScrollCheckBox.isChecked());
refreshPreview();
}
});
t.add(fadeScrollCheckBox).left();
fadeScrollCheckBox.addListener(main.getHandListener());
previewProperties.put("fadeScroll", fadeScrollCheckBox.isChecked());
t.row();
t.add(new Label("Smooth Scrolling: ", getSkin())).right();
ImageTextButton smoothScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
smoothScrollCheckBox.setChecked(true);
smoothScrollCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("smoothScroll", smoothScrollCheckBox.isChecked());
refreshPreview();
}
});
t.add(smoothScrollCheckBox).left();
smoothScrollCheckBox.addListener(main.getHandListener());
previewProperties.put("smoothScroll", smoothScrollCheckBox.isChecked());
t.row();
t.add(new Label("Flick Scroll: ", getSkin())).right();
ImageTextButton flickScrollCheckBox = new ImageTextButton("", getSkin(), "switch");
flickScrollCheckBox.setChecked(true);
flickScrollCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("flickScroll", flickScrollCheckBox.isChecked());
refreshPreview();
}
});
t.add(flickScrollCheckBox).left();
flickScrollCheckBox.addListener(main.getHandListener());
previewProperties.put("flickScroll", flickScrollCheckBox.isChecked());
t.row();
t.add(new Label("Clamp: ", getSkin())).right();
ImageTextButton clampCheckBox = new ImageTextButton("", getSkin(), "switch");
clampCheckBox.setChecked(true);
clampCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("clamp", clampCheckBox.isChecked());
refreshPreview();
}
});
t.add(clampCheckBox).left();
clampCheckBox.addListener(main.getHandListener());
previewProperties.put("clamp", clampCheckBox.isChecked());
t.row();
t.add(new Label("Sample Text: ", getSkin())).right();
TextArea previewTextArea = new TextArea(PARAGRAPH_SAMPLE_EXT, getSkin());
previewTextArea.setFocusTraversal(false);
previewTextArea.setPrefRows(5);
previewTextArea.addListener(main.getIbeamListener());
previewTextArea.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", previewTextArea.getText());
refreshPreview();
}
});
previewProperties.put("text", previewTextArea.getText());
t.add(previewTextArea).growX();
previewSizeSelectBox.setSelectedIndex(2);
} else if (clazz.equals(SelectBox.class)) {
t.row();
t.add(new Label("Disabled: ", getSkin())).right();
ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
disabledCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("disabled", disabledCheckBox.isChecked());
refreshPreview();
}
});
previewProperties.put("disabled", disabledCheckBox.isChecked());
disabledCheckBox.addListener(main.getHandListener());
t.add(disabledCheckBox).left();
t.row();
t.add(new Label("Max List Count: ", getSkin())).right();
Spinner spinner = new Spinner(3, 1, true, Spinner.Orientation.HORIZONTAL, getSkin());
spinner.getTextField().setFocusTraversal(false);
spinner.setMinimum(1);
spinner.getTextField().addListener(main.getIbeamListener());
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
t.add(spinner).growX();
t.row();
t.add(new Label("List Items: ", getSkin())).right();
TextArea listItemsTextArea = new TextArea("Lorem ipsum\ndolor sit\namet, consectetur", getSkin());
listItemsTextArea.setFocusTraversal(false);
listItemsTextArea.setPrefRows(3);
listItemsTextArea.addListener(main.getIbeamListener());
listItemsTextArea.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", listItemsTextArea.getText());
refreshPreview();
}
});
previewProperties.put("text", listItemsTextArea.getText());
t.add(listItemsTextArea).growX();
} else if (clazz.equals(Slider.class)) {
t.row();
t.add(new Label("Disabled: ", getSkin())).right();
ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
disabledCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("disabled", disabledCheckBox.isChecked());
refreshPreview();
}
});
previewProperties.put("disabled", disabledCheckBox.isChecked());
disabledCheckBox.addListener(main.getHandListener());
t.add(disabledCheckBox).left();
t.row();
t.add(new Label("Minimum: ", getSkin())).right();
Spinner minimumSpinner = new Spinner(0.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
minimumSpinner.getTextField().setFocusTraversal(false);
minimumSpinner.getTextField().addListener(main.getIbeamListener());
t.add(minimumSpinner).growX();
minimumSpinner.getButtonMinus().addListener(main.getHandListener());
minimumSpinner.getButtonPlus().addListener(main.getHandListener());
previewProperties.put("minimum", minimumSpinner.getValue());
t.row();
t.add(new Label("Maximum: ", getSkin())).right();
Spinner maximumSpinner = new Spinner(100.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
maximumSpinner.getTextField().setFocusTraversal(false);
maximumSpinner.getTextField().addListener(main.getIbeamListener());
t.add(maximumSpinner).growX();
maximumSpinner.getButtonMinus().addListener(main.getHandListener());
maximumSpinner.getButtonPlus().addListener(main.getHandListener());
previewProperties.put("maximum", maximumSpinner.getValue());
minimumSpinner.setMaximum(maximumSpinner.getValue());
maximumSpinner.setMinimum(minimumSpinner.getValue());
minimumSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("minimum", minimumSpinner.getValue());
maximumSpinner.setMinimum(minimumSpinner.getValue());
refreshPreview();
}
});
maximumSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("maximum", maximumSpinner.getValue());
minimumSpinner.setMaximum(maximumSpinner.getValue());
refreshPreview();
}
});
t.row();
t.add(new Label("Increment: ", getSkin())).right();
Spinner incrementSpinner = new Spinner(1.0f, 1.0f, false, Spinner.Orientation.HORIZONTAL, getSkin());
incrementSpinner.getTextField().setFocusTraversal(false);
incrementSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("increment", incrementSpinner.getValue());
refreshPreview();
}
});
incrementSpinner.getTextField().addListener(main.getIbeamListener());
t.add(incrementSpinner).growX();
incrementSpinner.getButtonMinus().addListener(main.getHandListener());
incrementSpinner.getButtonPlus().addListener(main.getHandListener());
incrementSpinner.setMinimum(1.0f);
previewProperties.put("increment", incrementSpinner.getValue());
t.row();
t.add(new Label("Orientation: ", getSkin())).right();
SelectBox<String> selectBox = new SelectBox<>(getSkin());
selectBox.setItems(new String[] { "Horizontal", "Vertical" });
if (getSelectedStyle().name.contains("vert")) {
previewProperties.put("orientation", true);
selectBox.setSelectedIndex(1);
} else {
previewProperties.put("orientation", false);
}
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
if (selectBox.getSelectedIndex() == 0) {
previewProperties.put("orientation", false);
} else {
previewProperties.put("orientation", true);
}
refreshPreview();
}
});
selectBox.addListener(main.getHandListener());
selectBox.getList().addListener(main.getHandListener());
t.add(selectBox).growX();
} else if (clazz.equals(SplitPane.class)) {
t.row();
t.add(new Label("Orientation: ", getSkin())).right();
SelectBox<String> selectBox = new SelectBox<>(getSkin());
selectBox.setItems(new String[] { "Horizontal", "Vertical" });
if (getSelectedStyle().name.contains("vert")) {
previewProperties.put("orientation", true);
selectBox.setSelectedIndex(1);
} else {
previewProperties.put("orientation", false);
}
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
if (selectBox.getSelectedIndex() == 0) {
previewProperties.put("orientation", false);
} else {
previewProperties.put("orientation", true);
}
refreshPreview();
}
});
selectBox.addListener(main.getHandListener());
selectBox.getList().addListener(main.getHandListener());
t.add(selectBox).growX();
t.row();
t.add(new Label("Sample Text: ", getSkin())).right();
TextArea textArea = new TextArea(PARAGRAPH_SAMPLE, getSkin());
textArea.setFocusTraversal(false);
textArea.setPrefRows(5);
textArea.addListener(main.getIbeamListener());
textArea.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", textArea.getText());
refreshPreview();
}
});
previewProperties.put("text", textArea.getText());
t.add(textArea).growX();
previewSizeSelectBox.setSelectedIndex(2);
} else if (clazz.equals(TextButton.class)) {
t.row();
t.add(new Label("Disabled: ", getSkin())).right();
ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
disabledCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("disabled", disabledCheckBox.isChecked());
refreshPreview();
}
});
previewProperties.put("disabled", disabledCheckBox.isChecked());
disabledCheckBox.addListener(main.getHandListener());
t.add(disabledCheckBox).left();
t.row();
t.add(new Label("Text: ", getSkin())).right();
TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
previewTextField.setFocusTraversal(false);
previewTextField.addListener(main.getIbeamListener());
previewTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", previewTextField.getText());
refreshPreview();
}
});
previewProperties.put("text", previewTextField.getText());
t.add(previewTextField).growX();
} else if (clazz.equals(TextField.class)) {
t.row();
t.add(new Label("Disabled: ", getSkin())).right();
ImageTextButton disabledCheckBox = new ImageTextButton("", getSkin(), "switch");
disabledCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("disabled", disabledCheckBox.isChecked());
refreshPreview();
}
});
previewProperties.put("disabled", disabledCheckBox.isChecked());
disabledCheckBox.addListener(main.getHandListener());
t.add(disabledCheckBox).left();
t.row();
t.add(new Label("Password Mode: ", getSkin())).right();
ImageTextButton checkBox = new ImageTextButton("", getSkin(), "switch");
checkBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("passwordMode", checkBox.isChecked());
refreshPreview();
}
});
t.add(checkBox).left();
checkBox.addListener(main.getHandListener());
previewProperties.put("passwordMode", checkBox.isChecked());
t.row();
t.add(new Label("Password Character: ", getSkin()));
TextField pcTextField = new TextField("*", getSkin());
pcTextField.setFocusTraversal(false);
pcTextField.addListener(main.getIbeamListener());
pcTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("password", pcTextField.getText());
refreshPreview();
}
});
previewProperties.put("password", pcTextField.getText());
t.add(pcTextField).growX();
t.row();
t.add(new Label("Text Alignment: ", getSkin())).right();
SelectBox<String> selectBox = new SelectBox<>(getSkin());
selectBox.setItems(new String[] { "Left", "Center", "Right" });
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
switch(selectBox.getSelectedIndex()) {
case 0:
previewProperties.put("alignment", Align.left);
break;
case 1:
previewProperties.put("alignment", Align.center);
break;
case 2:
previewProperties.put("alignment", Align.right);
break;
}
refreshPreview();
}
});
t.add(selectBox).growX();
selectBox.addListener(main.getHandListener());
selectBox.getList().addListener(main.getHandListener());
previewProperties.put("alignment", Align.left);
t.row();
t.add(new Label("Text: ", getSkin())).right();
TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
previewTextField.setFocusTraversal(false);
previewTextField.addListener(main.getIbeamListener());
previewTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", previewTextField.getText());
refreshPreview();
}
});
previewProperties.put("text", previewTextField.getText());
t.add(previewTextField).growX();
t.row();
t.add(new Label("Message Text: ", getSkin())).right();
TextField messageTextField = new TextField(TEXT_SAMPLE, getSkin());
messageTextField.setFocusTraversal(false);
messageTextField.addListener(main.getIbeamListener());
messageTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("message", messageTextField.getText());
refreshPreview();
}
});
previewProperties.put("message", messageTextField.getText());
t.add(messageTextField).growX();
} else if (clazz.equals(TextTooltip.class)) {
t.row();
t.add(new Label("Text: ", getSkin())).right();
TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
previewTextField.setFocusTraversal(false);
previewTextField.addListener(main.getIbeamListener());
previewTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", previewTextField.getText());
refreshPreview();
}
});
previewProperties.put("text", previewTextField.getText());
t.add(previewTextField).growX();
} else if (clazz.equals(Touchpad.class)) {
} else if (clazz.equals(Tree.class)) {
t.row();
t.add(new Label("Icon Spacing: ", getSkin())).right();
Spinner spinner = new Spinner(0.0, 1.0, false, Spinner.Orientation.HORIZONTAL, getSkin());
spinner.getTextField().setFocusTraversal(false);
spinner.setMinimum(1);
spinner.getTextField().addListener(main.getIbeamListener());
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
t.add(spinner).growX();
t.row();
t.add(new Label("Y Spacing: ", getSkin())).right();
spinner = new Spinner(0.0, 1.0, false, Spinner.Orientation.HORIZONTAL, getSkin());
spinner.getTextField().setFocusTraversal(false);
spinner.setMinimum(1);
spinner.getTextField().addListener(main.getIbeamListener());
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
t.add(spinner).growX();
} else if (clazz.equals(Window.class)) {
t.row();
t.add(new Label("Title Text: ", getSkin())).right();
TextField previewTextField = new TextField(TEXT_SAMPLE, getSkin());
previewTextField.setFocusTraversal(false);
previewTextField.addListener(main.getIbeamListener());
previewTextField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("title", previewTextField.getText());
refreshPreview();
}
});
previewProperties.put("title", previewTextField.getText());
t.add(previewTextField).growX();
t.row();
t.add(new Label("Sample Text Color: ", getSkin()));
BrowseField textColorField = new BrowseField(null, null, getSkin(), "color");
textColorField.addListener(main.getHandListener());
t.add(textColorField).growX();
t.row();
t.add(new Label("Sample Text: ", getSkin())).right();
TextArea textArea = new TextArea(PARAGRAPH_SAMPLE, getSkin());
textArea.setFocusTraversal(false);
textArea.setPrefRows(5);
textArea.addListener(main.getIbeamListener());
textArea.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("text", textArea.getText());
refreshPreview();
}
});
previewProperties.put("text", textArea.getText());
t.add(textArea).growX();
}
previewSizeSelectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewProperties.put("size", previewSizeSelectBox.getSelectedIndex());
if (previewSizeSelectBox.getSelectedIndex() != 7) {
refreshPreview();
}
}
});
previewProperties.put("size", previewSizeSelectBox.getSelectedIndex());
refreshPreview();
} else {
t.add(new Label("Stage Color: ", getSkin())).right();
BrowseField browseField = new BrowseField(null, null, getSkin(), "color");
browseField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
main.getDialogFactory().showDialogColorPicker((Color) previewProperties.get("bgcolor"), new DialogColorPicker.ColorListener() {
@Override
public void selected(Color color) {
if (color != null) {
browseField.getTextButton().setText((int) (color.r * 255) + "," + (int) (color.g * 255) + "," + (int) (color.b * 255) + "," + (int) (color.a * 255));
previewProperties.put("bgcolor", color);
previewBgColor.set(color);
refreshPreview();
}
}
});
}
});
browseField.addListener(main.getHandListener());
t.add(browseField).growX();
browseField.getTextButton().setText((int) (previewBgColor.r * 255) + "," + (int) (previewBgColor.g * 255) + "," + (int) (previewBgColor.b * 255) + "," + (int) (previewBgColor.a * 255));
}
}
}
use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project skin-composer by raeleus.
the class DialogFreeTypeFont method populate.
private void populate() {
root.pad(15.0f);
Label label = new Label(mode == Mode.NEW ? "Create a new FreeType Font placeholder." : "Edit FreeType Font placeholder.", skin, "required");
root.add(label);
root.row();
Table table = new Table();
root.add(table).growX();
table.defaults().space(5.0f);
label = new Label("Font Name:", skin);
table.add(label);
TextField textField = new TextField(data.name, skin);
textField.setName("fontName");
table.add(textField);
TextTooltip toolTip = new TextTooltip("The name used in skin JSON", main.getTooltipManager(), getSkin());
textField.addListener(toolTip);
textField.addListener(main.getIbeamListener());
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
TextField textField = (TextField) actor;
data.name = textField.getText();
updateDisabledFields();
}
});
label = new Label("Preview TTF:", skin);
table.add(label).spaceLeft(15.0f);
SelectBox<String> selectBox = new SelectBox(skin);
selectBox.setName("previewSelectBox");
Array<String> previewFontNames = new Array<>();
FileHandle previewFontsPath = Gdx.files.local("preview fonts");
if (previewFontsPath.exists()) {
Array<FileHandle> files = new Array<>(previewFontsPath.list("ttf"));
for (FileHandle file : files) {
previewFontNames.add(file.nameWithoutExtension());
}
}
selectBox.setItems(previewFontNames);
selectBox.setSelected(data.previewTTF);
table.add(selectBox);
toolTip = new TextTooltip("The TTF font for preview use in Skin Composer only", main.getTooltipManager(), getSkin());
selectBox.addListener(toolTip);
selectBox.addListener(main.getHandListener());
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
SelectBox<String> selectBox = (SelectBox) actor;
data.previewTTF = selectBox.getSelected();
updateDisabledFields();
}
});
TextButton textButton = new TextButton("Open Preview Folder", skin);
table.add(textButton);
toolTip = new TextTooltip("Add new preview fonts here", main.getTooltipManager(), getSkin());
textButton.addListener(toolTip);
textButton.addListener(main.getHandListener());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
try {
Utils.openFileExplorer(Gdx.files.local("preview fonts/"));
} catch (Exception e) {
}
}
});
root.row();
Image image = new Image(skin, "welcome-separator");
image.setScaling(Scaling.stretch);
root.add(image).growX().space(15.0f);
root.row();
textField = new TextField(previewText, previewStyle);
textField.setName("previewField");
textField.setAlignment(Align.center);
root.add(textField).growX();
textField.addListener(main.getIbeamListener());
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
previewText = ((TextField) actor).getText();
}
});
root.row();
image = new Image(skin, "welcome-separator");
image.setScaling(Scaling.stretch);
root.add(image).growX().space(15.0f);
root.row();
table = new Table();
root.add(table);
table.defaults().space(5.0f);
CheckBox checkBox = new CheckBox("Use custom serializer and integrate TTF in Skin JSON", skin);
checkBox.setName("serializerCheckBox");
checkBox.setChecked(data.useCustomSerializer);
table.add(checkBox);
checkBox.addListener(main.getHandListener());
checkBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
CheckBox checkBox = (CheckBox) actor;
ScrollPane scrollPane = findActor("scrollPane");
SelectBox selectBox = findActor("previewSelectBox");
if (checkBox.isChecked()) {
scrollPane.addAction(Actions.sequence(Actions.fadeIn(.25f), Actions.touchable(Touchable.enabled)));
selectBox.addAction(Actions.sequence(Actions.alpha(.25f, .25f), Actions.touchable(Touchable.disabled)));
} else {
scrollPane.addAction(Actions.sequence(Actions.alpha(.25f, .25f), Actions.touchable(Touchable.disabled)));
selectBox.addAction(Actions.sequence(Actions.fadeIn(.25f), Actions.touchable(Touchable.enabled)));
}
data.useCustomSerializer = checkBox.isChecked();
updateDisabledFields();
}
});
textButton = new TextButton("More Info...", skin);
table.add(textButton);
textButton.addListener(main.getHandListener());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
showMoreInfoDialog();
}
});
root.row();
Table bottom = new Table();
ScrollPane scrollPane = new ScrollPane(bottom, skin);
scrollPane.setName("scrollPane");
scrollPane.setFadeScrollBars(false);
scrollPane.setFlickScroll(false);
root.add(scrollPane).padTop(10.0f);
if (!data.useCustomSerializer) {
scrollPane.setColor(1, 1, 1, .25f);
scrollPane.setTouchable(Touchable.disabled);
} else {
selectBox.setColor(1, 1, 1, .25f);
selectBox.setTouchable(Touchable.disabled);
}
bottom.defaults().space(5.0f);
table = new Table();
bottom.add(table).growX().colspan(4).spaceBottom(15.0f);
table.defaults().space(5.0f);
label = new Label("TTF Path:", skin);
table.add(label);
textField = new TextField(data.file == null ? "" : data.file.path(), skin);
textField.setName("fileField");
textField.setDisabled(true);
table.add(textField).growX();
toolTip = new TextTooltip("Path to TTF font to be distributed with skin", main.getTooltipManager(), getSkin());
textField.addListener(toolTip);
textButton = new TextButton("Browse...", skin);
table.add(textButton);
textButton.addListener(main.getHandListener());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Runnable runnable = () -> {
String defaultPath = main.getProjectData().getLastFontPath();
String[] filterPatterns = null;
if (!Utils.isMac()) {
filterPatterns = new String[] { "*.ttf" };
}
File file = main.getDesktopWorker().openDialog("Select TTF file...", defaultPath, filterPatterns, "True Type Font files");
if (file != null) {
FileHandle fileHandle = new FileHandle(file);
data.file = fileHandle;
updateDisabledFields();
((TextField) DialogFreeTypeFont.this.findActor("fileField")).setText(fileHandle.path());
main.getProjectData().setLastFontPath(fileHandle.parent().path() + "/");
}
};
main.getDialogFactory().showDialogLoading(runnable);
}
});
bottom.row();
label = new Label("Size:", skin);
bottom.add(label).right();
Spinner spinner = new Spinner(data.size, 1.0, true, Spinner.Orientation.HORIZONTAL, skin);
bottom.add(spinner).left().minWidth(100.0f);
toolTip = new TextTooltip("The size in pixels", main.getTooltipManager(), getSkin());
spinner.addListener(toolTip);
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
spinner.getTextField().addListener(main.getIbeamListener());
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Spinner spinner = (Spinner) actor;
data.size = (int) spinner.getValue();
updateDisabledFields();
}
});
label = new Label("Mono:", skin);
bottom.add(label).right();
Button button = new Button(skin, "switch");
button.setChecked(data.mono);
bottom.add(button).left();
toolTip = new TextTooltip("If on, font smoothing is disabled", main.getTooltipManager(), getSkin());
button.addListener(toolTip);
button.addListener(main.getHandListener());
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Button button = (Button) actor;
data.mono = button.isChecked();
updateDisabledFields();
}
});
bottom.row();
label = new Label("Hinting:", skin);
bottom.add(label).right();
selectBox = new SelectBox(skin);
selectBox.setItems("None", "Slight", "Medium", "Full", "AutoSlight", "AutoMedium", "AutoFull");
selectBox.setSelected(data.hinting);
bottom.add(selectBox).fillX().left();
toolTip = new TextTooltip("Strength of hinting", main.getTooltipManager(), getSkin());
selectBox.addListener(toolTip);
selectBox.addListener(main.getHandListener());
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
SelectBox<String> selectBox = (SelectBox) actor;
data.hinting = selectBox.getSelected();
updateDisabledFields();
}
});
label = new Label("Color:", skin);
bottom.add(label).right();
textButton = new TextButton(data.color, skin);
textButton.setName("colorTextButton");
image = new Image(skin, "icon-colorwheel-over");
textButton.add(image).space(10.0f);
bottom.add(textButton).left();
toolTip = new TextTooltip("Foreground color (Required)", main.getTooltipManager(), getSkin());
textButton.addListener(toolTip);
textButton.addListener(main.getHandListener());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
TextButton textButton = (TextButton) actor;
main.getDialogFactory().showDialogColors(new StyleProperty(), (ColorData colorData) -> {
if (colorData != null) {
textButton.setText(colorData.getName());
textButton.setUserObject(colorData);
data.color = colorData.getName();
} else {
textButton.setText("");
textButton.setUserObject(null);
data.color = null;
}
updateColors();
updateDisabledFields();
});
}
});
bottom.row();
label = new Label("Gamma:", skin);
bottom.add(label).right();
spinner = new Spinner(Double.parseDouble(df.format(data.gamma)), 1.0, false, Spinner.Orientation.HORIZONTAL, skin);
bottom.add(spinner).left().minWidth(100.0f);
toolTip = new TextTooltip("Glyph gamma. Values > 1 reduce antialiasing.", main.getTooltipManager(), getSkin());
spinner.addListener(toolTip);
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
spinner.getTextField().addListener(main.getIbeamListener());
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Spinner spinner = (Spinner) actor;
data.gamma = (float) spinner.getValue();
updateDisabledFields();
}
});
label = new Label("Render Count:", skin);
bottom.add(label).right();
spinner = new Spinner(data.renderCount, 1.0, true, Spinner.Orientation.HORIZONTAL, skin);
bottom.add(spinner).left().minWidth(100.0f);
toolTip = new TextTooltip("Number of times to render the glyph. Useful with a shadow or border, so it doesn't show through the glyph.", main.getTooltipManager(), getSkin());
spinner.addListener(toolTip);
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
spinner.getTextField().addListener(main.getIbeamListener());
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Spinner spinner = (Spinner) actor;
data.renderCount = (int) spinner.getValue();
updateDisabledFields();
}
});
bottom.row();
label = new Label("Border Width:", skin);
bottom.add(label).right();
spinner = new Spinner(data.borderWidth, 1.0, false, Spinner.Orientation.HORIZONTAL, skin);
bottom.add(spinner).left().minWidth(100.0f);
toolTip = new TextTooltip("Border width in pixels, 0 to disable", main.getTooltipManager(), getSkin());
spinner.addListener(toolTip);
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
spinner.getTextField().addListener(main.getIbeamListener());
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Spinner spinner = (Spinner) actor;
data.borderWidth = (float) spinner.getValue();
updateDisabledFields();
}
});
label = new Label("Border Color:", skin);
bottom.add(label).right();
textButton = new TextButton(data.borderColor, skin);
textButton.setName("borderColorTextButton");
image = new Image(skin, "icon-colorwheel-over");
textButton.add(image).space(10.0f);
bottom.add(textButton).left();
toolTip = new TextTooltip("Border color; Required if borderWidth > 0", main.getTooltipManager(), getSkin());
textButton.addListener(toolTip);
textButton.addListener(main.getHandListener());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
TextButton textButton = (TextButton) actor;
main.getDialogFactory().showDialogColors(new StyleProperty(), (ColorData colorData) -> {
if (colorData != null) {
textButton.setText(colorData.getName());
textButton.setUserObject(colorData);
data.borderColor = colorData.getName();
} else {
textButton.setText("");
textButton.setUserObject(null);
data.borderColor = null;
}
updateColors();
updateDisabledFields();
});
}
});
bottom.row();
label = new Label("Border Straight:", skin);
bottom.add(label).right();
button = new Button(skin, "switch");
button.setChecked(data.borderStraight);
bottom.add(button).left();
toolTip = new TextTooltip("On for straight (mitered), off for rounded borders", main.getTooltipManager(), getSkin());
button.addListener(toolTip);
button.addListener(main.getHandListener());
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Button button = (Button) actor;
data.borderStraight = button.isChecked();
updateDisabledFields();
}
});
label = new Label("Border Gamma:", skin);
bottom.add(label).right();
spinner = new Spinner(Double.parseDouble(df.format(data.borderGamma)), 1.0, false, Spinner.Orientation.HORIZONTAL, skin);
bottom.add(spinner).left().minWidth(100.0f);
toolTip = new TextTooltip("Values < 1 increase the border size.", main.getTooltipManager(), getSkin());
spinner.addListener(toolTip);
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
spinner.getTextField().addListener(main.getIbeamListener());
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Spinner spinner = (Spinner) actor;
data.borderGamma = (float) spinner.getValue();
updateDisabledFields();
}
});
bottom.row();
label = new Label("Shadow Offset X:", skin);
bottom.add(label).right();
spinner = new Spinner(data.shadowOffsetX, 1.0, true, Spinner.Orientation.HORIZONTAL, skin);
bottom.add(spinner).left().minWidth(100.0f);
toolTip = new TextTooltip("Offset of text shadow on X axis in pixels, 0 to disable", main.getTooltipManager(), getSkin());
spinner.addListener(toolTip);
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
spinner.getTextField().addListener(main.getIbeamListener());
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Spinner spinner = (Spinner) actor;
data.shadowOffsetX = (int) spinner.getValue();
updateDisabledFields();
}
});
label = new Label("Shadow Offset Y:", skin);
bottom.add(label).right();
spinner = new Spinner(data.shadowOffsetY, 1.0, true, Spinner.Orientation.HORIZONTAL, skin);
bottom.add(spinner).left().minWidth(100.0f);
toolTip = new TextTooltip("Offset of text shadow on Y axis in pixels, 0 to disable", main.getTooltipManager(), getSkin());
spinner.addListener(toolTip);
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
spinner.getTextField().addListener(main.getIbeamListener());
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Spinner spinner = (Spinner) actor;
data.shadowOffsetY = (int) spinner.getValue();
updateDisabledFields();
}
});
bottom.row();
label = new Label("Shadow Color:", skin);
bottom.add(label).right();
textButton = new TextButton(data.shadowColor, skin);
textButton.setName("shadowColorTextButton");
image = new Image(skin, "icon-colorwheel-over");
textButton.add(image).space(10.0f);
bottom.add(textButton).left();
toolTip = new TextTooltip("Shadow color; required if shadowOffset > 0.", main.getTooltipManager(), getSkin());
textButton.addListener(toolTip);
textButton.addListener(main.getHandListener());
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
TextButton textButton = (TextButton) actor;
main.getDialogFactory().showDialogColors(new StyleProperty(), (ColorData colorData) -> {
if (colorData != null) {
textButton.setText(colorData.getName());
textButton.setUserObject(colorData);
data.shadowColor = colorData.getName();
} else {
textButton.setText("");
textButton.setUserObject(null);
data.shadowColor = null;
}
updateColors();
updateDisabledFields();
});
}
});
label = new Label("Incremental:", skin);
bottom.add(label).right();
button = new Button(skin, "switch");
button.setChecked(data.incremental);
bottom.add(button).left();
toolTip = new TextTooltip("When true, glyphs are rendered on the fly to the \n" + "font's glyph page textures as they are needed.", main.getTooltipManager(), getSkin());
button.addListener(toolTip);
button.addListener(main.getHandListener());
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Button button = (Button) actor;
data.incremental = button.isChecked();
updateDisabledFields();
}
});
bottom.row();
label = new Label("Space X:", skin);
bottom.add(label).right();
spinner = new Spinner(data.spaceX, 1.0, true, Spinner.Orientation.HORIZONTAL, skin);
bottom.add(spinner).left().minWidth(100.0f);
toolTip = new TextTooltip("Pixels to add to glyph spacing. Can be negative.", main.getTooltipManager(), getSkin());
spinner.addListener(toolTip);
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
spinner.getTextField().addListener(main.getIbeamListener());
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Spinner spinner = (Spinner) actor;
data.spaceX = (int) spinner.getValue();
updateDisabledFields();
}
});
label = new Label("Space Y:", skin);
bottom.add(label).right();
spinner = new Spinner(data.spaceY, 1.0, true, Spinner.Orientation.HORIZONTAL, skin);
bottom.add(spinner).left().minWidth(100.0f);
toolTip = new TextTooltip("Pixels to add to glyph spacing. Can be negative.", main.getTooltipManager(), getSkin());
spinner.addListener(toolTip);
spinner.getButtonMinus().addListener(main.getHandListener());
spinner.getButtonPlus().addListener(main.getHandListener());
spinner.getTextField().addListener(main.getIbeamListener());
spinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Spinner spinner = (Spinner) actor;
data.spaceY = (int) spinner.getValue();
updateDisabledFields();
}
});
bottom.row();
label = new Label("Characters:", skin);
bottom.add(label).right();
textField = new TextField(data.characters, skin);
bottom.add(textField).left().growX();
toolTip = new TextTooltip("The characters the font should contain. Leave blank for defaults.", main.getTooltipManager(), getSkin());
textField.addListener(toolTip);
textField.addListener(main.getIbeamListener());
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
TextField textField = (TextField) actor;
data.characters = textField.getText();
updateDisabledFields();
}
});
label = new Label("Kerning:", skin);
bottom.add(label).right();
button = new Button(skin, "switch");
button.setChecked(data.kerning);
bottom.add(button).left();
toolTip = new TextTooltip("Whether the font should include kerning", main.getTooltipManager(), getSkin());
button.addListener(toolTip);
button.addListener(main.getHandListener());
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Button button = (Button) actor;
data.kerning = button.isChecked();
updateDisabledFields();
}
});
bottom.row();
label = new Label("Flip:", skin);
bottom.add(label).right();
button = new Button(skin, "switch");
button.setChecked(data.flip);
bottom.add(button).left();
toolTip = new TextTooltip("Whether to flip the font vertically", main.getTooltipManager(), getSkin());
button.addListener(toolTip);
button.addListener(main.getHandListener());
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Button button = (Button) actor;
data.flip = button.isChecked();
updateDisabledFields();
}
});
label = new Label("GenMipMaps:", skin);
bottom.add(label).right();
button = new Button(skin, "switch");
button.setChecked(data.genMipMaps);
bottom.add(button).left();
toolTip = new TextTooltip("Whether to generate mip maps for the resulting texture", main.getTooltipManager(), getSkin());
button.addListener(toolTip);
button.addListener(main.getHandListener());
button.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
Button button = (Button) actor;
data.genMipMaps = button.isChecked();
updateDisabledFields();
}
});
bottom.row();
label = new Label("Min Filter:", skin);
bottom.add(label).right();
selectBox = new SelectBox(skin);
selectBox.setItems("Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapLinearNearest", "MipMapNearestLinear", "MipMapLinearLinear");
selectBox.setSelected(data.minFilter);
bottom.add(selectBox).left();
toolTip = new TextTooltip("Minification filter", main.getTooltipManager(), getSkin());
selectBox.addListener(toolTip);
selectBox.addListener(main.getHandListener());
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
SelectBox<String> selectBox = (SelectBox) actor;
data.minFilter = selectBox.getSelected();
updateDisabledFields();
}
});
label = new Label("Mag Filter:", skin);
bottom.add(label).right();
selectBox = new SelectBox(skin);
selectBox.setItems("Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapLinearNearest", "MipMapNearestLinear", "MipMapLinearLinear");
selectBox.setSelected(data.magFilter);
bottom.add(selectBox).left();
toolTip = new TextTooltip("Magnification filter", main.getTooltipManager(), getSkin());
selectBox.addListener(toolTip);
selectBox.addListener(main.getHandListener());
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
SelectBox<String> selectBox = (SelectBox) actor;
data.magFilter = selectBox.getSelected();
updateDisabledFields();
}
});
buttons.pad(10.0f);
buttons.defaults().minWidth(75.0f).space(25.0f);
textButton = new TextButton("OK", skin);
textButton.setName("okButton");
textButton.addListener(main.getHandListener());
button(textButton, true);
textButton = new TextButton("Cancel", skin);
textButton.setName("cancelButton");
textButton.addListener(main.getHandListener());
button(textButton, false);
}
use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project var3dframe by Var3D.
the class VGame method getCheckBox.
/**
* 创建CheckBox
*/
public UI<CheckBox> getCheckBox(String downimgname, String upimgname) {
UI<CheckBox> ui = new UI<CheckBox>(this);
CheckBox button = new CheckBox("", getCheckBoxStyle(downimgname, upimgname, Color.WHITE));
ui.setActor(button);
return ui;
}
Aggregations