Search in sources :

Example 31 with PopTableClickListener

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

the class SplitPaneListeners method splitPaneSplitListener.

public static EventListener splitPaneSplitListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simSplitPane = (DialogSceneComposerModel.SimSplitPane) 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 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("Split:", skin, "scene-label-colored");
            popTable.add(label).spaceRight(5);
            var splitSpinner = new Spinner(0, .1f, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            var splitMinSpinner = new Spinner(0, .1f, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            var splitMaxSpinner = new Spinner(0, .1f, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            splitSpinner.setName("pad-left");
            splitSpinner.setValue(simSplitPane.split);
            splitSpinner.setMinimum((double) simSplitPane.splitMin);
            splitSpinner.setMaximum((double) simSplitPane.splitMax);
            popTable.add(splitSpinner);
            splitSpinner.getTextField().addListener(ibeamListener);
            splitSpinner.getButtonMinus().addListener(handListener);
            splitSpinner.getButtonPlus().addListener(handListener);
            splitSpinner.addListener(new TextTooltip("The distance in pixels that the user is allowed to scroll beyond the bounds if overscroll is enabled.", tooltipManager, skin, "scene"));
            splitSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.splitPaneSplit((float) ((Spinner) actor).getValue());
                }
            });
            popTable.row();
            label = new Label("Split Min:", skin, "scene-label-colored");
            popTable.add(label).spaceRight(5);
            splitMinSpinner.setName("pad-left");
            splitMinSpinner.setValue(simSplitPane.splitMin);
            splitMinSpinner.setMinimum(0);
            splitMinSpinner.setMaximum(simSplitPane.splitMax);
            popTable.add(splitMinSpinner);
            splitMinSpinner.getTextField().addListener(ibeamListener);
            splitMinSpinner.getButtonMinus().addListener(handListener);
            splitMinSpinner.getButtonPlus().addListener(handListener);
            splitMinSpinner.addListener(new TextTooltip("The minimum speed that scroll returns to the widget bounds when overscroll is enabled.", tooltipManager, skin, "scene"));
            splitMinSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.splitPaneSplitMin((float) ((Spinner) actor).getValue());
                    splitSpinner.setMinimum(splitMinSpinner.getValue());
                    splitMaxSpinner.setMinimum(splitMinSpinner.getValue());
                }
            });
            popTable.row();
            label = new Label("Split Max:", skin, "scene-label-colored");
            popTable.add(label).spaceRight(5);
            splitMaxSpinner.setName("pad-left");
            splitMaxSpinner.setValue(simSplitPane.splitMax);
            splitMaxSpinner.setMinimum(simSplitPane.splitMin);
            splitMaxSpinner.setMaximum(1);
            popTable.add(splitMaxSpinner);
            splitMaxSpinner.getTextField().addListener(ibeamListener);
            splitMaxSpinner.getButtonMinus().addListener(handListener);
            splitMaxSpinner.getButtonPlus().addListener(handListener);
            splitMaxSpinner.addListener(new TextTooltip("The maximum speed that scroll returns to the widget bounds when overscroll is enabled.", tooltipManager, skin, "scene"));
            splitMaxSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.splitPaneSplitMax((float) ((Spinner) actor).getValue());
                    splitSpinner.setMaximum(splitMaxSpinner.getValue());
                    splitMinSpinner.setMaximum(splitMaxSpinner.getValue());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : PopTableClickListener(com.ray3k.stripe.PopTableClickListener) Spinner(com.ray3k.stripe.Spinner) 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) SimSplitPane(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimSplitPane)

Example 32 with PopTableClickListener

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

the class TableListeners method tablePaddingListener.

public static EventListener tablePaddingListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTable = (DialogSceneComposerModel.SimTable) 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 clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            update();
        }

        public void update() {
            var popTable = getPopTable();
            popTable.clearChildren();
            popTable.defaults().reset();
            var changeListener = new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    TextButton paddingButton = popTable.findActor("padding-button");
                    paddingButton.setText(paddingButton.isChecked() ? "Enabled" : "Disabled");
                    Spinner padLeft = popTable.findActor("pad-left");
                    padLeft.setTouchable(paddingButton.isChecked() ? Touchable.enabled : Touchable.disabled);
                    padLeft.getTextField().setDisabled(!paddingButton.isChecked());
                    padLeft.getButtonMinus().setDisabled(!paddingButton.isChecked());
                    padLeft.getButtonPlus().setDisabled(!paddingButton.isChecked());
                    Spinner padRight = popTable.findActor("pad-right");
                    padRight.setTouchable(paddingButton.isChecked() ? Touchable.enabled : Touchable.disabled);
                    padRight.getTextField().setDisabled(!paddingButton.isChecked());
                    padRight.getButtonMinus().setDisabled(!paddingButton.isChecked());
                    padRight.getButtonPlus().setDisabled(!paddingButton.isChecked());
                    Spinner padTop = popTable.findActor("pad-top");
                    padTop.setTouchable(paddingButton.isChecked() ? Touchable.enabled : Touchable.disabled);
                    padTop.getTextField().setDisabled(!paddingButton.isChecked());
                    padTop.getButtonMinus().setDisabled(!paddingButton.isChecked());
                    padTop.getButtonPlus().setDisabled(!paddingButton.isChecked());
                    Spinner padBottom = popTable.findActor("pad-bottom");
                    padBottom.setTouchable(paddingButton.isChecked() ? Touchable.enabled : Touchable.disabled);
                    padBottom.getTextField().setDisabled(!paddingButton.isChecked());
                    padBottom.getButtonMinus().setDisabled(!paddingButton.isChecked());
                    padBottom.getButtonPlus().setDisabled(!paddingButton.isChecked());
                    events.tablePadding(paddingButton.isChecked(), (float) padLeft.getValue(), (float) padRight.getValue(), (float) padTop.getValue(), (float) padBottom.getValue());
                }
            };
            var label = new Label("Padding", skin, "scene-label-colored");
            popTable.add(label).colspan(2);
            popTable.row();
            popTable.defaults().right().spaceRight(5);
            var textButton = new TextButton(simTable.paddingEnabled ? "Enabled" : "Disabled", skin, "scene-small");
            textButton.setChecked(simTable.paddingEnabled);
            textButton.setName("padding-button");
            popTable.add(textButton).minWidth(150).colspan(2);
            textButton.addListener(handListener);
            textButton.addListener(new TextTooltip("Whether the button is checked initially.", tooltipManager, skin, "scene"));
            textButton.addListener(changeListener);
            popTable.row();
            label = new Label("Left:", skin, "scene-label-colored");
            popTable.add(label);
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("pad-left");
            spinner.setValue(simTable.padLeft);
            spinner.setTouchable(simTable.paddingEnabled ? Touchable.enabled : Touchable.disabled);
            spinner.getTextField().setDisabled(!simTable.paddingEnabled);
            spinner.getButtonMinus().setDisabled(!simTable.paddingEnabled);
            spinner.getButtonPlus().setDisabled(!simTable.paddingEnabled);
            popTable.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The padding on the left of the contents.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            popTable.row();
            label = new Label("Right:", skin, "scene-label-colored");
            popTable.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("pad-right");
            spinner.setValue(simTable.padRight);
            spinner.setTouchable(simTable.paddingEnabled ? Touchable.enabled : Touchable.disabled);
            spinner.getTextField().setDisabled(!simTable.paddingEnabled);
            spinner.getButtonMinus().setDisabled(!simTable.paddingEnabled);
            spinner.getButtonPlus().setDisabled(!simTable.paddingEnabled);
            popTable.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The padding on the right of the contents.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            popTable.row();
            label = new Label("Top:", skin, "scene-label-colored");
            popTable.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("pad-top");
            spinner.setValue(simTable.padTop);
            spinner.setTouchable(simTable.paddingEnabled ? Touchable.enabled : Touchable.disabled);
            spinner.getTextField().setDisabled(!simTable.paddingEnabled);
            spinner.getButtonMinus().setDisabled(!simTable.paddingEnabled);
            spinner.getButtonPlus().setDisabled(!simTable.paddingEnabled);
            popTable.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The padding on the top of the contents.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            popTable.row();
            label = new Label("Bottom:", skin, "scene-label-colored");
            popTable.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("pad-bottom");
            spinner.setValue(simTable.padBottom);
            spinner.setTouchable(simTable.paddingEnabled ? Touchable.enabled : Touchable.disabled);
            spinner.getTextField().setDisabled(!simTable.paddingEnabled);
            spinner.getButtonMinus().setDisabled(!simTable.paddingEnabled);
            spinner.getButtonPlus().setDisabled(!simTable.paddingEnabled);
            popTable.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The padding on the bottom of the contents.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : PopTableClickListener(com.ray3k.stripe.PopTableClickListener) Spinner(com.ray3k.stripe.Spinner) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 33 with PopTableClickListener

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

the class TableListeners method tableSetCellsListener.

public static EventListener tableSetCellsListener(final DialogSceneComposerEvents events) {
    var popTableClickListener = new PopTableClickListener(skin, "dark");
    var popTable = popTableClickListener.getPopTable();
    popTable.key(Keys.ESCAPE, popTable::hide);
    var label = new Label("Erase contents\nand create\nnew cells:", skin, "scene-label");
    label.setAlignment(Align.center);
    popTable.add(label);
    label.addListener(new TextTooltip("Sets the cells for this table. This will erase the existing contents.", 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.tableSetCells(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) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 34 with PopTableClickListener

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

the class TextButtonListeners method textButtonTextListener.

public static EventListener textButtonTextListener(final DialogSceneComposer dialogSceneComposer) {
    var simTextButton = (DialogSceneComposerModel.SimTextButton) dialogSceneComposer.simActor;
    var textField = new TextField("", skin, "scene");
    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);
            dialogSceneComposer.getStage().setKeyboardFocus(textField);
            textField.setSelection(0, textField.getText().length());
            update();
        }

        public void update() {
            var popTable = getPopTable();
            popTable.clearChildren();
            var label = new Label("Text:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            textField.setText(simTextButton.text);
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The text inside of the button.", tooltipManager, skin, "scene"));
            textField.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    dialogSceneComposer.events.textButtonText(textField.getText());
                }
            });
            textField.addListener(new InputListener() {

                @Override
                public boolean keyDown(InputEvent event, int keycode) {
                    if (keycode == Input.Keys.ENTER || keycode == Keys.NUMPAD_ENTER) {
                        popTable.hide();
                        return true;
                    } else {
                        return false;
                    }
                }
            });
            dialogSceneComposer.getStage().setKeyboardFocus(textField);
            textField.setSelection(0, textField.getText().length());
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) 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 35 with PopTableClickListener

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

the class TextButtonListeners method textButtonCheckedListener.

public static EventListener textButtonCheckedListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTextButton = (DialogSceneComposerModel.SimTextButton) 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 label = new Label("Checked:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var textButton = new TextButton(simTextButton.checked ? "TRUE" : "FALSE", skin, "scene-small");
            textButton.setChecked(simTextButton.checked);
            popTable.add(textButton).minWidth(100);
            textButton.addListener(handListener);
            textButton.addListener(new TextTooltip("Whether the button is checked initially.", tooltipManager, skin, "scene"));
            textButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
                    events.textButtonChecked(textButton.isChecked());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : 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

PopTableClickListener (com.ray3k.stripe.PopTableClickListener)127 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)125 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)123 Actor (com.badlogic.gdx.scenes.scene2d.Actor)110 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)110 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)41 Spinner (com.ray3k.stripe.Spinner)34 PopTable (com.ray3k.stripe.PopTable)29 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)28 ValueBeginChangeEvent (com.ray3k.stripe.RangeSlider.ValueBeginChangeEvent)19 ValueBeginChangeListener (com.ray3k.stripe.RangeSlider.ValueBeginChangeListener)19 ValueEndChangeEvent (com.ray3k.stripe.RangeSlider.ValueEndChangeEvent)19 ValueEndChangeListener (com.ray3k.stripe.RangeSlider.ValueEndChangeListener)19 DialogSceneComposerModel (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel)11 Input (com.badlogic.gdx.Input)10 Keys (com.badlogic.gdx.Input.Keys)10 com.badlogic.gdx.scenes.scene2d.ui (com.badlogic.gdx.scenes.scene2d.ui)10 Main (com.ray3k.skincomposer.Main)10 DialogListener (com.ray3k.skincomposer.dialog.DialogListener)9 DialogSceneComposer (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposer)9