Search in sources :

Example 46 with PopTableClickListener

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

the class ImageTextButtonListeners method imageTextButtonPaddingListener.

public static EventListener imageTextButtonPaddingListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simImageTextButton = (DialogSceneComposerModel.SimImageTextButton) 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.imageTextButtonPadding((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(simImageTextButton.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(simImageTextButton.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(simImageTextButton.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(simImageTextButton.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)

Example 47 with PopTableClickListener

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

the class ProgressBarListeners method progressBarNameListener.

public static EventListener progressBarNameListener(final DialogSceneComposer dialogSceneComposer) {
    var simList = (DialogSceneComposerModel.SimProgressBar) 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(simList.name);
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The name of the ProgressBar 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.progressBarName(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 48 with PopTableClickListener

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

the class ProgressBarListeners method progressBarValueSettingsListener.

public static EventListener progressBarValueSettingsListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simProgressBar = (DialogSceneComposerModel.SimProgressBar) 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("Value:", skin, "scene-label-colored");
            table.add(label);
            var valueSpinner = new Spinner(simProgressBar.value, simProgressBar.increment, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            valueSpinner.setMinimum(simProgressBar.minimum);
            valueSpinner.setMaximum(simProgressBar.maximum);
            table.add(valueSpinner).width(100).uniformX();
            valueSpinner.getTextField().addListener(ibeamListener);
            valueSpinner.getButtonMinus().addListener(handListener);
            valueSpinner.getButtonPlus().addListener(handListener);
            valueSpinner.addListener(new TextTooltip("The value of the ProgressBar.", tooltipManager, skin, "scene"));
            valueSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.progressBarValue((float) valueSpinner.getValue());
                }
            });
            table.row();
            label = new Label("Minimum:", skin, "scene-label-colored");
            table.add(label);
            var minimumSpinner = new Spinner(simProgressBar.minimum, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            minimumSpinner.setMaximum(simProgressBar.maximum);
            var maximumSpinner = new Spinner(simProgressBar.maximum, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            maximumSpinner.setMinimum(simProgressBar.minimum);
            table.add(minimumSpinner).uniformX().fillX();
            minimumSpinner.getTextField().addListener(ibeamListener);
            minimumSpinner.getButtonMinus().addListener(handListener);
            minimumSpinner.getButtonPlus().addListener(handListener);
            minimumSpinner.addListener(new TextTooltip("The minimum value of the ProgressBar.", tooltipManager, skin, "scene"));
            minimumSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.progressBarMinimum((float) minimumSpinner.getValue());
                    if (valueSpinner.getValue() < minimumSpinner.getValue()) {
                        valueSpinner.setValue(simProgressBar.minimum);
                    }
                    maximumSpinner.setMinimum(simProgressBar.minimum);
                }
            });
            table.row();
            label = new Label("Maximum:", skin, "scene-label-colored");
            table.add(label);
            maximumSpinner.setValue(simProgressBar.maximum);
            table.add(maximumSpinner).uniformX().fillX();
            maximumSpinner.getTextField().addListener(ibeamListener);
            maximumSpinner.getButtonMinus().addListener(handListener);
            maximumSpinner.getButtonPlus().addListener(handListener);
            maximumSpinner.addListener(new TextTooltip("The maximum value of the ProgressBar.", tooltipManager, skin, "scene"));
            maximumSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.progressBarMaximum((float) maximumSpinner.getValue());
                    if (valueSpinner.getValue() > maximumSpinner.getValue()) {
                        valueSpinner.setValue(simProgressBar.maximum);
                    }
                    minimumSpinner.setMaximum(simProgressBar.maximum);
                }
            });
            table.row();
            label = new Label("Increment:", skin, "scene-label-colored");
            table.add(label);
            var incrementSpinner = new Spinner(0, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            incrementSpinner.setValue(simProgressBar.increment);
            incrementSpinner.setMinimum(.0000000001);
            table.add(incrementSpinner).uniformX().fillX();
            incrementSpinner.getTextField().addListener(ibeamListener);
            incrementSpinner.getButtonMinus().addListener(handListener);
            incrementSpinner.getButtonPlus().addListener(handListener);
            incrementSpinner.addListener(new TextTooltip("The increment value of the ProgressBar.", tooltipManager, skin, "scene"));
            incrementSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.progressBarIncrement((float) incrementSpinner.getValue());
                }
            });
        }
    };
    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 49 with PopTableClickListener

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

the class ProgressBarListeners method progressBarDisabledListener.

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

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

Example 50 with PopTableClickListener

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

the class CellListeners method cellColSpanListener.

public static EventListener cellColSpanListener(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 table = new Table();
            popTable.add(table);
            var label = new Label("Column Span:", skin, "scene-label-colored");
            table.add(label).colspan(2);
            table.row();
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simCell.colSpan);
            spinner.setMinimum(1);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The column span of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellColSpan(spinner.getValueAsInt());
                }
            });
        }
    };
    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

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