summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/gdx/boardgame
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/gdx/boardgame')
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/List.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/List.java b/core/src/ch/asynk/gdx/boardgame/ui/List.java
index 0c40a7b..3ed5985 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/List.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/List.java
@@ -30,6 +30,7 @@ public class List extends Element
this.layout = new GlyphLayout();
this.idx = null;
this.selected = new Bg(selected);
+ this.selected.setParent(this);
this.selected.visible = false;
this.sizing = Sizing.EXPAND_BOTH;
}
@@ -42,10 +43,13 @@ public class List extends Element
{
final Element touched = super.touch(x, y);
if (touched != null) {
- idx = (int) Math.floor((getInnerTop() - y) / itemHeight);
- if ((idx >= 0) && (idx < items.size())) {
- selected.setPosition(getX(), getInnerTop() - ((idx + 1) * itemHeight) + spacing / 2f, getWidth(), itemHeight);
- selected.visible = true;
+ int i = (int) Math.floor((getInnerTop() - y) / itemHeight);
+ if (i >= 0 && i < items.size()) {
+ if (idx == null || idx != i) {
+ idx = i;
+ selected.setPosition(0, getInnerHeight() - ((idx + 1) * itemHeight) + spacing / 2f, getWidth(), itemHeight);
+ selected.visible = true;
+ }
return touched;
}
}
@@ -81,6 +85,12 @@ public class List extends Element
}
}
+ @Override public void computePosition()
+ {
+ super.computePosition();
+ selected.computePosition();
+ }
+
@Override public void draw(Batch batch)
{
if (!visible) return;