Search in sources :

Example 11 with Spinner

use of com.ray3k.stripe.Spinner 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 12 with Spinner

use of com.ray3k.stripe.Spinner 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 13 with Spinner

use of com.ray3k.stripe.Spinner 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 14 with Spinner

use of com.ray3k.stripe.Spinner 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 15 with Spinner

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

Spinner (com.ray3k.stripe.Spinner)43 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)34 Actor (com.badlogic.gdx.scenes.scene2d.Actor)29 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)29 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)28 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)27 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)12 Color (com.badlogic.gdx.graphics.Color)11 PopTable (com.ray3k.stripe.PopTable)11 Keys (com.badlogic.gdx.Input.Keys)8 com.badlogic.gdx.scenes.scene2d.ui (com.badlogic.gdx.scenes.scene2d.ui)8 Main (com.ray3k.skincomposer.Main)8 Gdx (com.badlogic.gdx.Gdx)6 File (java.io.File)6 FileHandle (com.badlogic.gdx.files.FileHandle)5 MathUtils (com.badlogic.gdx.math.MathUtils)5 FilesDroppedListener (com.ray3k.skincomposer.FilesDroppedListener)5 Utils (com.ray3k.skincomposer.utils.Utils)5 Input (com.badlogic.gdx.Input)4 Pixmap (com.badlogic.gdx.graphics.Pixmap)4