Search in sources :

Example 1 with AssetListPopup

use of com.talosvfx.talos.editor.addons.scene.widgets.AssetListPopup in project talos by rockbite.

the class AssetSelectWidget method getSubWidget.

@Override
public Actor getSubWidget() {
    Table table = new Table();
    Skin skin = TalosMain.Instance().getSkin();
    final SquareButton button = new SquareButton(skin, skin.getDrawable("ic-file-edit"));
    nameLabel = new Label("", skin);
    nameLabel.setEllipsis(true);
    nameLabel.setAlignment(Align.right);
    table.add(nameLabel).growX().maxWidth(130).padRight(2);
    table.add(button).right().padRight(-2);
    button.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            Vector2 pos = new Vector2(button.getWidth() / 2f, button.getHeight() / 2f);
            button.localToStageCoordinates(pos);
            AssetListPopup assetListPopup = SceneEditorAddon.get().workspace.getAssetListPopup();
            assetListPopup.showPopup(getStage(), pos, filter, new FilteredTree.ItemListener() {

                @Override
                public void chosen(FilteredTree.Node node) {
                    String path = (String) node.getObject();
                    if (Gdx.files.absolute(path).isDirectory())
                        return;
                    String relative = AssetImporter.relative(Gdx.files.absolute(path));
                    updateWidget(relative);
                    callValueChanged(relative);
                    assetListPopup.remove();
                }
            });
        }
    });
    return table;
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) SquareButton(com.talosvfx.talos.editor.widgets.ui.common.SquareButton) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) Vector2(com.badlogic.gdx.math.Vector2) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) AssetListPopup(com.talosvfx.talos.editor.addons.scene.widgets.AssetListPopup)

Aggregations

Vector2 (com.badlogic.gdx.math.Vector2)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 AssetListPopup (com.talosvfx.talos.editor.addons.scene.widgets.AssetListPopup)1 EditableLabel (com.talosvfx.talos.editor.widgets.ui.EditableLabel)1 SquareButton (com.talosvfx.talos.editor.widgets.ui.common.SquareButton)1