Search in sources :

Example 76 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.

the class TextAreaListeners method textAreaFocusTraversalListener.

public static EventListener textAreaFocusTraversalListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTextArea = (DialogSceneComposerModel.SimTextArea) 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("Focus Traversal:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var textButton = new TextButton(simTextArea.focusTraversal ? "TRUE" : "FALSE", skin, "scene-small");
            textButton.setChecked(simTextArea.focusTraversal);
            popTable.add(textButton).minWidth(100);
            textButton.addListener(handListener);
            textButton.addListener(new TextTooltip("Whether the TextArea allows for the use of focus traversal keys.", tooltipManager, skin, "scene"));
            textButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
                    events.textAreaFocusTraversal(textButton.isChecked());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : 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 77 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.

the class TextAreaListeners method textAreaSelectionListener.

public static EventListener textAreaSelectionListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTextArea = (DialogSceneComposerModel.SimTextArea) 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 positionLabel = new Label("Cursor Position: (" + simTextArea.cursorPosition + ")", skin, "scene-label-colored");
            table.add(positionLabel);
            table.row();
            var slider = new Slider(0, simTextArea.text == null ? 0 : simTextArea.text.length(), 1, false, skin, "scene");
            slider.setValue(simTextArea.cursorPosition);
            table.add(slider).minWidth(200);
            slider.addListener(handListener);
            slider.addListener(new TextTooltip("The cursor position when the TextArea has keyboard focus.", tooltipManager, skin, "scene"));
            slider.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaCursorPosition(MathUtils.round(slider.getValue()));
                    positionLabel.setText("Cursor Position: (" + simTextArea.cursorPosition + ")");
                }
            });
            table.row();
            var selectionLabel = new Label("Selection: (" + simTextArea.selectionStart + ", " + simTextArea.selectionEnd + ")", skin, "scene-label-colored");
            table.add(selectionLabel);
            table.row();
            var rangeSlider = new RangeSlider(skin, "scene");
            rangeSlider.setMinimum(0);
            rangeSlider.setMaximum(simTextArea.text == null ? 0 : simTextArea.text.length());
            rangeSlider.setIncrement(1);
            rangeSlider.setValueBegin(simTextArea.selectionStart);
            rangeSlider.setValueEnd(simTextArea.selectionEnd);
            rangeSlider.setDisabled(simTextArea.selectAll);
            table.add(rangeSlider).minWidth(200);
            rangeSlider.getKnobBegin().addListener(handListener);
            rangeSlider.getKnobEnd().addListener(handListener);
            rangeSlider.addListener(new TextTooltip("The text range to be selected if this TextArea has keyboard focus.", tooltipManager, skin, "scene"));
            rangeSlider.addListener(new ValueBeginChangeListener() {

                @Override
                public void changed(ValueBeginChangeEvent event, float value, Actor actor) {
                    events.textAreaSelectionStart(MathUtils.round(value));
                }
            });
            rangeSlider.addListener(new ValueEndChangeListener() {

                @Override
                public void changed(ValueEndChangeEvent event, float value, Actor actor) {
                    events.textAreaSelectionEnd(MathUtils.round(value));
                }
            });
            rangeSlider.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    selectionLabel.setText("Selection: (" + simTextArea.selectionStart + ", " + simTextArea.selectionEnd + ")");
                }
            });
            table.row();
            var label = new Label("Select All: ", skin, "scene-label-colored");
            table.add(label);
            table.row();
            var textButton = new TextButton(simTextArea.selectAll ? "TRUE" : "FALSE", skin, "scene-small");
            textButton.setChecked(simTextArea.selectAll);
            table.add(textButton).minWidth(100);
            textButton.addListener(handListener);
            textButton.addListener(new TextTooltip("Convenience option to select all text.", tooltipManager, skin, "scene"));
            textButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
                    events.textAreaSelectAll(textButton.isChecked());
                    rangeSlider.setDisabled(textButton.isChecked());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : ValueEndChangeEvent(com.ray3k.stripe.RangeSlider.ValueEndChangeEvent) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) RangeSlider(com.ray3k.stripe.RangeSlider) RangeSlider(com.ray3k.stripe.RangeSlider) ValueEndChangeListener(com.ray3k.stripe.RangeSlider.ValueEndChangeListener) ValueBeginChangeEvent(com.ray3k.stripe.RangeSlider.ValueBeginChangeEvent) 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) ValueBeginChangeListener(com.ray3k.stripe.RangeSlider.ValueBeginChangeListener) 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 78 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.

the class TextAreaListeners method textAreaDisabledListener.

public static EventListener textAreaDisabledListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTextArea = (DialogSceneComposerModel.SimTextArea) 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(simTextArea.disabled ? "TRUE" : "FALSE", skin, "scene-small");
            textButton.setChecked(simTextArea.disabled);
            popTable.add(textButton).minWidth(100);
            textButton.addListener(handListener);
            textButton.addListener(new TextTooltip("Whether the TextArea 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.textAreaDisabled(textButton.isChecked());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : 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 79 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent 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 80 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent 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)

Aggregations

InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)358 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)183 Actor (com.badlogic.gdx.scenes.scene2d.Actor)174 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)144 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)110 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)109 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)86 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)53 Stage (com.badlogic.gdx.scenes.scene2d.Stage)49 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)47 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)45 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)35 Texture (com.badlogic.gdx.graphics.Texture)34 Spinner (com.ray3k.stripe.Spinner)32 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)31 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)29 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)26 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)25 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)25 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)22