From 8e313b2a0df743045dc5d3a45993b86d0b19f894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 12 Feb 2016 16:53:50 +0100 Subject: Widget: all positioning calls go through setPosition(int, int, int, int) --- core/src/ch/asynk/rustanddust/ui/Widget.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/ui/Widget.java b/core/src/ch/asynk/rustanddust/ui/Widget.java index 4ae8afd..8dfa029 100644 --- a/core/src/ch/asynk/rustanddust/ui/Widget.java +++ b/core/src/ch/asynk/rustanddust/ui/Widget.java @@ -38,15 +38,15 @@ public abstract class Widget implements Disposable, Drawable public void setPosition(Rectangle r) { - rect.set(r); + rect.set(r.x, r.x, r.width, r.height); } public void setPosition(float x, float y) { - rect.x = x; - rect.y = y; + rect.set(x, y, rect.width, rect.height); } + // override this if needed public void setPosition(float x, float y, float w, float h) { rect.set(x, y, w, h); @@ -54,8 +54,7 @@ public abstract class Widget implements Disposable, Drawable public void setPosition(Position position) { - this.position = position; - setParent(this.parent); + setPosition(position, this.parent); } public void setPosition(Position position, Widget parent) @@ -75,7 +74,7 @@ public abstract class Widget implements Disposable, Drawable rect.y = position.getY(parent, rect.height); } // might trigger something if overriden - setPosition(rect.x, rect.y); + setPosition(rect.x, rect.y, rect.width, rect.height); } public boolean hit(float x, float y) -- cgit v1.1-2-g2b99