Search in sources :

Example 6 with EditableLabel

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

the class NodeWidget method init.

public void init(Skin skin, NodeBoard nodeBoard) {
    super.init(skin);
    initMaps();
    this.nodeBoard = nodeBoard;
    Stack mainStack = new Stack();
    Table backgroundTable = new Table();
    Table contentTable = new Table();
    mainStack.add(backgroundTable);
    mainStack.add(contentTable);
    headerTable = new Table();
    Table bodyTable = new Table();
    headerTable.setBackground(ColorLibrary.obtainBackground(getSkin(), "node-header", ColorLibrary.BackgroundColor.RED));
    bodyTable.setBackground(ColorLibrary.obtainBackground(getSkin(), "node-body", ColorLibrary.BackgroundColor.WHITE));
    setBackground(ColorLibrary.obtainBackground(getSkin(), "node-shadow-border", ColorLibrary.BackgroundColor.WHITE));
    backgroundTable.add(headerTable).growX().height(32).row();
    backgroundTable.add(bodyTable).grow().row();
    title = new EditableLabel("Node Title", skin);
    headerTable.add(title).expandX().top().left().padLeft(12).height(15);
    contentTable.add(widgetContainer).padLeft(16).padRight(16).grow().top().padTop(32);
    contentTable.row();
    addAdditionalContent(contentTable);
    contentTable.add().height(15).row();
    contentTable.add().growY();
    add(mainStack).width(266).pad(15);
    setModal(false);
    setMovable(true);
    setResizable(false);
    addCaptureListener(new InputListener() {

        Vector2 tmp = new Vector2();

        Vector2 prev = new Vector2();

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            prev.set(x, y);
            NodeWidget.this.localToStageCoordinates(prev);
            if (nodeBoard != null) {
                nodeBoard.nodeClicked(NodeWidget.this);
            }
            return true;
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            tmp.set(x, y);
            NodeWidget.this.localToStageCoordinates(tmp);
            super.touchDragged(event, x, y, pointer);
            if (nodeBoard != null) {
                nodeBoard.wrapperMovedBy(NodeWidget.this, tmp.x - prev.x, tmp.y - prev.y);
            }
            prev.set(tmp);
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);
            if (nodeBoard != null) {
                nodeBoard.nodeClickedUp(NodeWidget.this);
            }
            event.cancel();
        }
    });
}
Also used : EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) Vector2(com.badlogic.gdx.math.Vector2) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Stack(com.badlogic.gdx.scenes.scene2d.ui.Stack)

Example 7 with EditableLabel

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

the class DynamicItemListWidget method getSubWidget.

@Override
public Actor getSubWidget() {
    Table table = new Table();
    Skin skin = TalosMain.Instance().getSkin();
    Table topBar = new Table();
    topBar.setBackground(ColorLibrary.obtainBackground(getSkin(), ColorLibrary.BackgroundColor.DARK_GRAY));
    SquareButton newBtn = new SquareButton(skin, skin.getDrawable("timeline-btn-icon-new"));
    SquareButton deleteBtn = new SquareButton(skin, skin.getDrawable("timeline-btn-icon-delete"));
    topBar.add().expandX();
    topBar.add(newBtn).padRight(2);
    topBar.add(deleteBtn).padRight(2);
    list = new FilteredTree<>(skin, "modern");
    list.draggable = true;
    list.setItemListener(new FilteredTree.ItemListener() {

        @Override
        public void onNodeMove(FilteredTree.Node parentToMoveTo, FilteredTree.Node childThatHasMoved, int indexInParent, int indexOfPayloadInPayloadBefore) {
            callValueChanged(makeDataArray());
        }

        @Override
        public void delete(Array<FilteredTree.Node> nodes) {
            deleteSelection();
        }
    });
    table.add(list).growX();
    table.row();
    table.add(topBar).growX().padLeft(-10).padRight(-10);
    newBtn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            ItemData newItemData = new ItemData(defaultItemName, defaultItemName);
            Selection<FilteredTree.Node<Object>> selection = list.getSelection();
            FilteredTree.Node node;
            if (selection.size() > 0) {
                int index = 0;
                Array<FilteredTree.Node<Object>> rootNodes = list.getRootNodes();
                for (index = 0; index < rootNodes.size; index++) {
                    if (rootNodes.get(index) == selection.first()) {
                        break;
                    }
                }
                node = addNode(newItemData, index + 1);
            } else {
                node = addNode(newItemData);
            }
            callValueChanged(makeDataArray());
            EditableLabel label = (EditableLabel) node.getActor();
            label.setEditMode();
        }
    });
    deleteBtn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            deleteSelection();
        }
    });
    return table;
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) SquareButton(com.talosvfx.talos.editor.widgets.ui.common.SquareButton) Selection(com.badlogic.gdx.scenes.scene2d.utils.Selection) FilteredTree(com.talosvfx.talos.editor.widgets.ui.FilteredTree) Array(com.badlogic.gdx.utils.Array) EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 8 with EditableLabel

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

the class EditableLabelWidget method getSubWidget.

@Override
public Actor getSubWidget() {
    propertyValue = new EditableLabel("", TalosMain.Instance().getSkin());
    propertyValue.setAlignment(Align.right);
    propertyValue.setListener(new EditableLabel.EditableLabelChangeListener() {

        @Override
        public void changed(String newText) {
            callValueChanged(newText);
        }
    });
    return propertyValue;
}
Also used : EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel)

Example 9 with EditableLabel

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

the class HierarchyWidget method traverseEntityContainer.

private void traverseEntityContainer(GameObjectContainer entityContainer, FilteredTree.Node node) {
    Array<GameObject> gameObjects = entityContainer.getGameObjects();
    if (gameObjects == null)
        return;
    for (int i = 0; i < gameObjects.size; i++) {
        final GameObject gameObject = gameObjects.get(i);
        EditableLabel editableLabel = new EditableLabel(gameObject.getName(), TalosMain.Instance().getSkin());
        FilteredTree.Node newNode = new FilteredTree.Node(gameObject.getName(), editableLabel);
        newNode.draggable = true;
        node.add(newNode);
        editableLabel.setListener(new EditableLabel.EditableLabelChangeListener() {

            @Override
            public void changed(String newText) {
                SceneEditorAddon.get().workspace.changeGOName(gameObject, newText);
            }
        });
        objectMap.put(gameObject.getName(), gameObject);
        nodeMap.put(gameObject, newNode);
        if (gameObject.getGameObjects() != null) {
            traverseEntityContainer(gameObject, newNode);
        }
    }
}
Also used : EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject) FilteredTree(com.talosvfx.talos.editor.widgets.ui.FilteredTree)

Example 10 with EditableLabel

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

the class HierarchyWidget method select.

private void select(GameObject gameObject) {
    if (gameObject == null)
        return;
    tree.getSelection().clear();
    tree.getSelection().add(nodeMap.get(gameObject));
    Actor actor = nodeMap.get(gameObject).getActor();
    if (actor instanceof EditableLabel) {
        EditableLabel editableLabel = (EditableLabel) actor;
        if (!editableLabel.isEditMode()) {
            getStage().setKeyboardFocus(nodeMap.get(gameObject).getActor());
        }
    } else {
        getStage().setKeyboardFocus(nodeMap.get(gameObject).getActor());
    }
}
Also used : EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) Actor(com.badlogic.gdx.scenes.scene2d.Actor)

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