summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/gdx/boardgame/Touchable.java1
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Assembly.java14
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Element.java6
3 files changed, 20 insertions, 1 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/Touchable.java b/core/src/ch/asynk/gdx/boardgame/Touchable.java
index 0fd99d0..fab7ab9 100644
--- a/core/src/ch/asynk/gdx/boardgame/Touchable.java
+++ b/core/src/ch/asynk/gdx/boardgame/Touchable.java
@@ -3,4 +3,5 @@ package ch.asynk.gdx.boardgame;
public interface Touchable
{
public boolean touch(float x, float y);
+ public boolean drag(float x, float y, int dx, int dy);
}
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java b/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java
index 6754518..866c3dd 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java
@@ -41,15 +41,27 @@ public abstract class Assembly extends Element
@Override public boolean touch(float x, float y)
{
- for (Element e : children)
+ for (Element e : children) {
if (e.touch(x, y)) {
touched = e;
return true;
}
+
+ }
touched = null;
return false;
}
+ @Override public boolean drag(float x, float y, int dx, int dy)
+ {
+ if (touched != null) {
+ if (touched.drag(x, y, dx, dy))
+ return true;
+ touched = null;
+ }
+ return false;
+ }
+
@Override public void draw(Batch batch)
{
if (tainted) computeGeometry();
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Element.java b/core/src/ch/asynk/gdx/boardgame/ui/Element.java
index 3368f3c..dec0cc7 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Element.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Element.java
@@ -83,6 +83,12 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch
return rect.contains(x, y);
}
+ @Override public boolean drag(float x, float y, int dx, int dy)
+ {
+ if (blocked || !visible) return false;
+ return rect.contains(x, y);
+ }
+
public void taint()
{
this.tainted = true;