Search in sources :

Example 21 with PopTable

use of com.ray3k.stripe.PopTable 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)

Example 22 with PopTable

use of com.ray3k.stripe.PopTable in project skin-composer by raeleus.

the class TreeListeners method treeSpacingListener.

public static EventListener treeSpacingListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTree = (SimTree) simActor;
    var popTableClickListener = new PopTableClickListener(skin) {

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

        @Override
        public void tableShown(Event event) {
            var popTable = getPopTable();
            popTable.clearChildren();
            var table = new Table();
            popTable.add(table);
            table.defaults().right().spaceRight(5);
            var label = new Label("Icon Space Left:", skin, "scene-label-colored");
            table.add(label);
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simTree.iconSpaceLeft);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The spacing on the left of the icon.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.treeIconSpaceLeft((float) ((Spinner) actor).getValue());
                }
            });
            table.row();
            label = new Label("Icon Space Right:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simTree.iconSpaceRight);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The spacing on the right of the icon.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.treeIconSpaceRight((float) ((Spinner) actor).getValue());
                }
            });
            table.row();
            label = new Label("Indent Spacing:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simTree.indentSpacing);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The indentation space for each indented node.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.treeIndentSpacing((float) ((Spinner) actor).getValue());
                }
            });
            table.row();
            label = new Label("Y Spacing:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simTree.ySpacing);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The vertical spacing between each node.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.treeYSpacing((float) ((Spinner) actor).getValue());
                }
            });
        }
    };
    return popTableClickListener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) Spinner(com.ray3k.stripe.Spinner) SimTree(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTree) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 23 with PopTable

use of com.ray3k.stripe.PopTable in project skin-composer by raeleus.

the class DialogSceneComposer method showSettingsDialog.

public PopTable showSettingsDialog() {
    var root = new PopTable(skin);
    root.setHideOnUnfocus(true);
    root.setModal(true);
    root.setKeepSizedWithinStage(true);
    root.setKeepCenteredInWindow(true);
    root.pad(20);
    var label = new Label("Settings", skin, "scene-title-bg");
    label.setAlignment(Align.center);
    root.add(label).growX().padBottom(10);
    root.row();
    var table = new Table();
    root.add(table).growX();
    table.defaults().left().space(5);
    label = new Label("Package", skin, "scene-label-colored");
    table.add(label);
    var textField = new TextField(rootActor.packageString, skin, "scene");
    var keyboardFocus = textField;
    table.add(textField).width(300).uniformX();
    textField.addListener(ibeamListener);
    textField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.rootPackage(((TextField) actor).getText());
        }
    });
    table.row();
    label = new Label("Class", skin, "scene-label-colored");
    table.add(label);
    textField = new TextField(rootActor.classString, skin, "scene");
    table.add(textField).uniformX().fillX();
    textField.addListener(ibeamListener);
    textField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.rootClass(((TextField) actor).getText());
        }
    });
    table.row();
    label = new Label("Skin Path", skin, "scene-label-colored");
    table.add(label);
    textField = new TextField(rootActor.skinPath, skin, "scene");
    table.add(textField).uniformX().fillX();
    textField.addListener(ibeamListener);
    textField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.rootSkinPath(((TextField) actor).getText());
        }
    });
    table.row();
    label = new Label("Background Color", skin, "scene-label-colored");
    table.add(label);
    var imageButton = new ImageButton(new ImageButton.ImageButtonStyle(skin.get("scene-color", ImageButton.ImageButtonStyle.class)));
    imageButton.getImage().setColor(rootActor.backgroundColor == null ? Color.WHITE : rootActor.backgroundColor.color);
    table.add(imageButton).left();
    imageButton.addListener(handListener);
    imageButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
                if (!pressedCancel) {
                    events.rootBackgroundColor(colorData);
                    imageButton.getImage().setColor(colorData == null ? Color.WHITE : colorData.color);
                }
            }, new DialogListener() {

                @Override
                public void opened() {
                }

                @Override
                public void closed() {
                }
            });
        }
    });
    root.show(getStage());
    getStage().setKeyboardFocus(keyboardFocus);
    return root;
}
Also used : PopTable(com.ray3k.stripe.PopTable) FileHandle(com.badlogic.gdx.files.FileHandle) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) com.badlogic.gdx.scenes.scene2d.ui(com.badlogic.gdx.scenes.scene2d.ui) com.ray3k.skincomposer.dialog.scenecomposer.menulisteners(com.ray3k.skincomposer.dialog.scenecomposer.menulisteners) Array(com.badlogic.gdx.utils.Array) Cursor(com.badlogic.gdx.graphics.Cursor) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) Gdx(com.badlogic.gdx.Gdx) Align(com.badlogic.gdx.utils.Align) Color(com.badlogic.gdx.graphics.Color) DialogSceneComposerModel(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel) PopTable(com.ray3k.stripe.PopTable) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) StripeMenuBar(com.ray3k.stripe.StripeMenuBar) KeyboardShortcut(com.ray3k.stripe.StripeMenuBar.KeyboardShortcut) Keys(com.badlogic.gdx.Input.Keys) Main(com.ray3k.skincomposer.Main) IntPair(com.ray3k.skincomposer.utils.IntPair) Input(com.badlogic.gdx.Input) com.badlogic.gdx.scenes.scene2d(com.badlogic.gdx.scenes.scene2d) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) PopTable(com.ray3k.stripe.PopTable) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 24 with PopTable

use of com.ray3k.stripe.PopTable in project skin-composer by raeleus.

the class DialogSceneComposer method rootAddTableListener.

private EventListener rootAddTableListener() {
    var popTableClickListener = new PopTableClickListener(skin, "dark");
    var popTable = popTableClickListener.getPopTable();
    popTable.key(Keys.ESCAPE, popTable::hide);
    var label = new Label("New Table:", skin, "scene-label");
    popTable.add(label);
    label.addListener(new TextTooltip("Creates a base Table and adds it directly to the stage. This will serve as the basis for the rest of your UI layout and will fill the entire screen.", tooltipManager, skin, "scene"));
    popTable.row();
    var table = new Table();
    popTable.add(table);
    table.pad(10).padTop(0);
    var buttons = new Button[6][6];
    for (int j = 0; j < 6; j++) {
        table.row();
        for (int i = 0; i < 6; i++) {
            var textButton = new Button(skin, "scene-table");
            textButton.setProgrammaticChangeEvents(false);
            textButton.setUserObject(new IntPair(i, j));
            table.add(textButton);
            buttons[i][j] = textButton;
            textButton.addListener(handListener);
            textButton.addListener(new ClickListener() {

                @Override
                public void clicked(InputEvent event, float x, float y) {
                    popTable.hide();
                    var intPair = (IntPair) textButton.getUserObject();
                    events.rootAddTable(intPair.x + 1, intPair.y + 1);
                }
            });
            textButton.addListener(new InputListener() {

                @Override
                public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
                    var intPair = (IntPair) textButton.getUserObject();
                    for (int y1 = 0; y1 < 6; y1++) {
                        for (int x1 = 0; x1 < 6; x1++) {
                            buttons[x1][y1].setChecked(y1 <= intPair.y && x1 <= intPair.x);
                        }
                    }
                    textButton.setChecked(true);
                }
            });
        }
    }
    table.setTouchable(Touchable.enabled);
    table.addListener(new InputListener() {

        @Override
        public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
            for (int y1 = 0; y1 < 6; y1++) {
                for (int x1 = 0; x1 < 6; x1++) {
                    buttons[x1][y1].setChecked(false);
                }
            }
        }
    });
    return popTableClickListener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) IntPair(com.ray3k.skincomposer.utils.IntPair) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 25 with PopTable

use of com.ray3k.stripe.PopTable in project skin-composer by raeleus.

the class HorizontalGroupListeners method horizontalGroupExpandFillGrowListener.

public static EventListener horizontalGroupExpandFillGrowListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simHorizontalGroup = (DialogSceneComposerModel.SimHorizontalGroup) 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();
            var expand = new ImageTextButton("Expand", skin, "scene-checkbox-colored");
            var fill = new ImageTextButton("Fill", skin, "scene-checkbox-colored");
            var grow = new ImageTextButton("Grow", skin, "scene-checkbox-colored");
            var changeListener = new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupExpand(expand.isChecked());
                    events.horizontalGroupFill(fill.isChecked());
                }
            };
            var table = new Table();
            popTable.add(table);
            table.defaults().left().spaceRight(5);
            expand.setChecked(simHorizontalGroup.expand);
            expand.setProgrammaticChangeEvents(false);
            table.add(expand);
            expand.addListener(handListener);
            expand.addListener(new TextTooltip("Set the widgets to expand to the available space.", tooltipManager, skin, "scene"));
            expand.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    if (expand.isChecked() && fill.isChecked()) {
                        grow.setChecked(true);
                    } else {
                        grow.setChecked(false);
                    }
                }
            });
            expand.addListener(changeListener);
            table.row();
            fill.setChecked(simHorizontalGroup.fill);
            fill.setProgrammaticChangeEvents(false);
            table.add(fill);
            fill.addListener(handListener);
            fill.addListener(new TextTooltip("Sets the widgets to fill the entire space.", tooltipManager, skin, "scene"));
            fill.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    if (expand.isChecked() && fill.isChecked()) {
                        grow.setChecked(true);
                    } else {
                        grow.setChecked(false);
                    }
                }
            });
            fill.addListener(changeListener);
            table.row();
            grow.setChecked(simHorizontalGroup.expand && simHorizontalGroup.fill);
            grow.setProgrammaticChangeEvents(false);
            table.add(grow);
            grow.addListener(handListener);
            grow.addListener(new TextTooltip("Sets the widgets to expand and fill.", tooltipManager, skin, "scene"));
            grow.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    expand.setChecked(grow.isChecked());
                    fill.setChecked(grow.isChecked());
                }
            });
            grow.addListener(changeListener);
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) 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

PopTable (com.ray3k.stripe.PopTable)34 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)32 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)32 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)26 Actor (com.badlogic.gdx.scenes.scene2d.Actor)18 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)18 Spinner (com.ray3k.stripe.Spinner)10 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)7 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)6 IntPair (com.ray3k.skincomposer.utils.IntPair)6 Array (com.badlogic.gdx.utils.Array)5 DialogSceneComposerModel (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel)5 Input (com.badlogic.gdx.Input)4 Keys (com.badlogic.gdx.Input.Keys)4 FileHandle (com.badlogic.gdx.files.FileHandle)4 Color (com.badlogic.gdx.graphics.Color)4 com.badlogic.gdx.scenes.scene2d (com.badlogic.gdx.scenes.scene2d)4 com.badlogic.gdx.scenes.scene2d.ui (com.badlogic.gdx.scenes.scene2d.ui)4 Align (com.badlogic.gdx.utils.Align)4 Main (com.ray3k.skincomposer.Main)4