Search in sources :

Example 1 with SimActor

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

the class HorizontalGroupListeners method horizontalGroupAlignmentListener.

public static EventListener horizontalGroupAlignmentListener(final DialogSceneComposerEvents events, final SimActor 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 simHorizontalGroup = (DialogSceneComposerModel.SimHorizontalGroup) simActor;
            var popTable = getPopTable();
            popTable.clearChildren();
            var table = new Table();
            popTable.add(table);
            var label = new Label("Alignment:", skin, "scene-label-colored");
            table.add(label).colspan(3);
            table.row();
            table.defaults().space(10).left().uniformX();
            var buttonGroup = new ButtonGroup<ImageTextButton>();
            var imageTextButton = new ImageTextButton("Top-Left", skin, "scene-checkbox-colored");
            var topLeft = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the top left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupAlignment(Align.topLeft);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Top", skin, "scene-checkbox-colored");
            var top = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the top center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupAlignment(Align.top);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Top-Right", skin, "scene-checkbox-colored");
            var topRight = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the top right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupAlignment(Align.topRight);
                }
            });
            buttonGroup.add(imageTextButton);
            table.row();
            imageTextButton = new ImageTextButton("Left", skin, "scene-checkbox-colored");
            var left = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the middle left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupAlignment(Align.left);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Center", skin, "scene-checkbox-colored");
            var center = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupAlignment(Align.center);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Right", skin, "scene-checkbox-colored");
            var right = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the middle right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupAlignment(Align.right);
                }
            });
            buttonGroup.add(imageTextButton);
            table.row();
            imageTextButton = new ImageTextButton("Bottom-Left", skin, "scene-checkbox-colored");
            var bottomLeft = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the bottom left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupAlignment(Align.bottomLeft);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Bottom", skin, "scene-checkbox-colored");
            var bottom = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the bottom center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupAlignment(Align.bottom);
                }
            });
            buttonGroup.add(imageTextButton);
            imageTextButton = new ImageTextButton("Bottom-Right", skin, "scene-checkbox-colored");
            var bottomRight = imageTextButton;
            imageTextButton.setProgrammaticChangeEvents(false);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Align the widgets to the bottom right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupAlignment(Align.bottomRight);
                }
            });
            buttonGroup.add(imageTextButton);
            switch(simHorizontalGroup.alignment) {
                case Align.topLeft:
                    topLeft.setChecked(true);
                    break;
                case Align.top:
                    top.setChecked(true);
                    break;
                case Align.topRight:
                    topRight.setChecked(true);
                    break;
                case Align.right:
                    right.setChecked(true);
                    break;
                case Align.bottomRight:
                    bottomRight.setChecked(true);
                    break;
                case Align.bottom:
                    bottom.setChecked(true);
                    break;
                case Align.bottomLeft:
                    bottomLeft.setChecked(true);
                    break;
                case Align.left:
                    left.setChecked(true);
                    break;
                case Align.center:
                    center.setChecked(true);
                    break;
            }
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) 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 2 with SimActor

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

the class HorizontalGroupListeners method horizontalGroupPaddingSpacingListener.

public static EventListener horizontalGroupPaddingSpacingListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simHorizontalGroup = (DialogSceneComposerModel.SimHorizontalGroup) 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(simHorizontalGroup.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.horizontalGroupPadLeft(((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(simHorizontalGroup.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.horizontalGroupPadRight(((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(simHorizontalGroup.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.horizontalGroupPadTop(((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(simHorizontalGroup.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.horizontalGroupPadBottom(((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(simHorizontalGroup.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.horizontalGroupSpace(((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)

Example 3 with SimActor

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

the class HorizontalGroupListeners method horizontalGroupWrapListener.

public static EventListener horizontalGroupWrapListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simHorizontalGroup = (DialogSceneComposerModel.SimHorizontalGroup) 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);
            table.defaults().left().spaceRight(5);
            var imageTextButton = new ImageTextButton("Wrap", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simHorizontalGroup.wrap);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Whether the widgets will wrap to the next line.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupWrap(imageTextButton.isChecked());
                }
            });
            table.row();
            var label = new Label("Wrap Space:", skin, "scene-label-colored");
            table.add(label);
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simHorizontalGroup.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 vertical space between rows when wrap is enabled.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

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

Example 4 with SimActor

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

the class HorizontalGroupListeners method horizontalGroupReverseListener.

public static EventListener horizontalGroupReverseListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simHorizontalGroup = (DialogSceneComposerModel.SimHorizontalGroup) 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);
            table.defaults().left().spaceRight(5);
            var imageTextButton = new ImageTextButton("Reverse", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simHorizontalGroup.reverse);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Reverse the display order of the widgets.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.horizontalGroupReverse(imageTextButton.isChecked());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) 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 5 with SimActor

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

the class ImageButtonListeners method imageButtonColorListener.

public static EventListener imageButtonColorListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simImageButton = (DialogSceneComposerModel.SimImageButton) 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("Color:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var imageButton = new ImageButton(skin, "scene-color");
            imageButton.getImage().setColor(simImageButton.color == null ? Color.WHITE : simImageButton.color.color);
            popTable.add(imageButton).minWidth(100);
            imageButton.addListener(handListener);
            imageButton.addListener(new TextTooltip("Select the color of the button.", tooltipManager, skin, "scene"));
            imageButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    popTable.hide();
                    dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
                        if (!pressedCancel) {
                            events.imageButtonColor(colorData);
                        }
                    }, new DialogListener() {

                        @Override
                        public void opened() {
                        }

                        @Override
                        public void closed() {
                        }
                    });
                }
            });
            popTable.row();
            label = new Label(simImageButton.color == null ? "white" : simImageButton.color.getName(), skin, "scene-label-colored");
            popTable.add(label);
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) com.badlogic.gdx.scenes.scene2d.ui(com.badlogic.gdx.scenes.scene2d.ui) DialogSceneComposer(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposer) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) TEXT_FIELD_WIDTH(com.ray3k.skincomposer.dialog.scenecomposer.menulisteners.ListenersUtils.TEXT_FIELD_WIDTH) Spinner(com.ray3k.stripe.Spinner) Color(com.badlogic.gdx.graphics.Color) Actor(com.badlogic.gdx.scenes.scene2d.Actor) DialogSceneComposerEvents(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerEvents) DialogSceneComposerModel(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) Keys(com.badlogic.gdx.Input.Keys) Main(com.ray3k.skincomposer.Main) Input(com.badlogic.gdx.Input) StyleData(com.ray3k.skincomposer.data.StyleData) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) EventListener(com.badlogic.gdx.scenes.scene2d.EventListener) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) 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