Search in sources :

Example 1 with SimTable

use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable in project skin-composer by raeleus.

the class CellListeners method cellAddCellListener.

public static EventListener cellAddCellListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simCell = (DialogSceneComposerModel.SimCell) simActor;
    var simTable = (SimTable) simActor.parent;
    var popTableClickListener = new PopTableClickListener(skin) {

        {
            getPopTable().key(Keys.ESCAPE, popTable::hide);
        }

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            update();
        }

        public void update() {
            var popTable = getPopTable();
            popTable.clearChildren();
            var table = new Table();
            popTable.add(table);
            var label = new Label("New Cell", skin, "scene-label-colored");
            table.add(label);
            table.row();
            var subTable = new Table();
            table.add(subTable);
            subTable.add();
            var button = new Button(skin, "scene-add-up");
            button.setDisabled(simCell.row == 0);
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new cell at the end of the row above.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellAddCellAbove();
                    popTable.hide();
                }
            });
            subTable.add();
            subTable.row();
            button = new Button(skin, "scene-add-left");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new cell to the left of the current one.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellAddCellToLeft();
                    popTable.hide();
                }
            });
            subTable.add();
            button = new Button(skin, "scene-add-right");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new cell to the right of the current one.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellAddCellToRight();
                    popTable.hide();
                }
            });
            subTable.row();
            subTable.add();
            button = new Button(skin, "scene-add-down");
            button.setDisabled(simCell.row == simTable.getRows() - 1);
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new cell at the end of the row below.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellAddCellBelow();
                    popTable.hide();
                }
            });
            subTable.add();
            table.row();
            label = new Label("New Row", skin, "scene-label-colored");
            table.add(label);
            table.row();
            subTable = new Table();
            table.add(subTable);
            button = new Button(skin, "scene-add-down-row");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new row below and adds a cell to it.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellAddRowBelow();
                    popTable.hide();
                }
            });
            button = new Button(skin, "scene-add-up-row");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new row above and adds a cell to it.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellAddRowAbove();
                    popTable.hide();
                }
            });
            var image = new Image(skin, "scene-menu-divider");
            popTable.add(image).space(10).growY();
            table = new Table();
            popTable.add(table);
            label = new Label("Duplicate Cell", skin, "scene-label-colored");
            table.add(label);
            table.row();
            subTable = new Table();
            table.add(subTable);
            subTable.add();
            button = new Button(skin, "scene-duplicate-up");
            subTable.add(button);
            button.setDisabled(simCell.row == 0);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Duplicates the cell to the row above.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellDuplicateCellAbove();
                    popTable.hide();
                }
            });
            subTable.add();
            subTable.row();
            button = new Button(skin, "scene-duplicate-left");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new cell to the left of the current one.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellDuplicateCellLeft();
                    popTable.hide();
                }
            });
            subTable.add();
            button = new Button(skin, "scene-duplicate-right");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new cell to the right of the current one.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellDuplicateCellRight();
                    popTable.hide();
                }
            });
            subTable.row();
            subTable.add();
            button = new Button(skin, "scene-duplicate-down");
            subTable.add(button);
            button.setDisabled(simCell.row == simTable.getRows() - 1);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Duplicates the cell to the row below.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellDuplicateCellBelow();
                    popTable.hide();
                }
            });
            subTable.add();
            table.row();
            label = new Label("Dup. to New Row", skin, "scene-label-colored");
            table.add(label);
            table.row();
            subTable = new Table();
            table.add(subTable);
            button = new Button(skin, "scene-duplicate-down-row");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new row below and adds a cell to it.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellDuplicateCellNewRowBelow();
                    popTable.hide();
                }
            });
            button = new Button(skin, "scene-duplicate-up-row");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new row below and adds a cell to it.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellDuplicateCellNewRowAbove();
                    popTable.hide();
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : SimTable(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable) SimTable(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 2 with SimTable

use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable in project skin-composer by raeleus.

the class CellListeners method cellMoveCellListener.

public static EventListener cellMoveCellListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simCell = (DialogSceneComposerModel.SimCell) simActor;
    var simTable = (SimTable) simActor.parent;
    var popTableClickListener = new PopTableClickListener(skin) {

        {
            getPopTable().key(Keys.ESCAPE, popTable::hide);
        }

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            update();
        }

        public void update() {
            var popTable = getPopTable();
            popTable.clearChildren();
            var label = new Label("Move Cell", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var subTable = new Table();
            popTable.add(subTable);
            subTable.add();
            var button = new Button(skin, "scene-move-up");
            button.setDisabled(simCell.row == 0);
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Moves the current cell up.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellMoveCellUp();
                    popTable.hide();
                }
            });
            subTable.add();
            subTable.row();
            button = new Button(skin, "scene-move-left");
            button.setDisabled(simCell.column == 0);
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Moves the current cell left.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellMoveCellLeft();
                    popTable.hide();
                }
            });
            subTable.add();
            button = new Button(skin, "scene-move-right");
            button.setDisabled(simCell.column == simTable.getColumns(simCell.row) - 1);
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Moves the current cell right.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellMoveCellRight();
                    popTable.hide();
                }
            });
            subTable.row();
            subTable.add();
            button = new Button(skin, "scene-move-down");
            button.setDisabled(simCell.row == simTable.getRows() - 1);
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Moves the current cell down.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellMoveCellDown();
                    popTable.hide();
                }
            });
            subTable.add();
            popTable.row();
            label = new Label("Move to New Row", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            subTable = new Table();
            popTable.add(subTable);
            button = new Button(skin, "scene-add-down-row");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new row below and moves this cell to it.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellMoveToNewRowBelow();
                    popTable.hide();
                }
            });
            button = new Button(skin, "scene-add-up-row");
            subTable.add(button);
            button.addListener(handListener);
            button.addListener(new TextTooltip("Creates a new row above and moves this cell to it.", tooltipManager, skin, "scene"));
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellMoveToNewRowAbove();
                    popTable.hide();
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : SimTable(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable) SimTable(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Aggregations

Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)2 SimTable (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable)2 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)2