Search in sources :

Example 6 with CheckBox

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);
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) List(com.badlogic.gdx.scenes.scene2d.ui.List) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) ScalingViewport(com.badlogic.gdx.utils.viewport.ScalingViewport)

Example 7 with CheckBox

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();
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Task(com.badlogic.gdx.utils.Timer.Task) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Slider(com.badlogic.gdx.scenes.scene2d.ui.Slider) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) Graphics(com.badlogic.gdx.Graphics) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Button(com.badlogic.gdx.scenes.scene2d.ui.Button) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) SliderStyle(com.badlogic.gdx.scenes.scene2d.ui.Slider.SliderStyle)

Example 8 with CheckBox

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);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) ExtendViewport(com.badlogic.gdx.utils.viewport.ExtendViewport) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Example 9 with CheckBox

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);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) TextureFilter(com.badlogic.gdx.graphics.Texture.TextureFilter)

Example 10 with CheckBox

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);
}
Also used : CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) ModelCache(com.badlogic.gdx.graphics.g3d.ModelCache)

Aggregations

CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)10 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)8 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)7 Stage (com.badlogic.gdx.scenes.scene2d.Stage)6 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)6 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)6 Actor (com.badlogic.gdx.scenes.scene2d.Actor)5 SelectBox (com.badlogic.gdx.scenes.scene2d.ui.SelectBox)4 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)4 Texture (com.badlogic.gdx.graphics.Texture)3 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)3 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)3 Button (com.badlogic.gdx.scenes.scene2d.ui.Button)3 List (com.badlogic.gdx.scenes.scene2d.ui.List)3 Slider (com.badlogic.gdx.scenes.scene2d.ui.Slider)3 Window (com.badlogic.gdx.scenes.scene2d.ui.Window)3 Batch (com.badlogic.gdx.graphics.g2d.Batch)2 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)2 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)2 SplitPane (com.badlogic.gdx.scenes.scene2d.ui.SplitPane)2