Search in sources :

Example 1 with DraggableTextList

use of com.ray3k.stripe.DraggableTextList 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 2 with DraggableTextList

use of com.ray3k.stripe.DraggableTextList 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 3 with DraggableTextList

use of com.ray3k.stripe.DraggableTextList 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 4 with DraggableTextList

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

the class SelectBoxListeners method selectBoxTextListListener.

public static EventListener selectBoxTextListListener(final DialogSceneComposer dialogSceneComposer) {
    var simSelectBox = (DialogSceneComposerModel.SimSelectBox) dialogSceneComposer.simActor;
    var textField = new TextField("", skin, "scene");
    textField.setFocusTraversal(false);
    var draggableTextList = new DraggableTextList(true, skin, "scene");
    draggableTextList.addListener(new ChangeListener() {

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

        {
            popTable.setAutomaticallyResized(true);
            popTable.key(Keys.ESCAPE, popTable::hide);
            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:\nDrag to change order\nClick the default option", skin, "scene-label-colored");
            label.setAlignment(Align.center);
            popTable.add(label).colspan(2);
            popTable.row();
            draggableTextList.clearChildren();
            draggableTextList.addAllTexts(simSelectBox.list);
            if (draggableTextList.getTexts().size > 0) {
                draggableTextList.setSelected(simSelectBox.selected);
            }
            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.selectBoxList(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)

Aggregations

Actor (com.badlogic.gdx.scenes.scene2d.Actor)4 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)4 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)4 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)4 DraggableTextList (com.ray3k.stripe.DraggableTextList)4 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)4 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)2