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/Bg.java4
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Button.java8
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Container.java4
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Element.java19
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Label.java4
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/List.java4
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Menu.java10
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Patch.java4
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java3
9 files changed, 26 insertions, 34 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Bg.java b/core/src/ch/asynk/gdx/boardgame/ui/Bg.java
index ba0385e..e7519b8 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Bg.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Bg.java
@@ -13,10 +13,8 @@ public class Bg extends Element
rect.set(0, 0, region.getRegionWidth(), region.getRegionHeight());
}
- @Override public void draw(Batch batch)
+ @Override public void drawReal(Batch batch)
{
- if (!visible) return;
- if (dirty) computeGeometry();
batch.draw(region, rect.x, rect.y, rect.width, rect.height);
}
}
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Button.java b/core/src/ch/asynk/gdx/boardgame/ui/Button.java
index 6798ea6..46232ba 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Button.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Button.java
@@ -55,12 +55,10 @@ public class Button extends Patch
label.computePosition();
}
- @Override public void draw(Batch batch)
+ @Override public void drawReal(Batch batch)
{
- if (!visible) return;
- if (dirty) computeGeometry();
- super.draw(batch);
- label.draw(batch);
+ super.drawReal(batch);
+ label.drawReal(batch);
}
@Override public void drawDebug(ShapeRenderer shapeRenderer)
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Container.java b/core/src/ch/asynk/gdx/boardgame/ui/Container.java
index 8225d1e..ab6b781 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Container.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Container.java
@@ -44,10 +44,8 @@ public class Container extends Element
children.forEach( c -> c.drip() );
}
- @Override public void draw(Batch batch)
+ @Override public void drawReal(Batch batch)
{
- if (!visible) return;
- if (dirty) computeGeometry();
if (children != null)
children.forEach( c -> c.draw(batch) );
}
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Element.java b/core/src/ch/asynk/gdx/boardgame/ui/Element.java
index 6d6fad1..b7604f6 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Element.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Element.java
@@ -1,5 +1,6 @@
package ch.asynk.gdx.boardgame.ui;
+import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Rectangle;
@@ -197,13 +198,19 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch
if (DEBUG_GEOMETRY) System.err.println(" pos " + print(-1));
}
- public final void computeGeometry()
+ public abstract void drawReal(Batch batch);
+
+ @Override public void draw(Batch batch)
{
- if (DEBUG_GEOMETRY) { print("[Geometry"); System.err.println(" --> " + print(-1)); }
- computeDimensions();
- computePosition();
- clear();
- if (DEBUG_GEOMETRY) System.err.println("Geometry]");
+ if (!visible) return;
+ if (dirty) {
+ if (DEBUG_GEOMETRY) { print("[Geometry"); System.err.println(" --> " + print(-1)); }
+ computeDimensions();
+ computePosition();
+ clear();
+ if (DEBUG_GEOMETRY) System.err.println("Geometry]");
+ }
+ drawReal(batch);
}
@Override public void drawDebug(ShapeRenderer shapeRenderer)
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Label.java b/core/src/ch/asynk/gdx/boardgame/ui/Label.java
index 779554b..4ff4789 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Label.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Label.java
@@ -59,10 +59,8 @@ public class Label extends Element
if (DEBUG_GEOMETRY) System.err.println(" dim " + print(-1));
}
- @Override public void draw(Batch batch)
+ @Override public void drawReal(Batch batch)
{
- if (!visible) return;
- if (dirty) computeGeometry();
font.draw(batch, layout, getInnerX(), getInnerY() + layout.height);
}
}
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/List.java b/core/src/ch/asynk/gdx/boardgame/ui/List.java
index 16a6aef..2d84a94 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/List.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/List.java
@@ -84,10 +84,8 @@ public class List extends Element
if (DEBUG_GEOMETRY) System.err.println(" pos " + print(-1));
}
- @Override public void draw(Batch batch)
+ @Override public void drawReal(Batch batch)
{
- if (!visible) return;
- if (dirty) computeGeometry();
float x = getInnerX();
float y = getInnerTop();
for (Item e : items) {
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Menu.java b/core/src/ch/asynk/gdx/boardgame/ui/Menu.java
index be14951..2c0c429 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Menu.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Menu.java
@@ -116,14 +116,12 @@ public class Menu extends Patch
return null;
}
- @Override public void draw(Batch batch)
+ @Override public void drawReal(Batch batch)
{
- if (!visible) return;
- if (dirty) computeGeometry();
- super.draw(batch);
- title.draw(batch);
+ super.drawReal(batch);
+ title.drawReal(batch);
for (Label label : entries) {
- label.draw(batch);
+ label.drawReal(batch);
}
}
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Patch.java b/core/src/ch/asynk/gdx/boardgame/ui/Patch.java
index cd71bb9..9cd4f56 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Patch.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Patch.java
@@ -14,10 +14,8 @@ public class Patch extends Element
setPosition(0, 0, patch.getTotalWidth(), patch.getTotalHeight());
}
- @Override public void draw(Batch batch)
+ @Override public void drawReal(Batch batch)
{
- if (!visible) return;
- if (dirty) computeGeometry();
patch.draw(batch, getX(), getY(), getWidth(), getHeight());
}
}
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java b/core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java
index abc0e27..b5f55f4 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Scrollable.java
@@ -97,9 +97,8 @@ public class Scrollable extends Element
scissorIdx = Scissors.compute(scissorIdx, clip);
}
- @Override public void draw(Batch batch)
+ @Override public void drawReal(Batch batch)
{
- if (!visible) return;
batch.flush();
Rectangle scissor = Scissors.get(scissorIdx, clip);
HdpiUtils.glScissor((int)scissor.x, (int)scissor.y, (int)scissor.width, (int)scissor.height);