use of com.badlogic.gdx.scenes.scene2d.ui.Slider.SliderStyle 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();
}
Aggregations