diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-19 16:39:10 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-19 16:39:10 +0100 |
commit | 5453479d03a9f2852a5c623ab58454dbd417ed6b (patch) | |
tree | 263c9bb33b39cb6625bf51906a7af9c06b1acc2e /core/src/ch/asynk/rustanddust/ui | |
parent | 3f565c31f0738b40e41471d33cb693da5d315056 (diff) | |
download | RustAndDust-5453479d03a9f2852a5c623ab58454dbd417ed6b.zip RustAndDust-5453479d03a9f2852a5c623ab58454dbd417ed6b.tar.gz |
Widget: add setTop/BottomRight/Left()
Diffstat (limited to 'core/src/ch/asynk/rustanddust/ui')
-rw-r--r-- | core/src/ch/asynk/rustanddust/ui/OkCancel.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/ui/Patch.java | 10 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/ui/Widget.java | 20 |
3 files changed, 22 insertions, 12 deletions
diff --git a/core/src/ch/asynk/rustanddust/ui/OkCancel.java b/core/src/ch/asynk/rustanddust/ui/OkCancel.java index 7b0bd1c..5036995 100644 --- a/core/src/ch/asynk/rustanddust/ui/OkCancel.java +++ b/core/src/ch/asynk/rustanddust/ui/OkCancel.java @@ -55,8 +55,8 @@ public class OkCancel extends Patch float y = position.getY(height); setPosition(x, y, width, height); - setBtnRight(okBtn); - setBtnLeft(cancelBtn); + setBottomRight(okBtn); + setBottomLeft(cancelBtn); label.setPosition((x + PADDING), (y + PADDING + okBtn.getHeight() + VSPACING)); cancelBtn.visible = true; visible = true; diff --git a/core/src/ch/asynk/rustanddust/ui/Patch.java b/core/src/ch/asynk/rustanddust/ui/Patch.java index f07c44d..acff791 100644 --- a/core/src/ch/asynk/rustanddust/ui/Patch.java +++ b/core/src/ch/asynk/rustanddust/ui/Patch.java @@ -25,14 +25,4 @@ public class Patch extends Widget if (!visible) return; patch.draw(batch, rect.x, rect.y, rect.width, rect.height); } - - public void setBtnRight(Bg btn) - { - btn.setPosition((rect.x + rect.width - (btn.getWidth() * 0.666f)), (rect.y - (btn.getHeight() * 0.333f))); - } - - public void setBtnLeft(Bg btn) - { - btn.setPosition((rect.x - (btn.getWidth() * 0.333f)), (rect.y - (btn.getHeight() * 0.333f))); - } } diff --git a/core/src/ch/asynk/rustanddust/ui/Widget.java b/core/src/ch/asynk/rustanddust/ui/Widget.java index 38a89ae..a776cf7 100644 --- a/core/src/ch/asynk/rustanddust/ui/Widget.java +++ b/core/src/ch/asynk/rustanddust/ui/Widget.java @@ -80,6 +80,26 @@ public abstract class Widget implements Disposable, Drawable setPosition(x, y); } + public void setTopRight(Widget btn) + { + btn.setPosition((getX() + getWidth() - (btn.getWidth() * 0.666f)), (getTop() - (btn.getHeight() * 0.666f))); + } + + public void setTopLeft(Widget btn) + { + btn.setPosition((getX() - (btn.getWidth() * 0.333f)), (getTop() - (btn.getHeight() * 0.666f))); + } + + public void setBottomRight(Widget btn) + { + btn.setPosition((getX() + getWidth() - (btn.getWidth() * 0.666f)), (getY() - (btn.getHeight() * 0.333f))); + } + + public void setBottomLeft(Widget btn) + { + btn.setPosition((getX() - (btn.getWidth() * 0.333f)), (getY() - (btn.getHeight() * 0.333f))); + } + public boolean hit(float x, float y) { if (blocked || !visible) return false; |