Search in sources :

Example 96 with PopTableClickListener

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

the class CellListeners method cellSizeListener.

public static EventListener cellSizeListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simCell = (DialogSceneComposerModel.SimCell) 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 changeListener = new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    Spinner minimumWidth = popTable.findActor("minimum-width");
                    Spinner minimumHeight = popTable.findActor("minimum-height");
                    Spinner maximumWidth = popTable.findActor("maximum-width");
                    Spinner maximumHeight = popTable.findActor("maximum-height");
                    Spinner preferredWidth = popTable.findActor("preferred-width");
                    Spinner preferredHeight = popTable.findActor("preferred-height");
                    Button link = popTable.findActor("link");
                    if (!link.isChecked()) {
                        events.cellSize((float) minimumWidth.getValue(), (float) minimumHeight.getValue(), (float) maximumWidth.getValue(), (float) maximumHeight.getValue(), (float) preferredWidth.getValue(), (float) preferredHeight.getValue());
                    } else if (actor != link) {
                        var val = 0.0f;
                        if (actor == minimumWidth)
                            val = (float) minimumWidth.getValue();
                        else if (actor == minimumHeight)
                            val = (float) minimumHeight.getValue();
                        else if (actor == maximumWidth)
                            val = (float) maximumWidth.getValue();
                        else if (actor == maximumHeight)
                            val = (float) maximumHeight.getValue();
                        else if (actor == preferredWidth)
                            val = (float) preferredWidth.getValue();
                        else if (actor == preferredHeight)
                            val = (float) preferredHeight.getValue();
                        events.cellSize(val, val, val, val, val, val);
                        minimumWidth.setValue(val);
                        minimumHeight.setValue(val);
                        maximumWidth.setValue(val);
                        maximumHeight.setValue(val);
                        preferredWidth.setValue(val);
                        preferredHeight.setValue(val);
                    }
                }
            };
            var label = new Label("Set to negative to disable", skin, "scene-label-colored");
            popTable.add(label).colspan(5);
            popTable.row();
            var table = new Table();
            popTable.add(table);
            label = new Label("Minimum:", skin, "scene-label-colored");
            table.add(label).colspan(2);
            table.row();
            table.defaults().right().spaceRight(5);
            label = new Label("Width:", skin, "scene-label-colored");
            table.add(label);
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("minimum-width");
            spinner.setValue(simCell.minWidth);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The minimum width of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            table.row();
            label = new Label("Height:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("minimum-height");
            spinner.setValue(simCell.minHeight);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The minimum height of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            var image = new Image(skin, "scene-menu-divider");
            popTable.add(image).space(10).growY();
            table = new Table();
            popTable.add(table);
            label = new Label("Maximum:", skin, "scene-label-colored");
            table.add(label).colspan(2);
            table.row();
            table.defaults().right().spaceRight(5);
            label = new Label("Width:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("maximum-width");
            spinner.setValue(simCell.maxWidth);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The maximum width of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            table.row();
            label = new Label("Height:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("maximum-height");
            spinner.setValue(simCell.maxHeight);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The maximum height of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            image = new Image(skin, "scene-menu-divider");
            popTable.add(image).space(10).growY();
            table = new Table();
            popTable.add(table);
            label = new Label("Preferred:", skin, "scene-label-colored");
            table.add(label).colspan(2);
            table.row();
            table.defaults().right().spaceRight(5);
            label = new Label("Width:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("preferred-width");
            spinner.setValue(simCell.preferredWidth);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The preferred width of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            table.row();
            label = new Label("Height:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("preferred-height");
            spinner.setValue(simCell.preferredHeight);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The preferred height of the contents of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(changeListener);
            popTable.row();
            var button = new Button(skin, "scene-link");
            button.setName("link");
            popTable.add(button).colspan(5).right();
            button.addListener(Main.handListener);
            button.addListener(changeListener);
            button.addListener(new TextTooltip("Click to modify all values at once.", tooltipManager, skin, "scene"));
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : SimTable(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable) Spinner(com.ray3k.stripe.Spinner) 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 97 with PopTableClickListener

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

the class CellListeners method cellExpandFillGrowListener.

public static EventListener cellExpandFillGrowListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simCell = (DialogSceneComposerModel.SimCell) 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 expandX = new ImageTextButton("Expand X", skin, "scene-checkbox-colored");
            var expandY = new ImageTextButton("Expand Y", skin, "scene-checkbox-colored");
            var fillX = new ImageTextButton("Fill X", skin, "scene-checkbox-colored");
            var fillY = new ImageTextButton("Fill Y", skin, "scene-checkbox-colored");
            var growX = new ImageTextButton("Grow X", skin, "scene-checkbox-colored");
            var growY = new ImageTextButton("Grow Y", skin, "scene-checkbox-colored");
            var changeListener = new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellExpandFillGrow(expandX.isChecked(), expandY.isChecked(), fillX.isChecked(), fillY.isChecked(), growX.isChecked(), growY.isChecked());
                }
            };
            var table = new Table();
            popTable.add(table);
            table.defaults().left().spaceRight(5);
            expandX.setChecked(simCell.expandX);
            expandX.setProgrammaticChangeEvents(false);
            table.add(expandX);
            expandX.addListener(handListener);
            expandX.addListener(new TextTooltip("Expands the width of the cell to the available space.", tooltipManager, skin, "scene"));
            expandX.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    if (expandX.isChecked() && fillX.isChecked()) {
                        growX.setChecked(true);
                    } else {
                        growX.setChecked(false);
                    }
                }
            });
            expandX.addListener(changeListener);
            expandY.setChecked(simCell.expandY);
            expandY.setProgrammaticChangeEvents(false);
            table.add(expandY);
            expandY.addListener(handListener);
            expandY.addListener(new TextTooltip("Expands the height of the cell to the available space.", tooltipManager, skin, "scene"));
            expandY.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    if (expandY.isChecked() && fillY.isChecked()) {
                        growY.setChecked(true);
                    } else {
                        growY.setChecked(false);
                    }
                }
            });
            expandY.addListener(changeListener);
            table.row();
            fillX.setChecked(simCell.fillX);
            fillX.setProgrammaticChangeEvents(false);
            table.add(fillX);
            fillX.addListener(handListener);
            fillX.addListener(new TextTooltip("Stretches the contents to fill the width of the cell.", tooltipManager, skin, "scene"));
            fillX.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    if (expandX.isChecked() && fillX.isChecked()) {
                        growX.setChecked(true);
                    } else {
                        growX.setChecked(false);
                    }
                }
            });
            fillX.addListener(changeListener);
            fillY.setChecked(simCell.fillY);
            fillY.setProgrammaticChangeEvents(false);
            table.add(fillY);
            fillY.addListener(handListener);
            fillY.addListener(new TextTooltip("Stretches the contents to fill the height of the cell.", tooltipManager, skin, "scene"));
            fillY.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    if (expandY.isChecked() && fillY.isChecked()) {
                        growY.setChecked(true);
                    } else {
                        growY.setChecked(false);
                    }
                }
            });
            fillY.addListener(changeListener);
            table.row();
            growX.setChecked(simCell.growX);
            growX.setProgrammaticChangeEvents(false);
            table.add(growX);
            growX.addListener(handListener);
            growX.addListener(new TextTooltip("Sets the cell to expand and fill across the available width.", tooltipManager, skin, "scene"));
            growX.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    expandX.setChecked(growX.isChecked());
                    fillX.setChecked(growX.isChecked());
                }
            });
            growX.addListener(changeListener);
            growY.setChecked(simCell.growY);
            growY.setProgrammaticChangeEvents(false);
            table.add(growY);
            growY.addListener(handListener);
            growY.addListener(new TextTooltip("Sets the cell to expand and fill across the available height.", tooltipManager, skin, "scene"));
            growY.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    expandY.setChecked(growY.isChecked());
                    fillY.setChecked(growY.isChecked());
                }
            });
            growY.addListener(changeListener);
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : SimTable(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimTable) 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 98 with PopTableClickListener

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

the class ContainerListeners method containerNameListener.

public static EventListener containerNameListener(final DialogSceneComposer dialogSceneComposer) {
    var simContainer = (DialogSceneComposerModel.SimContainer) 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(simContainer.name);
            popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
            textField.addListener(ibeamListener);
            textField.addListener(new TextTooltip("The name of the Container 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.containerName(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 : 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)

Example 99 with PopTableClickListener

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

Example 100 with PopTableClickListener

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

the class SelectBoxListeners method selectBoxDisabledListener.

public static EventListener selectBoxDisabledListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simSelectBox = (DialogSceneComposerModel.SimSelectBox) 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(simSelectBox.disabled ? "TRUE" : "FALSE", skin, "scene-small");
            textButton.setChecked(simSelectBox.disabled);
            popTable.add(textButton).minWidth(100);
            textButton.addListener(handListener);
            textButton.addListener(new TextTooltip("Whether the SelectBox 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.selectBoxDisabled(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

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