diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/ui/Button.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/ui/Element.java | 11 | ||||
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/ui/Label.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/ui/Menu.java | 10 | ||||
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/utils/Collection.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java | 3 |
6 files changed, 16 insertions, 14 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Button.java b/core/src/ch/asynk/gdx/boardgame/ui/Button.java index 9bc1149..2b1638b 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/Button.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/Button.java @@ -33,7 +33,7 @@ public class Button extends Patch public void write(String text) { label.write(text); - this.tainted = true; // might impact Button's geometry + taint(); // might impact Button's geometry } public void setLabelAlignment(Alignment alignment) diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Element.java b/core/src/ch/asynk/gdx/boardgame/ui/Element.java index 4b2d7fb..63e2e29 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/Element.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/Element.java @@ -18,6 +18,7 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch protected Rectangle rect; // outer drawing coordinates protected float x, y; // given position protected boolean tainted; // geometry must be computed + protected boolean taintParent; // propagate tainted state up the tree protected Element() { @@ -29,6 +30,7 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch this.rect = new Rectangle(0, 0, 0, 0); this.x = this.y = 0; this.tainted = true; + this.taintParent= false; } @Override public final float getX() { return rect.x; } @@ -55,6 +57,7 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch public void taint() { this.tainted = true; + if (parent != null && taintParent) parent.taint(); } @Override public void setPosition(float x, float y, float w, float h) @@ -63,26 +66,26 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch this.y = y; this.rect.width = w; this.rect.height = h; - this.tainted = true; + taint(); // rect.(x,y) will be set in computeGeometry } public void setParent(Element parent) { this.parent = parent; - this.tainted = true; + taint(); } @Override public void setPadding(float padding) { this.padding = padding; - this.tainted = true; + taint(); } public void setAlignment(Alignment alignment) { this.alignment = alignment; - this.tainted = true; + taint(); } @Override public final void centerOn(float cx, float cy) diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Label.java b/core/src/ch/asynk/gdx/boardgame/ui/Label.java index 96981a5..190dd83 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/Label.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/Label.java @@ -40,7 +40,7 @@ public class Label extends Element { this.text = text; this.layout.setText(font, (text == null) ? "" : text); - this.tainted = true; + taint(); } @Override public void computeGeometry() diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Menu.java b/core/src/ch/asynk/gdx/boardgame/ui/Menu.java index aa62483..68f65c5 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/Menu.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/Menu.java @@ -26,7 +26,7 @@ public class Menu extends Patch { this.title = new Label(font); this.title.write(title); - this.tainted = true; + taint(); } public void setEntries(BitmapFont font, String[] entries) @@ -37,13 +37,13 @@ public class Menu extends Patch l.write(entries[i]); this.entries[i] = l; } - this.tainted = true; + taint(); } public void setLabelsOffset(int entriesOffset) { this.entriesOffset = entriesOffset; - this.tainted = true; + taint(); } public void setPaddings(int titlePadding, int labelPadding) @@ -52,14 +52,14 @@ public class Menu extends Patch for (Label label : entries) { label.setPadding(labelPadding); } - this.tainted = true; + taint(); } public void setSpacings(int titleSpacing, int entriesSpacing) { this.titleSpacing = titleSpacing; this.entriesSpacing = entriesSpacing; - this.tainted = true; + taint(); } @Override public void computeGeometry() diff --git a/core/src/ch/asynk/gdx/boardgame/utils/Collection.java b/core/src/ch/asynk/gdx/boardgame/utils/Collection.java index b546217..220e4c7 100644 --- a/core/src/ch/asynk/gdx/boardgame/utils/Collection.java +++ b/core/src/ch/asynk/gdx/boardgame/utils/Collection.java @@ -2,7 +2,7 @@ package ch.asynk.gdx.boardgame.utils; import java.util.Iterator; -public interface Collection<E> extends Iterator, Iterable<E> +public interface Collection<E> extends Iterator<E>, Iterable<E> { public int size(); diff --git a/core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java b/core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java index 1edf84f..f592baa 100644 --- a/core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java +++ b/core/src/ch/asynk/gdx/boardgame/utils/IterableArray.java @@ -116,11 +116,10 @@ public class IterableArray<E> implements Collection<E> return false; } - @SuppressWarnings("unchecked") @Override public Iterator<E> iterator() { this.idx = 0; - return (Iterator<E>) this; + return this; } @Override public boolean hasNext() |