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

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

Introduction

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

Prototype

public void setClamp(boolean clamp) 

Source Link

Document

For flick scroll, prevents scrolling out of the widget's bounds.

Usage

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

License:Apache License

/**
 * @return/*from   w  w w  .  j  av  a2  s .  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

/**
 * //from w w  w . j a  va 2 s.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.mwplay.cocostudio.ui.parser.group.CCScrollView.java

License:Apache License

@Override
public Actor parse(CocoStudioUIEditor editor, ObjectData widget) {
    ScrollPaneStyle style = new ScrollPaneStyle();

    if (widget.getFileData() != null) {

        style.background = editor.findDrawable(widget, widget.getFileData());
    }/*from  w  w w. j av a2s  .co m*/

    ScrollPane scrollPane = new ScrollPane(null, style);

    if ("Vertical_Horizontal".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(true, true);
    } else if ("Horizontal".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(true, false);
    } else if ("Vertical".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(false, true);
    }

    scrollPane.setClamp(widget.isClipAble());
    scrollPane.setFlickScroll(widget.isIsBounceEnabled());

    Table table = new Table();
    table.setSize(widget.getInnerNodeSize().getWidth(), widget.getInnerNodeSize().getHeight());

    if (widget.getComboBoxIndex() == 0) {// 

    } else if (widget.getComboBoxIndex() == 1) {// ?

        Pixmap pixmap = new Pixmap((int) table.getWidth(), (int) table.getHeight(), Format.RGBA8888);
        Color color = editor.getColor(widget.getSingleColor(), widget.getBackColorAlpha());

        pixmap.setColor(color);

        pixmap.fill();

        Drawable drawable = new TextureRegionDrawable(new TextureRegion(new Texture(pixmap)));

        table.setBackground(drawable);
        pixmap.dispose();

    }
    scrollPane.setWidget(table);
    return scrollPane;
}