Example usage for com.badlogic.gdx.scenes.scene2d.ui SelectBox getItems

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui SelectBox getItems

Introduction

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

Prototype

public Array<T> getItems() 

Source Link

Document

Retrieve the backing Array that makes up the chocies available in the SelectBox

Usage

From source file:com.bladecoder.engineeditor.ui.EditAnimationDialog.java

License:Apache License

private void fillAnimations() {
    @SuppressWarnings("unchecked")
    SelectBox<String> cb = (SelectBox<String>) id.getField();
    cb.clearItems();/*from  ww  w .ja v  a  2  s.  c o  m*/

    // When creating, give option to add all elements
    if (e == null)
        cb.getItems().add("<ADD ALL>");

    String ids[] = spriteWidget.getAnimations();
    for (String s : ids)
        cb.getItems().add(s);

    cb.getList().setItems(cb.getItems());
    if (cb.getItems().size > 0)
        cb.setSelectedIndex(0);

    cb.invalidateHierarchy();

    setAnimation();
}

From source file:com.bladecoder.engineeditor.ui.EditAnimationDialog.java

License:Apache License

private void addSources() {
    @SuppressWarnings("unchecked")
    SelectBox<String> cb = (SelectBox<String>) source.getField();
    String[] src = getSources();/*www.  j a  v a2 s. co m*/
    cb.getItems().clear();

    for (String s : src)
        cb.getItems().add(s);

    cb.getList().setItems(cb.getItems());
    if (cb.getItems().size > 0)
        cb.setSelectedIndex(0);
    cb.invalidateHierarchy();
}

From source file:com.bladecoder.engineeditor.ui.EditAnimationDialog.java

License:Apache License

/**
 * Override to append all animations if selected.
 *//*from  ww w  .  j  a  v a 2s .  co  m*/
@Override
protected void ok() {
    @SuppressWarnings("unchecked")
    SelectBox<String> cb = (SelectBox<String>) id.getField();

    if (e == null && cb.getSelectedIndex() == 0) {
        for (int i = 1; i < cb.getItems().size; i++) {
            cb.setSelectedIndex(i);
            inputsToModel(true);
            //            doc.setId(e, cb.getItems().get(i));

            if (listener != null)
                listener.changed(new ChangeEvent(), this);
        }

    } else {
        super.ok();
    }
}

From source file:com.bladecoder.engineeditor.ui.EditSceneDialog.java

License:Apache License

private void fillBGRegions(InputPanel atlasInput, InputPanel regionInput) {
    @SuppressWarnings("unchecked")
    SelectBox<String> cb = (SelectBox<String>) regionInput.getField();

    // cb.clearItems();
    cb.getItems().clear();

    if (atlas != null) {
        atlas.dispose();/*from  w  w  w .j av a  2s  .co  m*/
        atlas = null;
    }

    if (backgroundAtlas.getText().isEmpty()) {
        setInfoWidget(new Label(INFO, getSkin()));
        return;
    }

    atlas = new TextureAtlas(Gdx.files.absolute(Ctx.project.getProjectPath() + Project.ATLASES_PATH + "/"
            + Ctx.project.getResDir() + "/" + atlasInput.getText() + ".atlas"));

    Array<AtlasRegion> regions = atlas.getRegions();

    for (AtlasRegion r : regions)
        if (cb.getItems().indexOf(r.name, false) == -1)
            cb.getItems().add(r.name);

    cb.getList().setItems(cb.getItems());
    if (cb.getItems().size > 0)
        cb.setSelectedIndex(0);

    cb.invalidateHierarchy();

    showBgImage(regionInput.getText());
}