[updated] Json, pretty print sorts.
[updated] Misc changes.
}\r
}\r
\r
+ public NinePatch (Texture texture) {\r
+ this(new TextureRegion(texture));\r
+ }\r
+\r
public NinePatch (TextureRegion region) {\r
this.patches = new TextureRegion[] {\r
//\r
public abstract class Interpolation {\r
abstract public float apply (float a);\r
\r
+ public float apply (float start, float end, float a) {\r
+ return start + (end - start) * apply(a);\r
+ }\r
+\r
static public final Interpolation linear = new Interpolation() {\r
public float apply (float a) {\r
return a;\r
case 2:\r
widths[0] = 0.6f;\r
widths[1] = 0.4f;\r
- heights[1] = 0.1f;\r
+ heights[1] = 0.33f;\r
break;\r
case 3:\r
widths[0] = 0.4f;\r
import com.badlogic.gdx.math.Vector3;\r
import com.badlogic.gdx.utils.Disposable;\r
\r
+// BOZO - Set culling area on root group?\r
+\r
/** A stage is a container for {@link Actor}s and handles distributing touch events, animating actors and asking them to render\r
* themselves. A stage is 2D scenegraph with hierarchies of Actors.\r
* <p>\r
super(null, null, null, name);
if (style == null) throw new IllegalArgumentException("style cannot be null.");
setStyle(style);
- initialize();
- }
+ pack();
- private void initialize () {
super.setClickListener(new ClickListener() {
public void click (Actor actor) {
boolean newChecked = !isChecked;
\r
/** @param region May be null. */\r
public Image (TextureRegion region, Scaling scaling, int align, String name) {\r
+ super(name);\r
setRegion(region);\r
this.scaling = scaling;\r
this.align = align;\r
\r
/** @param patch May be null. */\r
public Image (NinePatch patch, Scaling scaling, int align, String name) {\r
+ super(name);\r
setPatch(patch);\r
this.scaling = scaling;\r
this.align = align;\r
this(text, skin.getStyle(LabelStyle.class), null);\r
}\r
\r
+ /** Creates a label, using a {@link LabelStyle} that has a BitmapFont with the specified name and the specified color. */\r
+ public Label (String text, String fontName, Color color, Skin skin) {\r
+ this(text, new LabelStyle(skin.getResource(fontName, BitmapFont.class), color), null);\r
+ }\r
+\r
public Label (String text, LabelStyle style) {\r
this(text, style, null);\r
}\r
if (style.font == null) throw new IllegalArgumentException("Missing LabelStyle font.");\r
this.style = style;\r
cache = new BitmapFontCache(style.font);\r
- if (style.fontColor != null) cache.setColor(style.fontColor);\r
+ if (style.fontColor != null) {\r
+ if (style.fontColor.r == 0.51f)\r
+ System.out.println();\r
+ cache.setColor(style.fontColor);\r
+ }\r
invalidateHierarchy();\r
}\r
\r
\r
public void layout () {\r
for (int i = 0, n = children.size(); i < n; i++) {\r
- Actor actor = children.get(i);\r
- actor.x = 0;\r
- actor.y = 0;\r
- actor.width = width;\r
- actor.height = height;\r
- if (actor instanceof Layout) ((Layout)actor).invalidate();\r
+ Actor child = children.get(i);\r
+ child.x = 0;\r
+ child.y = 0;\r
+ child.width = width;\r
+ child.height = height;\r
+ if (child instanceof Layout) {\r
+ Layout layout = (Layout)child;\r
+ layout.invalidate();\r
+ layout.validate();\r
+ }\r
}\r
}\r
\r
actor.y = table.height - c.getWidgetY() - widgetHeight;\r
actor.width = c.getWidgetWidth();\r
actor.height = widgetHeight;\r
- if (actor instanceof Layout) ((Layout)actor).invalidate();\r
+ }\r
+ List<Actor> children = table.getActors();\r
+ for (int i = 0, n = children.size(); i < n; i++) {\r
+ Actor child = children.get(i);\r
+ if (child instanceof Layout) {\r
+ Layout layout = (Layout)child;\r
+ layout.invalidate();\r
+ layout.validate();\r
+ }\r
}\r
}\r
\r
\r
private void prettyPrint (Object object, StringBuilder buffer, int indent, boolean fieldsOnSameLine) {\r
if (object instanceof ObjectMap) {\r
- ObjectMap<?, ?> map = (ObjectMap)object;\r
+ ObjectMap map = (ObjectMap)object;\r
if (map.size == 0) {\r
buffer.append("{}");\r
} else {\r
boolean newLines = !fieldsOnSameLine || !isFlat(map) || map.size > 4;\r
buffer.append(newLines ? "{\n" : "{ ");\r
+ Array<String> keys = (Array)map.keys().toArray();\r
+ keys.sort();\r
int i = 0;\r
- for (Entry entry : map.entries()) {\r
+ for (String key : keys) {\r
if (newLines) indent(indent, buffer);\r
- buffer.append(outputType.quoteName((String)entry.key));\r
+ buffer.append(outputType.quoteName(key));\r
buffer.append(": ");\r
- prettyPrint(entry.value, buffer, indent + 1, fieldsOnSameLine);\r
+ prettyPrint(map.get(key), buffer, indent + 1, fieldsOnSameLine);\r
if (i++ < map.size - 1) buffer.append(",");\r
buffer.append(newLines ? '\n' : ' ');\r
}\r
public static int floatToRawIntBits (float value) {\r
return Float.floatToRawIntBits(value);\r
}\r
- \r
+\r
public static int floatToIntColor (float value) {\r
return Float.floatToRawIntBits(value);\r
}\r
- \r
- public static float intToFloatColor(int value) {\r
- return Float.intBitsToFloat(value);\r
+\r
+ public static float intToFloatColor (int value) {\r
+ // This mask avoids using bits in the NaN range. See Float.intBitsToFloat javadocs.\r
+ // This unfortunately means we don't get the full range of alpha.\r
+ return Float.intBitsToFloat(value & 0xfeffffff);\r
}\r
\r
public static float intBitsToFloat (int value) {\r