Search in sources :

Example 36 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.

the class CellListeners method cellColSpanListener.

public static EventListener cellColSpanListener(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 table = new Table();
            popTable.add(table);
            var label = new Label("Column Span:", skin, "scene-label-colored");
            table.add(label).colspan(2);
            table.row();
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setValue(simCell.colSpan);
            spinner.setMinimum(1);
            table.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The column span of the cell.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.cellColSpan(spinner.getValueAsInt());
                }
            });
        }
    };
    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 37 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent 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 38 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent 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 39 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent 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 40 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent 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)

Aggregations

InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)358 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)183 Actor (com.badlogic.gdx.scenes.scene2d.Actor)174 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)144 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)110 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)109 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)86 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)53 Stage (com.badlogic.gdx.scenes.scene2d.Stage)49 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)47 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)45 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)35 Texture (com.badlogic.gdx.graphics.Texture)34 Spinner (com.ray3k.stripe.Spinner)32 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)31 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)29 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)26 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)25 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)25 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)22