Search in sources :

Example 46 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project libgdx by libgdx.

the class ColorTest method create.

@Override
public void create() {
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    skin.add("default", new BitmapFont(Gdx.files.internal("data/arial-32.fnt"), false));
    Table root = new Table();
    stage.addActor(root);
    root.setFillParent(true);
    Table column1 = new Table(skin);
    column1.add("WHITE", "default", Color.WHITE).row();
    column1.add("LIGHT_GRAY", "default", Color.LIGHT_GRAY).row();
    column1.add("GRAY", "default", Color.GRAY).row();
    column1.add("DARK_GRAY", "default", Color.DARK_GRAY).row();
    column1.add("BLUE", "default", Color.BLUE).row();
    column1.add("NAVY", "default", Color.NAVY).row();
    column1.add("ROYAL", "default", Color.ROYAL).row();
    column1.add("SLATE", "default", Color.SLATE).row();
    column1.add("SKY", "default", Color.SKY).row();
    column1.add("CYAN", "default", Color.CYAN).row();
    column1.add("TEAL", "default", Color.TEAL).row();
    Table column2 = new Table(skin);
    column2.add("GREEN", "default", Color.GREEN).row();
    column2.add("CHARTREUSE", "default", Color.CHARTREUSE).row();
    column2.add("LIME", "default", Color.LIME).row();
    column2.add("FOREST", "default", Color.FOREST).row();
    column2.add("OLIVE", "default", Color.OLIVE).row();
    column2.add("YELLOW", "default", Color.YELLOW).row();
    column2.add("GOLD", "default", Color.GOLD).row();
    column2.add("GOLDENROD", "default", Color.GOLDENROD).row();
    column2.add("ORANGE", "default", Color.ORANGE).row();
    column2.add("BROWN", "default", Color.BROWN).row();
    column2.add("TAN", "default", Color.TAN).row();
    column2.add("FIREBRICK", "default", Color.FIREBRICK).row();
    Table column3 = new Table(skin);
    column3.add("RED", "default", Color.RED).row();
    column3.add("SCARLET", "default", Color.SCARLET).row();
    column3.add("CORAL", "default", Color.CORAL).row();
    column3.add("SALMON", "default", Color.SALMON).row();
    column3.add("PINK", "default", Color.PINK).row();
    column3.add("MAGENTA", "default", Color.MAGENTA).row();
    column3.add("PURPLE", "default", Color.PURPLE).row();
    column3.add("VIOLET", "default", Color.VIOLET).row();
    column3.add("MAROON", "default", Color.MAROON).row();
    root.add(column1);
    root.add(column2);
    root.add(column3);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 47 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project libgdx by libgdx.

the class ContainerTest method label.

Table label(String text) {
    Table table = new Table().debug();
    table.add(new Label(text, skin)).fill().expand();
    return table;
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label)

Example 48 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project libgdx by libgdx.

the class ParticleControllerTest method setupUI.

private void setupUI() {
    Skin skin = assets.get(DEFAULT_SKIN);
    Table table = new Table();
    table.setFillParent(true);
    table.top().left().add(new Label("FPS ", skin)).left();
    table.add(fpsLabel = new Label("", skin)).left().expandX().row();
    ui.addActor(table);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Example 49 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project libgdx by libgdx.

the class GwtTestWrapper method create.

@Override
public void create() {
    Gdx.app.setLogLevel(Application.LOG_DEBUG);
    Gdx.app.log("GdxTestGwt", "Setting up for " + tests.length + " tests.");
    ui = new Stage();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    container = new Table();
    ui.addActor(container);
    container.debug();
    Table table = new Table();
    ScrollPane scroll = new ScrollPane(table);
    container.add(scroll).expand().fill();
    table.pad(10).defaults().expandX().space(4);
    Arrays.sort(tests, new Comparator<Instancer>() {

        @Override
        public int compare(Instancer o1, Instancer o2) {
            return o1.instance().getClass().getName().compareTo(o2.instance().getClass().getName());
        }
    });
    for (final Instancer instancer : tests) {
        table.row();
        TextButton button = new TextButton(instancer.instance().getClass().getName(), skin);
        button.addListener(new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                ((InputWrapper) Gdx.input).multiplexer.removeProcessor(ui);
                test = instancer.instance();
                Gdx.app.log("GdxTestGwt", "Clicked on " + test.getClass().getName());
                test.create();
                test.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            }
        });
        table.add(button).expandX().fillX();
    }
    container.row();
    container.add(new Label("Click on a test to start it, press ESC to close it.", new LabelStyle(font, Color.WHITE))).pad(5, 5, 5, 5);
    Gdx.input = new InputWrapper(Gdx.input) {

        @Override
        public boolean keyUp(int keycode) {
            if (keycode == Keys.ESCAPE) {
                if (test != null) {
                    Gdx.app.log("GdxTestGwt", "Exiting current test.");
                    dispose = true;
                }
            }
            return false;
        }

        @Override
        public boolean touchDown(int screenX, int screenY, int pointer, int button) {
            if (screenX < Gdx.graphics.getWidth() / 10.0 && screenY < Gdx.graphics.getHeight() / 10.0) {
                if (test != null) {
                    dispose = true;
                }
            }
            return false;
        }
    };
    ((InputWrapper) Gdx.input).multiplexer.addProcessor(ui);
    Gdx.app.log("GdxTestGwt", "Test picker UI setup complete.");
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 50 with Table

use of com.badlogic.gdx.scenes.scene2d.ui.Table in project libgdx by libgdx.

the class ProjectiveTextureTest method setupUI.

public void setupUI() {
    ui = new Stage();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextButton reload = new TextButton("Reload Shaders", skin.get(TextButtonStyle.class));
    camera = new SelectBox(skin.get(SelectBoxStyle.class));
    camera.setItems("Camera", "Light");
    fps = new Label("fps: ", skin.get(LabelStyle.class));
    Table table = new Table();
    table.setFillParent(true);
    table.top().padTop(15);
    table.add(reload).spaceRight(5);
    table.add(camera).spaceRight(5);
    table.add(fps);
    ui.addActor(table);
    reload.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            ShaderProgram prog = new ShaderProgram(Gdx.files.internal("data/shaders/projtex-vert.glsl").readString(), Gdx.files.internal("data/shaders/projtex-frag.glsl").readString());
            if (prog.isCompiled() == false) {
                Gdx.app.log("GLSL ERROR", "Couldn't reload shaders:\n" + prog.getLog());
            } else {
                projTexShader.dispose();
                projTexShader = prog;
            }
        }
    });
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) ShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

Table (com.badlogic.gdx.scenes.scene2d.ui.Table)85 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)51 Stage (com.badlogic.gdx.scenes.scene2d.Stage)48 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)36 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)35 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)31 Actor (com.badlogic.gdx.scenes.scene2d.Actor)30 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)25 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)21 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)18 Texture (com.badlogic.gdx.graphics.Texture)17 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)16 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)15 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)14 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)13 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)12 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)11 ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)11 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)9 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)8