From b5dee2dc2d6efd124d2e26a3f1c96d28e55329e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 18 Dec 2019 10:27:18 +0100 Subject: ui.List : follow taint() computeGeometry() logic --- core/src/ch/asynk/gdx/boardgame/ui/List.java | 7 +++++++ test/src/ch/asynk/gdx/boardgame/test/UiScreen.java | 1 + 2 files changed, 8 insertions(+) diff --git a/core/src/ch/asynk/gdx/boardgame/ui/List.java b/core/src/ch/asynk/gdx/boardgame/ui/List.java index 19f08f2..e9f874a 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/List.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/List.java @@ -56,6 +56,11 @@ public class List extends Element { unselect(); this.items = items; + taint(); + } + + @Override public void computeGeometry() + { float w = 0f; for (Item e: items) { layout.setText(font, e.s()); @@ -65,12 +70,14 @@ public class List extends Element rect.width = w + (2 * padding); rect.height = (itemHeight * items.size()) + (2 * padding) - spacing; + super.computeGeometry(); } @Override public void draw(Batch batch) { if (!visible) return; + if (tainted) computeGeometry(); float x = getInnerX(); float y = getInnerTop(); for (Item e : items) { diff --git a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java index a0167dc..ec06a3f 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/UiScreen.java @@ -188,6 +188,7 @@ class MyList extends Patch // update dimensions title.computeGeometry(); + list.computeGeometry(); rect.width = title.getWidth() + pp; rect.height = title.getHeight() + pp + list.getHeight() + 15; if ((list.getWidth() + pp) > rect.width) rect.width = list.getWidth() + pp; -- cgit v1.1-2-g2b99