Example usage for com.badlogic.gdx.scenes.scene2d.ui ScrollPane setFadeScrollBars

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui ScrollPane setFadeScrollBars

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui ScrollPane setFadeScrollBars.

Prototype

public void setFadeScrollBars(boolean fadeScrollBars) 

Source Link

Document

When true the scrollbars don't reduce the scrollable size and fade out after some time of not being used.

Usage

From source file:it.alcacoop.fourinaline.actors.UIDialog.java

License:Open Source License

public static void getAboutDialog() {
    Stage stage = FourInALine.Instance.currentScreen.getStage();
    instance.visible = true;/*from ww w .j  a  v a 2s.  com*/
    instance.evt = Events.NOOP;
    instance.quitWindow = false;
    instance.leaveWindow = false;
    instance.remove();

    final String gnuBgLink = "http://code.google.com/p/fourinaline";
    final String gplLink = "http://www.gnu.org/licenses/gpl.html";
    final String githubLink1 = "https://github.com/alcacoop/it.alcacoop.fourinaline";
    final String wikipediaLink = "http://en.wikipedia.org/wiki/Connect_Four";

    Table t = new Table();
    t.add(new Label("ABOUT FOUR IN A LINE MOBILE", FourInALine.Instance.skin)).expand();
    t.row();
    t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand();
    t.row();
    t.add(new Label("\"Four in a Line Mobile!\" is based on FourInALine", FourInALine.Instance.skin));
    Label link1 = new Label(gnuBgLink, FourInALine.Instance.skin);
    link1.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            FourInALine.Instance.snd.playMove();
            FourInALine.Instance.nativeFunctions.openURL(gnuBgLink);
        };
    });
    t.row();
    t.add(link1);
    t.row();
    t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand();
    t.row();
    t.add(new Label("Its source code is released under a GPLv3 License", FourInALine.Instance.skin));
    Label link2 = new Label(gplLink, FourInALine.Instance.skin);
    link2.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            FourInALine.Instance.snd.playMove();
            FourInALine.Instance.nativeFunctions.openURL(gplLink);
        };
    });
    t.row();
    t.add(link2);
    t.row();
    t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand();
    t.row();
    t.add(new Label("and is available on GitHub at:", FourInALine.Instance.skin));
    Label link3 = new Label(githubLink1, FourInALine.Instance.skin);
    link3.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            FourInALine.Instance.snd.playMove();
            FourInALine.Instance.nativeFunctions.openURL(githubLink1);
        };
    });

    t.row();
    t.add(link3);

    t.row();
    t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand();
    t.row();
    t.add(new Label("You can find a detailed description of game rules on Wikipedia:",
            FourInALine.Instance.skin));
    Label link5 = new Label(wikipediaLink, FourInALine.Instance.skin);
    link5.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            FourInALine.Instance.snd.playMove();
            FourInALine.Instance.nativeFunctions.openURL(wikipediaLink);
        };
    });
    t.row();
    t.add(link5);
    t.row();
    t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand();
    t.row();
    t.add(new Label("If you enjoy our game, support us rating on the Play Store", FourInALine.Instance.skin));
    t.row();
    t.add(new Label(" ", FourInALine.Instance.skin)).fill().expand();
    t.row();
    t.add(new Label("Copyright 2013 - Alca Soc. Coop.", FourInALine.Instance.skin));

    ScrollPane sc = new ScrollPane(t, FourInALine.Instance.skin);
    sc.setFadeScrollBars(false);
    sc.setOverscroll(false, false);

    float height = stage.getHeight() * 0.85f;
    float width = stage.getWidth() * 0.95f;

    instance.clear();
    instance.row().padTop(width / 25);
    instance.add(sc).colspan(3).expand().fill().align(Align.center).padTop(width / 25).padLeft(width / 35)
            .padRight(width / 35);

    instance.row().pad(width / 25);
    instance.add();
    instance.add(instance.bContinue).fill().expand().height(height * 0.15f).width(width / 4);
    instance.add();

    instance.setWidth(width);
    instance.setHeight(height);
    instance.setX((stage.getWidth() - width) / 2);

    stage.addActor(instance);
    instance.setY(stage.getHeight());
    instance.addAction(Actions.sequence(Actions.parallel(Actions.color(new Color(1, 1, 1, alpha), 0.2f),
            Actions.moveTo((stage.getWidth() - width) / 2, (stage.getHeight() - height) / 2, 0.2f))));
}

From source file:mobi.shad.s3lib.gui.widget.ScrollBoxImageButton.java

License:Apache License

/**
 * @return/*  ww  w .ja  va 2s.c  o m*/
 */
public Table getTable() {

    Gui gui = new Gui();
    buttonAct = new Vector<Button>();

    gui.row();
    int j = 0;
    boolean newRow = false;
    for (int i = 0; i < items.size(); i++) {
        newRow = false;
        if (j > buttonX) {
            newRow = true;
            j = 0;
        }
        Button addImgButton = gui.addImgButton(items.get(i), this, "buttonIdx", i, newRow, 1, true, buttonSize,
                "btn" + this.toString(), localChangeListener);
        if (i == value) {
            addImgButton.setChecked(true);
        }
        buttonAct.add(i, addImgButton);
        j++;
    }

    Table table = gui.getTable();
    ScrollPane scrollPane = GuiResource.scrollPane(table, "scroll");
    scrollPane.setFadeScrollBars(true);
    scrollPane.setClamp(true);
    scrollPane.setFlickScroll(true);

    scrollPane.setScrollingDisabled(true, false);

    window = GuiResource.table("window");
    window.row();
    window.add(scrollPane).width(width).height(height);
    window.row();

    return window;
}

From source file:mobi.shad.s3lib.gui.widget.ScrollImageButton.java

License:Apache License

/**
 * /* ww w.ja va 2s .  c om*/
 * @return 
 */
public Table getTable() {

    Gui gui = new Gui();
    buttonAct = new Vector<Button>();

    gui.row();
    for (int i = 0; i < items.size(); i++) {
        Button addImgButton = gui.addImgButton(items.get(i), this, "buttonIdx", i, vertical, 1, true,
                buttonSize, "btn" + this.toString(), changeListener);
        if (i == value) {
            addImgButton.setChecked(true);
        }
        buttonAct.add(i, addImgButton);
    }
    if (!vertical) {
        gui.row();
        gui.addLabel("", true, items.size());
    }

    Table table = gui.getTable();
    table.row();
    table.add(" ").colspan(items.size());

    ScrollPane scrollPane = GuiResource.scrollPane(table, "scroll");
    scrollPane.setFadeScrollBars(true);
    scrollPane.setClamp(true);
    scrollPane.setFlickScroll(true);

    if (!vertical) {
        scrollPane.setScrollingDisabled(false, true);
    } else {
        scrollPane.setScrollingDisabled(true, false);
    }

    window = GuiResource.table("window");
    window.row();
    window.add(scrollPane);
    window.row();

    return window;
}

From source file:net.noviden.towerdefense.MapEditor.MapEditorSelectorScreen.java

License:Open Source License

public MapEditorSelectorScreen(final TowerDefense towerDefense) {
    this.towerDefense = towerDefense;

    Skin skin = new Skin(Gdx.files.internal("assets/uiskin.json"));

    Texture texture = new Texture(Gdx.files.internal("selectedMap.png"));
    _selectedMapIdentifierImage = new Image(texture);

    stage = new Stage();

    rootTable = new Table();
    rootTable.setFillParent(true);/*from  w w  w.jav a  2s  . c  o  m*/

    Table containerTable = new Table();
    _mapListTable = new Table();

    updateMapList();

    ScrollPane scrollPane = new ScrollPane(_mapListTable);
    scrollPane.layout();
    scrollPane.setFadeScrollBars(false);

    Table operationsTable = new Table();
    TextButton createButton = new TextButton("Create", skin);
    TextButton selectButton = new TextButton("Edit", skin);
    TextButton cloneButton = new TextButton("Clone", skin);
    TextButton deleteButton = new TextButton("Delete", skin);

    TextButton exitButton = new TextButton("Main Menu", skin);

    Label screenTitleLabel = new Label("Map Editor Browser", skin);

    containerTable.add(scrollPane).fillX().fillY();

    operationsTable.add(screenTitleLabel).pad(5.0f);
    operationsTable.add(createButton).pad(5.0f);
    operationsTable.add(selectButton).pad(5.0f);
    operationsTable.add(cloneButton).pad(5.0f);
    operationsTable.add(deleteButton).pad(5.0f);
    operationsTable.add(exitButton).pad(5.0f);

    rootTable.add(operationsTable).expandY().top().expandX().right();
    rootTable.row();
    rootTable.add(containerTable).top();
    rootTable.center();

    stage.addActor(rootTable);

    Gdx.input.setInputProcessor(stage);

    // set up input listeners
    exitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            towerDefense.setScreen(new MainMenuScreen(towerDefense));
        }
    });

    createButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            towerDefense.setScreen(new MapCreatorScreen(towerDefense));
        }
    });

    selectButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (_selectedMap != null)
                towerDefense.setScreen(new MapEditorScreen(towerDefense, _selectedMap));
        }
    });

    cloneButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (_selectedMap != null) {
                towerDefense.maps.add(_selectedMap.clone());
                updateMapList();
            }
        }
    });

    deleteButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (_selectedMap != null) {
                towerDefense.maps.remove(_selectedMap);
                updateMapList();

                _selectedMap = null;
            }
        }
    });
}

From source file:net.noviden.towerdefense.Screens.MapSelectorScreen.java

License:Open Source License

public MapSelectorScreen(final TowerDefense towerDefense) {
    this.towerDefense = towerDefense;

    Skin skin = new Skin(Gdx.files.internal("assets/uiskin.json"));

    stage = new Stage();

    rootTable = new Table();
    rootTable.setFillParent(true);//  w  w  w  .  ja  v  a  2s. co m

    Table containerTable = new Table();
    Table mapListTable = new Table();

    for (int i = 0; i < towerDefense.maps.size(); i++) {
        if (i > 0 && i % 3 == 0) {
            mapListTable.row();
        }

        final Map map = towerDefense.maps.get(i);

        ClickListener clickListener = new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                towerDefense.setScreen(new net.noviden.towerdefense.Screens.GameScreen(towerDefense, map));
            }
        };
        TextButton textButton = new TextButton(map.getName(), skin);
        textButton.addListener(clickListener);

        ImageButton imageButton = new ImageButton(MapThumbnail.createThumbnail(map, 200));
        imageButton.addListener(clickListener);

        mapListTable.add(imageButton).pad(10.0f);
    }

    ScrollPane scrollPane = new ScrollPane(mapListTable);
    scrollPane.layout();
    scrollPane.setFadeScrollBars(false);

    TextButton exitButton = new TextButton("Main Menu", skin);
    exitButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            towerDefense.setScreen(new MainMenuScreen(towerDefense));
        }
    });

    containerTable.add(scrollPane).fillX().fillY();

    rootTable.add(containerTable).expandY().pad(10.0f);
    rootTable.row();
    rootTable.add(exitButton).bottom().expandX().right().pad(8.0f);

    stage.addActor(rootTable);

    Gdx.input.setInputProcessor(stage);
}

From source file:org.brian.blueirisviewer.ui.AboutWnd.java

License:Open Source License

@Override
public void onCreate(Skin skin, Window window, Table table) {
    window.setTitle("About BlueIrisView");

    Table scrollTable = new Table(skin);
    scrollTable.columnDefaults(0).align(Align.left);
    scrollTable.pad(10, 10, 10, 30);/*from   www  .  j a v a 2 s.  co  m*/

    ScrollPane scrollPane = new ScrollPane(scrollTable, skin);
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollingDisabled(true, false);
    table.add(scrollPane).colspan(2).align(Align.center);
    table.row();

    scrollTable.add("BlueIrisView Version 2.8.1");
    scrollTable.row();

    scrollTable.add().height(10);
    scrollTable.row();

    scrollTable.add("by Brian Pearce - 2018");
    scrollTable.row();

    scrollTable.add().height(20);
    scrollTable.row();

    scrollTable.add("Powered by libGDX " + Version.VERSION);
    scrollTable.row();

    scrollTable.add().height(10);
    scrollTable.row();

    texLibGDXImage = new Texture(Gdx.files.internal("data/libgdx_about.png"));
    Image imgLibGDX = new Image(texLibGDXImage);
    scrollTable.add(imgLibGDX);
    scrollTable.row();

    scrollTable.add().height(20);
    scrollTable.row();

    scrollTable.add(
            "BlueIrisView uses the XStream library for settings serialization.\n\nXStream's license follows:");
    scrollTable.row();

    scrollTable.add().height(10);
    scrollTable.row();

    Label lblXStreamLicense = new Label(xStreamLicense, skin);
    scrollTable.add(lblXStreamLicense);
    scrollTable.row();

    scrollTable.add().height(20);
    scrollTable.row();

    scrollTable.add(new Label("-----------------------------------", skin));
    scrollTable.row();

    scrollTable.add().height(10);
    scrollTable.row();

    scrollTable.add(
            "BlueIrisView uses the json-simple library.\n\njson-simple is licensed with Apache License, Version 2.0 ");
    scrollTable.row();

    scrollTable.add().height(5);
    scrollTable.row();

    scrollTable.add(new Label("http://www.apache.org/licenses/LICENSE-2.0", skin));
    scrollTable.row();

    scrollTable.add().height(10);
    scrollTable.row();

    scrollTable.add().height(20);
    scrollTable.row();

    scrollTable.add(new Label("-----------------------------------", skin));
    scrollTable.row();

    scrollTable.add().height(10);
    scrollTable.row();

    scrollTable.add(new Label(
            "BlueIrisView optionally uses the libjpeg-turbo library to reduce CPU usage on Windows.", skin));
    scrollTable.row();
    scrollTable.add().height(5);
    scrollTable.row();
    scrollTable
            .add(new Label("this software is based in part on the work of the Independent JPEG Group", skin));
    scrollTable.row();
    scrollTable.add().height(5);
    scrollTable.row();
    scrollTable.add(new Label(
            "Redistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n- Redistributions of source code must retain the above copyright notice,\n  this list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice,\n  this list of conditions and the following disclaimer in the documentation\n  and/or other materials provided with the distribution.\n- Neither the name of the libjpeg-turbo Project nor the names of its\n  contributors may be used to endorse or promote products derived from this\n  software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\",\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.",
            skin));
    scrollTable.row();

    scrollTable.add().height(10);
    scrollTable.row();

    final CheckBox cbSaveErrorLogToDisk = new CheckBox("  Log Errors To Disk", skin);
    cbSaveErrorLogToDisk.setChecked(BlueIrisViewer.bivSettings.logErrorsToDisk);
    cbSaveErrorLogToDisk.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (BlueIrisViewer.bivSettings.logErrorsToDisk)
                Logger.debug("Disabling File Logging", AboutWnd.this);
            BlueIrisViewer.bivSettings.logErrorsToDisk = cbSaveErrorLogToDisk.isChecked();
            BlueIrisViewer.bivSettings.Save();
            if (BlueIrisViewer.bivSettings.logErrorsToDisk)
                Logger.debug("Enabled File Logging", AboutWnd.this);
        }
    });
    table.add(cbSaveErrorLogToDisk).align(Align.left);

    final TextButton btnClose = new TextButton("Close", skin);
    btnClose.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            hide();
        }
    });
    table.add(btnClose).align(Align.right);
    table.row();
}

From source file:org.gearvrf.widgetViewer.MyGdxWidget.java

License:Apache License

@SuppressWarnings("unchecked")
public void create() {
    mStage = new Stage();
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    Gdx.input.setInputProcessor(mStage);
    mContainer = new Table();
    mStage.addActor(mContainer);/*  w  ww.j a v  a 2 s.c  o m*/
    mContainer.setFillParent(true);
    Table table = new Table();
    final ScrollPane scroll = new ScrollPane(table, skin);

    InputListener stopTouchDown = new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
        }
    };

    table.pad(0).defaults().expandX().space(10);
    for (int i = 0; i < 4; i++) {
        table.row();
        table.add(new Label("", skin)).expandX().fillX();
        TextButton button = null;
        if (i == 0) {
            button = new TextButton("  Next  ", skin);
            button.getLabel().setFontScale(mFontScale);
            mNextButton = button;
            button.addListener(new ClickListener() {
                public void clicked(InputEvent event, float x, float y) {
                    System.out.println("click " + x + ", " + y);

                    mMain.ThumbnailSelected = (mMain.ThumbnailSelected + 1) % 5;
                    mNextButton.setChecked(false);
                }
            });
        } else if (i == 1) {
            button = new TextButton("Previous", skin);
            button.getLabel().setFontScale(mFontScale);
            mPreviousButton = button;
            button.addListener(new ClickListener() {
                public void clicked(InputEvent event, float x, float y) {
                    System.out.println("click " + x + ", " + y);
                    mMain.ThumbnailSelected = (mMain.ThumbnailSelected + 4) % 5;
                    mPreviousButton.setChecked(false);
                }
            });
        } else if (i == 2) {

            BitmapFont f = skin.getFont("default-font");
            f.getData().setScale(mFontScale - 1.0f);
            SelectBoxStyle style = new SelectBoxStyle(f, Color.WHITE, skin.getDrawable("default-select"),
                    skin.get(ScrollPaneStyle.class), skin.get(ListStyle.class));

            final SelectBox selectBox = new SelectBox(style);
            selectBox.addListener(new ChangeListener() {
                public void changed(ChangeEvent event, Actor actor) {
                    mMain.mTexColor = selectBox.getSelectedIndex() + 1;
                }
            });
            selectBox.setItems("Maroon", "Black", "Blue", "Green", "Silver");

            selectBox.setSelected("Maroon");
            selectBox.setVisible(false);
            selectBox.setName("colorbutton");

            table.add(selectBox).height(120.0f).width(600.0f);

        } else {
            final CheckBox box = new CheckBox("Reset", skin);
            mCheckBox = box;
            box.setChecked(true);
            box.addListener(new ChangeListener() {
                public void changed(ChangeEvent event, Actor actor) {
                    ((Slider) xSlider).setValue(0.0f);
                    mResetSlider = box.isChecked();
                }
            });
            box.getLabel().setFontScale(mFontScale);
            box.getCells().get(0).size(80.0f, 80.0f);
            table.add(box);
        }

        table.add(button).height(120).width(450);

        Slider slider = null;
        if (i < 3) {
            slider = new Slider(0, 100, 1, false, skin);
            if (i == 0) {
                slider.setName("X");
                slider.setVisible(false);
            }
            if (i == 1) {
                slider.setName("Y");
                slider.setVisible(false);
            }
            if (i == 2) {
                slider.setName("Z");
                slider.setVisible(false);
            }
            ;
            slider.addListener(stopTouchDown); // Stops touchDown events
                                               // from propagating to the
                                               // FlickScrollPane.
            if (i == 0) {
                Label l = new Label("Rotate X", skin);
                table.add(l);
                l.setVisible(false);
            }
            if (i == 1) {
                Label l = new Label("Rotate Y", skin);
                l.setVisible(false);
                table.add(l);
            }
            if (i == 2) {
                Label l2 = new Label("Rotate Z", skin);
                table.add(l2);
                l2.setVisible(false);
            }
            table.add(slider).height(120).width(500);
        }

    }

    table.row();
    table.add(new Label("", skin)).expandX().fillX();
    TextButton button = new TextButton("Look Inside", skin);
    button.getLabel().setFontScale(mFontScale);
    mLookInsideButton = button;
    button.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {

            mMain.mLookInside = true;
            mLookInsideButton.setChecked(false);
            mLookInsideButton.toggle();
        }
    });
    button.setVisible(false);
    button.setName("lookinsidebutton");
    table.add(button).height(120).width(450);
    table.row();

    Slider slider = null;

    slider = new Slider(0, 100, 1, false, skin);
    slider.setName("Zoom");
    slider.addListener(stopTouchDown);
    Label zoom = new Label("  Zoom  ", skin);
    zoom.setFontScale(mFontScale);
    table.pad(10).add(zoom);
    table.add(slider).height(150.0f).width(800);
    final TextButton flickButton = new TextButton("Flick Scroll", skin.get("toggle", TextButtonStyle.class));
    flickButton.setChecked(true);
    flickButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            scroll.setFlickScroll(flickButton.isChecked());
        }
    });
    final TextButton fadeButton = new TextButton("Fade Scrollbars", skin.get("toggle", TextButtonStyle.class));
    fadeButton.setChecked(true);
    fadeButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            scroll.setFadeScrollBars(fadeButton.isChecked());
        }
    });
    final TextButton smoothButton = new TextButton("Smooth Scrolling",
            skin.get("toggle", TextButtonStyle.class));
    smoothButton.setChecked(true);
    smoothButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            scroll.setSmoothScrolling(smoothButton.isChecked());
        }
    });
    final TextButton onTopButton = new TextButton("Scrollbars On Top",
            skin.get("toggle", TextButtonStyle.class));
    onTopButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            scroll.setScrollbarsOnTop(onTopButton.isChecked());
        }
    });
    mContainer.add(scroll).expand().fill().colspan(4);
    mContainer.row().space(10).padBottom(10);

}

From source file:org.shadebob.skineditor.actors.OptionsPane.java

License:Apache License

/**
 * // ww  w . j  a  v  a2 s. c  om
 */
public OptionsPane(final SkinEditorGame game) {
    super();

    this.game = game;

    left();
    top();
    setBackground(game.skin.getDrawable("default-pane"));

    add(new Label("Styles", game.skin, "title")).pad(5).row();
    listStyles = new List<String>(game.skin, "dimmed");
    listStyles.setItems(listItems);
    ScrollPane scroll = new ScrollPane(listStyles, game.skin);
    scroll.setFlickScroll(false);
    scroll.setFadeScrollBars(false);
    scroll.setScrollbarsOnTop(true);
    scroll.setScrollBarPositions(false, true);
    scroll.setScrollingDisabled(true, false);
    add(scroll).height(200).expandX().fillX().pad(5).row();

    // Add buttons
    Table tableStylesButtons = new Table();
    TextButton buttonNewStyle = new TextButton("New Style", game.skin);
    TextButton buttonDeleteStyle = new TextButton("Delete Style", game.skin);
    tableStylesButtons.add(buttonNewStyle).pad(5);
    tableStylesButtons.add(buttonDeleteStyle).pad(5);
    add(tableStylesButtons).row();

    // Callbacks

    listStyles.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {

            String key = (String) listStyles.getSelected();
            if (key != null) {
                Gdx.app.log("OptionsPane", "Selected style: " + key);
                currentStyle = styles.get(key);
                updateTableFields(key);
            }
        }

    });

    buttonNewStyle.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            createNewStyle();
        }

    });

    buttonDeleteStyle.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            showDeleteDialog();
        }

    });

    // Initialize table

    add(new Label("Fields", game.skin, "title")).pad(5).padTop(10).row();

    tableFields = new Table(game.skin);
    tableFields.setBackground(game.skin.getDrawable("dialogDim"));
    tableFields.left().top();

    ScrollPane scroll2 = new ScrollPane(tableFields, game.skin);
    scroll2.setFlickScroll(false);
    scroll2.setFadeScrollBars(false);
    scroll2.setScrollbarsOnTop(true);
    scroll2.setScrollBarPositions(false, true);
    scroll2.setScrollingDisabled(true, false);
    add(scroll2).pad(5).expand().fill();

}

From source file:org.shadebob.skineditor.ColorPickerDialog.java

License:Apache License

/**
 * /*w w w. j a v  a  2s . co  m*/
 */
public ColorPickerDialog(final SkinEditorGame game, final Field field) {

    super("Color Picker", game.skin);

    this.game = game;
    this.field = field;

    tableColors = new Table(game.skin);
    tableColors.left().top().pad(5);
    tableColors.defaults().pad(5);
    colors = game.skinProject.getAll(Color.class);

    updateTable();

    TextButton buttonNewColor = new TextButton("New Color", game.skin);
    buttonNewColor.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {

            // Need to steal focus first with this hack (Thanks to Z-Man)
            Frame frame = new Frame();
            frame.setUndecorated(true);
            // TODO fix falls frame.setOpacity(0);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
            frame.toFront();
            frame.setVisible(false);
            frame.dispose();

            // Call swing color picker
            java.awt.Color color = JColorChooser.showDialog(null, "Pick your color", java.awt.Color.WHITE);
            if (color != null) {

                String colorName = JOptionPane.showInputDialog("Name your color");

                if ((colorName != null) && (colorName.isEmpty() == false)) {
                    // Verify if the color name is already in use
                    if (colors.containsKey(colorName) == true) {
                        game.showNotice("Error", "Color name already in use!", game.screenMain.stage);
                    } else {
                        // Add the color (asuming RGBA)
                        float[] components = color.getComponents(null);
                        Color newColor = new Color(components[0], components[1], components[2], components[3]);
                        if (isColorInUse(newColor)) {
                            game.showNotice("Error",
                                    "Same color value (" + newColor.toString()
                                            + ") is already defined with a different name!",
                                    game.screenMain.stage);
                            return;
                        }

                        colors.put(colorName, newColor);
                        game.screenMain.saveToSkin();

                        // update table
                        updateTable();
                    }
                }
            }

        }

    });

    TextButton buttonNoColor = new TextButton("Empty Color", game.skin);
    buttonNoColor.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {

            try {
                field.set(game.screenMain.paneOptions.currentStyle, null);
            } catch (Exception e) {
                e.printStackTrace();
            }

            game.screenMain.saveToSkin();

            hide();
            game.screenMain.panePreview.refresh();
            game.screenMain.paneOptions.updateSelectedTableFields();

        }

    });

    ScrollPane scrollPane = new ScrollPane(tableColors, game.skin);
    scrollPane.setFlickScroll(false);
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollbarsOnTop(true);

    getContentTable().add(scrollPane).width(540).height(320).pad(20);
    getButtonTable().add(buttonNewColor);
    if (field != null) {
        getButtonTable().add(buttonNoColor);
    }
    getButtonTable().padBottom(15);
    button("Cancel", false);
    key(com.badlogic.gdx.Input.Keys.ESCAPE, false);

}

From source file:org.shadebob.skineditor.dialog.ColorPickerDialog.java

License:Apache License

public ColorPickerDialog(final SkinEditorGame game, final Field field) {
    super("Color Picker", game.skin);
    this.game = game;
    this.field = field;

    tableColors = new Table(game.skin);
    tableColors.left().top().pad(5);/*from   w w w .  ja  v  a2 s .  c o m*/
    tableColors.defaults().pad(5);

    updateTable();

    ScrollPane scrollPane = new ScrollPane(tableColors, game.skin);
    scrollPane.setFlickScroll(false);
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollbarsOnTop(true);
    getContentTable().add(scrollPane).width(540).height(320).pad(20);

    getButtonTable().add(new TextButton("New Color", game.skin)).getActor().addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            SwingUtils.forceFocus();
            // Call swing color picker
            java.awt.Color color = JColorChooser.showDialog(null, "Pick your color", java.awt.Color.WHITE);
            if (color != null) {
                String colorName = JOptionPane.showInputDialog("Name your color");
                if ((colorName != null) && (colorName.isEmpty() == false)) {
                    // Verify if the color name is already in use
                    if (colors.containsKey(colorName) == true) {
                        game.showNotice("Error", "Color name already in use!", game.screenMain.stage);
                    } else {
                        // Add the color (asuming RGBA)
                        float[] components = color.getComponents(null);
                        Color newColor = new Color(components[0], components[1], components[2], components[3]);
                        if (CustomSkin.isResInUse(game.skinProject, newColor)) {
                            game.showNotice("Error",
                                    "Same color value (" + newColor.toString()
                                            + ") is already defined with a different name!",
                                    game.screenMain.stage);
                            return;
                        }
                        colors.put(colorName, newColor);
                        game.screenMain.changeSkin();
                        // update table
                        updateTable();
                    }
                }
            }
        }
    });
    ;
    if (field != null) {
        getButtonTable().add(new TextButton("Empty Color", game.skin)).getActor()
                .addListener(new ChangeListener() {
                    @Override
                    public void changed(ChangeEvent event, Actor actor) {
                        try {
                            field.set(game.screenMain.paneOptions.currentStyleObj, null);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        game.screenMain.changeSkin();
                        hide();
                        game.screenMain.panePreview.refresh();
                        game.screenMain.paneOptions.updateSelectedTableFields();
                    }
                });
    }

    button("Cancel", false).key(Keys.ESCAPE, false).getButtonTable().padBottom(15);
}