summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2019-12-17 09:49:26 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2019-12-17 09:49:26 +0100
commit92dc3d356a30f58f6857ac680803e5311f7a1e0c (patch)
tree2410d1aba60865e7c96ad18e02236ed882a90d1c
parentc4053722222805a2b134c704e50100fd36f8bf64 (diff)
downloadgdx-boardgame-92dc3d356a30f58f6857ac680803e5311f7a1e0c.zip
gdx-boardgame-92dc3d356a30f58f6857ac680803e5311f7a1e0c.tar.gz
ui.Element : add optional Alignment parameter to setParent(…)
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Button.java3
-rw-r--r--core/src/ch/asynk/gdx/boardgame/ui/Element.java6
2 files changed, 7 insertions, 2 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Button.java b/core/src/ch/asynk/gdx/boardgame/ui/Button.java
index 2b1638b..965e126 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Button.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Button.java
@@ -26,8 +26,7 @@ public class Button extends Patch
this.padding = padding;
this.spacing = spacing;
label = new Label(font);
- label.setParent(this);
- label.setAlignment(Alignment.MIDDLE_CENTER);
+ label.setParent(this, Alignment.MIDDLE_CENTER);
}
public void write(String text)
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Element.java b/core/src/ch/asynk/gdx/boardgame/ui/Element.java
index 615c345..e24498b 100644
--- a/core/src/ch/asynk/gdx/boardgame/ui/Element.java
+++ b/core/src/ch/asynk/gdx/boardgame/ui/Element.java
@@ -77,7 +77,13 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch
public void setParent(Element parent)
{
+ setParent(parent, null);
+ }
+
+ public void setParent(Element parent, Alignment alignment)
+ {
this.parent = parent;
+ if (alignment != null) this.alignment = alignment;
taint();
}