Search in sources :

Example 11 with SimActor

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

the class ScrollPaneListeners method scrollPaneKnobsListener.

public static EventListener scrollPaneKnobsListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simScrollPane = (DialogSceneComposerModel.SimScrollPane) 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();
            popTable.pad(10);
            var table = new Table();
            popTable.add(table).space(5).left();
            table.defaults().left().expandX();
            var imageTextButton = new ImageTextButton("Variable Size Knobs", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.variableSizeKnobs);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Scroll knobs are sized based on getMaxX() or getMaxY()", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneVariableSizeKnobs(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Fade Scroll Bars", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.fadeScrollBars);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Scrollbars don't reduce the scrollable size and fade out if not used.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneFadeScrollBars(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("ScrollBarsVisible", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.scrollBarsVisible);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Shows or hides the scrollbars when Fade Scroll Bars is activated.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneScrollBarsVisible(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Scroll Bar Touch", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.scrollBarsOnTop);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Set whether scrollbars respond to mouse clicks.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneScrollBarTouch(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Scroll Bars On Top", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.scrollBarsOnTop);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Scrollbars don't reduce the scrollable size and fade out if not used.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneScrollBarsOnTop(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Force Horizontal Scroll", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.forceScrollX);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Forces the horizontal scroll bar to be enabled.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneForceScrollX(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Force Vertical Scroll", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.forceScrollY);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Forces the vertical scroll bar to be enabled.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneForceScrollY(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Horizontal Scrolling Disabled", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.scrollingDisabledX);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Horizontal Scrolling is disabled.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneScrollingDisabledX(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Vertical Scrolling Disabled", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.scrollingDisabledY);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Vertical scrolling is disabled.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneScrollingDisabledY(((ImageTextButton) actor).isChecked());
                }
            });
            popTable.row();
            table = new Table();
            popTable.add(table);
            table.defaults().space(5).fillX();
            var label = new Label("Horizontal Scroll Position: ", skin, "scene-label-colored");
            table.add(label);
            var selectBox = new SelectBox<String>(skin, "scene");
            selectBox.setItems("Top", "Bottom");
            selectBox.setSelectedIndex(simScrollPane.scrollBarBottom ? 1 : 0);
            table.add(selectBox);
            selectBox.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneScrollBarBottom(((SelectBox) actor).getSelectedIndex() == 1);
                }
            });
            table.row();
            label = new Label("Vertical Scroll Position: ", skin, "scene-label-colored");
            table.add(label);
            selectBox = new SelectBox<>(skin, "scene");
            selectBox.setItems("Left", "Right");
            selectBox.setSelectedIndex(simScrollPane.scrollBarRight ? 1 : 0);
            table.add(selectBox);
            selectBox.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneScrollBarRight(((SelectBox) actor).getSelectedIndex() == 1);
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) 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 12 with SimActor

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

the class ScrollPaneListeners method scrollPaneScrollListener.

public static EventListener scrollPaneScrollListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simScrollPane = (DialogSceneComposerModel.SimScrollPane) 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("Clamp", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.clamp);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Prevents scrolling out of the widget's bounds when using flick Scroll.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneClamp(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Flick Scroll", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.flickScroll);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Allow users to scroll by flicking the contents of the ScrollPanel", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneFlickScroll(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            var subTable = new Table();
            table.add(subTable);
            var label = new Label("Fling Time:", skin, "scene-label-colored");
            subTable.add(label).space(5);
            var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("pad-left");
            spinner.setValue(simScrollPane.flingTime);
            subTable.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The amount of time in seconds that a fling will continue to scroll.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneFlingTime((float) ((Spinner) actor).getValue());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Overscroll X", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.overScrollX);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("The widget can be scrolled passed the bounds horizontally and will snap back into place if flick scroll is enabled.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneOverScrollX(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Overscroll Y", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.overScrollY);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("The widget can be scrolled passed the bounds vertically and will snap back into place if flick scroll is enabled.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneOverScrollY(((ImageTextButton) actor).isChecked());
                }
            });
            table.row();
            subTable = new Table();
            table.add(subTable);
            label = new Label("Overscroll Distance:", skin, "scene-label-colored");
            subTable.add(label).spaceRight(5);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("pad-left");
            spinner.setValue(simScrollPane.overScrollDistance);
            subTable.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The distance in pixels that the user is allowed to scroll beyond the bounds if overscroll is enabled.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneOverScrollDistance((float) ((Spinner) actor).getValue());
                }
            });
            subTable.row();
            label = new Label("Overscroll Speed Min:", skin, "scene-label-colored");
            subTable.add(label).spaceRight(5);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("pad-left");
            spinner.setValue(simScrollPane.overScrollSpeedMin);
            subTable.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The minimum speed that scroll returns to the widget bounds when overscroll is enabled.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneOverScrollSpeedMin((float) ((Spinner) actor).getValue());
                }
            });
            subTable.row();
            label = new Label("Overscroll Speed Max:", skin, "scene-label-colored");
            subTable.add(label).spaceRight(5);
            spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            spinner.setName("pad-left");
            spinner.setValue(simScrollPane.overScrollSpeedMax);
            subTable.add(spinner);
            spinner.getTextField().addListener(ibeamListener);
            spinner.getButtonMinus().addListener(handListener);
            spinner.getButtonPlus().addListener(handListener);
            spinner.addListener(new TextTooltip("The maximum speed that scroll returns to the widget bounds when overscroll is enabled.", tooltipManager, skin, "scene"));
            spinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneOverScrollSpeedMax((float) ((Spinner) actor).getValue());
                }
            });
            table.row();
            imageTextButton = new ImageTextButton("Smooth Scrolling", skin, "scene-checkbox-colored");
            imageTextButton.setChecked(simScrollPane.smoothScrolling);
            table.add(imageTextButton);
            imageTextButton.addListener(handListener);
            imageTextButton.addListener(new TextTooltip("Scrolling is interpolated instead of jumping to position immediately.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.scrollPaneSmoothScrolling(((ImageTextButton) actor).isChecked());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) 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 13 with SimActor

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

the class SliderListeners method sliderValueSettingsListener.

public static EventListener sliderValueSettingsListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simSlider = (DialogSceneComposerModel.SimSlider) 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("Value:", skin, "scene-label-colored");
            table.add(label);
            var valueSpinner = new Spinner(simSlider.value, simSlider.increment, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            valueSpinner.setMinimum(simSlider.minimum);
            valueSpinner.setMaximum(simSlider.maximum);
            table.add(valueSpinner).width(100).uniformX();
            valueSpinner.getTextField().addListener(ibeamListener);
            valueSpinner.getButtonMinus().addListener(handListener);
            valueSpinner.getButtonPlus().addListener(handListener);
            valueSpinner.addListener(new TextTooltip("The value of the Slider.", tooltipManager, skin, "scene"));
            valueSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.sliderValue((float) valueSpinner.getValue());
                }
            });
            table.row();
            label = new Label("Minimum:", skin, "scene-label-colored");
            table.add(label);
            var minimumSpinner = new Spinner(simSlider.minimum, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            minimumSpinner.setMaximum(simSlider.maximum);
            var maximumSpinner = new Spinner(simSlider.maximum, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            maximumSpinner.setMinimum(simSlider.minimum);
            table.add(minimumSpinner).uniformX().fillX();
            minimumSpinner.getTextField().addListener(ibeamListener);
            minimumSpinner.getButtonMinus().addListener(handListener);
            minimumSpinner.getButtonPlus().addListener(handListener);
            minimumSpinner.addListener(new TextTooltip("The minimum value of the Slider.", tooltipManager, skin, "scene"));
            minimumSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.sliderMinimum((float) minimumSpinner.getValue());
                    if (valueSpinner.getValue() < minimumSpinner.getValue()) {
                        valueSpinner.setValue(simSlider.minimum);
                    }
                    maximumSpinner.setMinimum(simSlider.minimum);
                }
            });
            table.row();
            label = new Label("Maximum:", skin, "scene-label-colored");
            table.add(label);
            maximumSpinner.setValue(simSlider.maximum);
            table.add(maximumSpinner).uniformX().fillX();
            maximumSpinner.getTextField().addListener(ibeamListener);
            maximumSpinner.getButtonMinus().addListener(handListener);
            maximumSpinner.getButtonPlus().addListener(handListener);
            maximumSpinner.addListener(new TextTooltip("The maximum value of the Slider.", tooltipManager, skin, "scene"));
            maximumSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.sliderMaximum((float) maximumSpinner.getValue());
                    if (valueSpinner.getValue() > maximumSpinner.getValue()) {
                        valueSpinner.setValue(simSlider.maximum);
                    }
                    minimumSpinner.setMaximum(simSlider.maximum);
                }
            });
            table.row();
            label = new Label("Increment:", skin, "scene-label-colored");
            table.add(label);
            var incrementSpinner = new Spinner(0, 1, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
            incrementSpinner.setValue(simSlider.increment);
            incrementSpinner.setMinimum(.0000000001);
            table.add(incrementSpinner).uniformX().fillX();
            incrementSpinner.getTextField().addListener(ibeamListener);
            incrementSpinner.getButtonMinus().addListener(handListener);
            incrementSpinner.getButtonPlus().addListener(handListener);
            incrementSpinner.addListener(new TextTooltip("The increment value of the Slider.", tooltipManager, skin, "scene"));
            incrementSpinner.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.sliderIncrement((float) incrementSpinner.getValue());
                }
            });
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) 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 14 with SimActor

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

the class SliderListeners method sliderRoundListener.

public static EventListener sliderRoundListener(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("Round:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var textButton = new TextButton(simSlider.round ? "TRUE" : "FALSE", skin, "scene-small");
            textButton.setChecked(simSlider.round);
            popTable.add(textButton).minWidth(100);
            textButton.addListener(handListener);
            textButton.addListener(new TextTooltip("Whether the Slider inner positions are rounded to integer.", tooltipManager, skin, "scene"));
            textButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
                    events.sliderRound(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)

Example 15 with SimActor

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

the class TextAreaListeners method textAreaAlignmentListener.

public static EventListener textAreaAlignmentListener(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 simTextArea = (DialogSceneComposerModel.SimTextArea) 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 contents of the TextArea to the top left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(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 contents of the TextArea to the top center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(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 contents of the TextArea to the top right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(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 contents of the TextArea to the middle left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(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 contents of the TextArea to the center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(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 contents of the TextArea to the middle right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(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 contents of the TextArea to the bottom left.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(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 contents of the TextArea to the bottom center.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(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 contents of the TextArea to the bottom right.", tooltipManager, skin, "scene"));
            imageTextButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    events.textAreaAlignment(Align.bottomRight);
                }
            });
            buttonGroup.add(imageTextButton);
            switch(simTextArea.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 : StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) ValueEndChangeEvent(com.ray3k.stripe.RangeSlider.ValueEndChangeEvent) ValueBeginChangeEvent(com.ray3k.stripe.RangeSlider.ValueBeginChangeEvent) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ValueEndChangeListener(com.ray3k.stripe.RangeSlider.ValueEndChangeListener) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) ValueBeginChangeListener(com.ray3k.stripe.RangeSlider.ValueBeginChangeListener) 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