use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project libgdx by libgdx.
the class BaseG3dHudTest method createHUD.
protected void createHUD() {
hud = new Stage(new ScalingViewport(Scaling.fit, PREF_HUDWIDTH, PREF_HUDHEIGHT));
hudWidth = hud.getWidth();
hudHeight = hud.getHeight();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
final List<String> modelsList = new List(skin);
modelsList.setItems(models);
modelsList.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (!modelsWindow.isCollapsed() && getTapCount() == 2) {
onModelClicked(modelsList.getSelected());
modelsWindow.collapse();
}
}
});
modelsWindow = addListWindow("Models", modelsList, 0, -1);
fpsLabel = new Label("FPS: 999", skin);
hud.addActor(fpsLabel);
gridCheckBox = new CheckBox("Show grid", skin);
gridCheckBox.setChecked(showAxes);
gridCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
showAxes = gridCheckBox.isChecked();
}
});
gridCheckBox.setPosition(hudWidth - gridCheckBox.getWidth(), 0);
hud.addActor(gridCheckBox);
rotateCheckBox = new CheckBox("Rotate", skin);
rotateCheckBox.setChecked(true);
rotateCheckBox.setPosition(hudWidth - rotateCheckBox.getWidth(), gridCheckBox.getHeight());
hud.addActor(rotateCheckBox);
moveCheckBox = new CheckBox("Move", skin);
moveCheckBox.setChecked(false);
moveCheckBox.setPosition(hudWidth - moveCheckBox.getWidth(), rotateCheckBox.getTop());
hud.addActor(moveCheckBox);
}
use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project libgdx by libgdx.
the class NoncontinuousRenderingTest method populateTable.
private void populateTable() {
Table root = new Table();
stage.addActor(root);
root.setFillParent(true);
root.pad(5);
root.defaults().left().space(5);
Button button0 = new TextButton("Toggle continuous rendering", skin, "toggle");
button0.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
boolean continuous = Gdx.graphics.isContinuousRendering();
Gdx.graphics.setContinuousRendering(!continuous);
}
});
root.add(button0).row();
final String str1 = "2s sleep -> Application.postRunnable()";
Button button1 = new TextButton(str1, skin);
button1.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) {
}
nextColor();
Gdx.app.postRunnable(new Runnable() {
public void run() {
Gdx.app.log(str1, "Posted runnable to Gdx.app");
}
});
}
}).start();
}
});
root.add(button1).row();
final String str2 = "2s sleep -> Graphics.requestRendering()";
Button button2 = new TextButton(str2, skin);
button2.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
// caching necessary to ensure call on this window
final Graphics graphics = Gdx.graphics;
new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) {
}
nextColor();
graphics.requestRendering();
Gdx.app.log(str2, "Called Gdx.graphics.requestRendering()");
}
}).start();
}
});
root.add(button2).row();
final String str3 = "2s Timer -> Application.postRunnable()";
Button button3 = new TextButton(str3, skin);
button3.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
Timer.schedule(new Task() {
public void run() {
nextColor();
Gdx.app.postRunnable(new Runnable() {
public void run() {
Gdx.app.log(str3, "Posted runnable to Gdx.app");
}
});
}
}, 2f);
}
});
root.add(button3).row();
final String str4 = "2s DelayAction";
Button button4 = new TextButton(str4, skin);
button4.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
stage.addAction(Actions.sequence(Actions.delay(2), Actions.run(new Runnable() {
public void run() {
nextColor();
Gdx.app.log(str4, "RunnableAction executed");
}
})));
}
});
root.add(button4).row();
final String str5 = "(2s sleep -> toggle continuous) 2X";
Button button5 = new TextButton(str5, skin);
button5.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
// caching necessary to ensure call on this window
final Graphics graphics = Gdx.graphics;
new Thread(new Runnable() {
public void run() {
for (int i = 0; i < 2; i++) {
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) {
}
nextColor();
boolean continuous = graphics.isContinuousRendering();
graphics.setContinuousRendering(!continuous);
Gdx.app.log(str5, "Toggled continuous");
}
}
}).start();
}
});
root.add(button5).row();
final CheckBox actionsRequestRendering = new CheckBox("ActionsRequestRendering", skin);
actionsRequestRendering.setChecked(true);
actionsRequestRendering.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
stage.setActionsRequestRendering(actionsRequestRendering.isChecked());
}
});
root.add(actionsRequestRendering).row();
Drawable knobDown = skin.newDrawable("default-slider-knob", Color.GRAY);
SliderStyle sliderStyle = skin.get("default-horizontal", SliderStyle.class);
sliderStyle.knobDown = knobDown;
Slider slider = new Slider(0, 100, 1, false, sliderStyle);
root.add(slider).row();
SelectBox<Pixmap.Format> selectBox = new SelectBox(skin);
selectBox.setItems(Pixmap.Format.values());
root.add(selectBox).row();
root.add();
root.add().grow();
}
use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project libgdx by libgdx.
the class ParticleEmittersTest method setupUI.
private void setupUI() {
ui = new Stage(new ExtendViewport(640, 480));
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
skipCleanup = new CheckBox("Skip blend function clean-up", skin);
skipCleanup.setTransform(false);
skipCleanup.addListener(listener);
logLabel = new Label("", skin.get(LabelStyle.class));
clearEmitters = new TextButton("Clear screen", skin);
clearEmitters.setTransform(false);
clearEmitters.addListener(listener);
Table table = new Table();
table.setTransform(false);
table.setFillParent(true);
table.defaults().padTop(5).left();
table.top().left().padLeft(5);
table.add(skipCleanup).row();
table.add(clearEmitters).row();
table.add(logLabel);
ui.addActor(table);
}
use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project libgdx by libgdx.
the class MipMapTest method createUI.
private void createUI() {
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
ui = new Stage();
String[] filters = new String[TextureFilter.values().length];
int idx = 0;
for (TextureFilter filter : TextureFilter.values()) {
filters[idx++] = filter.toString();
}
hwMipMap = new CheckBox("Hardware Mips", skin);
minFilter = new SelectBox(skin);
minFilter.setItems(filters);
magFilter = new SelectBox(skin.get(SelectBoxStyle.class));
magFilter.setItems("Nearest", "Linear");
Table table = new Table();
table.setSize(ui.getWidth(), 30);
table.setY(ui.getHeight() - 30);
table.add(hwMipMap).spaceRight(5);
table.add(new Label("Min Filter", skin)).spaceRight(5);
table.add(minFilter).spaceRight(5);
table.add(new Label("Mag Filter", skin)).spaceRight(5);
table.add(magFilter);
ui.addActor(table);
}
use of com.badlogic.gdx.scenes.scene2d.ui.CheckBox in project libgdx by libgdx.
the class ModelCacheTest method create.
@Override
public void create() {
super.create();
modelCache = new ModelCache();
cacheCheckBox = new CheckBox("Cache", skin);
cacheCheckBox.setChecked(false);
cacheCheckBox.setPosition(hudWidth - cacheCheckBox.getWidth(), moveCheckBox.getTop());
hud.addActor(cacheCheckBox);
}
Aggregations