Search in sources :

Example 1 with FilteredTree

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

the class NodeListPopup method parseCategory.

private void parseCategory(FilteredTree<String> tree, FilteredTree.Node parent, XmlReader.Element element) {
    Array<XmlReader.Element> categories = element.getChildrenByName("category");
    for (XmlReader.Element category : categories) {
        FilteredTree.Node categoryNode = new FilteredTree.Node(category.getAttribute("title"), new Label(category.getAttribute("title"), getSkin()));
        if (parent != null)
            parent.add(categoryNode);
        else
            tree.add(categoryNode);
        parseCategory(tree, categoryNode, category);
    }
    // get modules
    Array<XmlReader.Element> modules = element.getChildrenByName("module");
    for (XmlReader.Element module : modules) {
        FilteredTree.Node node = new FilteredTree.Node(module.getAttribute("title"), new Label(module.getAttribute("title"), getSkin()));
        titleToNodeName.put(module.getAttribute("title"), module.getAttribute("name"));
        registerNode(module);
        if (parent != null)
            parent.add(node);
        else
            tree.add(node);
    }
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) XmlReader(com.badlogic.gdx.utils.XmlReader) FilteredTree(com.talosvfx.talos.editor.widgets.ui.FilteredTree) SearchFilteredTree(com.talosvfx.talos.editor.widgets.ui.SearchFilteredTree)

Example 2 with FilteredTree

use of com.talosvfx.talos.editor.widgets.ui.FilteredTree 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 3 with FilteredTree

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

the class TemplateListPopup method traverseTree.

private void traverseTree(FilteredTree<String> tree, Object o, XmlReader.Element root) {
    Array<XmlReader.Element> templates = root.getChildrenByName("template");
    for (XmlReader.Element template : templates) {
        configurationMap.put(template.getAttribute("name"), template);
        FilteredTree.Node node = new FilteredTree.Node(template.getAttribute("name"), new Label(template.getAttribute("title"), getSkin()));
        tree.add(node);
    }
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) XmlReader(com.badlogic.gdx.utils.XmlReader) FilteredTree(com.talosvfx.talos.editor.widgets.ui.FilteredTree) SearchFilteredTree(com.talosvfx.talos.editor.widgets.ui.SearchFilteredTree)

Aggregations

FilteredTree (com.talosvfx.talos.editor.widgets.ui.FilteredTree)3 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)2 XmlReader (com.badlogic.gdx.utils.XmlReader)2 SearchFilteredTree (com.talosvfx.talos.editor.widgets.ui.SearchFilteredTree)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)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 Selection (com.badlogic.gdx.scenes.scene2d.utils.Selection)1 Array (com.badlogic.gdx.utils.Array)1 EditableLabel (com.talosvfx.talos.editor.widgets.ui.EditableLabel)1 SquareButton (com.talosvfx.talos.editor.widgets.ui.common.SquareButton)1