Search in sources :

Example 1 with EditableLabel

use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.

the class ModuleWrapperGroup method init.

public void init(Skin skin) {
    this.skin = skin;
    frameImage = new Image(skin.getDrawable("group_frame"));
    frameImage.setColor(44 / 255f, 140 / 255f, 209 / 255f, 1f);
    addActor(frameImage);
    topHit = new Actor();
    topHit.setTouchable(Touchable.enabled);
    addActor(topHit);
    title = new EditableLabel("GROUP NAME", skin);
    addActor(title);
    settings = new ImageButton(skin, "settings");
    settings.setSize(25, 25);
    addActor(settings);
    settings.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            final Vector2 vec = new Vector2(Gdx.input.getX(), Gdx.input.getY());
            (TalosMain.Instance().UIStage().getStage().getViewport()).unproject(vec);
            settingsPopup.showMenu(TalosMain.Instance().UIStage().getStage(), vec.x, vec.y);
        }
    });
    settingsPopup = new PopupMenu();
    MenuItem changeColorMenuItem = new MenuItem("Change Color");
    MenuItem ungroupMenuItem = new MenuItem("Ungroup");
    settingsPopup.addItem(changeColorMenuItem);
    settingsPopup.addItem(ungroupMenuItem);
    changeColorMenuItem.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            TalosMain.Instance().UIStage().showColorPicker(new ColorPickerAdapter() {

                @Override
                public void changed(Color newColor) {
                    super.changed(newColor);
                    frameImage.setColor(newColor);
                }
            });
        }
    });
    ungroupMenuItem.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            TalosMain.Instance().NodeStage().moduleBoardWidget.removeGroup(ModuleWrapperGroup.this);
        }
    });
    topHit.addListener(new ClickListener() {

        Vector2 tmp = new Vector2();

        Vector2 pos = new Vector2();

        Vector2 diff = new Vector2();

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            pos.set(x, y);
            topHit.localToStageCoordinates(pos);
            TalosMain.Instance().NodeStage().moduleBoardWidget.setSelectedWrappers(wrappers);
            return true;
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            tmp.set(x, y);
            topHit.localToStageCoordinates(tmp);
            diff.set(tmp).sub(pos);
            moveGroupBy(diff.x, diff.y);
            pos.set(tmp);
            super.touchDragged(event, x, y, pointer);
        }
    });
    setTouchable(Touchable.childrenOnly);
    frameImage.setTouchable(Touchable.disabled);
}
Also used : Color(com.badlogic.gdx.graphics.Color) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) Vector2(com.badlogic.gdx.math.Vector2) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Example 2 with EditableLabel

use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.

the class ProjectExplorerWidget method traversePath.

private void traversePath(FileHandle path, int currDepth, int maxDepth, FilteredTree.Node node) {
    if (path.isDirectory() && currDepth <= maxDepth) {
        FileHandle[] list = path.list(fileFilter);
        for (int i = 0; i < list.length; i++) {
            FileHandle listItemHandle = list[i];
            if (!listItemHandle.isDirectory())
                continue;
            RowWidget widget = new RowWidget(listItemHandle);
            EditableLabel label = widget.getLabel();
            final FilteredTree.Node newNode = new FilteredTree.Node(listItemHandle.path(), widget);
            newNode.setObject(listItemHandle.path());
            // newNode.draggable = true; // todo: for later file manipulation
            node.add(newNode);
            nodes.put(listItemHandle.path(), newNode);
            if (listItemHandle.isDirectory()) {
                traversePath(list[i], currDepth++, maxDepth, newNode);
            }
            label.setListener(new EditableLabel.EditableLabelChangeListener() {

                @Override
                public void changed(String newText) {
                    String path = (String) newNode.getObject();
                    FileHandle fileHandle = Gdx.files.absolute(path);
                    if (newText.isEmpty()) {
                        newText = fileHandle.nameWithoutExtension();
                    }
                    FileHandle newHandle = AssetImporter.renameFile(fileHandle, newText);
                    notifyRename(fileHandle, newHandle);
                }
            });
        }
    }
}
Also used : EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) FileHandle(com.badlogic.gdx.files.FileHandle) FilteredTree(com.talosvfx.talos.editor.widgets.ui.FilteredTree)

Example 3 with EditableLabel

use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.

the class DynamicItemListWidget method makeDataArray.

private Array<ItemData> makeDataArray() {
    Array<ItemData> arr = new Array<>();
    Array<FilteredTree.Node<Object>> rootNodes = list.getRootNodes();
    for (FilteredTree.Node<Object> node : rootNodes) {
        EditableLabel label = (EditableLabel) node.getActor();
        arr.add(new ItemData(node.name, label.getText()));
    }
    return arr;
}
Also used : Array(com.badlogic.gdx.utils.Array) EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) FilteredTree(com.talosvfx.talos.editor.widgets.ui.FilteredTree)

Example 4 with EditableLabel

use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.

the class DynamicItemListWidget method createNode.

private FilteredTree.Node createNode(ItemData itemData) {
    Skin skin = TalosMain.Instance().getSkin();
    EditableLabel editableLabel = new EditableLabel(itemData.text, skin);
    editableLabel.setListener(new EditableLabel.EditableLabelChangeListener() {

        @Override
        public void changed(String newText) {
            callValueChanged(makeDataArray());
        }
    });
    FilteredTree.Node node = new FilteredTree.Node(itemData.id, editableLabel);
    node.draggable = true;
    node.draggableInLayerOnly = true;
    node.setObject(itemData);
    return node;
}
Also used : EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) FilteredTree(com.talosvfx.talos.editor.widgets.ui.FilteredTree)

Example 5 with EditableLabel

use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.

the class NodeGroup method init.

public void init(Skin skin) {
    this.skin = skin;
    frameImage = new Image(skin.getDrawable("group_frame"));
    frameImage.setColor(44 / 255f, 140 / 255f, 209 / 255f, 1f);
    addActor(frameImage);
    topHit = new Actor();
    topHit.setTouchable(Touchable.enabled);
    addActor(topHit);
    title = new EditableLabel("GROUP NAME", skin);
    addActor(title);
    settings = new ImageButton(skin, "settings");
    settings.setSize(25, 25);
    addActor(settings);
    settings.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            final Vector2 vec = new Vector2(Gdx.input.getX(), Gdx.input.getY());
            (TalosMain.Instance().UIStage().getStage().getViewport()).unproject(vec);
            settingsPopup.showMenu(TalosMain.Instance().UIStage().getStage(), vec.x, vec.y);
        }
    });
    settingsPopup = new PopupMenu();
    MenuItem changeColorMenuItem = new MenuItem("Change Color");
    MenuItem ungroupMenuItem = new MenuItem("Ungroup");
    settingsPopup.addItem(changeColorMenuItem);
    settingsPopup.addItem(ungroupMenuItem);
    changeColorMenuItem.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            TalosMain.Instance().UIStage().showColorPicker(new ColorPickerAdapter() {

                @Override
                public void changed(Color newColor) {
                    super.changed(newColor);
                    frameImage.setColor(newColor);
                }
            });
        }
    });
    ungroupMenuItem.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            nodeBoard.removeGroup(NodeGroup.this);
        }
    });
    topHit.addListener(new ClickListener() {

        Vector2 tmp = new Vector2();

        Vector2 pos = new Vector2();

        Vector2 diff = new Vector2();

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            pos.set(x, y);
            topHit.localToStageCoordinates(pos);
            nodeBoard.setSelectedNodes(nodes);
            return true;
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            tmp.set(x, y);
            topHit.localToStageCoordinates(tmp);
            diff.set(tmp).sub(pos);
            moveGroupBy(diff.x, diff.y);
            pos.set(tmp);
            super.touchDragged(event, x, y, pointer);
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            event.cancel();
        }
    });
    setTouchable(Touchable.childrenOnly);
    frameImage.setTouchable(Touchable.disabled);
}
Also used : Color(com.badlogic.gdx.graphics.Color) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Vector2(com.badlogic.gdx.math.Vector2) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Aggregations

EditableLabel (com.talosvfx.talos.editor.widgets.ui.EditableLabel)11 FilteredTree (com.talosvfx.talos.editor.widgets.ui.FilteredTree)6 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)4 Vector2 (com.badlogic.gdx.math.Vector2)3 Actor (com.badlogic.gdx.scenes.scene2d.Actor)3 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)3 FileHandle (com.badlogic.gdx.files.FileHandle)2 Color (com.badlogic.gdx.graphics.Color)2 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)2 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)2 Array (com.badlogic.gdx.utils.Array)2 MenuItem (com.kotcrab.vis.ui.widget.MenuItem)2 PopupMenu (com.kotcrab.vis.ui.widget.PopupMenu)2 ColorPickerAdapter (com.kotcrab.vis.ui.widget.color.ColorPickerAdapter)2 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)1 Stack (com.badlogic.gdx.scenes.scene2d.ui.Stack)1 Selection (com.badlogic.gdx.scenes.scene2d.utils.Selection)1 GameObject (com.talosvfx.talos.editor.addons.scene.logic.GameObject)1