OSDN Git Service

Actor, isAscendant isDescendant methods renamed to be more clear. It was confusing...
authorNathanSweet <nathan.sweet@gmail.com>
Wed, 5 Sep 2012 18:55:56 +0000 (11:55 -0700)
committerNathanSweet <nathan.sweet@gmail.com>
Wed, 5 Sep 2012 18:55:56 +0000 (11:55 -0700)
gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/TextButton.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Tree.java
gdx/src/com/badlogic/gdx/scenes/scene2d/utils/ClickListener.java
gdx/src/com/badlogic/gdx/scenes/scene2d/utils/DragAndDrop.java

index e8b73d4..7b75f79 100644 (file)
@@ -245,8 +245,8 @@ public class Actor {
                this.stage = stage;\r
        }\r
 \r
-       /** Returns true if the specified actor is this actor or a descendant of this actor. */\r
-       public boolean isDescendant (Actor actor) {\r
+       /** Returns true if this actor is the same as or is the descendant of the specified actor. */\r
+       public boolean isDescendantOf (Actor actor) {\r
                if (actor == null) throw new IllegalArgumentException("actor cannot be null.");\r
                Actor parent = this;\r
                while (true) {\r
@@ -256,8 +256,8 @@ public class Actor {
                }\r
        }\r
 \r
-       /** Returns true if the specified actor is this actor or an ancestor of this actor. */\r
-       public boolean isAscendant (Actor actor) {\r
+       /** Returns true if this actor is the same as or is the ascendant of the specified actor. */\r
+       public boolean isAscendantOf (Actor actor) {\r
                if (actor == null) throw new IllegalArgumentException("actor cannot be null.");\r
                while (true) {\r
                        if (actor == null) return false;\r
index 5dfda92..e35d0b9 100644 (file)
@@ -203,6 +203,18 @@ public class Table extends WidgetGroup {
                return add(new Label(text, skin.get(labelStyleName, LabelStyle.class)));\r
        }\r
 \r
+       /** Adds a new cell with a label. This may only be called if {@link Table#Table(Skin)} or {@link #setSkin(Skin)} was used. */\r
+       public Cell add (String text, String fontName, Color color) {\r
+               if (skin == null) throw new IllegalStateException("Table must have a skin set to use this method.");\r
+               return add(new Label(text, new LabelStyle(skin.getFont(fontName), color)));\r
+       }\r
+\r
+       /** Adds a new cell with a label. This may only be called if {@link Table#Table(Skin)} or {@link #setSkin(Skin)} was used. */\r
+       public Cell add (String text, String fontName, String colorName) {\r
+               if (skin == null) throw new IllegalStateException("Table must have a skin set to use this method.");\r
+               return add(new Label(text, new LabelStyle(skin.getFont(fontName), skin.getColor(colorName))));\r
+       }\r
+\r
        /** Adds a cell without a widget. */\r
        public Cell add () {\r
                return layout.add(null);\r
index 35e8011..253f1b6 100644 (file)
@@ -32,10 +32,12 @@ public class TextButton extends Button {
 \r
        public TextButton (String text, Skin skin) {\r
                this(text, skin.get(TextButtonStyle.class));\r
+               setSkin(skin);\r
        }\r
 \r
        public TextButton (String text, Skin skin, String styleName) {\r
                this(text, skin.get(styleName, TextButtonStyle.class));\r
+               setSkin(skin);\r
        }\r
 \r
        public TextButton (String text, TextButtonStyle style) {\r
index 759a603..53589d6 100644 (file)
@@ -92,7 +92,7 @@ public class Tree extends WidgetGroup {
 \r
                        public void exit (InputEvent event, float x, float y, int pointer, Actor toActor) {\r
                                super.exit(event, x, y, pointer, toActor);\r
-                               if (toActor == null || !toActor.isDescendant(Tree.this)) setOverNode(null);\r
+                               if (toActor == null || !toActor.isDescendantOf(Tree.this)) setOverNode(null);\r
                        }\r
                });\r
        }\r
index 5f76cb4..1c6d8cf 100644 (file)
@@ -109,7 +109,7 @@ public class ClickListener extends InputListener {
        /** Returns true if the specified position is over the specified actor or within the tap square. */\r
        public boolean isOver (Actor actor, float x, float y) {\r
                Actor hit = actor.hit(x, y, true);\r
-               if (hit == null || !hit.isDescendant(actor)) {\r
+               if (hit == null || !hit.isDescendantOf(actor)) {\r
                        if (touchDownX == -1 && touchDownY == -1) return false;\r
                        return Math.abs(x - touchDownX) < tapSquareSize && Math.abs(y - touchDownY) < tapSquareSize;\r
                }\r
index ecdeba1..b33bf09 100644 (file)
@@ -45,7 +45,7 @@ public class DragAndDrop {
                                if (hit != null) {
                                        for (int i = 0, n = targets.size; i < n; i++) {
                                                Target target = targets.get(i);
-                                               if (!target.actor.isAscendant(hit)) continue;
+                                               if (!target.actor.isAscendantOf(hit)) continue;
                                                newTarget = target;
                                                target.actor.stageToLocalCoordinates(Vector2.tmp.set(event.getStageX(), event.getStageY()));
                                                isValidTarget = target.drag(source, payload, Vector2.tmp.x, Vector2.tmp.y, pointer);