com.badlogic.gdx.scenes.scene2d.utils.Align Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.utils.Align. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddStateDialog.java    From gdx-soundboard with MIT License 6 votes vote down vote up
public AddStateDialog(final Stage stage, final Skin skin, final MusicEventManager eventManager) {

        super("Add State", skin);
        this.stage = stage;
        this.skin = skin;
        this.eventManager = eventManager;


        Table content = this.getContentTable();
        Label label = new Label("State name", skin);
        label.setAlignment(Align.left);
        content.add(label).left().fillX().expandX().row();

        eventName = new TextField("", skin);
        content.add(eventName).right().fillX().expandX().row();

        Table buttons = this.getButtonTable();
        buttons.defaults().fillX().expandX();
        
        this.button("Ok", true);
        this.button("Cancel", false);
        

        key(Keys.ENTER, true);
        key(Keys.ESCAPE, false);
    }
 
Example #2
Source File: UsersList.java    From Cardshifter with Apache License 2.0 6 votes vote down vote up
public void handleUserStatus(UserStatusMessage message) {
    switch (message.getStatus()) {
        case OFFLINE:
            UserTable table = userMap.get(message.getUserId());
            if (table != null) {
                table.remove();
            }
            break;
        case ONLINE:
            table = userMap.get(message.getUserId());
            if (table == null) {
                final UserTable userTable = new UserTable(skin, message.getUserId(), message.getName());
                userMap.put(message.getUserId(), userTable);
                userTable.getTable().addListener(new ClickListener() {
                    @Override
                    public void clicked(InputEvent event, float x, float y) {
                    	UsersList.this.selectUser(userTable);

                    }
                });
                this.table.add(userTable.getTable()).align(Align.left).row();
            }
            break;
    }
}
 
Example #3
Source File: Window.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
@Override
protected void drawBackground (Batch batch, float parentAlpha, float x, float y) {
	float width = getWidth(), height = getHeight();
	float padTop = getPadTop();

	super.drawBackground(batch, parentAlpha, x, y);

	// Draw button table.
	buttonTable.getColor().a = getColor().a;
	buttonTable.pack();
	buttonTable.setPosition(width - buttonTable.getWidth(), Math.min(height - padTop, height - buttonTable.getHeight()));
	buttonTable.draw(batch, parentAlpha);

	// Draw the title without the batch transformed or clipping applied.
	y += height;
	TextBounds bounds = titleCache.getBounds();
	if ((titleAlignment & Align.left) != 0)
		x += getPadLeft();
	else if ((titleAlignment & Align.right) != 0)
		x += width - bounds.width - getPadRight();
	else
		x += (width - bounds.width) / 2;
	if ((titleAlignment & Align.top) == 0) {
		if ((titleAlignment & Align.bottom) != 0)
			y -= padTop - bounds.height;
		else
			y -= (padTop - bounds.height) / 2;
	}
	titleCache.setColors(tmpColor.set(getColor()).mul(style.titleFontColor));
	titleCache.setPosition((int)x, (int)y - 15); // HACK for Kenney's skin only!!
	titleCache.draw(batch, parentAlpha);
}
 
Example #4
Source File: Splash.java    From Skyland with MIT License 5 votes vote down vote up
@Override
public void show() {
    queueAssets();

    splashImage = new Image(new Texture(Gdx.files.internal(Textures.TEXTURE_TOXSICK_LOGO)));
    splashImage.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, Align.center);
    Skyland.STAGE.addActor(splashImage);

    addSplashAnimation();
}
 
Example #5
Source File: ExampleMain.java    From gdx-smart-font with MIT License 5 votes vote down vote up
@Override
public void create() {
	Gdx.app.setLogLevel(Application.LOG_DEBUG);
	SmartFontGenerator fontGen = new SmartFontGenerator();
	FileHandle exoFile = Gdx.files.local("LiberationMono-Regular.ttf");
	BitmapFont fontSmall = fontGen.createFont(exoFile, "exo-small", 24);
	BitmapFont fontMedium = fontGen.createFont(exoFile, "exo-medium", 48);
	BitmapFont fontLarge = fontGen.createFont(exoFile, "exo-large", 64);

	stage = new Stage();

	Label.LabelStyle smallStyle = new Label.LabelStyle();
	smallStyle.font = fontSmall;
	Label.LabelStyle mediumStyle = new Label.LabelStyle();
	mediumStyle.font = fontMedium;
	Label.LabelStyle largeStyle = new Label.LabelStyle();
	largeStyle.font = fontLarge;

	Label small = new Label("Small Font", smallStyle);
	Label medium = new Label("Medium Font", mediumStyle);
	Label large = new Label("Large Font", largeStyle);

	Table table = new Table();
	table.setFillParent(true);
	table.align(Align.center);
	stage.addActor(table);

	table.defaults().size(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 6);

	table.add(small).row();
	table.add(medium).row();
	table.add(large).row();
}
 
Example #6
Source File: Scene2dUtils.java    From gdx-soundboard with MIT License 5 votes vote down vote up
public static Label addLabel(String labelText, Table parent, Skin skin){
    Label label = new Label(labelText, skin);
    label.setAlignment(Align.left);
    parent.add(label).left();

    Label info = new Label("", skin);
    info.setAlignment(Align.right);
    parent.add(info).right().row();

    return info;
}
 
Example #7
Source File: Scene2dUtils.java    From gdx-soundboard with MIT License 5 votes vote down vote up
public static TextField addTextField(String labelText, Table parent, Skin skin){
    Label label = new Label(labelText, skin);
    label.setAlignment(Align.left);
    parent.add(label).left();

    TextField info = new TextField("", skin);
    parent.add(info).right().fillX().expandX().row();

    return info;
}
 
Example #8
Source File: Resources.java    From Skyland with MIT License 4 votes vote down vote up
private void update() {
    woodLabel.setText("" + wood);
    woodLabel.setPosition(Gdx.graphics.getWidth() / 2 - 50 - woodLabel.getText().length() * Gdx.graphics.getHeight() / 40, Gdx.graphics.getHeight() - 60, Align.right);
    stoneLabel.setText("" + stone);
    stoneLabel.setPosition(Gdx.graphics.getWidth() / 2 + 250 - stoneLabel.getText().length() * Gdx.graphics.getHeight() / 40, Gdx.graphics.getHeight() - 60, Align.right);
}
 
Example #9
Source File: MenuTopWidget.java    From ingress-apk-mod with Apache License 2.0 4 votes vote down vote up
public MenuTopWidget(Skin skin, int width, MenuControllerImpl controller, com.nianticproject.ingress.common.ui.widget.MenuTabId currTabId) {
    this.skin = skin;
    this.currTabId = currTabId;
    setWidth(width);

    Table titleTable = new Table();
    titleTable.setBackground(skin.getDrawable("ops-title-background"));
    Label opsLabel = new Label("OPS", skin, "ops-title");
    opsLabel.setAlignment(Align.right, Align.right);
    titleTable.add(opsLabel).expandX().fillX().right().padRight(Value.percentWidth(0.02F));

    this.tabsTable = new Table();
    this.scroll = new ScrollPane(this.tabsTable, new ScrollPane.ScrollPaneStyle()) {
        @Override
        public float getMinHeight() {
            return super.getPrefHeight();
        }
    };
    this.scroll.setWidth(width);
    this.scroll.setScrollingDisabled(false, true);
    this.scroll.setSmoothScrolling(false);

    Table indicatorssTable = new Table();
    this.scrollIndicatorLeft = new Table();
    this.scrollIndicatorLeft.setBackground(skin.getDrawable("ops-scroll-indicator-left"));
    indicatorssTable.add(this.scrollIndicatorLeft).expand().fill().left().width(Value.percentWidth(0.1F));
    this.scrollIndicatorRight = new Table();
    this.scrollIndicatorRight.setBackground(skin.getDrawable("ops-scroll-indicator-right"));
    indicatorssTable.add(this.scrollIndicatorRight).expand().fill().right().width(Value.percentWidth(0.1F));

    Table rootTable = new Table();
    rootTable.add(titleTable).expandX().fillX();
    rootTable.row();
    rootTable.stack(this.scroll, indicatorssTable);

    Table closeBtnTable = new Table();
    closeBtnTable.setWidth(getWidth());
    closeBtnTable.setHeight(getHeight());
    Button closeBtn = new Button(skin, "ops-close");
    closeBtnTable.add(closeBtn).expand().left().top();

    stack(rootTable, closeBtnTable);
}