Search in sources :

Example 1 with HorizontalGroup

use of com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup in project libgdx by libgdx.

the class GroupTest method create.

public void create() {
    batch = new SpriteBatch();
    font = new BitmapFont();
    renderer = new ShapeRenderer();
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);
    region = new TextureRegion(new Texture(Gdx.files.internal("data/group-debug.png")));
    group2 = new TestGroup("group2");
    group2.setTransform(true);
    stage.addActor(group2);
    group1 = new TestGroup("group1");
    group1.setTransform(true);
    group2.addActor(group1);
    LabelStyle style = new LabelStyle();
    style.font = new BitmapFont();
    Texture texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    horiz = new HorizontalGroup().pad(10, 20, 30, 40).top().space(5).reverse();
    for (int i = 1; i <= 15; i++) {
        horiz.addActor(new Label(i + ",", style));
        if (i == 7)
            horiz.addActor(new Container(new Image(texture)).size(10));
    }
    horiz.addActor(new Container(new Image(texture)).fill().prefSize(30));
    horiz.debug();
    horiz.setPosition(10, 10);
    horiz.pack();
    stage.addActor(horiz);
    horizWrap = new HorizontalGroup().wrap().pad(10, 20, 30, 40).right().rowBottom().space(5).wrapSpace(15).reverse();
    for (int i = 1; i <= 15; i++) {
        horizWrap.addActor(new Label(i + ",", style));
        if (i == 7)
            horizWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
    }
    horizWrap.addActor(new Container(new Image(texture)).prefSize(30));
    horizWrap.debug();
    horizWrap.setBounds(10, 85, 150, 40);
    stage.addActor(horizWrap);
    vert = new VerticalGroup().pad(10, 20, 30, 40).top().space(5).reverse();
    for (int i = 1; i <= 8; i++) {
        vert.addActor(new Label(i + ",", style));
        if (i == 4)
            vert.addActor(new Container(new Image(texture)).size(10));
    }
    vert.addActor(new Container(new Image(texture)).size(30));
    vert.debug();
    vert.setPosition(515, 10);
    vert.pack();
    stage.addActor(vert);
    vertWrap = new VerticalGroup().wrap().pad(10, 20, 30, 40).bottom().columnRight().space(5).wrapSpace(15).reverse();
    for (int i = 1; i <= 8; i++) {
        vertWrap.addActor(new Label(i + ",", style));
        if (i == 4)
            vertWrap.addActor(new Container(new Image(texture)).prefSize(10).fill());
    }
    vertWrap.addActor(new Container(new Image(texture)).prefSize(30));
    vertWrap.debug();
    vertWrap.setBounds(610, 10, 150, 40);
    stage.addActor(vertWrap);
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) VerticalGroup(com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) Stage(com.badlogic.gdx.scenes.scene2d.Stage) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 2 with HorizontalGroup

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

the class RootTable method refreshPreview.

public void refreshPreview() {
    if (previewTable != null) {
        previewTable.clear();
        previewTable.setBackground("white");
        previewTable.setColor((Color) previewProperties.get("bgcolor"));
        for (BitmapFont font : previewFonts) {
            font.dispose();
        }
        if (classSelectBox.getSelectedIndex() >= 0 && classSelectBox.getSelectedIndex() < Main.BASIC_CLASSES.length) {
            StyleData styleData = getSelectedStyle();
            Class clazz = Main.BASIC_CLASSES[classSelectBox.getSelectedIndex()];
            if (!styleData.hasMandatoryFields()) {
                Label label;
                if (clazz.equals(SelectBox.class)) {
                    label = new Label("Please fill all mandatory fields\n(Highlighted on the left)\n\nscrollStyle and listStyle\nmust already be defined", getSkin());
                } else if (clazz.equals(TextTooltip.class)) {
                    label = new Label("Please fill all mandatory fields\n(Highlighted on the left)\n\nlabel must already be defined", getSkin());
                } else {
                    label = new Label("Please fill all mandatory fields\n(Highlighted on the left)", getSkin());
                }
                label.setAlignment(Align.center);
                previewTable.add(label);
            } else if (styleData.hasAllNullFields()) {
                Label label;
                label = new Label("All fields are empty!\nEmpty classes are not exported\nAdd style properties in the menu to the left", getSkin());
                label.setAlignment(Align.center);
                previewTable.add(label);
            } else {
                Actor widget = null;
                if (clazz.equals(Button.class)) {
                    Button.ButtonStyle style = createPreviewStyle(Button.ButtonStyle.class, styleData);
                    widget = new Button(style);
                    ((Button) widget).setDisabled((boolean) previewProperties.get("disabled"));
                    widget.addListener(main.getHandListener());
                } else if (clazz.equals(CheckBox.class)) {
                    CheckBox.CheckBoxStyle style = createPreviewStyle(CheckBox.CheckBoxStyle.class, styleData);
                    widget = new CheckBox("", style);
                    ((CheckBox) widget).setDisabled((boolean) previewProperties.get("disabled"));
                    ((CheckBox) widget).setText((String) previewProperties.get("text"));
                    widget.addListener(main.getHandListener());
                } else if (clazz.equals(ImageButton.class)) {
                    ImageButtonStyle style = createPreviewStyle(ImageButtonStyle.class, styleData);
                    widget = new ImageButton(style);
                    ((ImageButton) widget).setDisabled((boolean) previewProperties.get("disabled"));
                    widget.addListener(main.getHandListener());
                } else if (clazz.equals(ImageTextButton.class)) {
                    ImageTextButton.ImageTextButtonStyle style = createPreviewStyle(ImageTextButton.ImageTextButtonStyle.class, styleData);
                    widget = new ImageTextButton("", style);
                    ((ImageTextButton) widget).setDisabled((boolean) previewProperties.get("disabled"));
                    ((ImageTextButton) widget).setText((String) previewProperties.get("text"));
                    widget.addListener(main.getHandListener());
                } else if (clazz.equals(Label.class)) {
                    LabelStyle style = createPreviewStyle(LabelStyle.class, styleData);
                    widget = new Label("", style);
                    ((Label) widget).setText((String) previewProperties.get("text"));
                } else if (clazz.equals(List.class)) {
                    ListStyle style = createPreviewStyle(ListStyle.class, styleData);
                    widget = new List(style);
                    Array<String> items = new Array<>(((String) previewProperties.get("text")).split("\\n"));
                    ((List) widget).setItems(items);
                    widget.addListener(main.getHandListener());
                } else if (clazz.equals(ProgressBar.class)) {
                    ProgressBar.ProgressBarStyle style = createPreviewStyle(ProgressBar.ProgressBarStyle.class, styleData);
                    widget = new ProgressBar((float) (double) previewProperties.get("minimum"), (float) (double) previewProperties.get("maximum"), (float) (double) previewProperties.get("increment"), (boolean) previewProperties.get("orientation"), style);
                    ((ProgressBar) widget).setValue((float) (double) previewProperties.get("value"));
                    ((ProgressBar) widget).setDisabled((boolean) previewProperties.get("disabled"));
                } else if (clazz.equals(ScrollPane.class)) {
                    ScrollPaneStyle style = createPreviewStyle(ScrollPaneStyle.class, styleData);
                    Label label = new Label("", getSkin());
                    widget = new ScrollPane(label, style);
                    ((ScrollPane) widget).setScrollbarsOnTop((boolean) previewProperties.get("scrollbarsOnTop"));
                    ((ScrollPane) widget).setScrollBarPositions((boolean) previewProperties.get("hScrollBarPosition"), (boolean) previewProperties.get("vScrollBarPosition"));
                    ((ScrollPane) widget).setScrollingDisabled((boolean) previewProperties.get("hScrollDisabled"), (boolean) previewProperties.get("vScrollDisabled"));
                    ((ScrollPane) widget).setForceScroll((boolean) previewProperties.get("forceHscroll"), (boolean) previewProperties.get("forceVscroll"));
                    ((ScrollPane) widget).setVariableSizeKnobs((boolean) previewProperties.get("variableSizeKnobs"));
                    ((ScrollPane) widget).setOverscroll((boolean) previewProperties.get("hOverscroll"), (boolean) previewProperties.get("vOverscroll"));
                    ((ScrollPane) widget).setFadeScrollBars((boolean) previewProperties.get("fadeScroll"));
                    ((ScrollPane) widget).setSmoothScrolling((boolean) previewProperties.get("smoothScroll"));
                    ((ScrollPane) widget).setFlickScroll((boolean) previewProperties.get("flickScroll"));
                    ((ScrollPane) widget).setClamp((boolean) previewProperties.get("clamp"));
                    label.setText((String) previewProperties.get("text"));
                } else if (clazz.equals(SelectBox.class)) {
                    SelectBox.SelectBoxStyle style = createPreviewStyle(SelectBox.SelectBoxStyle.class, styleData);
                    widget = new SelectBox(style);
                    ((SelectBox) widget).setDisabled((boolean) previewProperties.get("disabled"));
                    Array<String> items = new Array<>(((String) previewProperties.get("text")).split("\\n"));
                    ((SelectBox) widget).setItems(items);
                    widget.addListener(main.getHandListener());
                    ((SelectBox) widget).getList().addListener(main.getHandListener());
                } else if (clazz.equals(Slider.class)) {
                    Slider.SliderStyle style = createPreviewStyle(Slider.SliderStyle.class, styleData);
                    widget = new Slider((float) (double) previewProperties.get("minimum"), (float) (double) previewProperties.get("maximum"), (float) (double) previewProperties.get("increment"), (boolean) previewProperties.get("orientation"), style);
                    ((Slider) widget).setDisabled((boolean) previewProperties.get("disabled"));
                    widget.addListener(main.getHandListener());
                } else if (clazz.equals(SplitPane.class)) {
                    SplitPane.SplitPaneStyle style = createPreviewStyle(SplitPane.SplitPaneStyle.class, styleData);
                    Label label1 = new Label("", getSkin());
                    Label label2 = new Label("", getSkin());
                    widget = new SplitPane(label1, label2, (boolean) previewProperties.get("orientation"), style);
                    label1.setText((String) previewProperties.get("text"));
                    label2.setText((String) previewProperties.get("text"));
                    if ((boolean) previewProperties.get("orientation")) {
                        widget.addListener(vSplitPaneDragListener);
                        widget.addListener(vSplitPaneInputListener);
                    } else {
                        widget.addListener(hSplitPaneDragListener);
                        widget.addListener(hSplitPaneInputListener);
                    }
                } else if (clazz.equals(TextButton.class)) {
                    TextButtonStyle style = createPreviewStyle(TextButtonStyle.class, styleData);
                    widget = new TextButton("", style);
                    ((TextButton) widget).setDisabled((boolean) previewProperties.get("disabled"));
                    ((TextButton) widget).setText((String) previewProperties.get("text"));
                    widget.addListener(main.getHandListener());
                } else if (clazz.equals(TextField.class)) {
                    TextFieldStyle style = createPreviewStyle(TextFieldStyle.class, styleData);
                    widget = new TextField("", style);
                    ((TextField) widget).setFocusTraversal(false);
                    ((TextField) widget).setDisabled((boolean) previewProperties.get("disabled"));
                    ((TextField) widget).setPasswordMode((boolean) previewProperties.get("passwordMode"));
                    ((TextField) widget).setAlignment((int) previewProperties.get("alignment"));
                    ((TextField) widget).setText((String) previewProperties.get("text"));
                    ((TextField) widget).setMessageText((String) previewProperties.get("message"));
                    String string = (String) previewProperties.get("password");
                    if (string.length() > 0) {
                        ((TextField) widget).setPasswordCharacter(string.charAt(0));
                    }
                    widget.addListener(main.getIbeamListener());
                } else if (clazz.equals(TextTooltip.class)) {
                    TextTooltip.TextTooltipStyle style = createPreviewStyle(TextTooltip.TextTooltipStyle.class, styleData);
                    TooltipManager manager = new TooltipManager();
                    manager.animations = false;
                    manager.initialTime = 0.0f;
                    manager.resetTime = 0.0f;
                    manager.subsequentTime = 0.0f;
                    manager.hideAll();
                    manager.instant();
                    TextTooltip toolTip = new TextTooltip((String) previewProperties.get("text"), manager, style);
                    widget = new Label("Hover over me", getSkin());
                    widget.addListener(toolTip);
                } else if (clazz.equals(Touchpad.class)) {
                    Touchpad.TouchpadStyle style = createPreviewStyle(Touchpad.TouchpadStyle.class, styleData);
                    widget = new Touchpad(0, style);
                    widget.addListener(main.getHandListener());
                } else if (clazz.equals(Tree.class)) {
                    Tree.TreeStyle style = createPreviewStyle(Tree.TreeStyle.class, styleData);
                    widget = new Tree(style);
                    String[] lines = { "this", "is", "a", "test" };
                    Tree.Node parentNode = null;
                    for (String line : lines) {
                        Label label = new Label(line, getSkin());
                        Tree.Node node = new Tree.Node(label);
                        if (parentNode == null) {
                            ((Tree) widget).add(node);
                        } else {
                            parentNode.add(node);
                        }
                        parentNode = node;
                    }
                    widget.addListener(main.getHandListener());
                } else if (clazz.equals(Window.class)) {
                    Window.WindowStyle style = createPreviewStyle(Window.WindowStyle.class, styleData);
                    if (style.stageBackground != null) {
                        previewTable.setBackground(style.stageBackground);
                        previewTable.setColor(Color.WHITE);
                        style.stageBackground = null;
                    }
                    Label sampleText = new Label("", getSkin());
                    sampleText.setText((String) previewProperties.get("text"));
                    widget = new Window((String) previewProperties.get("title"), style);
                    ((Window) widget).add(sampleText);
                }
                if (widget != null) {
                    switch((int) previewProperties.get("size")) {
                        case (0):
                            previewTable.add(widget).size(10.0f);
                            previewSizeSelectBox.setItems(DEFAULT_SIZES);
                            break;
                        case (1):
                            previewTable.add(widget);
                            previewSizeSelectBox.setItems(DEFAULT_SIZES);
                            break;
                        case (2):
                            previewTable.add(widget).size(200.0f);
                            previewSizeSelectBox.setItems(DEFAULT_SIZES);
                            break;
                        case (3):
                            previewTable.add(widget).growX();
                            previewSizeSelectBox.setItems(DEFAULT_SIZES);
                            break;
                        case (4):
                            previewTable.add(widget).growY();
                            previewSizeSelectBox.setItems(DEFAULT_SIZES);
                            break;
                        case (5):
                            previewTable.add(widget).grow();
                            previewSizeSelectBox.setItems(DEFAULT_SIZES);
                            break;
                        case (6):
                            Actor addWidget = widget;
                            TraversalTextField widthField = new TraversalTextField("", getSkin());
                            TraversalTextField heightField = new TraversalTextField("", getSkin());
                            widthField.setNextFocus(heightField);
                            heightField.setNextFocus(widthField);
                            Dialog dialog = new Dialog("Enter dimensions...", getSkin()) {

                                @Override
                                protected void result(Object object) {
                                    if ((boolean) object) {
                                        previewTable.add(addWidget).size(Integer.parseInt(widthField.getText()), Integer.parseInt(heightField.getText()));
                                        Array<String> items = new Array<>(DEFAULT_SIZES);
                                        items.add(widthField.getText() + "x" + heightField.getText());
                                        previewProperties.put("sizeX", Integer.parseInt(widthField.getText()));
                                        previewProperties.put("sizeY", Integer.parseInt(heightField.getText()));
                                        previewSizeSelectBox.setItems(items);
                                        previewSizeSelectBox.setSelectedIndex(7);
                                    } else {
                                        previewSizeSelectBox.setSelectedIndex(1);
                                    }
                                }
                            };
                            dialog.getTitleTable().getCells().first().padLeft(5.0f);
                            dialog.text("Enter the preview dimensions: ");
                            dialog.getContentTable().getCells().first().pad(10.0f);
                            dialog.getContentTable().row();
                            Table sizeTable = new Table();
                            sizeTable.add(widthField).padLeft(10.0f);
                            sizeTable.add(new Label(" x ", getSkin()));
                            sizeTable.add(heightField).padRight(10.0f);
                            dialog.getContentTable().add(sizeTable);
                            dialog.getButtonTable().defaults().padBottom(10.0f).minWidth(50.0f);
                            dialog.button("OK", true);
                            dialog.button("Cancel", false);
                            TextButton okButton = (TextButton) dialog.getButtonTable().getCells().first().getActor();
                            okButton.setDisabled(true);
                            okButton.addListener(main.getHandListener());
                            widthField.addListener(new ChangeListener() {

                                @Override
                                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                                    okButton.setDisabled(!widthField.getText().matches("^\\d+$") || !heightField.getText().matches("^\\d+$"));
                                }
                            });
                            heightField.addListener(new ChangeListener() {

                                @Override
                                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                                    okButton.setDisabled(!widthField.getText().matches("^\\d+$") || !heightField.getText().matches("^\\d+$"));
                                }
                            });
                            dialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
                            dialog.key(Input.Keys.ESCAPE, false);
                            dialog.show(stage);
                            stage.setKeyboardFocus(widthField);
                            break;
                        case (7):
                            previewTable.add(widget).size((int) previewProperties.get("sizeX"), (int) previewProperties.get("sizeY"));
                            break;
                    }
                }
            }
        } else {
            CustomStyle customStyle = (CustomStyle) styleSelectBox.getSelected();
            boolean showMessage = true;
            if (customStyle.getProperties().size == 0) {
                Label label = new Label("No style properties!\nEmpty classes are not exported\nAdd style properties in the menu to the left", getSkin());
                label.setAlignment(0);
                previewTable.add(label);
            } else {
                for (CustomProperty customProperty : customStyle.getProperties()) {
                    if (customProperty.getValue() != null && !(customProperty.getValue() instanceof String) || customProperty.getValue() != null && !((String) customProperty.getValue()).equals("")) {
                        showMessage = false;
                        break;
                    }
                }
                if (showMessage) {
                    Label label = new Label("All properties are empty!\nEmpty classes are not exported\nAdd style properties in the menu to the left", getSkin());
                    label.setAlignment(0);
                    previewTable.add(label);
                }
            }
            if (!showMessage) {
                HorizontalGroup horizontalGroup = new HorizontalGroup();
                horizontalGroup.wrap();
                // the following causes a crash. LibGDX bug.
                // horizontalGroup.space(10.0f);
                horizontalGroup.wrapSpace(10.0f);
                horizontalGroup.setTouchable(Touchable.disabled);
                previewTable.add(horizontalGroup).grow().pad(10.0f);
                for (CustomProperty customProperty : customStyle.getProperties()) {
                    if (customProperty.getValue() != null) {
                        Container container = new Container();
                        container.pad(5.0f);
                        horizontalGroup.addActor(container);
                        switch(customProperty.getType()) {
                            case TEXT:
                            case RAW_TEXT:
                                Label labelText = new Label((String) customProperty.getValue(), getSkin());
                                container.setActor(labelText);
                                break;
                            case NUMBER:
                                Label labelNumber = new Label(Double.toString((double) customProperty.getValue()), getSkin());
                                container.setActor(labelNumber);
                                break;
                            case BOOL:
                                Label labelBoolean = new Label(Boolean.toString((boolean) customProperty.getValue()), getSkin());
                                container.setActor(labelBoolean);
                                break;
                            case COLOR:
                                ColorData colorData = null;
                                String colorName = (String) customProperty.getValue();
                                for (ColorData cd : main.getJsonData().getColors()) {
                                    if (cd.getName().equals(colorName)) {
                                        colorData = cd;
                                        break;
                                    }
                                }
                                if (colorData != null) {
                                    Table colorTable = new Table(getSkin());
                                    colorTable.setBackground("white");
                                    colorTable.setColor(colorData.color);
                                    colorTable.add().size(25.0f);
                                    container.setActor(colorTable);
                                }
                                break;
                            case FONT:
                                BitmapFont font = null;
                                FontData fontData = null;
                                String fontName = (String) customProperty.getValue();
                                for (FontData fd : main.getJsonData().getFonts()) {
                                    if (fd.getName().equals(fontName)) {
                                        fontData = fd;
                                        font = new BitmapFont(fd.file);
                                        previewFonts.add(font);
                                        break;
                                    }
                                }
                                if (font != null) {
                                    Label labelFont = new Label(fontData.getName(), new LabelStyle(font, Color.WHITE));
                                    container.setActor(labelFont);
                                }
                                FreeTypeFontData freeTypeFontData = null;
                                for (FreeTypeFontData fd : main.getJsonData().getFreeTypeFonts()) {
                                    if (fd.name.equals(fontName)) {
                                        freeTypeFontData = fd;
                                        break;
                                    }
                                }
                                if (freeTypeFontData.bitmapFont != null) {
                                    Label labelFont = new Label(freeTypeFontData.name, new LabelStyle(freeTypeFontData.bitmapFont, Color.WHITE));
                                    container.setActor(labelFont);
                                }
                                break;
                            case DRAWABLE:
                                DrawableData drawable = null;
                                String drawableName = (String) customProperty.getValue();
                                for (DrawableData dd : main.getAtlasData().getDrawables()) {
                                    if (dd.name.equals(drawableName)) {
                                        drawable = dd;
                                        break;
                                    }
                                }
                                if (drawable != null) {
                                    Image image = new Image(drawablePairs.get(drawable.name));
                                    container.setActor(image);
                                }
                                break;
                        }
                    }
                }
            }
        }
    }
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) SplitPane(com.badlogic.gdx.scenes.scene2d.ui.SplitPane) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) DrawableData(com.ray3k.skincomposer.data.DrawableData) TextTooltip(com.badlogic.gdx.scenes.scene2d.ui.TextTooltip) Button(com.badlogic.gdx.scenes.scene2d.ui.Button) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Touchpad(com.badlogic.gdx.scenes.scene2d.ui.Touchpad) Dialog(com.badlogic.gdx.scenes.scene2d.ui.Dialog) Actor(com.badlogic.gdx.scenes.scene2d.Actor) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) Tree(com.badlogic.gdx.scenes.scene2d.ui.Tree) List(com.badlogic.gdx.scenes.scene2d.ui.List) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) ImageButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle) TextButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) FreeTypeFontData(com.ray3k.skincomposer.data.FreeTypeFontData) FontData(com.ray3k.skincomposer.data.FontData) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) TooltipManager(com.badlogic.gdx.scenes.scene2d.ui.TooltipManager) ScrollPaneStyle(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle) ListStyle(com.badlogic.gdx.scenes.scene2d.ui.List.ListStyle) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Slider(com.badlogic.gdx.scenes.scene2d.ui.Slider) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) TextButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle) ImageButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) ProgressBar(com.badlogic.gdx.scenes.scene2d.ui.ProgressBar) StyleData(com.ray3k.skincomposer.data.StyleData) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Window(com.badlogic.gdx.scenes.scene2d.ui.Window) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) TextFieldStyle(com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldStyle) CustomStyle(com.ray3k.skincomposer.data.CustomStyle) Array(com.badlogic.gdx.utils.Array) ColorData(com.ray3k.skincomposer.data.ColorData) FreeTypeFontData(com.ray3k.skincomposer.data.FreeTypeFontData) CustomProperty(com.ray3k.skincomposer.data.CustomProperty)

Example 3 with HorizontalGroup

use of com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup in project bladecoder-adventure-engine by bladecoder.

the class DebugScreen method show.

@Override
public void show() {
    float size = DPIUtils.getPrefButtonSize();
    float margin = DPIUtils.getMarginSize();
    stage = new Stage(new ScreenViewport());
    table = new Table(ui.getSkin());
    table.setFillParent(true);
    table.left().top();
    table.pad(margin);
    table.addListener(new InputListener() {

        @Override
        public boolean keyUp(InputEvent event, int keycode) {
            if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK)
                ui.setCurrentScreen(Screens.SCENE_SCREEN);
            return true;
        }
    });
    stage.setKeyboardFocus(table);
    Button back = new Button(ui.getSkin(), "back");
    back.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            ui.setCurrentScreen(Screens.SCENE_SCREEN);
        }
    });
    Label title = new Label("DEBUG SCREEN", ui.getSkin(), "title");
    Table header = new Table();
    header.padBottom(margin);
    Container<Button> cont = new Container<Button>(back);
    cont.size(size);
    header.add(cont);
    header.add(title).fillX().expandX().left();
    table.add(header).colspan(3).fillX().expandX().left();
    // ------------- SPEED
    speedText = new TextField(Float.toString(((SceneScreen) ui.getScreen(Screens.SCENE_SCREEN)).getSpeed()), ui.getSkin());
    TextButton speedButton = new TextButton("Set Speed", ui.getSkin());
    speedButton.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            SceneScreen scnScr = (SceneScreen) ui.getScreen(Screens.SCENE_SCREEN);
            scnScr.setSpeed(Float.parseFloat(speedText.getText()));
        }
    });
    speedButton.pad(2, 3, 2, 3);
    HorizontalGroup sGroup = new HorizontalGroup();
    sGroup.space(10);
    sGroup.addActor(speedText);
    sGroup.addActor(speedButton);
    table.row().pad(5).align(Align.left);
    table.add(new Label("Game Speed: ", ui.getSkin(), "debug"));
    table.add(sGroup);
    // ------------- RECORDING
    final Recorder r = ui.getRecorder();
    TextButton play = new TextButton(r.isPlaying() ? "Stop" : "Play", ui.getSkin());
    rec = new TextButton(r.isRecording() ? "Stop Rec" : "Rec", ui.getSkin());
    play.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            final Recorder r = ui.getRecorder();
            if (!r.isPlaying()) {
                r.setFilename(recordings.getSelected());
                r.load();
                r.setPlaying(true);
                ui.setCurrentScreen(Screens.SCENE_SCREEN);
            } else {
                r.setPlaying(false);
                ui.setCurrentScreen(Screens.SCENE_SCREEN);
            }
        }
    });
    rec.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            final Recorder r = ui.getRecorder();
            if (r.isPlaying()) {
                r.setPlaying(false);
            }
            if (!r.isRecording())
                r.setFilename(recFilename.getText());
            r.setRecording(!r.isRecording());
            rec.setText(r.isRecording() ? "Stop Rec" : "Rec");
            if (r.isRecording())
                ui.setCurrentScreen(Screens.SCENE_SCREEN);
        }
    });
    recordings = new SelectBox<String>(ui.getSkin());
    String[] testFiles = EngineAssetManager.getInstance().listAssetFiles("tests");
    ArrayList<String> al = new ArrayList<String>();
    for (String file : testFiles) if (file.endsWith(Recorder.RECORD_EXT))
        al.add(file.substring(0, file.indexOf(Recorder.RECORD_EXT)));
    FileHandle[] testFiles2 = EngineAssetManager.getInstance().getUserFolder().list();
    for (FileHandle file : testFiles2) if (file.name().endsWith(Recorder.RECORD_EXT))
        al.add(file.name().substring(0, file.name().indexOf(Recorder.RECORD_EXT)));
    recordings.setItems(al.toArray(new String[al.size()]));
    play.pad(2, 3, 2, 3);
    rec.pad(2, 3, 2, 3);
    recFilename = new TextField(r.getFileName(), ui.getSkin());
    HorizontalGroup rGroup = new HorizontalGroup();
    rGroup.space(10);
    rGroup.addActor(recordings);
    rGroup.addActor(play);
    rGroup.addActor(new Label("Rec. Filename", ui.getSkin(), "debug"));
    rGroup.addActor(recFilename);
    rGroup.addActor(rec);
    table.row().pad(5).align(Align.left);
    table.add(new Label("Game Recording: ", ui.getSkin(), "debug"));
    table.add(rGroup);
    // ------------- LOAD CHAPTER
    table.row().pad(5).align(Align.left);
    table.add(new Label("Load Chapter: ", ui.getSkin(), "debug"));
    HorizontalGroup chGroup = new HorizontalGroup();
    chGroup.space(10);
    final TextField chapter = new TextField("", ui.getSkin());
    chGroup.addActor(chapter);
    TextButton loadButton = new TextButton("Load", ui.getSkin());
    loadButton.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            String c = chapter.getText();
            if (!c.isEmpty()) {
                try {
                    World.getInstance().loadChapter(c);
                    ui.setCurrentScreen(Screens.SCENE_SCREEN);
                } catch (IOException e) {
                    EngineLogger.error("Loading chapter.", e);
                }
            }
        }
    });
    chGroup.addActor(loadButton);
    table.add(chGroup);
    // ------------- SCENES
    final TextButton testScene = new TextButton("Run Test Verb", ui.getSkin(), "toggle");
    TextButton go = new TextButton("Go", ui.getSkin());
    go.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            World.getInstance().resume();
            World.getInstance().setCutMode(false);
            if (testScene.isChecked())
                World.getInstance().setTestScene(scenes.getSelected());
            World.getInstance().setCurrentScene(scenes.getSelected());
            ui.setCurrentScreen(Screens.SCENE_SCREEN);
        }
    });
    go.pad(2, 3, 2, 3);
    scenes = new SelectBox<String>(ui.getSkin());
    scenes.setItems(World.getInstance().getScenes().keySet().toArray(new String[World.getInstance().getScenes().size()]));
    HorizontalGroup scGroup = new HorizontalGroup();
    scGroup.space(10);
    scGroup.addActor(scenes);
    scGroup.addActor(go);
    scGroup.addActor(testScene);
    table.row().pad(5).align(Align.left);
    table.add(new Label("Go to Scene: ", ui.getSkin(), "debug"));
    table.add(scGroup);
    // ------------- TESTERBOT
    final TesterBot bot = ui.getTesterBot();
    TextButton runBot = new TextButton(bot.isEnabled() ? "Stop" : "Run", ui.getSkin());
    runBot.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            final TesterBot bot = ui.getTesterBot();
            bot.setMaxWaitInverval(Float.parseFloat(testerTimeConf.getText()));
            bot.setInSceneTime(Float.parseFloat(inSceneTimeConf.getText()));
            bot.setExcludeList(testerExcludeList.getText());
            bot.setEnabled(!bot.isEnabled());
            ui.setCurrentScreen(Screens.SCENE_SCREEN);
        }
    });
    runBot.pad(2, 3, 2, 3);
    testerTimeConf = new TextField(Float.toString(bot.getMaxWaitInverval()), ui.getSkin());
    inSceneTimeConf = new TextField(Float.toString(bot.getInSceneTime()), ui.getSkin());
    testerExcludeList = new TextField(bot.getExcludeList(), ui.getSkin());
    TextButton testerLeaveConf = new TextButton("Leave", ui.getSkin(), "toggle");
    testerLeaveConf.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            final TesterBot bot = ui.getTesterBot();
            bot.setRunLeaveVerbs(!bot.isRunLeaveVerbs());
        }
    });
    testerLeaveConf.setChecked(bot.isRunLeaveVerbs());
    TextButton testerGotoConf = new TextButton("Goto", ui.getSkin(), "toggle");
    testerGotoConf.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            final TesterBot bot = ui.getTesterBot();
            bot.setRunGoto(!bot.isRunGoto());
        }
    });
    testerGotoConf.setChecked(bot.isRunGoto());
    TextButton testerPassText = new TextButton("Pass Texts", ui.getSkin(), "toggle");
    testerPassText.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            final TesterBot bot = ui.getTesterBot();
            bot.setPassTexts(!bot.isPassTexts());
        }
    });
    testerPassText.setChecked(bot.isPassTexts());
    TextButton testerWaitWhenWalking = new TextButton("Wait When Walking", ui.getSkin(), "toggle");
    testerWaitWhenWalking.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            final TesterBot bot = ui.getTesterBot();
            bot.setWaitWhenWalking(!bot.isWaitWhenWalking());
        }
    });
    testerWaitWhenWalking.setChecked(bot.isWaitWhenWalking());
    HorizontalGroup botGroup = new HorizontalGroup();
    botGroup.space(10);
    botGroup.addActor(testerLeaveConf);
    botGroup.addActor(testerGotoConf);
    botGroup.addActor(testerPassText);
    botGroup.addActor(testerWaitWhenWalking);
    HorizontalGroup botGroup2 = new HorizontalGroup();
    botGroup2.space(10);
    botGroup2.addActor(new Label("Excl. List: ", ui.getSkin(), "debug"));
    botGroup2.addActor(testerExcludeList);
    botGroup2.addActor(new Label("Interval: ", ui.getSkin(), "debug"));
    botGroup2.addActor(testerTimeConf);
    botGroup2.addActor(new Label("Scn Time: ", ui.getSkin(), "debug"));
    botGroup2.addActor(inSceneTimeConf);
    botGroup2.addActor(runBot);
    table.row().pad(5).align(Align.left);
    table.add(new Label("Tester Bot: ", ui.getSkin(), "debug"));
    table.add(botGroup);
    table.row().pad(5).align(Align.left);
    table.add();
    table.add(botGroup2);
    // ------------- VERSION LABEL NOT IN TABLE
    String versionString = Config.getProperty(Config.TITLE_PROP, "title unspecified") + " v" + Config.getProperty(Config.VERSION_PROP, "unspecified") + "\n" + "Blade Engine: v" + Config.getProperty(Config.BLADE_ENGINE_VERSION_PROP, "unspecified") + "\n" + "libGdx: v" + Config.getProperty("gdxVersion", "unspecified") + "\n" + "RoboVM: v" + Config.getProperty("roboVMVersion", "unspecified") + "\n";
    // + "Gdx.app.getVersion: " + Gdx.app.getVersion();
    Label version = new Label(versionString, ui.getSkin(), "debug");
    version.setColor(Color.LIGHT_GRAY);
    Table versionStack = new Table();
    versionStack.defaults().pad(DPIUtils.getSpacing());
    versionStack.pad(0);
    versionStack.add(version);
    versionStack.bottom().left();
    versionStack.setFillParent(true);
    versionStack.pack();
    table.row();
    table.add(versionStack).colspan(3).left();
    table.pack();
    ScrollPane scrollPane = new ScrollPane(table);
    scrollPane.setFillParent(true);
    stage.addActor(scrollPane);
    pointer = new Pointer(ui.getSkin());
    stage.addActor(pointer);
    Gdx.input.setInputProcessor(stage);
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) ArrayList(java.util.ArrayList) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Button(com.badlogic.gdx.scenes.scene2d.ui.Button) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) IOException(java.io.IOException) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)

Example 4 with HorizontalGroup

use of com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup in project libgdx by libgdx.

the class Scene2dTest method create.

public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    final TextureRegion region = new TextureRegion(new Texture("data/badlogic.jpg"));
    final Actor actor = new Actor() {

        public void draw(Batch batch, float parentAlpha) {
            Color color = getColor();
            batch.setColor(color.r, color.g, color.b, parentAlpha);
            batch.draw(region, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation());
        }
    };
    actor.setBounds(15, 15, 100, 100);
    actor.setOrigin(50, 50);
    stage.addActor(actor);
    actor.addListener(new InputListener() {

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("down");
            return true;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("up " + event.getTarget());
        }
    });
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    VerticalGroup g = new VerticalGroup().space(5).reverse().pad(5).fill();
    for (int i = 0; i < 10; i++) g.addActor(new TextButton("button " + i, skin));
    g.addActor(new TextButton("longer button", skin));
    Table table = new Table().debug();
    table.add(g);
    table.pack();
    table.setPosition(5, 100);
    stage.addActor(table);
    HorizontalGroup h = new HorizontalGroup().space(5).reverse().pad(5).fill();
    for (int i = 0; i < 5; i++) h.addActor(new TextButton("button " + i, skin));
    h.addActor(new TextButton("some taller\nbutton", skin));
    table = new Table().debug();
    table.add(h);
    table.pack();
    table.setPosition(130, 100);
    stage.addActor(table);
    table.toFront();
    final TextButton button = new TextButton("Fancy Background", skin);
    // button.addListener(new ClickListener() {
    // public void clicked (InputEvent event, float x, float y) {
    // System.out.println("click! " + x + " " + y);
    // }
    // });
    button.addListener(new ActorGestureListener() {

        public boolean longPress(Actor actor, float x, float y) {
            System.out.println("long press " + x + ", " + y);
            return true;
        }

        public void fling(InputEvent event, float velocityX, float velocityY, int button) {
            System.out.println("fling " + velocityX + ", " + velocityY);
        }

        public void zoom(InputEvent event, float initialDistance, float distance) {
            System.out.println("zoom " + initialDistance + ", " + distance);
        }

        public void pan(InputEvent event, float x, float y, float deltaX, float deltaY) {
            event.getListenerActor().moveBy(deltaX, deltaY);
            if (deltaX < 0)
                System.out.println("panning " + deltaX + ", " + deltaY + " " + event.getTarget());
        }
    });
    // button.addListener(new ChangeListener() {
    // public void changed (ChangeEvent event, Actor actor) {
    // // event.cancel();
    // }
    // });
    button.setPosition(50, 50);
    stage.addActor(button);
    // List select = new List(skin);
    // select.setBounds(200, 200, 100, 100);
    // select.setItems(new Object[] {1, 2, 3, 4, 5});
    // stage.addActor(select);
    // stage.addListener(new ChangeListener() {
    // public void changed (ChangeEvent event, Actor actor) {
    // System.out.println(actor);
    // }
    // });
    meow.setDuration(2);
    actor.addAction(forever(sequence(moveBy(50, 0, 2), moveBy(-50, 0, 2), run(new Runnable() {

        public void run() {
            actor.setZIndex(0);
        }
    }))));
    // actor.addAction(parallel(rotateBy(90, 2), rotateBy(90, 2)));
    // actor.addAction(parallel(moveTo(250, 250, 2, elasticOut), color(RED, 6), delay(0.5f), rotateTo(180, 5, swing)));
    // actor.addAction(forever(sequence(scaleTo(2, 2, 0.5f), scaleTo(1, 1, 0.5f), delay(0.5f))));
    patch = new TiledDrawable(skin.getRegion("default-round"));
    Window window = new Window("Moo", skin);
    Label lbl = new Label("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", skin);
    lbl.setWrap(true);
    window.row();
    window.add(lbl).width(400);
    window.pack();
    window.pack();
    stage.addActor(window);
    ImageTextButtonStyle style = new ImageTextButtonStyle(skin.get("default", TextButtonStyle.class));
    style.imageUp = skin.getDrawable("default-round");
    ImageTextButton buttonLeft = new ImageTextButton("HI IM LEFT", style);
    ImageTextButton buttonRight = new ImageTextButton("HI IM RIGHT", style) {

        {
            clearChildren();
            add(getLabel());
            add(getImage());
        }
    };
    CheckBox checkBoxLeft = new CheckBox("HI IM LEFT", skin, "default");
    CheckBox checkBoxRight = new CheckBox("HI IM RIGHT", skin, "default") {

        {
            clearChildren();
            add(getLabel());
            add(getImage());
        }
    };
    buttonLeft.setPosition(300, 400);
    buttonRight.setPosition(300, 370);
    checkBoxLeft.setPosition(150, 400);
    checkBoxRight.setPosition(150, 370);
    stage.addActor(buttonLeft);
    stage.addActor(buttonRight);
    stage.addActor(checkBoxLeft);
    stage.addActor(checkBoxRight);
    buttonLeft.debug();
    buttonRight.debug();
    checkBoxLeft.debug();
    checkBoxRight.debug();
}
Also used : ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Window(com.badlogic.gdx.scenes.scene2d.ui.Window) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Color(com.badlogic.gdx.graphics.Color) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) VerticalGroup(com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup) Texture(com.badlogic.gdx.graphics.Texture) ActorGestureListener(com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) Batch(com.badlogic.gdx.graphics.g2d.Batch) TiledDrawable(com.badlogic.gdx.scenes.scene2d.utils.TiledDrawable) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) ImageTextButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton.ImageTextButtonStyle) TextButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ImageTextButtonStyle(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton.ImageTextButtonStyle)

Example 5 with HorizontalGroup

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

the class DialogDrawables method populate.

public void populate() {
    getContentTable().clear();
    getButtonTable().padBottom(15.0f);
    if (property == null && customProperty == null) {
        getContentTable().add(new Label("Drawables", getSkin(), "title"));
    } else {
        getContentTable().add(new Label("Select a Drawable", getSkin(), "title"));
    }
    getContentTable().row();
    Table table = new Table(getSkin());
    table.defaults().pad(10.0f);
    getContentTable().add(table).growX();
    table.add("Sort by:");
    sortSelectBox = new SelectBox(getSkin());
    sortSelectBox.setItems("A-Z", "Z-A", "Oldest", "Newest");
    sortSelectBox.setSelectedIndex(sortSelection);
    sortSelectBox.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            sortSelection = sortSelectBox.getSelectedIndex();
            sortBySelectedMode();
        }
    });
    sortSelectBox.addListener(main.getHandListener());
    sortSelectBox.getList().addListener(main.getHandListener());
    table.add(sortSelectBox);
    TextButton textButton = new TextButton("Add Drawable", getSkin(), "new");
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow);
            newDrawableDialog();
        }
    });
    textButton.addListener(main.getHandListener());
    table.add(textButton);
    textButton = new TextButton("Custom Drawable", getSkin(), "new");
    textButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow);
            customDrawableDialog();
        }
    });
    textButton.addListener(main.getHandListener());
    table.add(textButton);
    table.add(new Label("Zoom:", getSkin())).right().expandX();
    zoomSlider = new Slider(0, 3, 1, false, getSkin());
    zoomSlider.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            refreshDrawableDisplay();
        }
    });
    zoomSlider.addListener(main.getHandListener());
    table.add(zoomSlider);
    getContentTable().row();
    contentGroup = new HorizontalGroup();
    contentGroup.center().wrap(true).space(5.0f).wrapSpace(5.0f).rowAlign(Align.left);
    scrollPane = new ScrollPane(contentGroup, getSkin());
    scrollPane.setFadeScrollBars(false);
    scrollPane.setFlickScroll(false);
    getContentTable().add(scrollPane).grow();
    sortBySelectedMode();
    getContentTable().row();
    if (property != null || customProperty != null) {
        button("Clear Drawable", true);
        button("Cancel", false);
        getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
        getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
    } else {
        button("Close", false);
        getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    }
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Slider(com.badlogic.gdx.scenes.scene2d.ui.Slider) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Aggregations

HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)5 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)5 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)4 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)4 Actor (com.badlogic.gdx.scenes.scene2d.Actor)3 Stage (com.badlogic.gdx.scenes.scene2d.Stage)3 Container (com.badlogic.gdx.scenes.scene2d.ui.Container)3 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)3 Texture (com.badlogic.gdx.graphics.Texture)2 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)2 Button (com.badlogic.gdx.scenes.scene2d.ui.Button)2 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)2 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)2 ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)2 LabelStyle (com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle)2 SelectBox (com.badlogic.gdx.scenes.scene2d.ui.SelectBox)2 Slider (com.badlogic.gdx.scenes.scene2d.ui.Slider)2