From 8eac24bbd56b02a8ad18c5fc4e1095643ba7d10c Mon Sep 17 00:00:00 2001 From: Daniel Holderbaum Date: Sun, 22 Jun 2014 01:01:25 +0200 Subject: [PATCH 1/9] Added a Scene2DDebugRenderer. --- .../scene2d/utils/Scene2DDebugRenderer.java | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java new file mode 100644 index 00000000000..7d371d10219 --- /dev/null +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright 2011 See AUTHORS file. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +package com.badlogic.gdx.scenes.scene2d.utils; + +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.Group; +import com.badlogic.gdx.scenes.scene2d.Stage; + +/** This debugging utility takes a {@link Stage} and renders all {@link Actor}s bounding boxes via a {@link ShapeRenderer}. The + * bounding boxes are not axis-aligned but rotated and scaled just like the actor. All you need to do is calling the + * {@link #render()} method each frame. + * + * @author Daniel Holderbaum */ +public class Scene2DDebugRenderer { + + /** Set to {@code true} if you want to render the actors that are not visible ({@code visible=false} of the actor or any parent) + * as well. */ + public boolean renderInvisibleActors = false; + + /** Set to {@code true} to also render group actors. They usually act only as invisible in the scene graph. */ + public boolean renderGroups = true; + + private Stage stage; + + private ShapeRenderer shapeRenderer; + + public Scene2DDebugRenderer (Stage stage) { + this.stage = stage; + this.shapeRenderer = new ShapeRenderer(); + } + + /** Renders the bounding boxes of all actors of the stage. */ + public void render () { + shapeRenderer.setProjectionMatrix(stage.getCamera().projection); + shapeRenderer.setTransformMatrix(stage.getCamera().view); + shapeRenderer.begin(ShapeType.Line); + for (Actor actor : stage.getActors()) { + render(actor); + } + shapeRenderer.end(); + } + + private Vector2 topLeft = new Vector2(); + private Vector2 topRight = new Vector2(); + private Vector2 bottomRight = new Vector2(); + private Vector2 bottomLeft = new Vector2(); + + private void render (Actor actor) { + if (renderInvisibleActors || isActorVisible(actor)) { + if (renderGroups || !(actor instanceof Group)) { + // local coordinates + topLeft.set(0, actor.getHeight()); + topRight.set(actor.getWidth(), actor.getHeight()); + bottomRight.set(actor.getWidth(), 0); + bottomLeft.set(0, 0); + + // transform to stage coordinates using offsets, scales, + // rotations etc of the whole ancestor hierarchy until the root + actor.localToStageCoordinates(topLeft); + actor.localToStageCoordinates(topRight); + actor.localToStageCoordinates(bottomRight); + actor.localToStageCoordinates(bottomLeft); + + shapeRenderer.line(topLeft, topRight); + shapeRenderer.line(topRight, bottomRight); + shapeRenderer.line(bottomRight, bottomLeft); + shapeRenderer.line(bottomLeft, topLeft); + } + } + + if (actor instanceof Group) { + for (Actor child : ((Group)actor).getChildren()) { + render(child); + } + } + } + + /** Returns {@code true} in case the given actor and all of its ancestors are visible. {@code False} otherwise. */ + private boolean isActorVisible (Actor actor) { + Actor currentActor = actor; + while (currentActor != null) { + if (currentActor.isVisible() == false) { + return false; + } else { + currentActor = currentActor.getParent(); + } + } + + return true; + } +} From a4eed120659c09c10d0f28bdb78e2d4c75019cd9 Mon Sep 17 00:00:00 2001 From: Daniel Holderbaum Date: Sun, 22 Jun 2014 10:53:44 +0200 Subject: [PATCH 2/9] Made colours configurable. --- .../scenes/scene2d/utils/Scene2DDebugRenderer.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java index 7d371d10219..c7296c6c049 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java @@ -16,6 +16,7 @@ package com.badlogic.gdx.scenes.scene2d.utils; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.Vector2; @@ -34,9 +35,13 @@ public class Scene2DDebugRenderer { * as well. */ public boolean renderInvisibleActors = false; - /** Set to {@code true} to also render group actors. They usually act only as invisible in the scene graph. */ + /** Set to {@code false} to not render group actors. They usually act only as invisible in the scene graph. */ public boolean renderGroups = true; + public Color actorColor = new Color(1, 0, 0, 1); + + public Color groupColor = new Color(0, 1, 0, 1); + private Stage stage; private ShapeRenderer shapeRenderer; @@ -46,7 +51,6 @@ public Scene2DDebugRenderer (Stage stage) { this.shapeRenderer = new ShapeRenderer(); } - /** Renders the bounding boxes of all actors of the stage. */ public void render () { shapeRenderer.setProjectionMatrix(stage.getCamera().projection); shapeRenderer.setTransformMatrix(stage.getCamera().view); @@ -78,6 +82,12 @@ private void render (Actor actor) { actor.localToStageCoordinates(bottomRight); actor.localToStageCoordinates(bottomLeft); + if (actor instanceof Group) { + shapeRenderer.setColor(groupColor); + } else { + shapeRenderer.setColor(actorColor); + } + shapeRenderer.line(topLeft, topRight); shapeRenderer.line(topRight, bottomRight); shapeRenderer.line(bottomRight, bottomLeft); From 6c8d5934f224203ae20e90f252a90761ba5acafe Mon Sep 17 00:00:00 2001 From: Daniel Holderbaum Date: Tue, 24 Jun 2014 20:36:53 +0200 Subject: [PATCH 3/9] Table debug rendering included. --- .../scene2d/utils/Scene2DDebugRenderer.java | 153 ++++++++++++++---- 1 file changed, 119 insertions(+), 34 deletions(-) diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java index c7296c6c049..9d605bff031 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java @@ -23,6 +23,8 @@ import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.Cell; +import com.badlogic.gdx.scenes.scene2d.ui.Table; /** This debugging utility takes a {@link Stage} and renders all {@link Actor}s bounding boxes via a {@link ShapeRenderer}. The * bounding boxes are not axis-aligned but rotated and scaled just like the actor. All you need to do is calling the @@ -38,9 +40,26 @@ public class Scene2DDebugRenderer { /** Set to {@code false} to not render group actors. They usually act only as invisible in the scene graph. */ public boolean renderGroups = true; - public Color actorColor = new Color(1, 0, 0, 1); + /** Set to {@code false} to not render "leaf" actors. Those are the ones that are no {@link Group}s. */ + public boolean renderActors = true; - public Color groupColor = new Color(0, 1, 0, 1); + /** Set to {@code false} to not render table cells. This will not prevent the cell's actor to be rendered. */ + public boolean renderCells = true; + + /** Set to {@code false} to not render the table outlines. This will not prevent the cells to be rendered. */ + public boolean renderTable = true; + + /** Used for the outline of any {@link Actor} that is not a {@link Group} of any kind. */ + public Color actorColor = new Color(1, 1, 1, 1); + + /** Used in case the actor is a {@link Group}, but not a {@link Table}. */ + public Color groupColor = new Color(1, 0, 0, 1); + + /** Used for the outline of the individual {@link Cell}s of a {@link Table}. */ + public Color cellColor = new Color(0, 1, 0, 1); + + /** Used for the outline of a {@link Table}. */ + public Color tableColor = new Color(0, 0, 1, 1); private Stage stage; @@ -51,55 +70,111 @@ public Scene2DDebugRenderer (Stage stage) { this.shapeRenderer = new ShapeRenderer(); } + /** Renders the bounding boxes of all actors of the stage. */ public void render () { shapeRenderer.setProjectionMatrix(stage.getCamera().projection); shapeRenderer.setTransformMatrix(stage.getCamera().view); shapeRenderer.begin(ShapeType.Line); for (Actor actor : stage.getActors()) { - render(actor); + renderRecursive(actor); } shapeRenderer.end(); } + /** Acts like a switch and delegates the real rendering call to the method with the most precise type. */ + private void renderRecursive (Actor actor) { + if (renderInvisibleActors || isActorVisible(actor)) { + if (actor instanceof Table) { + Table table = (Table)actor; + if (renderTable) { + render(table); + } + for (Cell cell : table.getCells()) { + if (renderCells) { + render(cell); + } + if (cell.hasActor()) { + renderRecursive(cell.getActor()); + } + } + } else if (actor instanceof Group) { + Group group = (Group)actor; + if (renderGroups) { + render(group); + } + for (Actor child : group.getChildren()) { + renderRecursive(child); + } + } else { + if (renderActors) { + render(actor); + } + } + } + } + private Vector2 topLeft = new Vector2(); private Vector2 topRight = new Vector2(); private Vector2 bottomRight = new Vector2(); private Vector2 bottomLeft = new Vector2(); + /** Works for both {@link Group} and {@link Actor}. */ private void render (Actor actor) { - if (renderInvisibleActors || isActorVisible(actor)) { - if (renderGroups || !(actor instanceof Group)) { - // local coordinates - topLeft.set(0, actor.getHeight()); - topRight.set(actor.getWidth(), actor.getHeight()); - bottomRight.set(actor.getWidth(), 0); - bottomLeft.set(0, 0); - - // transform to stage coordinates using offsets, scales, - // rotations etc of the whole ancestor hierarchy until the root - actor.localToStageCoordinates(topLeft); - actor.localToStageCoordinates(topRight); - actor.localToStageCoordinates(bottomRight); - actor.localToStageCoordinates(bottomLeft); - - if (actor instanceof Group) { - shapeRenderer.setColor(groupColor); - } else { - shapeRenderer.setColor(actorColor); - } + topLeft.set(0, actor.getHeight()); + topRight.set(actor.getWidth(), actor.getHeight()); + bottomRight.set(actor.getWidth(), 0); + bottomLeft.set(0, 0); - shapeRenderer.line(topLeft, topRight); - shapeRenderer.line(topRight, bottomRight); - shapeRenderer.line(bottomRight, bottomLeft); - shapeRenderer.line(bottomLeft, topLeft); - } - } + Color color = getColorByType(actor); + renderBoundingBox(actor, topLeft, topRight, bottomRight, bottomLeft, color); + } - if (actor instanceof Group) { - for (Actor child : ((Group)actor).getChildren()) { - render(child); - } - } + private void render (Cell cell) { + Table table = cell.getTable(); + + // render an outline of the cell + // it's an outline around the actor + the cell's padding + topLeft.set(cell.getActorX() - cell.getPadLeft(), cell.getActorY() + cell.getActorHeight() + cell.getPadTop()); + topRight.set(cell.getActorX() + cell.getActorWidth() + cell.getPadRight(), + cell.getActorY() + cell.getActorHeight() + cell.getPadTop()); + bottomRight.set(cell.getActorX() + cell.getActorWidth() + cell.getPadRight(), cell.getActorY() - cell.getPadBottom()); + bottomLeft.set(cell.getActorX() - cell.getPadLeft(), cell.getActorY() - cell.getPadBottom()); + + renderBoundingBox(table, topLeft, topRight, bottomRight, bottomLeft, cellColor); + } + + private void render (Table table) { + // table outline + topLeft.set(0, table.getHeight()); + topRight.set(table.getWidth(), table.getHeight()); + bottomRight.set(table.getWidth(), 0); + bottomLeft.set(0, 0); + + renderBoundingBox(table, topLeft, topRight, bottomRight, bottomLeft, tableColor); + + // table outline minus the table's padding + topLeft.set(table.getPadLeft(), table.getHeight() - table.getPadTop()); + topRight.set(table.getWidth() - table.getPadRight(), table.getHeight() - table.getPadTop()); + bottomRight.set(table.getWidth() - table.getPadRight(), table.getPadBottom()); + bottomLeft.set(table.getPadLeft(), table.getPadBottom()); + + renderBoundingBox(table, topLeft, topRight, bottomRight, bottomLeft, tableColor); + } + + private void renderBoundingBox (Actor actor, Vector2 topLeft, Vector2 topRight, Vector2 bottomRight, Vector2 bottomLeft, + Color color) { + // transform to stage coordinates using offsets, scales, + // rotations etc of the whole ancestor hierarchy until the root + actor.localToStageCoordinates(topLeft); + actor.localToStageCoordinates(topRight); + actor.localToStageCoordinates(bottomRight); + actor.localToStageCoordinates(bottomLeft); + + shapeRenderer.setColor(color); + shapeRenderer.line(topLeft, topRight); + shapeRenderer.line(topRight, bottomRight); + shapeRenderer.line(bottomRight, bottomLeft); + shapeRenderer.line(bottomLeft, topLeft); } /** Returns {@code true} in case the given actor and all of its ancestors are visible. {@code False} otherwise. */ @@ -115,4 +190,14 @@ private boolean isActorVisible (Actor actor) { return true; } + + private Color getColorByType (Actor actor) { + Color color; + if (actor instanceof Group) { + color = groupColor; + } else { + color = actorColor; + } + return color; + } } From 6ea8293da1e0a825c1fa33b3ce4a83ea3ec80658 Mon Sep 17 00:00:00 2001 From: Daniel Holderbaum Date: Tue, 24 Jun 2014 20:51:17 +0200 Subject: [PATCH 4/9] Small JavaDoc change. --- .../badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java index 9d605bff031..c111e0d65ed 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java @@ -37,7 +37,7 @@ public class Scene2DDebugRenderer { * as well. */ public boolean renderInvisibleActors = false; - /** Set to {@code false} to not render group actors. They usually act only as invisible in the scene graph. */ + /** Set to {@code false} to not render group actors. This will not prevent the group's children to be rendered. */ public boolean renderGroups = true; /** Set to {@code false} to not render "leaf" actors. Those are the ones that are no {@link Group}s. */ From 0cffe3c321f2f63612b5c428c40a166eea37adbc Mon Sep 17 00:00:00 2001 From: Daniel Holderbaum Date: Sat, 28 Jun 2014 21:18:10 +0200 Subject: [PATCH 5/9] Actors now know themselves how to debug render. Adjusted all tests. Added a new Scene2DDebugRendererTest. --- .../badlogic/gdx/scenes/scene2d/Actor.java | 25 +++ .../badlogic/gdx/scenes/scene2d/Group.java | 20 ++- .../badlogic/gdx/scenes/scene2d/ui/Table.java | 148 +++++------------- .../scene2d/utils/Scene2DDebugRenderer.java | 146 +++++------------ .../com/badlogic/gdx/tests/ContainerTest.java | 5 +- .../badlogic/gdx/tests/DragAndDropTest.java | 1 - .../src/com/badlogic/gdx/tests/ImageTest.java | 9 +- .../badlogic/gdx/tests/LabelScaleTest.java | 5 +- .../src/com/badlogic/gdx/tests/LabelTest.java | 5 +- .../gdx/tests/ProjectiveTextureTest.java | 3 +- .../gdx/tests/Scene2DDebugRendererTest.java | 132 ++++++++++++++++ .../com/badlogic/gdx/tests/Scene2dTest.java | 5 +- .../badlogic/gdx/tests/ScrollPane2Test.java | 5 +- .../gdx/tests/ScrollPaneScrollBarsTest.java | 1 - .../badlogic/gdx/tests/ScrollPaneTest.java | 1 - .../badlogic/gdx/tests/TableLayoutTest.java | 5 +- .../src/com/badlogic/gdx/tests/TableTest.java | 5 +- .../src/com/badlogic/gdx/tests/TreeTest.java | 1 - .../com/badlogic/gdx/tests/UISimpleTest.java | 1 - .../src/com/badlogic/gdx/tests/UITest.java | 1 - .../com/badlogic/gdx/tests/ViewportTest1.java | 6 +- .../badlogic/gdx/tests/utils/GdxTests.java | 1 + 22 files changed, 296 insertions(+), 235 deletions(-) create mode 100644 tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java index 4dfa3c2e617..7a5966d545f 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java @@ -24,6 +24,8 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent.Type; import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer.DebugRect; import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.DelayedRemovalArray; @@ -65,6 +67,9 @@ public class Actor { final Color color = new Color(1, 1, 1, 1); private Object userObject; + private boolean debuggingEnabled = true; + public static final Color debugColor = new Color(0, 1, 0, 1); + /** Draws the actor. The Batch is configured to draw in the parent's coordinate system. * {@link Batch#draw(com.badlogic.gdx.graphics.g2d.TextureRegion, float, float, float, float, float, float, float, float, float) * This draw method} is convenient to draw a rotated and scaled TextureRegion. {@link Batch#begin()} has already been called on @@ -542,6 +547,26 @@ public void setName (String name) { this.name = name; } + /** The {@link Scene2DDebugRenderer} will ask every actor of a stage for their debugging rectangles. To fill the given array you + * can obtain fresh {@link DebugRect}s via the {@link Scene2DDebugRenderer#debugRectPool}. To avoid the garbage collection you + * should make sure to free them later, but it's not a strict requirement. */ + public void getDebugRects (Array debugRects) { + DebugRect debugRect = Scene2DDebugRenderer.debugRectPool.obtain(); + debugRect.bottomLeft.set(0, 0); + debugRect.topRight.set(width, height); + debugRect.color.set(Actor.debugColor); + debugRects.add(debugRect); + } + + /** Used only in combination with a {@link Scene2DDebugRenderer}. */ + public void setDebuggingEnabled (boolean enabled) { + debuggingEnabled = enabled; + } + + public boolean isDebuggingEnabled () { + return debuggingEnabled; + } + /** Changes the z-order for this actor so it is in front of all siblings. */ public void toFront () { setZIndex(Integer.MAX_VALUE); diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/Group.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/Group.java index bda642c5949..1b8b493a867 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/Group.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/Group.java @@ -22,6 +22,7 @@ import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.utils.Cullable; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.SnapshotArray; @@ -289,12 +290,12 @@ public void clear () { public T findActor (String name) { Array children = this.children; for (int i = 0, n = children.size; i < n; i++) - if (name.equals(children.get(i).getName())) return (T) children.get(i); + if (name.equals(children.get(i).getName())) return (T)children.get(i); for (int i = 0, n = children.size; i < n; i++) { Actor child = children.get(i); if (child instanceof Group) { Actor actor = ((Group)child).findActor(name); - if (actor != null) return (T) actor; + if (actor != null) return (T)actor; } } return null; @@ -364,6 +365,21 @@ public void print () { print(""); } + /** Used only in combination with a {@link Scene2DDebugRenderer}. + * @param recursively If {@code true} it will also recursively disable all children of this group. */ + public void setDebuggingEnabled (boolean enabled, boolean recursively) { + setDebuggingEnabled(enabled); + if (recursively) { + for (Actor child : children) { + if (child instanceof Group) { + ((Group)child).setDebuggingEnabled(enabled, recursively); + } else { + child.setDebuggingEnabled(enabled); + } + } + } + } + private void print (String indent) { Actor[] actors = children.begin(); for (int i = 0, n = children.size; i < n; i++) { diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java index df8df21617a..da18138cc1e 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java @@ -16,23 +16,17 @@ package com.badlogic.gdx.scenes.scene2d.ui; -import com.badlogic.gdx.Application; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer; -import com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20; -import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.scenes.scene2d.Actor; -import com.badlogic.gdx.scenes.scene2d.Group; -import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle; import com.badlogic.gdx.scenes.scene2d.ui.Value.Fixed; import com.badlogic.gdx.scenes.scene2d.utils.Align; import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.Layout; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer.DebugRect; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Pool; @@ -42,6 +36,11 @@ * The preferred and minimum sizes are that of the children when laid out in columns and rows. * @author Nathan Sweet */ public class Table extends WidgetGroup { + + public static final Color tableColor = new Color(0, 0, 1, 1); + + public static final Color cellColor = new Color(1, 0, 0, 1); + static Pool cellPool = new Pool() { protected Cell newObject () { return new Cell(); @@ -68,7 +67,7 @@ protected Cell newObject () { int align = Align.center; Debug debug = Debug.none; - Array debugRects; + Array debugRects = new Array(); private Drawable background; private boolean clip; @@ -329,7 +328,10 @@ public void reset () { padBottom = Value.zero; padRight = Value.zero; align = Align.center; - if (debug != Debug.none) debugRects.clear(); + if (debug != Debug.none) { + Scene2DDebugRenderer.debugRectPool.freeAll(debugRects); + debugRects.clear(); + } debug = Debug.none; cellDefaults.defaults(); for (int i = 0, n = columnDefaults.size; i < n; i++) { @@ -589,7 +591,10 @@ public Table debugActor () { public Table debug (Debug debug) { this.debug = debug; if (debug == Debug.none) { - if (debugRects != null) debugRects.clear(); + if (debugRects != null) { + Scene2DDebugRenderer.debugRectPool.freeAll(debugRects); + debugRects.clear(); + } } else invalidate(); return this; @@ -1081,19 +1086,22 @@ else if ((c.align & Align.bottom) != 0) // Store debug rectangles. if (debug == Debug.none) return; - if (debugRects != null) debugRects.clear(); + if (debugRects != null) { + Scene2DDebugRenderer.debugRectPool.freeAll(debugRects); + debugRects.clear(); + } currentX = x; currentY = y; if (debug == Debug.table || debug == Debug.all) { - TableDebug.addRectangle(this, Debug.table, layoutX, layoutY, layoutWidth, layoutHeight); - TableDebug.addRectangle(this, Debug.table, x, y, tableWidth - hpadding, tableHeight - vpadding); + addDebugRect(layoutX, layoutY, layoutWidth, layoutHeight, tableColor); + addDebugRect(x, y, tableWidth - hpadding, tableHeight - vpadding, tableColor); } for (int i = 0; i < cellCount; i++) { Cell c = cells.get(i); // Actor bounds. if (debug == Debug.actor || debug == Debug.all) - TableDebug.addRectangle(this, Debug.actor, c.actorX, c.actorY, c.actorWidth, c.actorHeight); + addDebugRect(c.actorX, c.actorY, c.actorWidth, c.actorHeight, Actor.debugColor); // Cell bounds. float spannedCellWidth = 0; @@ -1102,8 +1110,8 @@ else if ((c.align & Align.bottom) != 0) spannedCellWidth -= c.computedPadLeft + c.computedPadRight; currentX += c.computedPadLeft; if (debug == Debug.cell || debug == Debug.all) { - TableDebug.addRectangle(this, Debug.cell, currentX, currentY + c.computedPadTop, spannedCellWidth, rowHeight[c.row] - - c.computedPadTop - c.computedPadBottom); + addDebugRect(currentX, currentY + c.computedPadTop, spannedCellWidth, rowHeight[c.row] - c.computedPadTop + - c.computedPadBottom, cellColor); } if (c.endRow) { @@ -1114,105 +1122,23 @@ else if ((c.align & Align.bottom) != 0) } } - /** Draws the debug lines for all tables in the stage. If this method is not called each frame, no debug lines will be drawn. If - * debug is never turned on for any table in the application, calling this method will have no effect. If a table has ever had - * debug set, calling this method causes an expensive traversal of all actors in the stage. */ - static public void drawDebug (Stage stage) { - if (TableDebug.draw) TableDebug.draw(stage); + @Override + public void getDebugRects (Array debugRects) { + debugRects.addAll(this.debugRects); } - /** @author Nathan Sweet */ - static public enum Debug { - none, all, table, cell, actor + private void addDebugRect (float x, float y, float width, float height, Color color) { + DebugRect debugRect = Scene2DDebugRenderer.debugRectPool.obtain(); + float yCorrected = getHeight() - y - height; + debugRect.bottomLeft.set(x, yCorrected); + debugRect.topRight.set(x + width, yCorrected + height); + debugRect.color.set(color); + debugRects.add(debugRect); } /** @author Nathan Sweet */ - static class DebugRect extends Rectangle { - final Debug type; - - public DebugRect (Debug type, float x, float y, float width, float height) { - super(x, y, width, height); - this.type = type; - } + static public enum Debug { + none, all, table, cell, actor } - /** @author Nathan Sweet */ - static class TableDebug { - static boolean draw; - - static private Application app; - static private ImmediateModeRenderer debugRenderer; - - static public void addRectangle (Table table, Debug type, float x, float y, float w, float h) { - draw = true; - if (table.debugRects == null) table.debugRects = new Array(); - table.debugRects.add(new DebugRect(type, x, table.getHeight() - y, w, h)); - } - - static void draw (Stage stage) { - if (app != Gdx.app) debugRenderer = new ImmediateModeRenderer20(128, false, true, 0); - - debugRenderer.begin(stage.getBatch().getProjectionMatrix(), GL20.GL_LINES); - draw(stage.getActors()); - debugRenderer.end(); - } - - static void draw (Array actors) { - for (int i = 0, n = actors.size; i < n; i++) { - Actor actor = actors.get(i); - if (!actor.isVisible()) continue; - if (actor instanceof Table) draw((Table)actor); - if (actor instanceof Group) draw(((Group)actor).getChildren()); - } - } - - static public void draw (Table table) { - if (table.debug == Debug.none) return; - Array debugRects = table.debugRects; - if (debugRects == null) return; - - float x = 0, y = 0; - Actor parent = table; - while (parent != null) { - if (parent instanceof Group) { - x += parent.getX(); - y += parent.getY(); - } - parent = parent.getParent(); - } - - for (int i = 0, n = debugRects.size; i < n; i++) { - DebugRect rect = debugRects.get(i); - float x1 = x + rect.x; - float y1 = y + rect.y - rect.height; - float x2 = x1 + rect.width; - float y2 = y1 + rect.height; - float r = rect.type == Debug.cell ? 1 : 0; - float g = rect.type == Debug.actor ? 1 : 0; - float b = rect.type == Debug.table ? 1 : 0; - - debugRenderer.color(r, g, b, 1); - debugRenderer.vertex(x1, y1, 0); - debugRenderer.color(r, g, b, 1); - debugRenderer.vertex(x1, y2, 0); - - debugRenderer.color(r, g, b, 1); - debugRenderer.vertex(x1, y2, 0); - debugRenderer.color(r, g, b, 1); - debugRenderer.vertex(x2, y2, 0); - - debugRenderer.color(r, g, b, 1); - debugRenderer.vertex(x2, y2, 0); - debugRenderer.color(r, g, b, 1); - debugRenderer.vertex(x2, y1, 0); - - debugRenderer.color(r, g, b, 1); - debugRenderer.vertex(x2, y1, 0); - debugRenderer.color(r, g, b, 1); - debugRenderer.vertex(x1, y1, 0); - - if (debugRenderer.getNumVertices() == 128) debugRenderer.flush(); - } - } - } } diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java index c111e0d65ed..66214efd9f6 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java @@ -23,8 +23,10 @@ import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.ui.Cell; -import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.Pool; +import com.badlogic.gdx.utils.Pool.Poolable; +import com.badlogic.gdx.utils.ReflectionPool; /** This debugging utility takes a {@link Stage} and renders all {@link Actor}s bounding boxes via a {@link ShapeRenderer}. The * bounding boxes are not axis-aligned but rotated and scaled just like the actor. All you need to do is calling the @@ -33,33 +35,32 @@ * @author Daniel Holderbaum */ public class Scene2DDebugRenderer { - /** Set to {@code true} if you want to render the actors that are not visible ({@code visible=false} of the actor or any parent) - * as well. */ - public boolean renderInvisibleActors = false; - - /** Set to {@code false} to not render group actors. This will not prevent the group's children to be rendered. */ - public boolean renderGroups = true; - - /** Set to {@code false} to not render "leaf" actors. Those are the ones that are no {@link Group}s. */ - public boolean renderActors = true; - - /** Set to {@code false} to not render table cells. This will not prevent the cell's actor to be rendered. */ - public boolean renderCells = true; + public static class DebugRect implements Poolable { + public Vector2 bottomLeft; + public Vector2 topRight; + public Color color; - /** Set to {@code false} to not render the table outlines. This will not prevent the cells to be rendered. */ - public boolean renderTable = true; + public DebugRect () { + bottomLeft = new Vector2(); + topRight = new Vector2(); + color = new Color(1, 1, 1, 1); + } - /** Used for the outline of any {@link Actor} that is not a {@link Group} of any kind. */ - public Color actorColor = new Color(1, 1, 1, 1); + @Override + public void reset () { + bottomLeft.setZero(); + topRight.setZero(); + color.set(1, 1, 1, 1); + } + } - /** Used in case the actor is a {@link Group}, but not a {@link Table}. */ - public Color groupColor = new Color(1, 0, 0, 1); + public static Pool debugRectPool = new ReflectionPool(DebugRect.class); - /** Used for the outline of the individual {@link Cell}s of a {@link Table}. */ - public Color cellColor = new Color(0, 1, 0, 1); + private Array debugRects = new Array(); - /** Used for the outline of a {@link Table}. */ - public Color tableColor = new Color(0, 0, 1, 1); + /** Set to {@code true} if you want to render the actors that are not visible ({@code visible=false} of the actor or any parent) + * as well. */ + public boolean renderInvisibleActors = false; private Stage stage; @@ -81,84 +82,33 @@ public void render () { shapeRenderer.end(); } - /** Acts like a switch and delegates the real rendering call to the method with the most precise type. */ - private void renderRecursive (Actor actor) { - if (renderInvisibleActors || isActorVisible(actor)) { - if (actor instanceof Table) { - Table table = (Table)actor; - if (renderTable) { - render(table); - } - for (Cell cell : table.getCells()) { - if (renderCells) { - render(cell); - } - if (cell.hasActor()) { - renderRecursive(cell.getActor()); - } - } - } else if (actor instanceof Group) { - Group group = (Group)actor; - if (renderGroups) { - render(group); - } - for (Actor child : group.getChildren()) { - renderRecursive(child); - } - } else { - if (renderActors) { - render(actor); - } - } - } - } - private Vector2 topLeft = new Vector2(); private Vector2 topRight = new Vector2(); private Vector2 bottomRight = new Vector2(); private Vector2 bottomLeft = new Vector2(); - /** Works for both {@link Group} and {@link Actor}. */ - private void render (Actor actor) { - topLeft.set(0, actor.getHeight()); - topRight.set(actor.getWidth(), actor.getHeight()); - bottomRight.set(actor.getWidth(), 0); - bottomLeft.set(0, 0); - - Color color = getColorByType(actor); - renderBoundingBox(actor, topLeft, topRight, bottomRight, bottomLeft, color); - } - - private void render (Cell cell) { - Table table = cell.getTable(); - - // render an outline of the cell - // it's an outline around the actor + the cell's padding - topLeft.set(cell.getActorX() - cell.getPadLeft(), cell.getActorY() + cell.getActorHeight() + cell.getPadTop()); - topRight.set(cell.getActorX() + cell.getActorWidth() + cell.getPadRight(), - cell.getActorY() + cell.getActorHeight() + cell.getPadTop()); - bottomRight.set(cell.getActorX() + cell.getActorWidth() + cell.getPadRight(), cell.getActorY() - cell.getPadBottom()); - bottomLeft.set(cell.getActorX() - cell.getPadLeft(), cell.getActorY() - cell.getPadBottom()); - - renderBoundingBox(table, topLeft, topRight, bottomRight, bottomLeft, cellColor); - } + private void renderRecursive (Actor actor) { + if (actor.isDebuggingEnabled() && (renderInvisibleActors || isActorVisible(actor))) { - private void render (Table table) { - // table outline - topLeft.set(0, table.getHeight()); - topRight.set(table.getWidth(), table.getHeight()); - bottomRight.set(table.getWidth(), 0); - bottomLeft.set(0, 0); + actor.getDebugRects(debugRects); + for (DebugRect debugRect : debugRects) { + topLeft.set(debugRect.bottomLeft.x, debugRect.topRight.y); + topRight.set(debugRect.topRight.x, debugRect.topRight.y); + bottomRight.set(debugRect.topRight.x, debugRect.bottomLeft.y); + bottomLeft.set(debugRect.bottomLeft.x, debugRect.bottomLeft.y); - renderBoundingBox(table, topLeft, topRight, bottomRight, bottomLeft, tableColor); + renderBoundingBox(actor, topLeft, topRight, bottomRight, bottomLeft, debugRect.color); + } + debugRects.clear(); - // table outline minus the table's padding - topLeft.set(table.getPadLeft(), table.getHeight() - table.getPadTop()); - topRight.set(table.getWidth() - table.getPadRight(), table.getHeight() - table.getPadTop()); - bottomRight.set(table.getWidth() - table.getPadRight(), table.getPadBottom()); - bottomLeft.set(table.getPadLeft(), table.getPadBottom()); + if (actor instanceof Group) { + Group group = (Group)actor; + for (Actor child : group.getChildren()) { + renderRecursive(child); + } + } + } - renderBoundingBox(table, topLeft, topRight, bottomRight, bottomLeft, tableColor); } private void renderBoundingBox (Actor actor, Vector2 topLeft, Vector2 topRight, Vector2 bottomRight, Vector2 bottomLeft, @@ -190,14 +140,4 @@ private boolean isActorVisible (Actor actor) { return true; } - - private Color getColorByType (Actor actor) { - Color color; - if (actor instanceof Group) { - color = groupColor; - } else { - color = actorColor; - } - return color; - } } diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ContainerTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ContainerTest.java index 09f09c0147d..ac55466425f 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ContainerTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ContainerTest.java @@ -10,17 +10,20 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.tests.utils.GdxTest; public class ContainerTest extends GdxTest { Skin skin; Stage stage; + Scene2DDebugRenderer debugRenderer; @Override public void create () { skin = new Skin(Gdx.files.internal("data/uiskin.json")); stage = new Stage(); + debugRenderer = new Scene2DDebugRenderer(stage); Gdx.input.setInputProcessor(stage); TextureRegionDrawable logo = new TextureRegionDrawable(new TextureRegion(new Texture( @@ -81,7 +84,7 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(); stage.draw(); - Table.drawDebug(stage); + debugRenderer.render(); } @Override diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/DragAndDropTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/DragAndDropTest.java index cb2ae5efafc..a4951eb1949 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/DragAndDropTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/DragAndDropTest.java @@ -109,7 +109,6 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); - Table.drawDebug(stage); } public void resize (int width, int height) { diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ImageTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ImageTest.java index 0cb64991ea8..cf6ceb824e9 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ImageTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ImageTest.java @@ -24,6 +24,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.tests.utils.GdxTest; import com.badlogic.gdx.utils.Scaling; @@ -32,21 +33,24 @@ public class ImageTest extends GdxTest { Stage ui; Table root; TextureRegion image2; + Scene2DDebugRenderer debugRenderer; @Override public void create () { skin = new Skin(Gdx.files.internal("data/uiskin.json")); image2 = new TextureRegion(new Texture(Gdx.files.internal("data/badlogic.jpg"))); ui = new Stage(); + debugRenderer = new Scene2DDebugRenderer(ui); Gdx.input.setInputProcessor(ui); root = new Table(); + root.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); ui.addActor(root); root.debug(); Image image = new Image(image2); image.setScaling(Scaling.fill); - root.add(image).width(160).height(100); + root.add(image).width(image2.getRegionWidth()).height(image2.getRegionHeight()); } @Override @@ -62,12 +66,11 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); ui.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); ui.draw(); - Table.drawDebug(ui); + debugRenderer.render(); } @Override public void resize (int width, int height) { ui.getViewport().update(width, height, true); - root.setSize(width, height); } } diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/LabelScaleTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/LabelScaleTest.java index bafb24dbf54..a08cb4fb7d2 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/LabelScaleTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/LabelScaleTest.java @@ -24,6 +24,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.tests.utils.GdxTest; public class LabelScaleTest extends GdxTest { @@ -31,12 +32,14 @@ public class LabelScaleTest extends GdxTest { Stage stage; SpriteBatch batch; Actor root; + Scene2DDebugRenderer debugRenderer; @Override public void create () { batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json")); stage = new Stage(); + debugRenderer = new Scene2DDebugRenderer(stage); Gdx.input.setInputProcessor(stage); Table table = new Table(); @@ -70,7 +73,7 @@ public void render () { stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); - Table.drawDebug(stage); + debugRenderer.render(); } @Override diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/LabelTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/LabelTest.java index 834cf80c004..98b6a1f560c 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/LabelTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/LabelTest.java @@ -30,6 +30,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.utils.Align; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.tests.utils.GdxTest; public class LabelTest extends GdxTest { @@ -38,6 +39,7 @@ public class LabelTest extends GdxTest { SpriteBatch batch; Actor root; ShapeRenderer renderer; + Scene2DDebugRenderer debugRenderer; @Override public void create () { @@ -47,6 +49,7 @@ public void create () { skin.getAtlas().getTextures().iterator().next().setFilter(TextureFilter.Nearest, TextureFilter.Nearest); skin.getFont("default-font").setMarkupEnabled(true); stage = new Stage(); + debugRenderer = new Scene2DDebugRenderer(stage); Gdx.input.setInputProcessor(stage); Table table = new Table(); @@ -89,7 +92,7 @@ public void render () { stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); - Table.drawDebug(stage); + debugRenderer.render(); float x = 40, y = 40; diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ProjectiveTextureTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ProjectiveTextureTest.java index 287206db1bc..5ba9d092528 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ProjectiveTextureTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ProjectiveTextureTest.java @@ -102,7 +102,7 @@ public void setupScene () { } public void setupUI () { - ui = new Stage();; + ui = new Stage(); skin = new Skin(Gdx.files.internal("data/uiskin.json")); TextButton reload = new TextButton("Reload Shaders", skin.get(TextButtonStyle.class)); camera = new SelectBox(skin.get(SelectBoxStyle.class)); @@ -170,7 +170,6 @@ public void render () { fps.setText("fps: " + Gdx.graphics.getFramesPerSecond()); ui.act(); ui.draw(); - Table.drawDebug(ui); } Vector3 position = new Vector3(); diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java new file mode 100644 index 00000000000..4e3c6e78aec --- /dev/null +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java @@ -0,0 +1,132 @@ +/* ###################################### + * Copyright 2014 (c) Pixel Scientists + * All rights reserved. + * Unauthorized copying of this file, via + * any medium is strictly prohibited. + * Proprietary and confidential. + * ###################################### */ + +package com.badlogic.gdx.tests; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.Pixmap.Format; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.Group; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; +import com.badlogic.gdx.tests.utils.GdxTest; + +/** @author Daniel Holderbaum */ +public class Scene2DDebugRendererTest extends GdxTest { + + static TextureRegion textureRegion; + + private Stage stage; + private Stage stage1; + private Stage stage2; + + private Scene2DDebugRenderer debugRenderer; + + class DebugActor extends Actor { + + @Override + public void draw (Batch batch, float parentAlpha) { + batch.draw(textureRegion, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), + getRotation()); + } + } + + @Override + public void create () { + textureRegion = new TextureRegion(new Texture("data/badlogic.jpg")); + + Gdx.input.setInputProcessor(this); + + stage1 = new Stage(); + stage1.getCamera().position.set(100, 100, 0); + + Group group = new Group(); +// group.setBounds(0, 0, 10, 10); + // group.setOrigin(25, 50); + group.setRotation(10); + group.setScale(1.2f); + stage1.addActor(group); + + DebugActor actor = new DebugActor(); + actor.setBounds(400, 240, 50, 100); + actor.setOrigin(25, 50); + actor.setRotation(-45); + actor.setScale(2f); + group.addActor(actor); + + stage2 = new Stage(); + Skin skin = new Skin(Gdx.files.internal("data/uiskin.json")); + + Table root = new Table(skin); + root.setFillParent(true); + root.setBackground(skin.getDrawable("default-pane")); + root.defaults().space(6); + root.debug(); + TextButton shortButton = new TextButton("Button short", skin); + root.add(shortButton).pad(5); + shortButton.debug(); + TextButton longButton = new TextButton("Button loooooooooong", skin); + longButton.debug(); + root.add(longButton).row(); + root.add("Colspan").colspan(2).row(); + root.setTransform(true); + root.rotateBy(10); + stage2.addActor(root); + + switchStage(); + } + + @Override + public void render () { + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); + + stage.draw(); + debugRenderer.render(); + } + + @Override + public boolean touchDown (int screenX, int screenY, int pointer, int button) { + switchStage(); + return false; + } + + @Override + public void resize (int width, int height) { + stage1.getViewport().update(width, height, true); + stage2.getViewport().update(width, height, true); + } + + private void switchStage () { + if (stage != stage1) { + stage = stage1; + } else { + stage = stage2; + } + debugRenderer = new Scene2DDebugRenderer(stage); + } + + /** A workaround for the limitations of UI elements when it comes to rotation and scaling. For most groups this is disabled by + * default. */ + private Table createWrapper (Actor actor) { + Table wrapper = new Table(); + wrapper.setTransform(true); + wrapper.add(actor); + wrapper.setOrigin(wrapper.getPrefWidth() / 2f, wrapper.getPrefHeight() / 2f); + return wrapper; + } + +} diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2dTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2dTest.java index 1b0ade235b2..efa16aa9b71 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2dTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2dTest.java @@ -40,16 +40,19 @@ import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; import com.badlogic.gdx.scenes.scene2d.ui.Window; import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.scenes.scene2d.utils.TiledDrawable; import com.badlogic.gdx.tests.utils.GdxTest; public class Scene2dTest extends GdxTest { Stage stage; + Scene2DDebugRenderer debugRenderer; private FloatAction meow = new FloatAction(10, 5); private TiledDrawable patch; public void create () { stage = new Stage(); + debugRenderer = new Scene2DDebugRenderer(stage); Gdx.input.setInputProcessor(stage); final TextureRegion region = new TextureRegion(new Texture("data/badlogic.jpg")); @@ -174,7 +177,7 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); - Table.drawDebug(stage); + debugRenderer.render(); stage.getBatch().begin(); patch.draw(stage.getBatch(), 300, 100, 126, 126); diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPane2Test.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPane2Test.java index 3d6f4e7841c..2fc53be115b 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPane2Test.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPane2Test.java @@ -26,14 +26,17 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.tests.utils.GdxTest; public class ScrollPane2Test extends GdxTest { Stage stage; Skin skin; + Scene2DDebugRenderer debugRenderer; public void create () { stage = new Stage(); + debugRenderer = new Scene2DDebugRenderer(stage); Gdx.input.setInputProcessor(stage); skin = new Skin(Gdx.files.internal("data/uiskin.json")); @@ -82,7 +85,7 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); - Table.drawDebug(stage); + debugRenderer.render(); } public void resize (int width, int height) { diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPaneScrollBarsTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPaneScrollBarsTest.java index 7cfd4494e27..445757acbb5 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPaneScrollBarsTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPaneScrollBarsTest.java @@ -224,7 +224,6 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); - Table.drawDebug(stage); } public void resize (int width, int height) { diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPaneTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPaneTest.java index 08004fc979f..ceb9cd2e7b8 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPaneTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ScrollPaneTest.java @@ -123,7 +123,6 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); - Table.drawDebug(stage); } public void resize (int width, int height) { diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/TableLayoutTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/TableLayoutTest.java index 3ae1f7f3ff3..71a36e93222 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/TableLayoutTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/TableLayoutTest.java @@ -30,13 +30,16 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextField; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.tests.utils.GdxTest; public class TableLayoutTest extends GdxTest { Stage stage; + Scene2DDebugRenderer debugRenderer; public void create () { stage = new Stage(); + debugRenderer = new Scene2DDebugRenderer(stage); Gdx.input.setInputProcessor(stage); Skin skin = new Skin(Gdx.files.internal("data/uiskin.json")); @@ -91,7 +94,7 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); - Table.drawDebug(stage); + debugRenderer.render(); } public void resize (int width, int height) { diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/TableTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/TableTest.java index 063551757bd..5b11fcf088d 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/TableTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/TableTest.java @@ -31,6 +31,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.tests.utils.GdxTest; public class TableTest extends GdxTest { @@ -38,10 +39,12 @@ public class TableTest extends GdxTest { Stage stage; Texture texture; Table root; + Scene2DDebugRenderer debugRenderer; @Override public void create () { stage = new Stage(); + debugRenderer = new Scene2DDebugRenderer(stage); Gdx.input.setInputProcessor(stage); skin = new Skin(Gdx.files.internal("data/uiskin.json")); @@ -105,7 +108,7 @@ public void render () { stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); - Table.drawDebug(stage); + debugRenderer.render(); } @Override diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/TreeTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/TreeTest.java index 4fc0785c58b..2a65472a50f 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/TreeTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/TreeTest.java @@ -68,7 +68,6 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Gdx.graphics.getDeltaTime()); stage.draw(); - Table.drawDebug(stage); } public void resize (int width, int height) { diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/UISimpleTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/UISimpleTest.java index 95363b9e238..aeb53277208 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/UISimpleTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/UISimpleTest.java @@ -97,7 +97,6 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); - Table.drawDebug(stage); } @Override diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java index c4678d3e13a..fca61caa7d8 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/UITest.java @@ -182,7 +182,6 @@ public void render () { stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); - Table.drawDebug(stage); } @Override diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/ViewportTest1.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/ViewportTest1.java index a9b7195b8b7..82a0e9c2c09 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/ViewportTest1.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/ViewportTest1.java @@ -27,6 +27,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.utils.Scene2DDebugRenderer; import com.badlogic.gdx.tests.utils.GdxTest; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Scaling; @@ -44,10 +45,12 @@ public class ViewportTest1 extends GdxTest { Array names; Stage stage; Label label; + Scene2DDebugRenderer debugRenderer; public void create () { stage = new Stage(); Skin skin = new Skin(Gdx.files.internal("data/uiskin.json")); + debugRenderer = new Scene2DDebugRenderer(stage); label = new Label("", skin); @@ -86,7 +89,8 @@ public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.draw(); - Table.drawDebug(stage); + debugRenderer.render(); +// Table.drawDebug(stage); } public void resize (int width, int height) { diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTests.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTests.java index e9633000886..c4b26b257e1 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTests.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTests.java @@ -157,6 +157,7 @@ public class GdxTests { ReflectionTest.class, RotationTest.class, RunnablePostTest.class, + Scene2DDebugRendererTest.class, Scene2dTest.class, ScrollPane2Test.class, ScrollPaneScrollBarsTest.class, From 9e8654d6736de21a47ef2a82322030d771f133a6 Mon Sep 17 00:00:00 2001 From: Daniel Holderbaum Date: Sat, 28 Jun 2014 22:17:56 +0200 Subject: [PATCH 6/9] Removed an unused method. --- .../badlogic/gdx/tests/Scene2DDebugRendererTest.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java index 4e3c6e78aec..803481b629d 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java @@ -119,14 +119,4 @@ private void switchStage () { debugRenderer = new Scene2DDebugRenderer(stage); } - /** A workaround for the limitations of UI elements when it comes to rotation and scaling. For most groups this is disabled by - * default. */ - private Table createWrapper (Actor actor) { - Table wrapper = new Table(); - wrapper.setTransform(true); - wrapper.add(actor); - wrapper.setOrigin(wrapper.getPrefWidth() / 2f, wrapper.getPrefHeight() / 2f); - return wrapper; - } - } From 3ddad494fa24661d221319afb2b18e52e8b54a63 Mon Sep 17 00:00:00 2001 From: Daniel Holderbaum Date: Sun, 29 Jun 2014 07:48:28 +0200 Subject: [PATCH 7/9] Small bugfix and renamed fields. --- gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java | 13 +++++++------ .../com/badlogic/gdx/scenes/scene2d/ui/Table.java | 10 +++++----- .../scenes/scene2d/utils/Scene2DDebugRenderer.java | 11 ++++++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java index f25a0f3ef39..a20a17ff27e 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java @@ -380,16 +380,16 @@ public void setPosition (float x, float y) { } /** Set position of Actor centered on x, y */ - public void setCenterPosition(float x, float y) { + public void setCenterPosition (float x, float y) { this.x = x - width / 2; this.y = y - height / 2; } - public float getCenterX() { + public float getCenterX () { return this.x + width / 2; } - public float getCenterY() { + public float getCenterY () { return this.y + height / 2; } @@ -555,8 +555,7 @@ public Color getColor () { return color; } - /** Retrieve custom actor name set with {@link Actor#setName(String)}, - * used for easier identification */ + /** Retrieve custom actor name set with {@link Actor#setName(String)}, used for easier identification */ public String getName () { return name; } @@ -578,11 +577,13 @@ public void getDebugRects (Array debugRects) { debugRects.add(debugRect); } - /** Used only in combination with a {@link Scene2DDebugRenderer}. */ + /** Used only in combination with a {@link Scene2DDebugRenderer}. It does only influence this particular actor, not its + * children, in case we have a {@link Group}. */ public void setDebuggingEnabled (boolean enabled) { debuggingEnabled = enabled; } + /** Used only in combination with a {@link Scene2DDebugRenderer}. */ public boolean isDebuggingEnabled () { return debuggingEnabled; } diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java index 3c8c07a5bce..9f6a9bd6db6 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java @@ -37,8 +37,8 @@ * @author Nathan Sweet */ public class Table extends WidgetGroup { - public static final Color tableColor = new Color(0, 0, 1, 1); - public static final Color cellColor = new Color(1, 0, 0, 1); + public static final Color debugColor = new Color(0, 0, 1, 1); + public static final Color debugCellColor = new Color(1, 0, 0, 1); static Pool cellPool = new Pool() { protected Cell newObject () { @@ -1092,8 +1092,8 @@ else if ((c.align & Align.bottom) != 0) currentX = x; currentY = y; if (debug == Debug.table || debug == Debug.all) { - addDebugRect(layoutX, layoutY, layoutWidth, layoutHeight, tableColor); - addDebugRect(x, y, tableWidth - hpadding, tableHeight - vpadding, tableColor); + addDebugRect(layoutX, layoutY, layoutWidth, layoutHeight, debugColor); + addDebugRect(x, y, tableWidth - hpadding, tableHeight - vpadding, debugColor); } for (int i = 0; i < cellCount; i++) { Cell c = cells.get(i); @@ -1110,7 +1110,7 @@ else if ((c.align & Align.bottom) != 0) currentX += c.computedPadLeft; if (debug == Debug.cell || debug == Debug.all) { addDebugRect(currentX, currentY + c.computedPadTop, spannedCellWidth, rowHeight[c.row] - c.computedPadTop - - c.computedPadBottom, cellColor); + - c.computedPadBottom, debugCellColor); } if (c.endRow) { diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java index 66214efd9f6..62c3998ae62 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/utils/Scene2DDebugRenderer.java @@ -100,12 +100,13 @@ private void renderRecursive (Actor actor) { renderBoundingBox(actor, topLeft, topRight, bottomRight, bottomLeft, debugRect.color); } debugRects.clear(); + } - if (actor instanceof Group) { - Group group = (Group)actor; - for (Actor child : group.getChildren()) { - renderRecursive(child); - } + // children are still rendered, even if the group has no debugging enabled + if (actor instanceof Group) { + Group group = (Group)actor; + for (Actor child : group.getChildren()) { + renderRecursive(child); } } From 0bf494aa4e926eeeb2123ff13ffcc1fd6430f320 Mon Sep 17 00:00:00 2001 From: Daniel Holderbaum Date: Sun, 29 Jun 2014 11:49:37 +0200 Subject: [PATCH 8/9] Removed the final modifiers for colors. --- .../badlogic/gdx/scenes/scene2d/Actor.java | 2 +- .../badlogic/gdx/scenes/scene2d/ui/Table.java | 4 ++-- .../gdx/tests/Scene2DDebugRendererTest.java | 22 +++++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java index a20a17ff27e..ddbd33be2c1 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/Actor.java @@ -68,7 +68,7 @@ public class Actor { private Object userObject; private boolean debuggingEnabled = true; - public static final Color debugColor = new Color(0, 1, 0, 1); + public static Color debugColor = new Color(0, 1, 0, 1); /** Draws the actor. The Batch is configured to draw in the parent's coordinate system. * {@link Batch#draw(com.badlogic.gdx.graphics.g2d.TextureRegion, float, float, float, float, float, float, float, float, float) diff --git a/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java b/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java index 9f6a9bd6db6..cab85cda1c2 100644 --- a/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java +++ b/gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Table.java @@ -37,8 +37,8 @@ * @author Nathan Sweet */ public class Table extends WidgetGroup { - public static final Color debugColor = new Color(0, 0, 1, 1); - public static final Color debugCellColor = new Color(1, 0, 0, 1); + public static Color debugColor = new Color(0, 0, 1, 1); + public static Color debugCellColor = new Color(1, 0, 0, 1); static Pool cellPool = new Pool() { protected Cell newObject () { diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java index 803481b629d..b8043fccd7c 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/Scene2DDebugRendererTest.java @@ -1,10 +1,18 @@ -/* ###################################### - * Copyright 2014 (c) Pixel Scientists - * All rights reserved. - * Unauthorized copying of this file, via - * any medium is strictly prohibited. - * Proprietary and confidential. - * ###################################### */ +/******************************************************************************* + * Copyright 2011 See AUTHORS file. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ package com.badlogic.gdx.tests; From 3335ae71971a08533f4ebc54facf4491fcad802c Mon Sep 17 00:00:00 2001 From: Daniel Holderbaum Date: Wed, 23 Jul 2014 18:41:18 +0200 Subject: [PATCH 9/9] Added entry to CHANGES --- CHANGES | 1 + CONTRIBUTORS | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index f5145017f29..ca27e708c77 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,5 @@ [1.2.1] +- API change: Added a new Scene2DDebugRenderer and removed the old Table debug rendering, see https://github.com/libgdx/libgdx/pull/2011 - Files#getLocalStoragePath now returns the actual path instead of the empty string synonym on desktop (LWJGL and JGLFW). - Fixed and improved xorshift128+ PRNG implementation. - Added support for Tiled's animated tiles, and varying frame duration tile animations. diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 3e9ea9101a2..e318e42a50b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -169,4 +169,5 @@ mbforbes https://github.com/mbforbes Unkn0wn0ne https://github.com/Unkn0wn0ne davebaol https://github.com/davebaol CodePoKE https://github.com/codepoke -Konijnendijk https://github.com/Konijnendijk \ No newline at end of file +Konijnendijk https://github.com/Konijnendijk +nooone https://github.com/nooone \ No newline at end of file