diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2019-12-26 21:41:39 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2019-12-26 21:41:39 +0100 |
commit | 97caa84105cceb98ec1253426e200858b4bcb9da (patch) | |
tree | dcb5590bec09f216cfbb44806f5eaab561eca9c0 /test | |
parent | 059f93fd23c46dd58a9a6e92491c108eec05e26c (diff) | |
download | gdx-boardgame-97caa84105cceb98ec1253426e200858b4bcb9da.zip gdx-boardgame-97caa84105cceb98ec1253426e200858b4bcb9da.tar.gz |
ui : add Sizing, final computeGeometry() calls computeDimensions() and computePosition()
Diffstat (limited to 'test')
-rw-r--r-- | test/src/ch/asynk/gdx/boardgame/test/UiScreen.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java index e8aea09..e0fcaf4 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java @@ -10,6 +10,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera; import ch.asynk.gdx.boardgame.ui.Alignment; import ch.asynk.gdx.boardgame.ui.Button; +import ch.asynk.gdx.boardgame.ui.Element; import ch.asynk.gdx.boardgame.ui.Label; import ch.asynk.gdx.boardgame.ui.List; import ch.asynk.gdx.boardgame.ui.Patch; @@ -46,6 +47,8 @@ public class UiScreen extends AbstractScreen { super(app, "UiScreen"); + Element.DEBUG_GEOMETRY = true; + final NinePatch patch = app.assets.getNinePatch(app.assets.PATCH, 23, 23, 23 ,23); final BitmapFont font = app.assets.getFont(app.assets.FONT_25); @@ -97,6 +100,7 @@ public class UiScreen extends AbstractScreen app.switchToMenu(); break; } + System.err.println("switched to : " + state); this.state = state; } @@ -150,9 +154,9 @@ class MyButton extends Button super(font, patch, padding, spacing); } - @Override public void computeGeometry() + @Override public void computePosition() { - super.computeGeometry(); + super.computePosition(); label.write(String.format("%04d;%04d", (int)getX(), (int)getY())); } } @@ -194,17 +198,18 @@ class MyList extends Patch this.scrollable.hScroll = true; } - @Override public void computeGeometry() + @Override public void computeDimensions() { - // update dimensions - title.computeGeometry(); - scrollable.computeGeometry(); + title.computeDimensions(); + scrollable.computeDimensions(); rect.height = 300; rect.width = scrollable.getBestWidth() + (2 * padding) - 100; + } - // update position - super.computeGeometry(); - title.computeGeometry(); + @Override public void computePosition() + { + super.computePosition(); + title.computePosition(); scrollable.setPosition(getInnerX(), getInnerY(), getInnerWidth(), getInnerHeight() - title.getHeight() - 15); } |