Search in sources :

Example 26 with PopTableClickListener

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

the class TextAreaListeners method textAreaTextListener.

public static EventListener textAreaTextListener(final DialogSceneComposer dialogSceneComposer) {
    var simTextArea = (DialogSceneComposerModel.SimTextArea) 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("Text:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            textField.setText(simTextArea.text);
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The default text inside the TextArea.", tooltipManager, skin, "scene"));
            textField.addListener(new ChangeListener() {

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

Example 27 with PopTableClickListener

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

the class TextAreaListeners method textAreaAlignmentListener.

public static EventListener textAreaAlignmentListener(final DialogSceneComposerEvents events, final SimActor 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 simTextArea = (DialogSceneComposerModel.SimTextArea) simActor;
            var popTable = getPopTable();
            popTable.clearChildren();
            var table = new Table();
            popTable.add(table);
            var label = new Label("Alignment:", skin, "scene-label-colored");
            table.add(label).colspan(3);
            table.row();
            table.defaults().space(10).left().uniformX();
            var buttonGroup = new ButtonGroup<ImageTextButton>();
            var imageTextButton = new ImageTextButton("Top-Left", skin, "scene-checkbox-colored");
            var topLeft = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the contents of the TextArea to the top left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.topLeft);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Top", skin, "scene-checkbox-colored");
            var top = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the contents of the TextArea to the top center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.top);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Top-Right", skin, "scene-checkbox-colored");
            var topRight = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the contents of the TextArea to the top right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.topRight);
                }
            });
            buttonGroup.add(imageTextButton);
            table.row();
            imageTextButton = new ImageTextButton("Left", skin, "scene-checkbox-colored");
            var left = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the contents of the TextArea to the middle left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.left);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Center", skin, "scene-checkbox-colored");
            var center = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the contents of the TextArea to the center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.center);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Right", skin, "scene-checkbox-colored");
            var right = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the contents of the TextArea to the middle right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.right);
                }
            });
            buttonGroup.add(imageTextButton);
            table.row();
            imageTextButton = new ImageTextButton("Bottom-Left", skin, "scene-checkbox-colored");
            var bottomLeft = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the contents of the TextArea to the bottom left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.bottomLeft);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Bottom", skin, "scene-checkbox-colored");
            var bottom = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the contents of the TextArea to the bottom center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.bottom);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Bottom-Right", skin, "scene-checkbox-colored");
            var bottomRight = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the contents of the TextArea to the bottom right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.bottomRight);
                }
            });
            buttonGroup.add(imageTextButton);
            switch(simTextArea.alignment) {
                case Align.topLeft:
                    topLeft.setChecked(true);
                    break;
                case Align.top:
                    top.setChecked(true);
                    break;
                case Align.topRight:
                    topRight.setChecked(true);
                    break;
                case Align.right:
                    right.setChecked(true);
                    break;
                case Align.bottomRight:
                    bottomRight.setChecked(true);
                    break;
                case Align.bottom:
                    bottom.setChecked(true);
                    break;
                case Align.bottomLeft:
                    bottomLeft.setChecked(true);
                    break;
                case Align.left:
                    left.setChecked(true);
                    break;
                case Align.center:
                    center.setChecked(true);
                    break;
            }
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) 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 28 with PopTableClickListener

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

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

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

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