Example usage for com.badlogic.gdx.scenes.scene2d.ui Image setAlign

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Image setAlign

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui Image setAlign.

Prototype

public void setAlign(int align) 

Source Link

Usage

From source file:com.bladecoder.engineeditor.Editor.java

License:Apache License

@Override
public void create() {
    skin = new Skin(Gdx.files.internal(SKIN));

    EditorLogger.setDebug();//from ww w . jav a 2s.c  om
    EditorLogger.debug("CREATE");
    Ctx.project = new Project();
    Message.init(skin);
    Ctx.assetManager = new EditorAssetManager();

    scnEditor = new ScnEditor(skin);
    scnEditor.setBackground("background");
    skin.getFont("default-font").getData().markupEnabled = true;

    /*** STAGE SETUP ***/
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);

    // RIGHT PANEL
    ScenePanel scenePanel = new ScenePanel(skin);
    ActorPanel actorPanel = new ActorPanel(skin);

    Table rightPanel = new Table(skin);
    rightPanel.top().left();
    rightPanel.add(actorPanel).expand().fill().left();
    rightPanel.setBackground("background");

    SplitPane splitPaneRight = new SplitPane(scnEditor, rightPanel, false, skin);

    splitPaneRight.setSplitAmount(0.75f);

    // LEFT PANEL
    ProjectPanel projectPanel = new ProjectPanel(skin);
    Image img = new Image(Ctx.assetManager.getIcon("title"));
    img.setScaling(Scaling.none);
    img.setAlign(Align.left);

    Table leftPanel = new Table(skin);
    leftPanel.top().left().padLeft(10);
    leftPanel.add(img).expand().fill().padBottom(20).padTop(20).padLeft(0).left();
    leftPanel.row();
    leftPanel.add(new ProjectToolbar(skin)).expandX().fill().left();
    leftPanel.row();
    leftPanel.add(projectPanel).expand().fill().left();
    leftPanel.row();
    leftPanel.add(scenePanel).expand().fill().left();
    leftPanel.setBackground("background");

    SplitPane splitPaneLeft = new SplitPane(leftPanel, splitPaneRight, false, skin);
    splitPaneLeft.setFillParent(true);
    splitPaneLeft.setSplitAmount(0.25f);
    stage.addActor(splitPaneLeft);

    // LOAD LAST OPEN PROJECT
    String lastProject = Ctx.project.getEditorConfig().getProperty(Project.LAST_PROJECT_PROP, "");

    if (!lastProject.isEmpty() && new File(lastProject).exists()) {
        try {
            EditorLogger.debug("Loading last project: " + lastProject);
            Ctx.project.loadProject(new File(lastProject));
        } catch (Exception e) {
            EditorLogger.debug("Error loading last project: " + e.getMessage());
            Ctx.project.closeProject();
            e.printStackTrace();
        }
    }

    stage.setScrollFocus(scnEditor.getScnWidget());
    stage.setKeyboardFocus(scnEditor.getScnWidget());

    TooltipManager.getInstance().instant();
}

From source file:com.vlaaad.dice.ui.windows.CreatureQueueWindow.java

License:Open Source License

@Override
protected void initialize() {
    creaturesList.defaults().pad(2);/* w ww. j a va  2 s .  c  o m*/
    creaturesList.padTop(12);

    Image left = new Image(Config.skin, "ui-creature-queue-gradient-left");
    left.setScaling(Scaling.stretchY);
    left.setAlign(Align.left);
    left.setTouchable(Touchable.disabled);

    Image right = new Image(Config.skin, "ui-creature-queue-gradient-right");
    right.setScaling(Scaling.stretchY);
    right.setAlign(Align.right);
    right.setTouchable(Touchable.disabled);

    Stack stack = new Stack();
    stack.add(new ScrollPane(creaturesList, new ScrollPane.ScrollPaneStyle()));
    stack.add(left);
    stack.add(right);

    Table content = new Table(Config.skin);
    content.setTouchable(Touchable.enabled);
    content.setBackground("ui-inventory-ability-window-background");
    content.defaults().pad(2);
    content.add(new LocLabel("ui-turns-order")).row();
    content.add(new Image(Config.skin, "ui-creature-info-line")).width(100).row();
    content.add(stack).maxWidth(table.getStage().getWidth() - 45).padRight(4).padLeft(4).row();

    table.add(content);
}

From source file:net.onedaybeard.keyflection.demo.DemoUI.java

License:Apache License

@Override
public void create() {
    background = new Color(0.2f, 0.2f, 0.2f, 1f);

    texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), false);

    stageActions = new StageKeys();

    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);

    float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2;
    for (int i = 0; i < NUM_GROUPS; i++) {
        Group group = new Group();
        group.setX((float) Math.random() * (stage.getWidth() - NUM_SPRITES * (32 + SPACING)));
        group.setY((float) Math.random() * (stage.getHeight() - NUM_SPRITES * (32 + SPACING)));
        group.setOrigin(loc, loc);/*ww  w . ja va 2  s .c o m*/

        fillGroup(group, texture);
        stage.addActor(group);
    }

    uiTexture = new Texture(Gdx.files.internal("data/ui.png"));
    uiTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    ui = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    ui.addListener(new KeyflectionInputListener(stageActions));

    Image blend = new Image(new TextureRegion(uiTexture, 0, 0, 64, 32));
    blend.setAlign(Align.center);
    blend.setScaling(Scaling.none);
    blend.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            stageActions.toggleBlending();
            return true;
        }
    });
    blend.setY(ui.getHeight() - 64);

    Image rotate = new Image(new TextureRegion(uiTexture, 64, 0, 64, 32));
    rotate.setAlign(Align.center);
    rotate.setScaling(Scaling.none);
    rotate.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            stageActions.toggleRotation();
            return true;
        }
    });
    rotate.setPosition(64, blend.getY());

    Image scale = new Image(new TextureRegion(uiTexture, 64, 32, 64, 32));
    scale.setAlign(Align.center);
    scale.setScaling(Scaling.none);
    scale.addListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            stageActions.toggleScaling();
            return true;
        }
    });
    scale.setPosition(128, blend.getY());

    ui.addActor(blend);
    ui.addActor(rotate);
    ui.addActor(scale);

    hint = new Label("Press F1 to see keyboard shortcuts.", new Label.LabelStyle(font, Color.WHITE));
    hint.setPosition(10, 45);
    hint.setColor(0, 1, 0, 1);
    ui.addActor(hint);

    fps = new Label("fps: 0", new Label.LabelStyle(font, Color.WHITE));
    fps.setPosition(10, 30);
    fps.setColor(0, 1, 0, 1);
    ui.addActor(fps);

    renderer = new ShapeRenderer();

    InputMultiplexer multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(new KeyflectionInputProcessor(new GlobalKeys()));
    multiplexer.addProcessor(stage);
    multiplexer.addProcessor(ui);

    Gdx.input.setInputProcessor(multiplexer);
}

From source file:net.onedaybeard.keyflection.demo.DemoUI.java

License:Apache License

private void fillGroup(Group group, Texture texture) {
    float advance = 32 + SPACING;
    for (int y = 0; y < NUM_SPRITES * advance; y += advance)
        for (int x = 0; x < NUM_SPRITES * advance; x += advance) {
            Image img = new Image(new TextureRegion(texture));
            img.setAlign(Align.center);
            img.setScaling(Scaling.none);
            img.setBounds(x, y, 32, 32);
            img.setOrigin(16, 16);/*from  ww  w.  ja va2 s  . com*/
            group.addActor(img);
            images.add(img);
        }
}