Search in sources :

Example 66 with PopTableClickListener

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

the class SliderListeners method sliderDisabledListener.

public static EventListener sliderDisabledListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simSlider = (DialogSceneComposerModel.SimSlider) 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(simSlider.disabled ? "TRUE" : "FALSE", skin, "scene-small");
            textButton.setChecked(simSlider.disabled);
            popTable.add(textButton).minWidth(100);
            textButton.addListener(handListener);
            textButton.addListener(new TextTooltip("Whether the Slider 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.sliderDisabled(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 67 with PopTableClickListener

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

the class SliderListeners method sliderOrientationListener.

public static EventListener sliderOrientationListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simSlider = (DialogSceneComposerModel.SimSlider) 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(simSlider.vertical ? 1 : 0);
            popTable.add(draggableTextList);
            draggableTextList.addListener(handListener);
            draggableTextList.addListener(new TextTooltip("The orientation of the Slider.", tooltipManager, skin, "scene"));
            draggableTextList.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.sliderVertical(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 68 with PopTableClickListener

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

the class StackListeners method stackNameListener.

public static EventListener stackNameListener(final DialogSceneComposer dialogSceneComposer) {
    var simStack = (SimStack) 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(simStack.name);
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The name of the Stack 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.stackName(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 : SimStack(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimStack) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) TextTooltip(com.badlogic.gdx.scenes.scene2d.ui.TextTooltip) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 69 with PopTableClickListener

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

the class TextAreaListeners method textAreaNameListener.

public static EventListener textAreaNameListener(final DialogSceneComposer dialogSceneComposer) {
    var simTextArea = (DialogSceneComposerModel.SimTextArea) dialogSceneComposer.simActor;
    var textField = new TextField("", skin, "scene");
    var popTableClickListener = new PopTableClickListener(skin) {

        @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(simTextArea.name);
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The name of the TextArea 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.textAreaName(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 70 with PopTableClickListener

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

the class TextAreaListeners method textAreaPreferredRowsListener.

public static EventListener textAreaPreferredRowsListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simTextArea = (DialogSceneComposerModel.SimTextArea) 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("Preferred Rows:", skin, "scene-label-colored");
            table.add(label).right();
            var valueSpinner = new Spinner(simTextArea.preferredRows, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            valueSpinner.setMinimum(1);
            table.add(valueSpinner).width(100).left();
            valueSpinner.getTextField().addListener(ibeamListener);
            valueSpinner.getButtonMinus().addListener(handListener);
            valueSpinner.getButtonPlus().addListener(handListener);
            valueSpinner.addListener(new TextTooltip("The number of lines of text to help determine preferred height.", tooltipManager, skin, "scene"));
            valueSpinner.addListener(new ChangeListener() {

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

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