Search in sources :

Example 26 with Label

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

the class BitmapFontTest method create.

@Override
public void create() {
    spriteBatch = new SpriteBatch();
    // font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false);
    font = new BitmapFont(Gdx.files.internal("data/arial-32-pad.fnt"), false);
    // font = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf")).generateFont(new FreeTypeFontParameter());
    font.getData().markupEnabled = true;
    font.getData().breakChars = new char[] { '-' };
    multiPageFont = new BitmapFont(Gdx.files.internal("data/multipagefont.fnt"));
    // Add user defined color
    Colors.put("PERU", Color.valueOf("CD853F"));
    renderer = new ShapeRenderer();
    renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
    stage = new Stage(new ScreenViewport());
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    BitmapFont labelFont = skin.get("default-font", BitmapFont.class);
    labelFont.getData().markupEnabled = true;
    // Notice that the last [] has been deliberately added to test the effect of excessive pop operations.
    // They are silently ignored, as expected.
    label = new Label("<<[BLUE]M[RED]u[YELLOW]l[GREEN]t[OLIVE]ic[]o[]l[]o[]r[]*[MAROON]Label[][] [Unknown Color]>>", skin);
    label.setPosition(100, 200);
    stage.addActor(label);
    Window window = new Window("[RED]Multicolor[GREEN] Title", skin);
    window.setPosition(400, 300);
    window.pack();
    stage.addActor(window);
    layout = new GlyphLayout();
}
Also used : Window(com.badlogic.gdx.scenes.scene2d.ui.Window) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) GlyphLayout(com.badlogic.gdx.graphics.g2d.GlyphLayout) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 27 with Label

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

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

the class LabelTest method create.

@Override
public void create() {
    batch = new SpriteBatch();
    renderer = new ShapeRenderer();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    skin.getAtlas().getTextures().iterator().next().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    skin.getFont("default-font").getData().markupEnabled = true;
    float scale = 1;
    skin.getFont("default-font").getData().setScale(scale);
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
    Table table = new Table();
    stage.addActor(table);
    table.setPosition(200, 65);
    table.debug();
    table.add(new Label("This is regular text.", skin));
    table.row();
    table.add(new Label("This is regular text\nwith a newline.", skin));
    table.row();
    Label label3 = new Label("This is [RED]regular text\n\nwith newlines,\naligned bottom, right.", skin);
    label3.setColor(Color.GREEN);
    label3.setAlignment(Align.bottom | Align.right);
    table.add(label3).minWidth(200 * scale).minHeight(110 * scale).fill();
    table.row();
    Label label4 = new Label("This is regular text with NO newlines, wrap enabled and aligned bottom, right.", skin);
    label4.setWrap(true);
    label4.setAlignment(Align.bottom | Align.right);
    table.add(label4).minWidth(200 * scale).minHeight(110 * scale).fill();
    table.row();
    Label label5 = new Label("This is regular text with\n\nnewlines, wrap\nenabled and aligned bottom, right.", skin);
    label5.setWrap(true);
    label5.setAlignment(Align.bottom | Align.right);
    table.add(label5).minWidth(200 * scale).minHeight(110 * scale).fill();
    table.pack();
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 29 with Label

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

use of com.badlogic.gdx.scenes.scene2d.ui.Label 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)

Aggregations

Label (com.badlogic.gdx.scenes.scene2d.ui.Label)43 Stage (com.badlogic.gdx.scenes.scene2d.Stage)25 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)24 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)23 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)20 Actor (com.badlogic.gdx.scenes.scene2d.Actor)18 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)16 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)16 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)10 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)10 Texture (com.badlogic.gdx.graphics.Texture)9 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)9 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)9 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)8 ScreenViewport (com.badlogic.gdx.utils.viewport.ScreenViewport)8 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)7 Window (com.badlogic.gdx.scenes.scene2d.ui.Window)7 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)6 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)5 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)5