Search in sources :

Example 26 with Skin

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

the class StageDebugTest method create.

@Override
public void create() {
    textureRegion = new TextureRegion(new Texture("data/badlogic.jpg"));
    Gdx.input.setInputProcessor(this);
    stage1 = new Stage();
    stage1.getCamera().position.set(100, 100, 0);
    Group group = new Group();
    // group.setBounds(0, 0, 10, 10);
    // group.setOrigin(25, 50);
    group.setRotation(10);
    group.setScale(1.2f);
    stage1.addActor(group);
    DebugActor actor = new DebugActor();
    actor.setBounds(300, 140, 50, 100);
    actor.setOrigin(25, 50);
    actor.setRotation(-45);
    actor.setScale(2f);
    actor.addAction(forever(rotateBy(360, 8f)));
    group.addActor(actor);
    group.debugAll();
    stage2 = new Stage();
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextButton shortButton = new TextButton("Button short", skin);
    shortButton.debug();
    TextButton longButton = new TextButton("Button loooooooooong", skin);
    longButton.debug();
    Table root = new Table(skin);
    root.setFillParent(true);
    root.setBackground(skin.getDrawable("default-pane"));
    root.defaults().space(6);
    root.setTransform(true);
    root.rotateBy(10);
    root.setScale(1.3f, 1);
    root.debug();
    stage2.addActor(root);
    root.add(shortButton).pad(5);
    root.add(longButton).row();
    root.add("Colspan").colspan(2).row();
    switchStage();
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Group(com.badlogic.gdx.scenes.scene2d.Group) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) Texture(com.badlogic.gdx.graphics.Texture)

Example 27 with Skin

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

the class TableLayoutTest method create.

public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    Label nameLabel = new Label("Name:", skin);
    TextField nameText = new TextField("", skin);
    Label addressLabel = new Label("Address:", skin);
    TextField addressText = new TextField("", skin);
    Table table = new Table();
    stage.addActor(table);
    table.setSize(260, 195);
    table.setPosition(190, 142);
    // table.align(Align.right | Align.bottom);
    table.debug();
    TextureRegion upRegion = skin.getRegion("default-slider-knob");
    TextureRegion downRegion = skin.getRegion("default-slider-knob");
    BitmapFont buttonFont = skin.getFont("default-font");
    TextButton button = new TextButton("Button 1", skin);
    button.addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("touchDown 1");
            return false;
        }
    });
    table.add(button);
    // table.setTouchable(Touchable.disabled);
    Table table2 = new Table();
    stage.addActor(table2);
    table2.setFillParent(true);
    table2.bottom();
    TextButton button2 = new TextButton("Button 2", skin);
    button2.addListener(new ChangeListener() {

        public void changed(ChangeEvent event, Actor actor) {
            System.out.println("2!");
        }
    });
    button2.addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("touchDown 2");
            return false;
        }
    });
    table2.add(button2);
}
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) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 28 with Skin

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

the class TableTest method create.

@Override
public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    TextureRegion region = new TextureRegion(texture);
    NinePatch patch = skin.getPatch("default-round");
    Label label = new Label("This is some text.", skin);
    root = new Table() {

        public void draw(Batch batch, float parentAlpha) {
            super.draw(batch, parentAlpha);
        }
    };
    stage.addActor(root);
    // root.setTransform(true);
    Table table = new Table();
    table.setTransform(true);
    table.setPosition(100, 100);
    table.setOrigin(0, 0);
    table.setRotation(45);
    table.setScaleY(2);
    table.add(label);
    table.add(new TextButton("Text Button", skin));
    table.pack();
    // table.debug();
    table.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            System.out.println("click!");
        }
    });
    //		root.addActor(table);
    TextButton button = new TextButton("Text Button", skin);
    Table table2 = new Table();
    // table2.debug()
    table2.add(button);
    table2.setTransform(true);
    table2.setScaleX(1.5f);
    table2.setOrigin(table2.getPrefWidth() / 2, table2.getPrefHeight() / 2);
    // Test colspan with expandX.
    // root.setPosition(10, 10);
    root.debug();
    root.setFillParent(true);
    root.add(new Label("meow meow meow meow meow meow meow meow meow meow meow meow", skin)).colspan(3).expandX();
    root.add(new TextButton("Text Button", skin));
    root.row();
    root.add(new TextButton("Text Button", skin));
    root.add(new TextButton("Toggle Button", skin.get("toggle", TextButtonStyle.class)));
    root.add(new CheckBox("meow meow meow meow meow meow meow meow", skin));
// root.pack();
// root.add(new Button(new Image(region), skin));
// root.add(new LabelButton("Toggley", skin.getStyle("toggle", LabelButtonStyle.class)));
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) NinePatch(com.badlogic.gdx.graphics.g2d.NinePatch) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Texture(com.badlogic.gdx.graphics.Texture) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Batch(com.badlogic.gdx.graphics.g2d.Batch) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 29 with Skin

use of com.badlogic.gdx.scenes.scene2d.ui.Skin 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 30 with Skin

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

the class ControllersTest method setupUi.

private void setupUi() {
    // setup a tiny ui with a console and a clear button.
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    stage = new Stage();
    ui = new Table();
    ui.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    console = new List(skin);
    scrollPane = new ScrollPane(console);
    scrollPane.setScrollbarsOnTop(true);
    TextButton clear = new TextButton("Clear", skin);
    ui.add(scrollPane).expand(true, true).fill();
    ui.row();
    ui.add(clear).expand(true, false).fill();
    stage.addActor(ui);
    clear.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            clear();
        }
    });
    Gdx.input.setInputProcessor(stage);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) List(com.badlogic.gdx.scenes.scene2d.ui.List) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)41 Stage (com.badlogic.gdx.scenes.scene2d.Stage)36 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)27 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)20 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)17 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)13 Texture (com.badlogic.gdx.graphics.Texture)11 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)10 Actor (com.badlogic.gdx.scenes.scene2d.Actor)10 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)9 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)9 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)9 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)9 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)8 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)8 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)6 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)6 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)4 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)4 List (com.badlogic.gdx.scenes.scene2d.ui.List)4