Search in sources :

Example 1 with SimNode

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

the class TreeListeners method showConfirmNodeSetWidgetDialog.

public static Dialog showConfirmNodeSetWidgetDialog(final DialogSceneComposer dialogSceneComposer, WidgetType widgetType, PopTable popTable) {
    var simNode = (SimNode) dialogSceneComposer.simActor;
    if (simNode.actor == null) {
        popTable.hide();
        dialogSceneComposer.events.nodeSetWidget(widgetType);
        return null;
    } else {
        var dialog = new Dialog("", skin, "scene-dialog") {

            @Override
            protected void result(Object object) {
                if ((Boolean) object) {
                    popTable.hide();
                    dialogSceneComposer.events.nodeSetWidget(widgetType);
                }
            }
        };
        var root = dialog.getTitleTable();
        root.clear();
        root.add().uniform();
        var label = new Label("Confirm Overwrite Widget", skin, "scene-title");
        root.add(label).expandX();
        var button = new Button(skin, "scene-close");
        root.add(button).uniform();
        button.addListener(handListener);
        button.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                dialog.hide();
            }
        });
        root = dialog.getContentTable();
        root.pad(10);
        label = new Label("This will overwrite the existing widget in the node.\nAre you okay with that?", skin, "scene-label-colored");
        label.setWrap(true);
        label.setAlignment(Align.center);
        root.add(label).growX();
        dialog.getButtonTable().defaults().uniformX();
        var textButton = new TextButton("OK", skin, "scene-med");
        dialog.button(textButton, true);
        textButton.addListener(handListener);
        textButton = new TextButton("Cancel", skin, "scene-med");
        dialog.button(textButton, false);
        textButton.addListener(handListener);
        dialog.key(Input.Keys.ENTER, true).key(Keys.NUMPAD_ENTER, true).key(Input.Keys.SPACE, true);
        dialog.key(Input.Keys.ESCAPE, false);
        dialog.show(dialogSceneComposer.getStage());
        dialog.setSize(500, 200);
        dialog.setPosition((int) (dialogSceneComposer.getStage().getWidth() / 2f - dialog.getWidth() / 2f), (int) (dialogSceneComposer.getStage().getHeight() / 2f - dialog.getHeight() / 2f));
        return dialog;
    }
}
Also used : SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) SimNode(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimNode)

Example 2 with SimNode

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

the class TreeListeners method nodeOptionsListener.

public static EventListener nodeOptionsListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simNode = (SimNode) simActor;
    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();
            popTable.pad(10);
            var table = new Table();
            popTable.add(table).space(5);
            table.defaults().left().expandX();
            var imageTextButton = new ImageTextButton("Expanded", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simNode.expanded);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Sets whether the children are expanded and visible.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.nodeExpanded(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Selectable", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simNode.selectable);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Sets whether this node can be selected.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.nodeSelectable(((ImageTextButton) actor).isChecked());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) SimNode(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimNode)

Aggregations

ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)2 SimNode (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimNode)2 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)1 PopTable (com.ray3k.stripe.PopTable)1 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)1