Search in sources :

Example 36 with PopTableClickListener

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

the class TextFieldListeners method textFieldMaxLengthListener.

public static EventListener textFieldMaxLengthListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTextField = (DialogSceneComposerModel.SimTextField) 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 table = new Table();
            popTable.add(table);
            var label = new Label("Max Length:", skin, "scene-label-colored");
            table.add(label).right();
            var valueSpinner = new Spinner(simTextField.maxLength, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            valueSpinner.setMinimum(0);
            table.add(valueSpinner).width(100).left();
            valueSpinner.getTextField().addListener(ibeamListener);
            valueSpinner.getButtonMinus().addListener(handListener);
            valueSpinner.getButtonPlus().addListener(handListener);
            valueSpinner.addListener(new TextTooltip("The maximum length of characters allowed in the TextField.", tooltipManager, skin, "scene"));
            valueSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textFieldMaxLength(valueSpinner.getValueAsInt());
                }
            });
            table.row();
            label = new Label("(Set to 0 to show as many as possible)", skin, "scene-label-colored");
            table.add(label).colspan(2);
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) Spinner(com.ray3k.stripe.Spinner) ValueEndChangeEvent(com.ray3k.stripe.RangeSlider.ValueEndChangeEvent) ValueBeginChangeEvent(com.ray3k.stripe.RangeSlider.ValueBeginChangeEvent) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ValueEndChangeListener(com.ray3k.stripe.RangeSlider.ValueEndChangeListener) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) ValueBeginChangeListener(com.ray3k.stripe.RangeSlider.ValueBeginChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 37 with PopTableClickListener

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

the class TextFieldListeners method textFieldNameListener.

public static EventListener textFieldNameListener(final DialogSceneComposer dialogSceneComposer) {
    var simTextField = (DialogSceneComposerModel.SimTextField) 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("Name:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            textField.setText(simTextField.name);
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The name of the TextField to allow for convenient searching via Group#findActor().", tooltipManager, skin, "scene"));
            textField.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    dialogSceneComposer.events.textFieldName(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 : ValueEndChangeEvent(com.ray3k.stripe.RangeSlider.ValueEndChangeEvent) ValueBeginChangeEvent(com.ray3k.stripe.RangeSlider.ValueBeginChangeEvent) 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) ValueEndChangeListener(com.ray3k.stripe.RangeSlider.ValueEndChangeListener) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) ValueBeginChangeListener(com.ray3k.stripe.RangeSlider.ValueBeginChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 38 with PopTableClickListener

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

the class TouchPadListeners method touchPadDeadZoneListener.

public static EventListener touchPadDeadZoneListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTouchPad = (DialogSceneComposerModel.SimTouchPad) 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 table = new Table();
            popTable.add(table);
            table.defaults().right().spaceRight(5);
            var label = new Label("Dead Zone:", skin, "scene-label-colored");
            table.add(label);
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simTouchPad.deadZone);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The dead zone that does not react to user input.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.touchPadDeadZone(spinner.getValueAsInt());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) Spinner(com.ray3k.stripe.Spinner) 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 39 with PopTableClickListener

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

the class VerticalGroupListeners method verticalGroupColumnAlignmentListener.

public static EventListener verticalGroupColumnAlignmentListener(final DialogSceneComposerEvents events, final SimActor 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 simVerticalGroup = (DialogSceneComposerModel.SimVerticalGroup) simActor;
            var popTable = getPopTable();
            popTable.clearChildren();
            var table = new Table();
            popTable.add(table);
            var label = new Label("Alignment:", skin, "scene-label-colored");
            table.add(label).colspan(3);
            table.row();
            table.defaults().space(10).left().uniformX();
            var buttonGroup = new ButtonGroup<ImageTextButton>();
            var imageTextButton = new ImageTextButton("Top-Left", skin, "scene-checkbox-colored");
            var topLeft = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the top left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupColumnAlignment(Align.topLeft);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Top", skin, "scene-checkbox-colored");
            var top = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the top center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupColumnAlignment(Align.top);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Top-Right", skin, "scene-checkbox-colored");
            var topRight = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the top right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupColumnAlignment(Align.topRight);
                }
            });
            buttonGroup.add(imageTextButton);
            table.row();
            imageTextButton = new ImageTextButton("Left", skin, "scene-checkbox-colored");
            var left = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the middle left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupColumnAlignment(Align.left);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Center", skin, "scene-checkbox-colored");
            var center = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupColumnAlignment(Align.center);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Right", skin, "scene-checkbox-colored");
            var right = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the middle right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupColumnAlignment(Align.right);
                }
            });
            buttonGroup.add(imageTextButton);
            table.row();
            imageTextButton = new ImageTextButton("Bottom-Left", skin, "scene-checkbox-colored");
            var bottomLeft = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the bottom left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupColumnAlignment(Align.bottomLeft);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Bottom", skin, "scene-checkbox-colored");
            var bottom = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the bottom center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupColumnAlignment(Align.bottom);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Bottom-Right", skin, "scene-checkbox-colored");
            var bottomRight = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the bottom right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupColumnAlignment(Align.bottomRight);
                }
            });
            buttonGroup.add(imageTextButton);
            switch(simVerticalGroup.alignment) {
                case Align.topLeft:
                    topLeft.setChecked(true);
                    break;
                case Align.top:
                    top.setChecked(true);
                    break;
                case Align.topRight:
                    topRight.setChecked(true);
                    break;
                case Align.right:
                    right.setChecked(true);
                    break;
                case Align.bottomRight:
                    bottomRight.setChecked(true);
                    break;
                case Align.bottom:
                    bottom.setChecked(true);
                    break;
                case Align.bottomLeft:
                    bottomLeft.setChecked(true);
                    break;
                case Align.left:
                    left.setChecked(true);
                    break;
                case Align.center:
                    center.setChecked(true);
                    break;
            }
        }
    };
    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)

Example 40 with PopTableClickListener

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

the class ImageButtonListeners method imageButtonPaddingListener.

public static EventListener imageButtonPaddingListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simImageButton = (DialogSceneComposerModel.SimImageButton) 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 changeListener = new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    Spinner padLeft = popTable.findActor("pad-left");
                    Spinner padRight = popTable.findActor("pad-right");
                    Spinner padTop = popTable.findActor("pad-top");
                    Spinner padBottom = popTable.findActor("pad-bottom");
                    events.imageButtonPadding((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);
            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(simImageButton.padLeft);
            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(simImageButton.padRight);
            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(simImageButton.padTop);
            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(simImageButton.padBottom);
            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) 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