summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2020-05-13 15:27:08 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2020-05-13 15:27:08 +0200
commitc93fd2cf018184a1d2fc83977a84a29319af0dd1 (patch)
tree4848a0d5042d020273dd8abf2361f6fd289b4423
parent78f139da6fc8ebe4a1a2c3316404aa1b9460cab0 (diff)
downloadgdx-boardgame-c93fd2cf018184a1d2fc83977a84a29319af0dd1.zip
gdx-boardgame-c93fd2cf018184a1d2fc83977a84a29319af0dd1.tar.gz
UI : taint() does mark up, to mark down use Container.taintChildren()
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Container.java3
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Element.java11
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Root.java2
3 files changed, 4 insertions, 12 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Container.java b/core/src/ch/asynk/gdx/boardgame/ui/Container.java
index f12a15d..79e0c45 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Container.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Container.java
@@ -35,9 +35,8 @@ public class Container extends Element
}
}
- @Override public void taint()
+ public void taintChildren()
{
- super.taint();
if (children != null)
children.forEach( c -> c.taint() );
}
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Element.java b/core/src/ch/asynk/gdx/boardgame/ui/Element.java
index 5df6587..13b1d42 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Element.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Element.java
@@ -21,15 +21,9 @@ 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
- public boolean taintParent; // propagate tainted state up the tree
protected Element()
{
- this(false);
- }
-
- protected Element(boolean taintParent)
- {
this.blocked = false;
this.visible = true;
this.padding = 0;
@@ -38,8 +32,7 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch
this.alignment = alignment.RELATIVE;
this.rect = new Rectangle(0, 0, 0, 0);
this.x = this.y = 0;
- this.tainted = true;
- this.taintParent = taintParent;
+ taint();
}
@Override public final float getX() { return rect.x; }
@@ -81,7 +74,7 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch
public void taint()
{
this.tainted = true;
- if (parent != null && taintParent) parent.taint();
+ if (parent != null) parent.taint();
}
@Override public void setPosition(float x, float y, float w, float h)
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Root.java b/core/src/ch/asynk/gdx/boardgame/ui/Root.java
index c3ad0c3..dfa8e04 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Root.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Root.java
@@ -28,7 +28,7 @@ public class Root extends Container
public void resize(float x, float y, float width, float height)
{
setPosition(x, y, width, height);
- taint();
+ taintChildren();
}
public Element touched()