\r
import com.badlogic.gdx.Gdx;\r
import com.badlogic.gdx.graphics.GL10;\r
+import com.badlogic.gdx.scenes.scene2d.Actor;\r
import com.badlogic.gdx.scenes.scene2d.Stage;\r
import com.badlogic.gdx.scenes.scene2d.ui.Label;\r
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;\r
import com.badlogic.gdx.scenes.scene2d.ui.Skin;\r
import com.badlogic.gdx.scenes.scene2d.ui.Table;\r
+import com.badlogic.gdx.scenes.scene2d.ui.TextButton;\r
+import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;\r
import com.badlogic.gdx.tests.utils.GdxTest;\r
+import com.badlogic.gdx.utils.Array;\r
\r
-/**\r
- * Test switch of scroll bars + knobs from right to left, and bottom to top\r
- */\r
+/** Test switch of scroll bars + knobs from right to left, and bottom to top */\r
public class ScrollPaneScrollBarsTest extends GdxTest {\r
private Stage stage;\r
- private Table bottomLeft, bottomRight, topLeft, topRight,\r
- horizOnlyTop, horizOnlyBottom, vertOnlyLeft, vertOnlyRight;\r
+ private Array<ScrollPane> scrollPanes = new Array<ScrollPane>();\r
+ private boolean doFade = true;\r
+ private boolean doOnTop = true;\r
+ private Table bottomLeft, bottomRight, topLeft, topRight, horizOnlyTop, horizOnlyBottom, vertOnlyLeft, vertOnlyRight;\r
\r
public void create () {\r
+ float width = Gdx.graphics.getWidth();\r
+ float height = Gdx.graphics.getHeight();\r
+ float btnWidth = 200;\r
+ float btnHeight = 40;\r
stage = new Stage(0, 0, false);\r
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));\r
Gdx.input.setInputProcessor(stage);\r
\r
+ final TextButton fadeBtn = new TextButton("Fade: " + doFade, skin);\r
+ fadeBtn.setSize(btnWidth, btnHeight);\r
+ fadeBtn.setPosition(0, height - fadeBtn.getHeight());\r
+ stage.addActor(fadeBtn);\r
+ fadeBtn.addListener(new ChangeListener() {\r
+ @Override\r
+ public void changed (ChangeEvent event, Actor actor) {\r
+ doFade = !doFade;\r
+ fadeBtn.setText("Fade: " + doFade);\r
+ for (ScrollPane pane : scrollPanes) {\r
+ pane.setFadeScrollBars(doFade);\r
+ }\r
+ }\r
+ });\r
+\r
+ final TextButton onTopBtn = new TextButton("ScrollbarsOnTop: " + doOnTop, skin);\r
+ onTopBtn.setSize(btnWidth, btnHeight);\r
+ onTopBtn.setPosition(0 + fadeBtn.getWidth() + 20, height - onTopBtn.getHeight());\r
+ stage.addActor(onTopBtn);\r
+ onTopBtn.addListener(new ChangeListener() {\r
+ @Override\r
+ public void changed (ChangeEvent event, Actor actor) {\r
+ doOnTop = !doOnTop;\r
+ onTopBtn.setText("ScrollbarOnTop: " + doOnTop);\r
+ onTopBtn.invalidate();\r
+ for (ScrollPane pane : scrollPanes) {\r
+ pane.setScrollbarsOnTop(doOnTop);\r
+ }\r
+ }\r
+ });\r
+\r
// Gdx.graphics.setVSync(false);\r
\r
- float width = Gdx.graphics.getWidth();\r
- float height = Gdx.graphics.getHeight();\r
float gap = 8;\r
float x = gap;\r
float y = gap;\r
float contWidth = width / 2 - gap * 1.5f;\r
- float contHeight = height / 4 - gap * 1.25f;\r
+ float contHeight = height / 4.5f - gap * 1.25f;\r
\r
bottomLeft = new Table();\r
bottomLeft.setPosition(x, y);\r
bottomLeft.setSize(contWidth, contHeight);\r
stage.addActor(bottomLeft);\r
- \r
+\r
bottomRight = new Table();\r
bottomRight.setSize(contWidth, contHeight);\r
x = bottomLeft.getX() + bottomLeft.getWidth() + gap;\r
y = topLeft.getY();\r
topRight.setPosition(x, y);\r
stage.addActor(topRight);\r
- \r
+\r
horizOnlyTop = new Table();\r
horizOnlyTop.setSize(contWidth, contHeight);\r
x = topRight.getX();\r
y = topRight.getY() + topRight.getHeight() + gap;\r
horizOnlyTop.setPosition(x, y);\r
stage.addActor(horizOnlyTop);\r
- \r
+\r
horizOnlyBottom = new Table();\r
horizOnlyBottom.setSize(contWidth, contHeight);\r
x = topLeft.getX();\r
Table vertOnlyRightTable = new Table();\r
\r
final ScrollPane bottomLeftScroll = new ScrollPane(bottomLeftTable, skin);\r
- bottomLeftScroll.setVScrollBarAtRight(false);\r
- bottomLeftScroll.setHScrollBarAtBottom(true);\r
+ bottomLeftScroll.setScrollBarPositions(true, false);\r
\r
final ScrollPane bottomRightScroll = new ScrollPane(bottomRightTable, skin);\r
- bottomRightScroll.setVScrollBarAtRight(true);\r
- bottomRightScroll.setHScrollBarAtBottom(true);\r
+ bottomRightScroll.setScrollBarPositions(true, true);\r
\r
final ScrollPane topLeftScroll = new ScrollPane(topLeftTable, skin);\r
- topLeftScroll.setVScrollBarAtRight(false);\r
- topLeftScroll.setHScrollBarAtBottom(false);\r
+ topLeftScroll.setScrollBarPositions(false, false);\r
\r
final ScrollPane topRightScroll = new ScrollPane(topRightTable, skin);\r
- topRightScroll.setVScrollBarAtRight(true);\r
- topRightScroll.setHScrollBarAtBottom(false);\r
- \r
+ topRightScroll.setScrollBarPositions(false, true);\r
+\r
final ScrollPane horizOnlyTopScroll = new ScrollPane(horizOnlyTopTable, skin);\r
- horizOnlyTopScroll.setHScrollBarAtBottom(false);\r
- \r
+ horizOnlyTopScroll.setScrollBarPositions(false, true);\r
+\r
final ScrollPane horizOnlyBottomScroll = new ScrollPane(horizOnlyBottomTable, skin);\r
- horizOnlyBottomScroll.setHScrollBarAtBottom(true);\r
+ horizOnlyBottomScroll.setScrollBarPositions(true, true);\r
\r
final ScrollPane vertOnlyLeftScroll = new ScrollPane(vertOnlyLeftTable, skin);\r
- vertOnlyLeftScroll.setVScrollBarAtRight(false);\r
+ vertOnlyLeftScroll.setScrollBarPositions(true, false);\r
\r
final ScrollPane vertOnlyRightScroll = new ScrollPane(vertOnlyRightTable, skin);\r
- vertOnlyRightScroll.setVScrollBarAtRight(true);\r
- \r
- ScrollPane[] scrollPanes = new ScrollPane[] {\r
- bottomLeftScroll, bottomRightScroll, topLeftScroll, topRightScroll,\r
- horizOnlyTopScroll, horizOnlyBottomScroll,\r
- vertOnlyLeftScroll, vertOnlyRightScroll\r
- };\r
- // want to see all scroll bars all the time\r
- for (ScrollPane pane : scrollPanes) {\r
- pane.setFadeScrollBars(false);\r
+ vertOnlyRightScroll.setScrollBarPositions(true, true);\r
+\r
+ ScrollPane[] panes = new ScrollPane[] {bottomLeftScroll, bottomRightScroll, topLeftScroll, topRightScroll,\r
+ horizOnlyTopScroll, horizOnlyBottomScroll, vertOnlyLeftScroll, vertOnlyRightScroll};\r
+ for (ScrollPane pane : panes) {\r
+ scrollPanes.add(pane);\r
}\r
\r
- Table[] tables = new Table[] { \r
- bottomLeftTable, bottomRightTable, topLeftTable, topRightTable,\r
- horizOnlyTopTable, horizOnlyBottomTable,\r
- vertOnlyLeftTable, vertOnlyRightTable\r
- };\r
+ Table[] tables = new Table[] {bottomLeftTable, bottomRightTable, topLeftTable, topRightTable, horizOnlyTopTable,\r
+ horizOnlyBottomTable, vertOnlyLeftTable, vertOnlyRightTable};\r
for (Table t : tables) {\r
t.pad(10).defaults().expandX().space(4);\r
}\r
- \r
- horizOnlyTopTable.add(new Label("HORIZONTAL-ONLY-TOP verify HORIZONTAL scroll bar is on the TOP and properly aligned", skin));\r
- horizOnlyBottomTable.add(new Label("HORIZONTAL-ONLY-BOTTOM verify HORIZONTAL scroll bar is on the BOTTOM and properly aligned", skin));\r
- \r
+\r
+ horizOnlyTopTable\r
+ .add(new Label("HORIZONTAL-ONLY-TOP verify HORIZONTAL scroll bar is on the TOP and properly aligned", skin));\r
+ horizOnlyBottomTable.add(new Label(\r
+ "HORIZONTAL-ONLY-BOTTOM verify HORIZONTAL scroll bar is on the BOTTOM and properly aligned", skin));\r
+\r
for (int i = 0; i < 12; i++) {\r
bottomLeftTable.row();\r
bottomRightTable.row();\r
topLeftTable.row();\r
- topRightTable.row(); \r
+ topRightTable.row();\r
\r
- bottomLeftTable.add(new Label(i + " BOTTOM-LEFT verify scroll bars are on the BOTTOM and the LEFT, and are properly aligned", skin));\r
- bottomRightTable.add(new Label(i + " BOTTOM-RIGHT verify scroll bars are on the BOTTOM and the RIGHT, and are properly aligned", skin));\r
- topLeftTable.add(new Label(i + " TOP-LEFT verify scroll bars are on the TOP and the LEFT, and are properly aligned", skin));\r
- topRightTable.add(new Label(i + " TOP-RIGHT verify scroll bars are on the TOP and the RIGHT, and are properly aligned", skin));\r
+ bottomLeftTable.add(new Label(i\r
+ + " BOTTOM-LEFT verify scroll bars are on the BOTTOM and the LEFT, and are properly aligned", skin));\r
+ bottomRightTable.add(new Label(i\r
+ + " BOTTOM-RIGHT verify scroll bars are on the BOTTOM and the RIGHT, and are properly aligned", skin));\r
+ topLeftTable.add(new Label(i + " TOP-LEFT verify scroll bars are on the TOP and the LEFT, and are properly aligned",\r
+ skin));\r
+ topRightTable.add(new Label(i + " TOP-RIGHT verify scroll bars are on the TOP and the RIGHT, and are properly aligned",\r
+ skin));\r
\r
vertOnlyLeftTable.row();\r
vertOnlyRightTable.row();\r
\r
vertOnlyLeftTable.add(new Label("VERT-ONLY-LEFT", skin));\r
vertOnlyRightTable.add(new Label("VERT-ONLY-RIGHT", skin));\r
- } \r
+ }\r
\r
bottomLeft.add(bottomLeftScroll).expand().fill().colspan(4);\r
bottomRight.add(bottomRightScroll).expand().fill().colspan(4);\r