List of usage examples for com.badlogic.gdx.scenes.scene2d.ui ScrollPane scrollTo
public void scrollTo(float x, float y, float width, float height)
From source file:com.vlaaad.dice.ui.windows.DiceWindow.java
License:Open Source License
@Override protected void doShow(final UserData userData) { final Table items = new Table(); final ScrollPane pane = new ScrollPane(items, new ScrollPane.ScrollPaneStyle()) { @Override// w w w. j a va 2s.c o m public void layout() { float w = items.getPrefWidth(); float h = Math.min(getParent().getHeight(), items.getPrefHeight()); if (w != getWidth() || h != getHeight()) { setSize(w, h); invalidateHierarchy(); } super.layout(); } }; pane.setTouchable(Touchable.childrenOnly); pane.setOverscroll(false, false); pane.setCancelTouchFocus(false); pane.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { pane.layout(); pane.layout(); items.layout(); if (actor instanceof Layout) ((Layout) actor).layout(); pane.layout(); pane.layout(); pane.scrollTo(actor.getX(), actor.getY(), actor.getWidth(), actor.getHeight() + 100); } }); Iterable<Die> dice = userData.dice(); int i = 1; int count = userData.diceCount(); for (Die die : dice) { DiePane diePane = new DiePane(die, userData, diceWindowGroup); table.add(diePane); diePane.setWidth(0); diePane.pack(); diePane.setWidth(ViewController.CELL_SIZE * 6.6f); Cell cell = items.add(diePane).fillX().maxWidth(ViewController.CELL_SIZE * 6.6f); if (i != count) { cell.padBottom(-1); } cell.row(); map.put(die, diePane); diePane.info.addListener(createMinimizeListener(die, dice)); i++; } items.pack(); table.add(pane).width(items.getPrefWidth());//.size(items.getPrefWidth(), 200); }