Search in sources :

Example 26 with Spinner

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

the class TextAreaListeners method textAreaMaxLengthListener.

public static EventListener textAreaMaxLengthListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTextArea = (DialogSceneComposerModel.SimTextArea) 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);
            var label = new Label("Max Length:", skin, "scene-label-colored");
            table.add(label).right();
            var valueSpinner = new Spinner(simTextArea.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 TextArea.", tooltipManager, skin, "scene"));
            valueSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaMaxLength(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 27 with Spinner

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

the class ProgressBarListeners method progressBarAnimationListener.

public static EventListener progressBarAnimationListener(final DialogSceneComposer dialogSceneComposer) {
    var simProgressBar = (DialogSceneComposerModel.SimProgressBar) dialogSceneComposer.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);
            table.defaults().spaceRight(5);
            var textButton = new TextButton("Animate Interpolation", skin, "scene-med");
            table.add(textButton).uniformX().fillX().colspan(2);
            textButton.addListener(handListener);
            textButton.addListener(GeneralListeners.interpolationListener(dialogSceneComposer, selection -> dialogSceneComposer.events.progressBarAnimateInterpolation(selection)));
            table.row();
            textButton = new TextButton("Visual Interpolation", skin, "scene-med");
            table.add(textButton).uniformX().fillX().colspan(2);
            textButton.addListener(handListener);
            textButton.addListener(GeneralListeners.interpolationListener(dialogSceneComposer, selection -> dialogSceneComposer.events.progressBarVisualInterpolation(selection)));
            table.row();
            var label = new Label("Animation Duration:", skin, "scene-label-colored");
            table.add(label).right();
            var durationSpinner = new Spinner(simProgressBar.animationDuration, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            durationSpinner.setMinimum(0);
            table.add(durationSpinner).left();
            durationSpinner.getTextField().addListener(ibeamListener);
            durationSpinner.getButtonMinus().addListener(handListener);
            durationSpinner.getButtonPlus().addListener(handListener);
            durationSpinner.addListener(new TextTooltip("The animation duration of the ProgressBar as the value changes.", tooltipManager, skin, "scene"));
            durationSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    dialogSceneComposer.events.progressBarAnimationDuration((float) durationSpinner.getValue());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) com.badlogic.gdx.scenes.scene2d.ui(com.badlogic.gdx.scenes.scene2d.ui) DialogSceneComposer(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposer) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) TEXT_FIELD_WIDTH(com.ray3k.skincomposer.dialog.scenecomposer.menulisteners.ListenersUtils.TEXT_FIELD_WIDTH) Spinner(com.ray3k.stripe.Spinner) Actor(com.badlogic.gdx.scenes.scene2d.Actor) DialogSceneComposerEvents(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerEvents) DialogSceneComposerModel(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) Keys(com.badlogic.gdx.Input.Keys) Main(com.ray3k.skincomposer.Main) Input(com.badlogic.gdx.Input) StyleData(com.ray3k.skincomposer.data.StyleData) DraggableTextList(com.ray3k.stripe.DraggableTextList) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) EventListener(com.badlogic.gdx.scenes.scene2d.EventListener) 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 28 with Spinner

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

the class TreeListeners method treePaddingListener.

public static EventListener treePaddingListener(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("Left:", skin, "scene-label-colored");
            table.add(label);
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simTree.padLeft);
            table.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 Tree.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.treePadLeft((float) ((Spinner) actor).getValue());
                }
            });
            table.row();
            label = new Label("Right:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simTree.padRight);
            table.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 Tree.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.treePadLeft((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 29 with Spinner

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

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

the class CellListeners method cellSizeListener.

public static EventListener cellSizeListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simCell = (DialogSceneComposerModel.SimCell) 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 minimumWidth = popTable.findActor("minimum-width");
                    Spinner minimumHeight = popTable.findActor("minimum-height");
                    Spinner maximumWidth = popTable.findActor("maximum-width");
                    Spinner maximumHeight = popTable.findActor("maximum-height");
                    Spinner preferredWidth = popTable.findActor("preferred-width");
                    Spinner preferredHeight = popTable.findActor("preferred-height");
                    Button link = popTable.findActor("link");
                    if (!link.isChecked()) {
                        events.cellSize((float) minimumWidth.getValue(), (float) minimumHeight.getValue(), (float) maximumWidth.getValue(), (float) maximumHeight.getValue(), (float) preferredWidth.getValue(), (float) preferredHeight.getValue());
                    } else if (actor != link) {
                        var val = 0.0f;
                        if (actor == minimumWidth)
                            val = (float) minimumWidth.getValue();
                        else if (actor == minimumHeight)
                            val = (float) minimumHeight.getValue();
                        else if (actor == maximumWidth)
                            val = (float) maximumWidth.getValue();
                        else if (actor == maximumHeight)
                            val = (float) maximumHeight.getValue();
                        else if (actor == preferredWidth)
                            val = (float) preferredWidth.getValue();
                        else if (actor == preferredHeight)
                            val = (float) preferredHeight.getValue();
                        events.cellSize(val, val, val, val, val, val);
                        minimumWidth.setValue(val);
                        minimumHeight.setValue(val);
                        maximumWidth.setValue(val);
                        maximumHeight.setValue(val);
                        preferredWidth.setValue(val);
                        preferredHeight.setValue(val);
                    }
                }
            };
            var label = new Label("Set to negative to disable", skin, "scene-label-colored");
            popTable.add(label).colspan(5);
            popTable.row();
            var table = new Table();
            popTable.add(table);
            label = new Label("Minimum:", skin, "scene-label-colored");
            table.add(label).colspan(2);
            table.row();
            table.defaults().right().spaceRight(5);
            label = new Label("Width:", skin, "scene-label-colored");
            table.add(label);
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("minimum-width");
            spinner.setValue(simCell.minWidth);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The minimum width of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            table.row();
            label = new Label("Height:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("minimum-height");
            spinner.setValue(simCell.minHeight);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The minimum height of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            var image = new Image(skin, "scene-menu-divider");
            popTable.add(image).space(10).growY();
            table = new Table();
            popTable.add(table);
            label = new Label("Maximum:", skin, "scene-label-colored");
            table.add(label).colspan(2);
            table.row();
            table.defaults().right().spaceRight(5);
            label = new Label("Width:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("maximum-width");
            spinner.setValue(simCell.maxWidth);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The maximum width of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            table.row();
            label = new Label("Height:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("maximum-height");
            spinner.setValue(simCell.maxHeight);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The maximum height of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            image = new Image(skin, "scene-menu-divider");
            popTable.add(image).space(10).growY();
            table = new Table();
            popTable.add(table);
            label = new Label("Preferred:", skin, "scene-label-colored");
            table.add(label).colspan(2);
            table.row();
            table.defaults().right().spaceRight(5);
            label = new Label("Width:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("preferred-width");
            spinner.setValue(simCell.preferredWidth);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The preferred width of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            table.row();
            label = new Label("Height:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("preferred-height");
            spinner.setValue(simCell.preferredHeight);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The preferred height of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            popTable.row();
            var button = new Button(skin, "scene-link");
            button.setName("link");
            popTable.add(button).colspan(5).right();
            button.addListener(Main.handListener);
            button.addListener(changeListener);
            button.addListener(new TextTooltip("Click to modify all values at once.", tooltipManager, skin, "scene"));
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : SimTable(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable) 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)

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