Search in sources :

Example 81 with PopTableClickListener

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

the class ListListeners method listTextListListener.

public static EventListener listTextListListener(final DialogSceneComposer dialogSceneComposer) {
    var simList = (DialogSceneComposerModel.SimList) dialogSceneComposer.simActor;
    var textField = new TextField("", skin, "scene");
    textField.setFocusTraversal(false);
    var draggableTextList = new DraggableTextList(true, skin, "scene-unchecked");
    draggableTextList.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            dialogSceneComposer.events.listList(draggableTextList.getTexts());
        }
    });
    var scrollPane = new ScrollPane(draggableTextList, skin, "scene");
    scrollPane.setFadeScrollBars(false);
    scrollPane.addListener(scrollFocusListener);
    var popTableClickListener = new PopTableClickListener(skin) {

        {
            popTable.key(Keys.ESCAPE, popTable::hide);
            popTable.setAutomaticallyResized(true);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The text to add to the list.", tooltipManager, skin, "scene"));
            textField.addListener(new InputListener() {

                @Override
                public boolean keyDown(InputEvent event, int keycode) {
                    if (keycode == Input.Keys.ENTER || keycode == Keys.NUMPAD_ENTER) {
                        addItem(textField.getText());
                        return true;
                    } else {
                        return false;
                    }
                }
            });
        }

        @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("List Entries:\n(Drag to change order)", skin, "scene-label-colored");
            label.setAlignment(Align.center);
            popTable.add(label).colspan(2);
            popTable.row();
            draggableTextList.clearChildren();
            draggableTextList.addAllTexts(simList.list);
            popTable.add(scrollPane).colspan(2).minHeight(150).growX();
            popTable.row();
            label = new Label("Add New Item:", skin, "scene-label-colored");
            popTable.add(label).colspan(2).padTop(10);
            popTable.row();
            textField.setText("");
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            var textButton = new Button(skin, "scene-plus");
            popTable.add(textButton);
            textButton.addListener(handListener);
            textButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    addItem(textField.getText());
                }
            });
            dialogSceneComposer.getStage().setKeyboardFocus(textField);
            dialogSceneComposer.getStage().setScrollFocus(scrollPane);
        }

        public void addItem(String item) {
            draggableTextList.addText(item);
            dialogSceneComposer.events.listList(draggableTextList.getTexts());
            update();
        }
    };
    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) DraggableTextList(com.ray3k.stripe.DraggableTextList)

Example 82 with PopTableClickListener

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

the class ProgressBarListeners method progressBarOrientationListener.

public static EventListener progressBarOrientationListener(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("Orientation:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var draggableTextList = new DraggableTextList(true, skin, "scene");
            draggableTextList.setDraggable(false);
            draggableTextList.addAllTexts("Horizontal", "Vertical");
            draggableTextList.setSelected(simProgressBar.vertical ? 1 : 0);
            popTable.add(draggableTextList);
            draggableTextList.addListener(handListener);
            draggableTextList.addListener(new TextTooltip("The orientation of the ProgressBar.", tooltipManager, skin, "scene"));
            draggableTextList.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.progressBarVertical(draggableTextList.getSelectedIndex() == 1);
                }
            });
        }
    };
    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) DraggableTextList(com.ray3k.stripe.DraggableTextList)

Example 83 with PopTableClickListener

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

the class ProgressBarListeners method progressBarRoundListener.

public static EventListener progressBarRoundListener(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("Round:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var textButton = new TextButton(simProgressBar.round ? "TRUE" : "FALSE", skin, "scene-small");
            textButton.setChecked(simProgressBar.round);
            popTable.add(textButton).minWidth(100);
            textButton.addListener(handListener);
            textButton.addListener(new TextTooltip("Whether the ProgressBar inner positions are rounded to integer.", tooltipManager, skin, "scene"));
            textButton.addListener(new ChangeListener() {

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

use of com.ray3k.stripe.PopTableClickListener 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 85 with PopTableClickListener

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

the class TextFieldListeners method textFieldMessageTextListener.

public static EventListener textFieldMessageTextListener(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("Message Text:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            textField.setText(simTextField.messageText);
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The message inside the field when nothing is inputted and the field does not have focus.", tooltipManager, skin, "scene"));
            textField.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    dialogSceneComposer.events.textFieldMessageText(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)

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