Search in sources :

Example 1 with LabelStyle

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

the class TextButton method setStyle.

public void setStyle(ButtonStyle style) {
    if (style == null)
        throw new NullPointerException("style cannot be null");
    if (!(style instanceof TextButtonStyle))
        throw new IllegalArgumentException("style must be a TextButtonStyle.");
    super.setStyle(style);
    this.style = (TextButtonStyle) style;
    if (label != null) {
        TextButtonStyle textButtonStyle = (TextButtonStyle) style;
        LabelStyle labelStyle = label.getStyle();
        labelStyle.font = textButtonStyle.font;
        labelStyle.fontColor = textButtonStyle.fontColor;
        label.setStyle(labelStyle);
    }
}
Also used : LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle)

Example 2 with LabelStyle

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

the class ImageTextButton method setStyle.

public void setStyle(ButtonStyle style) {
    if (!(style instanceof ImageTextButtonStyle))
        throw new IllegalArgumentException("style must be a ImageTextButtonStyle.");
    super.setStyle(style);
    this.style = (ImageTextButtonStyle) style;
    if (image != null)
        updateImage();
    if (label != null) {
        ImageTextButtonStyle textButtonStyle = (ImageTextButtonStyle) style;
        LabelStyle labelStyle = label.getStyle();
        labelStyle.font = textButtonStyle.font;
        labelStyle.fontColor = textButtonStyle.fontColor;
        label.setStyle(labelStyle);
    }
}
Also used : LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle)

Example 3 with LabelStyle

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

the class GroupTest method create.

public void create() {
    batch = new SpriteBatch();
    font = new BitmapFont();
    renderer = new ShapeRenderer();
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
    region = new TextureRegion(new Texture(Gdx.files.internal("data/group-debug.png")));
    group2 = new TestGroup("group2");
    group2.setTransform(true);
    stage.addActor(group2);
    group1 = new TestGroup("group1");
    group1.setTransform(true);
    group2.addActor(group1);
    LabelStyle style = new LabelStyle();
    style.font = new BitmapFont();
    Texture texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    horiz = new HorizontalGroup().pad(10, 20, 30, 40).top().space(5).reverse();
    for (int i = 1; i <= 15; i++) {
        horiz.addActor(new Label(i + ",", style));
        if (i == 7)
            horiz.addActor(new Container(new Image(texture)).size(10));
    }
    horiz.addActor(new Container(new Image(texture)).fill().prefSize(30));
    horiz.debug();
    horiz.setPosition(10, 10);
    horiz.pack();
    stage.addActor(horiz);
    horizWrap = new HorizontalGroup().wrap().pad(10, 20, 30, 40).right().rowBottom().space(5).wrapSpace(15).reverse();
    for (int i = 1; i <= 15; i++) {
        horizWrap.addActor(new Label(i + ",", style));
        if (i == 7)
            horizWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
    }
    horizWrap.addActor(new Container(new Image(texture)).prefSize(30));
    horizWrap.debug();
    horizWrap.setBounds(10, 85, 150, 40);
    stage.addActor(horizWrap);
    vert = new VerticalGroup().pad(10, 20, 30, 40).top().space(5).reverse();
    for (int i = 1; i <= 8; i++) {
        vert.addActor(new Label(i + ",", style));
        if (i == 4)
            vert.addActor(new Container(new Image(texture)).size(10));
    }
    vert.addActor(new Container(new Image(texture)).size(30));
    vert.debug();
    vert.setPosition(515, 10);
    vert.pack();
    stage.addActor(vert);
    vertWrap = new VerticalGroup().wrap().pad(10, 20, 30, 40).bottom().columnRight().space(5).wrapSpace(15).reverse();
    for (int i = 1; i <= 8; i++) {
        vertWrap.addActor(new Label(i + ",", style));
        if (i == 4)
            vertWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
    }
    vertWrap.addActor(new Container(new Image(texture)).prefSize(30));
    vertWrap.debug();
    vertWrap.setBounds(610, 10, 150, 40);
    stage.addActor(vertWrap);
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) VerticalGroup(com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) Stage(com.badlogic.gdx.scenes.scene2d.Stage) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 4 with LabelStyle

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

the class DragAndDropTest method create.

public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    final Skin skin = new Skin();
    skin.add("default", new LabelStyle(new BitmapFont(), Color.WHITE));
    skin.add("badlogic", new Texture("data/badlogic.jpg"));
    Image sourceImage = new Image(skin, "badlogic");
    sourceImage.setBounds(50, 125, 100, 100);
    stage.addActor(sourceImage);
    Image validTargetImage = new Image(skin, "badlogic");
    validTargetImage.setBounds(200, 50, 100, 100);
    stage.addActor(validTargetImage);
    Image invalidTargetImage = new Image(skin, "badlogic");
    invalidTargetImage.setBounds(200, 200, 100, 100);
    stage.addActor(invalidTargetImage);
    DragAndDrop dragAndDrop = new DragAndDrop();
    dragAndDrop.addSource(new Source(sourceImage) {

        public Payload dragStart(InputEvent event, float x, float y, int pointer) {
            Payload payload = new Payload();
            payload.setObject("Some payload!");
            payload.setDragActor(new Label("Some payload!", skin));
            Label validLabel = new Label("Some payload!", skin);
            validLabel.setColor(0, 1, 0, 1);
            payload.setValidDragActor(validLabel);
            Label invalidLabel = new Label("Some payload!", skin);
            invalidLabel.setColor(1, 0, 0, 1);
            payload.setInvalidDragActor(invalidLabel);
            return payload;
        }
    });
    dragAndDrop.addTarget(new Target(validTargetImage) {

        public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
            getActor().setColor(Color.GREEN);
            return true;
        }

        public void reset(Source source, Payload payload) {
            getActor().setColor(Color.WHITE);
        }

        public void drop(Source source, Payload payload, float x, float y, int pointer) {
            System.out.println("Accepted: " + payload.getObject() + " " + x + ", " + y);
        }
    });
    dragAndDrop.addTarget(new Target(invalidTargetImage) {

        public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
            getActor().setColor(Color.RED);
            return false;
        }

        public void reset(Source source, Payload payload) {
            getActor().setColor(Color.WHITE);
        }

        public void drop(Source source, Payload payload, float x, float y, int pointer) {
        }
    });
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) Texture(com.badlogic.gdx.graphics.Texture) Source(com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Source) Target(com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Target) DragAndDrop(com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) Payload(com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Payload) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 5 with LabelStyle

use of com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle in project gdx-skineditor by cobolfoo.

the class Tooltips method showTooltip.

public void showTooltip(Actor actor) {
    Vector2 v = new Vector2();
    actor.localToStageCoordinates(v);
    if (tooltip == null) {
        LabelStyle style = new LabelStyle();
        style.font = tooltipStyle.font;
        style.background = tooltipStyle.background;
        style.fontColor = tooltipStyle.fontColor;
        tooltip = new Label(tooltips.get(actor), style);
        tooltip.setStyle(style);
        tooltip.pack();
        tooltip.setPosition(v.x + 7.5f, v.y - tooltip.getPrefHeight() - 15);
        tooltip.setOriginY(tooltip.getPrefHeight());
        tooltip.setColor(1, 1, 1, 0);
        tooltip.setScale(1, 0);
        tooltip.addAction(parallel(fadeIn(0.15f), scaleTo(1, 1, 0.15f)));
    } else {
        tooltip.setText(tooltips.get(actor));
        tooltip.pack();
        tooltip.setPosition(v.x + 7.5f, v.y - tooltip.getPrefHeight() - 15);
    }
    stage.addActor(tooltip);
}
Also used : Vector2(com.badlogic.gdx.math.Vector2) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle)

Aggregations

LabelStyle (com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle)17 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)12 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)6 Color (com.badlogic.gdx.graphics.Color)4 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)4 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)4 FontData (com.ray3k.skincomposer.data.FontData)4 FreeTypeFontData (com.ray3k.skincomposer.data.FreeTypeFontData)4 Actor (com.badlogic.gdx.scenes.scene2d.Actor)3 Stage (com.badlogic.gdx.scenes.scene2d.Stage)3 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)3 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)3 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)3 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)3 TextTooltip (com.badlogic.gdx.scenes.scene2d.ui.TextTooltip)3 Array (com.badlogic.gdx.utils.Array)3 StyleData (com.ray3k.skincomposer.data.StyleData)3 FileHandle (com.badlogic.gdx.files.FileHandle)2 Texture (com.badlogic.gdx.graphics.Texture)2 BitmapFontData (com.badlogic.gdx.graphics.g2d.BitmapFont.BitmapFontData)2