OSDN Git Service

scene2d, changed semantics of Stage#clear() and Group#clear(), added clearChildren...
authorNathanSweet <nathan.sweet@gmail.com>
Tue, 19 Feb 2013 14:49:08 +0000 (15:49 +0100)
committerNathanSweet <nathan.sweet@gmail.com>
Tue, 19 Feb 2013 14:49:08 +0000 (15:49 +0100)
gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java
gdx/src/com/badlogic/gdx/scenes/scene2d/Group.java
gdx/src/com/badlogic/gdx/scenes/scene2d/Stage.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/CheckBox.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Tree.java

index 8d729d1..d3a07fe 100644 (file)
@@ -31,23 +31,21 @@ import com.badlogic.gdx.utils.DelayedRemovalArray;
 import com.badlogic.gdx.utils.GdxRuntimeException;\r
 import com.badlogic.gdx.utils.Pools;\r
 \r
-/** 2D scene graph node. An actor has a position, rectangular size, origin, scale, rotation, Z index, and color. The position corresponds to\r
- * the unrotated, unscaled bottom left corner of the actor. The position is relative to the actor's parent. The origin is relative\r
- * to the position and is used for scale and rotation.\r
+/** 2D scene graph node. An actor has a position, rectangular size, origin, scale, rotation, Z index, and color. The position\r
+ * corresponds to the unrotated, unscaled bottom left corner of the actor. The position is relative to the actor's parent. The\r
+ * origin is relative to the position and is used for scale and rotation.\r
  * <p>\r
- * An actor has a list of in-progress {@link Action actions} that are applied to the actor (over time).  These are generally used to change\r
- * the presentation of the actor (moving it, resizing it, etc).  See {@link #act(float)} and {@link Action}.\r
+ * An actor has a list of in-progress {@link Action actions} that are applied to the actor (over time). These are generally used to\r
+ * change the presentation of the actor (moving it, resizing it, etc). See {@link #act(float)} and {@link Action}.\r
  * <p>\r
- * An actor has two kinds of listeners associated with it: "capture" and regular.  \r
- * The listeners are notified of\r
- * events the actor or its children receive. \r
- * The capture listeners are \r
- * designed to allow a parent or container actor to hide events from child actors.  The regular listeners\r
- * are designed to allow an actor to respond to events that have been delivered.  See {@link #fire} for more details.\r
+ * An actor has two kinds of listeners associated with it: "capture" and regular. The listeners are notified of events the actor\r
+ * or its children receive. The capture listeners are designed to allow a parent or container actor to hide events from child\r
+ * actors. The regular listeners are designed to allow an actor to respond to events that have been delivered. See {@link #fire}\r
+ * for more details.\r
  * <p>\r
- * An {@link InputListener} can receive all the basic input events, and more \r
- * complex listeners (like {@link ClickListener} and {@link ActorGestureListener}) can listen for and combine \r
- * primitive events and recognize complex interactions like multi-click or pinch. \r
+ * An {@link InputListener} can receive all the basic input events, and more complex listeners (like {@link ClickListener} and\r
+ * {@link ActorGestureListener}) can listen for and combine primitive events and recognize complex interactions like multi-click\r
+ * or pinch.\r
  * \r
  * @author mzechner\r
  * @author Nathan Sweet */\r
@@ -98,15 +96,14 @@ public class Actor {
        /** Sets this actor as the event {@link Event#setTarget(Actor) target} and propagates the event to this actor and ancestor\r
         * actors as necessary. If this actor is not in the stage, the stage must be set before calling this method.\r
         * <p>\r
-        * Events are fired in 2 phases. \r
+        * Events are fired in 2 phases.\r
         * <ol>\r
-        * <li>The first phase (the "capture" phase) notifies listeners on each actor starting at the root and propagating downward\r
-        * to (and including) this actor.</li> \r
-        * <li>The second phase notifies listeners on each actor starting at this actor and, if\r
-        * {@link Event#getBubbles()} is true, propagating upward to the root.</li>\r
+        * <li>The first phase (the "capture" phase) notifies listeners on each actor starting at the root and propagating downward to\r
+        * (and including) this actor.</li>\r
+        * <li>The second phase notifies listeners on each actor starting at this actor and, if {@link Event#getBubbles()} is true,\r
+        * propagating upward to the root.</li>\r
         * </ol>\r
-        * If the event is {@link Event#stop() stopped} at any time,\r
-        * it will not propagate to the next actor.\r
+        * If the event is {@link Event#stop() stopped} at any time, it will not propagate to the next actor.\r
         * @return true if the event was {@link Event#cancel() cancelled}. */\r
        public boolean fire (Event event) {\r
                if (event.getStage() == null) event.setStage(getStage());\r
@@ -188,7 +185,8 @@ public class Actor {
         * {@link #isVisible() visible}, or null if no actor was hit. The point is specified in the actor's local coordinate system (0,0\r
         * is the bottom left of the actor and width,height is the upper right).\r
         * <p>\r
-        * This method is used to delegate touchDown, mouse, and enter/exit events. If this method returns null, those events will not occur on this Actor.\r
+        * This method is used to delegate touchDown, mouse, and enter/exit events. If this method returns null, those events will not\r
+        * occur on this Actor.\r
         * <p>\r
         * The default implementation returns this actor if the point is within this actor's bounds.\r
         * \r
@@ -206,9 +204,7 @@ public class Actor {
                return false;\r
        }\r
 \r
-       /**\r
-        * Add a listener to receive events that {@link #hit(float, float, boolean) hit} this actor.  \r
-        * See {@link #fire(Event)}.\r
+       /** Add a listener to receive events that {@link #hit(float, float, boolean) hit} this actor. See {@link #fire(Event)}.\r
         * \r
         * @see InputListener\r
         * @see ClickListener */\r
@@ -263,6 +259,18 @@ public class Actor {
                actions.clear();\r
        }\r
 \r
+       /** Removes all listeners on this actor. */\r
+       public void clearListeners () {\r
+               listeners.clear();\r
+               captureListeners.clear();\r
+       }\r
+\r
+       /** Removes all actions and listeners on this actor. */\r
+       public void clear () {\r
+               clearActions();\r
+               clearListeners();\r
+       }\r
+\r
        /** Returns the stage that this actor is currently in, or null if not in a stage. */\r
        public Stage getStage () {\r
                return stage;\r
index ab41c0e..3c37a0e 100644 (file)
@@ -268,7 +268,7 @@ public class Group extends Actor implements Cullable {
        }
 
        /** Removes all actors from this group. */
-       public void clear () {
+       public void clearChildren () {
                Actor[] actors = children.begin();
                for (int i = 0, n = children.size; i < n; i++) {
                        Actor child = actors[i];
@@ -280,6 +280,12 @@ public class Group extends Actor implements Cullable {
                childrenChanged();
        }
 
+       /** Removes all children, actions, and listeners from this group. */
+       public void clear () {
+               super.clear();
+               clearChildren();
+       }
+
        /** Returns the first actor found with the specified name. Note this recursively compares the name of every actor in the group. */
        public Actor findActor (String name) {
                Array<Actor> children = this.children;
index 30c7a7b..8286ff1 100644 (file)
@@ -46,7 +46,7 @@ import com.badlogic.gdx.utils.SnapshotArray;
  * {@link Input#setInputProcessor(com.badlogic.gdx.InputProcessor) Gdx.input.setInputProcessor}. An {@link InputMultiplexer} may be\r
  * used to handle input events before or after the stage does. If an actor handles an event by returning true from the input\r
  * method, then the stage's input method will also return true, causing subsequent InputProcessors to not receive the event.\r
-\r
+ * \r
  * @author mzechner\r
  * @author Nathan Sweet */\r
 public class Stage extends InputAdapter implements Disposable {\r
@@ -507,7 +507,7 @@ public class Stage extends InputAdapter implements Disposable {
                return root.removeCaptureListener(listener);\r
        }\r
 \r
-       /** Clears the stage, removing all actors. */\r
+       /** Removes the root's children, actions, and listeners. */\r
        public void clear () {\r
                unfocusAll();\r
                root.clear();\r
index eb8b716..22b88bc 100644 (file)
@@ -38,7 +38,7 @@ public class CheckBox extends TextButton {
 \r
        public CheckBox (String text, CheckBoxStyle style) {\r
                super(text, style);\r
-               clear();\r
+               clearChildren();\r
                add(image = new Image(style.checkboxOff));\r
                Label label = getLabel();\r
                add(label);\r
index 9e25796..7b8a409 100644 (file)
@@ -177,8 +177,8 @@ public class Table extends WidgetGroup {
        }\r
 \r
        /** Removes all actors and cells from the table. */\r
-       public void clear () {\r
-               super.clear();\r
+       public void clearChildren () {\r
+               super.clearChildren();\r
                layout.clear();\r
                invalidate();\r
        }\r
@@ -250,8 +250,8 @@ public class Table extends WidgetGroup {
                layout.layout();\r
        }\r
 \r
-       /** Removes all actors and cells from the table (same as {@link #clear()}) and additionally resets all table properties and\r
-        * cell, column, and row defaults. */\r
+       /** Removes all actors and cells from the table (same as {@link #clearChildren()}) and additionally resets all table properties\r
+        * and cell, column, and row defaults. */\r
        public void reset () {\r
                layout.reset();\r
        }\r
index b4c41d6..32e3ed4 100644 (file)
@@ -143,8 +143,8 @@ public class Tree extends WidgetGroup {
        }\r
 \r
        /** Removes all tree nodes. */\r
-       public void clear () {\r
-               super.clear();\r
+       public void clearChildren () {\r
+               super.clearChildren();\r
                rootNodes.clear();\r
                selectedNodes.clear();\r
                setOverNode(null);\r