Search in sources :

Example 6 with VisImageButton

use of com.kotcrab.vis.ui.widget.VisImageButton in project HyperLap2D by rednblackgames.

the class UISceneBox method init.

private void init() {
    VisImageButton.VisImageButtonStyle visImageButtonStyle = new VisImageButton.VisImageButtonStyle(VisUI.getSkin().get("dark", VisImageButton.VisImageButtonStyle.class));
    visImageButtonStyle.imageUp = VisUI.getSkin().getDrawable("icon-trash");
    visImageButtonStyle.imageOver = VisUI.getSkin().getDrawable("icon-trash-over");
    visImageButtonStyle.imageDisabled = VisUI.getSkin().getDrawable("icon-trash-disabled");
    deleteBtn = new VisImageButton("dark");
    deleteBtn.setStyle(visImageButtonStyle);
    deleteBtn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            if (!deleteBtn.isDisabled())
                facade.sendNotification(DELETE_CURRENT_SCENE_BTN_CLICKED, visSelectBox.getSelected().sceneName);
        }
    });
    visSelectBox = StandardWidgetsFactory.createSelectBox(SceneVO.class);
    visSelectBox.addListener(new SceneChangeListener());
    add("Scene:").padRight(4);
    add(visSelectBox).padRight(11).width(156);
    add(deleteBtn).height(25);
}
Also used : VisImageButton(com.kotcrab.vis.ui.widget.VisImageButton) SceneVO(games.rednblack.editor.renderer.data.SceneVO) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 7 with VisImageButton

use of com.kotcrab.vis.ui.widget.VisImageButton in project HyperLap2D by rednblackgames.

the class AlternativeAutoTileDialog method initView.

/**
 * Initiates the view of the dialog.
 */
public void initView() {
    clear();
    String[] allAutoTileVOArray = new String[tiledPlugin.dataToSave.getAutoTiles().size];
    int index = 0;
    // add a "none" to the drop down list
    allAutoTileVOArray[index++] = "";
    for (int i = 0; i < tiledPlugin.dataToSave.getAutoTiles().size; i++) {
        AutoTileVO next = tiledPlugin.dataToSave.getAutoTiles().get(i);
        if (!openingAutoTileVO.equals(next)) {
            allAutoTileVOArray[index++] = next.regionName;
        }
    }
    alternativeSelectBoxArray = new VisSelectBox[allAutoTileVOArray.length - 1];
    alternativePercentTextFieldArray = new VisValidatableTextField[allAutoTileVOArray.length + 0];
    VisTable table = new VisTable();
    table.row().padTop(20);
    table.add(getVisImageButton(openingAutoTileVO.regionName)).maxHeight(32);
    // .width(115);
    table.add(StandardWidgetsFactory.createLabel(openingAutoTileVO.regionName, Align.left)).padLeft(5).left();
    alternativePercentTextFieldArray[0] = StandardWidgetsFactory.createValidableTextField(new FloatValidator());
    alternativePercentTextFieldArray[0].setText(openingAutoTileVO.alternativeAutoTileList.get(0, new AlternativeAutoTileVO()).percent.toString());
    table.add(alternativePercentTextFieldArray[0]).padLeft(5).padRight(5).fillX().left();
    table.row();
    for (int i = 0; i < allAutoTileVOArray.length - 1; i++) {
        String region = openingAutoTileVO.alternativeAutoTileList.get(i + 1, new AlternativeAutoTileVO()).region;
        VisImageButton imgButton = getVisImageButton(region);
        table.add(imgButton).maxHeight(32);
        alternativeSelectBoxArray[i] = StandardWidgetsFactory.createSelectBox(String.class);
        alternativeSelectBoxArray[i].setItems(allAutoTileVOArray);
        alternativeSelectBoxArray[i].setSelected(openingAutoTileVO.alternativeAutoTileList.get(i + 1, new AlternativeAutoTileVO()).region);
        alternativeSelectBoxArray[i].addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                updateVisImageButton(imgButton, ((SelectBox<String>) actor).getSelected());
                pack();
            }
        });
        table.add(alternativeSelectBoxArray[i]).padLeft(5).left();
        alternativePercentTextFieldArray[i + 1] = StandardWidgetsFactory.createValidableTextField(new FloatValidator());
        alternativePercentTextFieldArray[i + 1].setText(openingAutoTileVO.alternativeAutoTileList.get(i + 1, new AlternativeAutoTileVO()).percent.toString());
        table.add(alternativePercentTextFieldArray[i + 1]).padLeft(5).padRight(5).fillX().left();
        table.row().padTop(5).padBottom(5);
    }
    VisTextButton saveButton = StandardWidgetsFactory.createTextButton("Save");
    saveButton.addListener(new ClickListener() {

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);
            tiledPlugin.facade.sendNotification(TiledPlugin.ACTION_SAVE_ALTERNATIVES_AUTO_TILE);
            hide();
        }
    });
    VisTextButton cancelButton = StandardWidgetsFactory.createTextButton("Cancel");
    cancelButton.addListener(new ClickListener() {

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);
            hide();
        }
    });
    row();
    add(table);
    row();
    add(saveButton).center().padLeft(5).padRight(5);
    add(cancelButton).center().padLeft(5).padRight(5);
    row();
    pack();
}
Also used : VisImageButton(com.kotcrab.vis.ui.widget.VisImageButton) VisTextButton(com.kotcrab.vis.ui.widget.VisTextButton) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) VisSelectBox(com.kotcrab.vis.ui.widget.VisSelectBox) AlternativeAutoTileVO(games.rednblack.editor.plugin.tiled.data.AlternativeAutoTileVO) AlternativeAutoTileVO(games.rednblack.editor.plugin.tiled.data.AlternativeAutoTileVO) AutoTileVO(games.rednblack.editor.plugin.tiled.data.AutoTileVO) VisTable(com.kotcrab.vis.ui.widget.VisTable) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) FloatValidator(com.kotcrab.vis.ui.util.Validators.FloatValidator) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 8 with VisImageButton

use of com.kotcrab.vis.ui.widget.VisImageButton in project HyperLap2D by rednblackgames.

the class GridTabInputListener method handleDrop.

/**
 * Handles the drop of a VisImageButton.
 *
 * @param x The coordinates relative to the source. Comes from the touchUp event.
 * @param y The coordinates relative to the source. Comes from the touchUp event.
 */
private void handleDrop(float x, float y) {
    Actor draggingTarget = table.hit(draggingSource.getX() + x, draggingSource.getY() + y, false);
    if (draggingTarget instanceof Image) {
        for (VisImageButton imgButton : tiles) {
            if (imgButton.getImage() == draggingTarget) {
                draggingTarget = imgButton;
                break;
            }
        }
    }
    if (draggingTarget != null) {
        String sourceRegionName = String.valueOf(draggingSource.getUserObject());
        String targetRegionName = String.valueOf(draggingTarget.getUserObject());
        int sourceIndex = -1;
        int targetIndex = -1;
        for (int i = 0; i < savedTiles.size; i++) {
            if (sourceRegionName.equals(savedTiles.get(i).getRegionName())) {
                sourceIndex = i;
            }
            if (targetRegionName.equals(savedTiles.get(i).getRegionName())) {
                targetIndex = i;
            }
        }
        // thus, an empty button, which are always after the ones with an image
        if (targetIndex < 0) {
            targetIndex = savedTiles.size - 1;
        }
        if (sourceIndex >= 0) {
            T sourceTileVO = savedTiles.removeIndex(sourceIndex);
            savedTiles.insert(targetIndex, sourceTileVO);
            tab.initTiles();
            // select the dropped button
            tiledPlugin.facade.sendNotification(TiledPlugin.TILE_SELECTED, sourceTileVO);
            tiles.get(targetIndex).setChecked(true);
        }
    }
}
Also used : VisImageButton(com.kotcrab.vis.ui.widget.VisImageButton) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Image(com.badlogic.gdx.scenes.scene2d.ui.Image)

Example 9 with VisImageButton

use of com.kotcrab.vis.ui.widget.VisImageButton in project HyperLap2D by rednblackgames.

the class AlternativeAutoTileDialog method getVisImageButton.

/**
 * Returns a button with the given region as image.
 *
 * @param regionName The name of the image.
 *
 * @return An image button.
 */
private VisImageButton getVisImageButton(String regionName) {
    VisImageButton.VisImageButtonStyle imageBoxStyle = new VisImageButton.VisImageButtonStyle();
    Drawable tileDrawable = null;
    if (!"".equals(regionName)) {
        tileDrawable = new TextureRegionDrawable(tiledPlugin.pluginRM.getTextureRegion(regionName, EntityFactory.IMAGE_TYPE));
    }
    imageBoxStyle.imageUp = tileDrawable;
    imageBoxStyle.imageDown = tileDrawable;
    imageBoxStyle.imageChecked = tileDrawable;
    imageBoxStyle.imageOver = tileDrawable;
    VisImageButton ct = new VisImageButton(imageBoxStyle);
    return ct;
}
Also used : VisImageButton(com.kotcrab.vis.ui.widget.VisImageButton) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)

Example 10 with VisImageButton

use of com.kotcrab.vis.ui.widget.VisImageButton in project vis-ui by kotcrab.

the class Toast method createMainTable.

protected void createMainTable() {
    mainTable = new VisTable();
    mainTable.setBackground(style.background);
    VisImageButton closeButton = new VisImageButton(style.closeButtonStyle);
    closeButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            close();
        }
    });
    mainTable.add(contentTable).pad(3).fill().expand();
    mainTable.add(closeButton).top();
}
Also used : VisImageButton(com.kotcrab.vis.ui.widget.VisImageButton) VisTable(com.kotcrab.vis.ui.widget.VisTable) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Aggregations

VisImageButton (com.kotcrab.vis.ui.widget.VisImageButton)21 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)7 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)7 VisTable (com.kotcrab.vis.ui.widget.VisTable)6 Actor (com.badlogic.gdx.scenes.scene2d.Actor)5 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)4 Drawable (com.badlogic.gdx.scenes.scene2d.utils.Drawable)4 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)4 VisLabel (com.kotcrab.vis.ui.widget.VisLabel)2 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)1 Vector2 (com.badlogic.gdx.math.Vector2)1 Touchable (com.badlogic.gdx.scenes.scene2d.Touchable)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1 SelectBox (com.badlogic.gdx.scenes.scene2d.ui.SelectBox)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 NinePatchDrawable (com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable)1 VisUI (com.kotcrab.vis.ui.VisUI)1 FloatValidator (com.kotcrab.vis.ui.util.Validators.FloatValidator)1 Dialogs (com.kotcrab.vis.ui.util.dialog.Dialogs)1 VisImageTextButton (com.kotcrab.vis.ui.widget.VisImageTextButton)1