Search in sources :

Example 81 with SimActor

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

the class VerticalGroupListeners method verticalGroupPaddingSpacingListener.

public static EventListener verticalGroupPaddingSpacingListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simVerticalGroup = (DialogSceneComposerModel.SimVerticalGroup) 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("Padding:", skin, "scene-label-colored");
            table.add(label).colspan(2);
            table.row();
            table.defaults().right().spaceRight(5);
            label = new Label("Left:", skin, "scene-label-colored");
            table.add(label);
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simVerticalGroup.padLeft);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The padding to the left of the widgets.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupPadLeft(((Spinner) actor).getValueAsInt());
                }
            });
            table.row();
            label = new Label("Right:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simVerticalGroup.padRight);
            spinner.setName("padding-right");
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The padding to the right of the widgets.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupPadRight(((Spinner) actor).getValueAsInt());
                }
            });
            table.row();
            label = new Label("Top:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simVerticalGroup.padTop);
            spinner.setName("padding-top");
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The padding to the top of the widgets.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupPadTop(((Spinner) actor).getValueAsInt());
                }
            });
            table.row();
            label = new Label("Bottom:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simVerticalGroup.padBottom);
            spinner.setName("padding-bottom");
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The padding to the bottom of the widgets.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupPadBottom(((Spinner) actor).getValueAsInt());
                }
            });
            var image = new Image(skin, "scene-menu-divider");
            popTable.add(image).space(10).growY();
            table = new Table();
            popTable.add(table);
            table.defaults().right().spaceRight(5);
            label = new Label("Spacing:", skin, "scene-label-colored");
            table.add(label);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simVerticalGroup.space);
            spinner.setName("spacing-left");
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The spacing between the widgets.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.verticalGroupSpace(((Spinner) actor).getValueAsInt());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) 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)

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