Search in sources :

Example 1 with PopTable

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

the class GeneralListeners method interpolationListener.

public static PopTableClickListener interpolationListener(final DialogSceneComposer dialogSceneComposer, InterpolationSelected interpolationSelected) {
    var graphDrawerDrawables = new Array<GraphDrawerDrawable>();
    var table = new Table();
    var scrollPane = new ScrollPane(table, skin, "scene");
    var listener = new PopTableClickListener(skin) {

        {
            getPopTable().key(Keys.ESCAPE, popTable::hide);
        }

        @Override
        public void tableShown(Event event) {
            dialogSceneComposer.getStage().setScrollFocus(scrollPane);
            for (var graphDrawerDrawable : graphDrawerDrawables) {
                graphDrawerDrawable.setColor(Color.BLACK);
            }
        }

        @Override
        public void tableHidden(Event event) {
            for (var graphDrawerDrawable : graphDrawerDrawables) {
                graphDrawerDrawable.setColor(Color.CLEAR);
            }
        }
    };
    var popTable = listener.getPopTable();
    scrollPane.setFadeScrollBars(false);
    popTable.add(scrollPane);
    table.defaults().space(5);
    for (Interpol interpol : Interpol.values()) {
        var button = new Button(skin, "scene-med");
        table.add(button).growX();
        var stack = new Stack();
        button.add(stack).size(50);
        var image = new Image(skin.getDrawable("white"));
        stack.add(image);
        var graphDrawerDrawable = new GraphDrawerDrawable(graphDrawer);
        graphDrawerDrawable.setColor(Color.BLACK);
        graphDrawerDrawable.setInterpolation(interpol.interpolation);
        graphDrawerDrawable.setSamples(10);
        graphDrawerDrawables.add(graphDrawerDrawable);
        image = new Image(graphDrawerDrawable);
        var container = new Container(image);
        container.pad(5).fill();
        stack.add(container);
        var label = new Label(interpol.toString(), skin, "scene-label");
        button.add(label).expandX().left().space(5);
        button.addListener(handListener);
        button.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                popTable.hide();
                interpolationSelected.selected(interpol);
            }
        });
        table.row();
    }
    dialogSceneComposer.getStage().setScrollFocus(scrollPane);
    return listener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) GraphDrawerDrawable(space.earlygrey.shapedrawer.scene2d.GraphDrawerDrawable) Interpol(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.Interpol) Array(com.badlogic.gdx.utils.Array) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 2 with PopTable

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

the class GeneralListeners method setWidgetListener.

public static PopTableClickListener setWidgetListener(final DialogSceneComposer dialogSceneComposer, WidgetSelectedListener widgetSelectedListener) {
    var table = new Table();
    var scrollPane = new ScrollPane(table, skin, "scene");
    var scrollFocus = scrollPane;
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollingDisabled(true, false);
    scrollPane.setFlickScroll(false);
    scrollPane.addListener(scrollFocusListener);
    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);
            var popTable = getPopTable();
            popTable.setWidth(popTable.getPrefWidth() + 50);
            popTable.validate();
            dialogSceneComposer.getStage().setScrollFocus(scrollFocus);
        }
    };
    var popTable = popTableClickListener.getPopTable();
    var label = new Label("Widgets:", skin, "scene-label-colored");
    popTable.add(label);
    label.addListener(new TextTooltip("Widgets are interactive components of your UI.", tooltipManager, skin, "scene"));
    label = new Label("Layout:", skin, "scene-label-colored");
    popTable.add(label);
    label.addListener(new TextTooltip("Layout widgets help organize the components of your UI and make it more adaptable to varying screen size.", tooltipManager, skin, "scene"));
    popTable.row();
    popTable.defaults().top();
    popTable.add(scrollPane).grow();
    var textButton = new TextButton("Button", skin, "scene-med");
    table.add(textButton);
    var valid = jsonData.classHasValidStyles(Button.class);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nButtons are the most basic component to UI design. These are clickable widgets that can perform a certain action such as starting a game or activating a power.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(Button.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("Buttons are the most basic component to UI design. These are clickable widgets that can perform a certain action such as starting a game or activating a power.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.BUTTON, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("CheckBox", skin, "scene-med");
    valid = jsonData.classHasValidStyles(CheckBox.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nCheckBoxes are great for setting/displaying boolean values for an options screen.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(CheckBox.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("CheckBoxes are great for setting/displaying boolean values for an options screen.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.CHECK_BOX, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("Image", skin, "scene-med");
    table.add(textButton);
    textButton.addListener(handListener);
    textButton.addListener(new TextTooltip("Images are not directly interactable elements of a layout, but are necessary to showcase graphics or pictures in your UI. Scaling options make them a very powerful tool.", tooltipManager, skin, "scene"));
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            widgetSelectedListener.widgetSelected(WidgetType.IMAGE, popTable);
        }
    });
    table.row();
    textButton = new TextButton("ImageButton", skin, "scene-med");
    valid = jsonData.classHasValidStyles(ImageButton.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nA Button with an image graphic in it. The image can change depending on the state of the button.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(ImageButton.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("A Button with an image graphic in it. The image can change depending on the state of the button.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.IMAGE_BUTTON, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("ImageTextButton", skin, "scene-med");
    valid = jsonData.classHasValidStyles(ImageTextButton.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nA Button with an image graphic followed by text in it. The image and text color can change depending on the state of the button.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(ImageTextButton.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("A Button with an image graphic followed by text in it. The image and text color can change depending on the state of the button.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.IMAGE_TEXT_BUTTON, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("Label", skin, "scene-med");
    valid = jsonData.classHasValidStyles(Label.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nThe most common way to display text in your layouts. Wrapping and ellipses options help mitigate sizing issues in small spaces.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(Label.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("The most common way to display text in your layouts. Wrapping and ellipses options help mitigate sizing issues in small spaces.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.LABEL, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("List", skin, "scene-med");
    valid = jsonData.classHasValidStyles(List.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nList presents text options in a clickable menu.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(List.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("List presents text options in a clickable menu.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.LIST, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("ProgressBar", skin, "scene-med");
    valid = jsonData.classHasValidStyles(ProgressBar.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nCommonly used to display loading progress or as a health/mana indicator in HUD's.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(ProgressBar.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("Commonly used to display loading progress or as a health/mana indicator in HUD's.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.PROGRESS_BAR, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("SelectBox", skin, "scene-med");
    valid = jsonData.classHasValidStyles(SelectBox.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nSelectBox is a kind of button that displays a selectable option list when opened.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(SelectBox.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("SelectBox is a kind of button that displays a selectable option list when opened.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.SELECT_BOX, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("Slider", skin, "scene-med");
    valid = jsonData.classHasValidStyles(Slider.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nSlider is a kind of user interactable ProgressBar that allows a user to select a value along a sliding scale.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(Slider.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("Slider is a kind of user interactable ProgressBar that allows a user to select a value along a sliding scale.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.SLIDER, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("TextButton", skin, "scene-med");
    valid = jsonData.classHasValidStyles(TextButton.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nA kind of button that contains a text element inside of it. The text color can change depending on the state of the button.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(TextButton.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("A kind of button that contains a text element inside of it. The text color can change depending on the state of the button.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.TEXT_BUTTON, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("TextField", skin, "scene-med");
    valid = jsonData.classHasValidStyles(TextField.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nTextFields are the primary way of getting text input from the user.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(TextField.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("TextFields are the primary way of getting text input from the user.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.TEXT_FIELD, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("TextArea", skin, "scene-med");
    valid = jsonData.classHasValidStyles(TextField.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nTextAreas are a multiline version of a TextField.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(TextArea.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("TextAreas are a multiline version of a TextField.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.TEXT_AREA, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("Touchpad", skin, "scene-med");
    valid = jsonData.classHasValidStyles(Touchpad.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nTouchpad is a UI element common to mobile games. It is used lieu of keyboard input, for example.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(Touchpad.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("Touchpad is a UI element common to mobile games. It is used lieu of keyboard input, for example.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.TOUCH_PAD, popTable);
            }
        });
    }
    table = new Table();
    scrollPane = new ScrollPane(table, skin, "scene");
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollingDisabled(true, false);
    scrollPane.setFlickScroll(false);
    popTable.add(scrollPane);
    scrollPane.addListener(scrollFocusListener);
    table.row();
    textButton = new TextButton("Container", skin, "scene-med");
    table.add(textButton);
    textButton.addListener(handListener);
    textButton.addListener(new TextTooltip("Container is like a lightweight, single cell version of Table.", tooltipManager, skin, "scene"));
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            widgetSelectedListener.widgetSelected(WidgetType.CONTAINER, popTable);
        }
    });
    table.row();
    textButton = new TextButton("HorizontalGroup", skin, "scene-med");
    table.add(textButton);
    textButton.addListener(handListener);
    textButton.addListener(new TextTooltip("Allows layout of multiple elements horizontally. It is most useful for its wrap functionality, which cannot be achieved with a Table.", tooltipManager, skin, "scene"));
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            widgetSelectedListener.widgetSelected(WidgetType.HORIZONTAL_GROUP, popTable);
        }
    });
    table.row();
    textButton = new TextButton("ScrollPane", skin, "scene-med");
    valid = jsonData.classHasValidStyles(ScrollPane.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nCreates a scrollable layout for your widgets. It is commonly used to adapt the UI to variable content and screen sizes.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(ScrollPane.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("Creates a scrollable layout for your widgets. It is commonly used to adapt the UI to variable content and screen sizes.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.SCROLL_PANE, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("Stack", skin, "scene-med");
    table.add(textButton);
    textButton.addListener(handListener);
    textButton.addListener(new TextTooltip("Allows stacking of elements on top of each other.", tooltipManager, skin, "scene"));
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            widgetSelectedListener.widgetSelected(WidgetType.STACK, popTable);
        }
    });
    table.row();
    textButton = new TextButton("SplitPane", skin, "scene-med");
    valid = jsonData.classHasValidStyles(SplitPane.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nAn organizational layout that allows the user to adjust the width or height of two widgets next to each other.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(SplitPane.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("An organizational layout that allows the user to adjust the width or height of two widgets next to each other.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.SPLIT_PANE, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("Table", skin, "scene-med");
    table.add(textButton);
    textButton.addListener(handListener);
    textButton.addListener(new TextTooltip("The most powerful layout widget available. Consisting of a series of configurable cells, it organizes elements in rows and columns. It serves as the basis of all layout design in Scene2D.UI.", tooltipManager, skin, "scene"));
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            widgetSelectedListener.widgetSelected(WidgetType.TABLE, popTable);
        }
    });
    table.row();
    textButton = new TextButton("Tree", skin, "scene-med");
    valid = jsonData.classHasValidStyles(Tree.class);
    table.add(textButton);
    textButton.addListener(handListener);
    if (!valid) {
        textButton.setStyle(skin.get("scene-med-disabled", TextButtonStyle.class));
        textButton.addListener(new TextTooltip("Missing valid style for widget. Click to open in Skin Composer.\nTree is an organizational widget that allows collapsing and expanding elements like file structures.", tooltipManager, skin, "scene"));
        textButton.addListener(rl(() -> {
            dialogSceneComposer.hide();
            popTable.hide();
            rootTable.setSelectedClass(Tree.class);
            var toast = dialogFactory.showToast(2f, skin, "dialog-no-bg");
            toast.pad(10f);
            var l = new Label("Please enter all required fields for style", skin);
            toast.add(l);
        }));
    } else {
        textButton.addListener(new TextTooltip("Tree is an organizational widget that allows collapsing and expanding elements like file structures.", tooltipManager, skin, "scene"));
        textButton.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                widgetSelectedListener.widgetSelected(WidgetType.TREE, popTable);
            }
        });
    }
    table.row();
    textButton = new TextButton("VerticalGroup", skin, "scene-med");
    table.add(textButton);
    textButton.addListener(handListener);
    textButton.addListener(new TextTooltip("Allows layout of multiple elements vertically. It is most useful for its wrap functionality, which cannot be achieved with a Table.", tooltipManager, skin, "scene"));
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            widgetSelectedListener.widgetSelected(WidgetType.VERTICAL_GROUP, popTable);
        }
    });
    return popTableClickListener;
}
Also used : SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) TextButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) PopTable(com.ray3k.stripe.PopTable) PopTableClickListener(com.ray3k.stripe.PopTableClickListener)

Example 3 with PopTable

use of com.ray3k.stripe.PopTable 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 4 with PopTable

use of com.ray3k.stripe.PopTable 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 5 with PopTable

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

Aggregations

PopTable (com.ray3k.stripe.PopTable)34 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)32 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)32 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)26 Actor (com.badlogic.gdx.scenes.scene2d.Actor)18 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)18 Spinner (com.ray3k.stripe.Spinner)10 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)7 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)6 IntPair (com.ray3k.skincomposer.utils.IntPair)6 Array (com.badlogic.gdx.utils.Array)5 DialogSceneComposerModel (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel)5 Input (com.badlogic.gdx.Input)4 Keys (com.badlogic.gdx.Input.Keys)4 FileHandle (com.badlogic.gdx.files.FileHandle)4 Color (com.badlogic.gdx.graphics.Color)4 com.badlogic.gdx.scenes.scene2d (com.badlogic.gdx.scenes.scene2d)4 com.badlogic.gdx.scenes.scene2d.ui (com.badlogic.gdx.scenes.scene2d.ui)4 Align (com.badlogic.gdx.utils.Align)4 Main (com.ray3k.skincomposer.Main)4