Search in sources :

Example 51 with SimActor

use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.

the class TextFieldListeners method textFieldSelectionListener.

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

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textFieldCursorPosition(MathUtils.round(slider.getValue()));
                    positionLabel.setText("Cursor Position: (" + simTextField.cursorPosition + ")");
                }
            });
            table.row();
            var selectionLabel = new Label("Selection: (" + simTextField.selectionStart + ", " + simTextField.selectionEnd + ")", skin, "scene-label-colored");
            table.add(selectionLabel);
            table.row();
            var rangeSlider = new RangeSlider(skin, "scene");
            rangeSlider.setMinimum(0);
            rangeSlider.setMaximum(simTextField.text == null ? 0 : simTextField.text.length());
            rangeSlider.setIncrement(1);
            rangeSlider.setValueBegin(simTextField.selectionStart);
            rangeSlider.setValueEnd(simTextField.selectionEnd);
            rangeSlider.setDisabled(simTextField.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 textField has keyboard focus.", tooltipManager, skin, "scene"));
            rangeSlider.addListener(new ValueBeginChangeListener() {

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

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

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    selectionLabel.setText("Selection: (" + simTextField.selectionStart + ", " + simTextField.selectionEnd + ")");
                }
            });
            table.row();
            var label = new Label("Select All: ", skin, "scene-label-colored");
            table.add(label);
            table.row();
            var textButton = new TextButton(simTextField.selectAll ? "TRUE" : "FALSE", skin, "scene-small");
            textButton.setChecked(simTextField.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.textFieldSelectAll(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 52 with SimActor

use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.

the class ImageListeners method imageScalingListener.

public static EventListener imageScalingListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var scalingNames = new Array<>(new String[] { "none", "fill", "fillX", "fillY", "fit", "stretch", "stretchX", "stretchY" });
    var simImage = (DialogSceneComposerModel.SimImage) simActor;
    var selectBox = new SelectBox<String>(skin, "scene");
    selectBox.setItems(scalingNames);
    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("Scaling:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            selectBox.setSelected(simImage.scaling);
            popTable.add(selectBox);
            selectBox.addListener(handListener);
            selectBox.addListener(new TextTooltip("The scaling strategy applied to the image.", tooltipManager, skin, "scene"));
            selectBox.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.imageScaling(selectBox.getSelected());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Array(com.badlogic.gdx.utils.Array) TextTooltip(com.badlogic.gdx.scenes.scene2d.ui.TextTooltip) 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 53 with SimActor

use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.

the class ImageTextButtonListeners method imageTextButtonCheckedListener.

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

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

use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor 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 55 with SimActor

use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor 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)

Aggregations

ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)81 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)81 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)81 Actor (com.badlogic.gdx.scenes.scene2d.Actor)75 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)75 Spinner (com.ray3k.stripe.Spinner)32 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)26 PopTable (com.ray3k.stripe.PopTable)23 ValueBeginChangeEvent (com.ray3k.stripe.RangeSlider.ValueBeginChangeEvent)11 ValueBeginChangeListener (com.ray3k.stripe.RangeSlider.ValueBeginChangeListener)11 ValueEndChangeEvent (com.ray3k.stripe.RangeSlider.ValueEndChangeEvent)11 ValueEndChangeListener (com.ray3k.stripe.RangeSlider.ValueEndChangeListener)11 Input (com.badlogic.gdx.Input)7 Keys (com.badlogic.gdx.Input.Keys)7 Color (com.badlogic.gdx.graphics.Color)7 com.badlogic.gdx.scenes.scene2d.ui (com.badlogic.gdx.scenes.scene2d.ui)7 Main (com.ray3k.skincomposer.Main)7 StyleProperty (com.ray3k.skincomposer.data.StyleProperty)7 DialogListener (com.ray3k.skincomposer.dialog.DialogListener)7 DialogSceneComposer (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposer)7