Permalink
Browse files

* 09/15/2012 0.4 Build 319*

---------------------------
* FIX. CAAT.Actor.scaleTo wasn't scaling correctly.
* ADD. Automatic Actor layout capabilities on CAAT.ActorContainer. Switch from CAAT.UI.BorderLayout, CAAT.UI.GridLayout,
       CAAT.UI.BoxLayout.
* ADD. Demo29. Layouts
  • Loading branch information...
1 parent b12a296 commit dc51fa9530f3283ec52ce705e7726cc295f171e7 ibon tolosana committed Sep 16, 2012
Showing with 9,057 additions and 4,034 deletions.
  1. +3 −3 build/caat-box2d-min.js
  2. +3 −3 build/caat-box2d.js
  3. +3 −338 build/caat-css-min.js
  4. +872 −87 build/caat-css.js
  5. +73 −50 build/caat-min.js
  6. +847 −46 build/caat.js
  7. +7 −0 changelog
  8. +4 −4 documentation/demos/demo27/font.html
  9. +325 −0 documentation/demos/demo29/layout.html
  10. +316 −0 documentation/demos/demo29/layout2.html
  11. +1 −1 documentation/demos/demo4/coordinates_org.html
  12. +1 −0 documentation/demos/index.html
  13. +1 −0 documentation/demos/menu/menu.html
  14. +35 −9 documentation/jsdoc/files.html
  15. +9 −1 documentation/jsdoc/index.html
  16. +267 −19 documentation/jsdoc/symbols/CAAT.Actor.html
  17. +266 −8 documentation/jsdoc/symbols/CAAT.ActorContainer.html
  18. +3 −1 documentation/jsdoc/symbols/CAAT.AlphaBehavior.html
  19. +3 −1 documentation/jsdoc/symbols/CAAT.ArcPath.html
  20. +3 −1 documentation/jsdoc/symbols/CAAT.AudioManager.html
  21. +3 −1 documentation/jsdoc/symbols/CAAT.Behavior.html
  22. +3 −1 documentation/jsdoc/symbols/CAAT.Bezier.html
  23. +3 −1 documentation/jsdoc/symbols/CAAT.CatmullRom.html
  24. +3 −1 documentation/jsdoc/symbols/CAAT.Color.RGB.html
  25. +3 −1 documentation/jsdoc/symbols/CAAT.Color.html
  26. +3 −1 documentation/jsdoc/symbols/CAAT.ColorBehavior.html
  27. +3 −1 documentation/jsdoc/symbols/CAAT.ContainerBehavior.html
  28. +3 −1 documentation/jsdoc/symbols/CAAT.Curve.html
  29. +3 −1 documentation/jsdoc/symbols/CAAT.CurvePath.html
  30. +4 −2 documentation/jsdoc/symbols/CAAT.Director.html
  31. +3 −1 documentation/jsdoc/symbols/CAAT.Font.html
  32. +3 −1 documentation/jsdoc/symbols/CAAT.GenericBehavior.html
  33. +4 −2 documentation/jsdoc/symbols/CAAT.IMActor.html
  34. +3 −1 documentation/jsdoc/symbols/CAAT.IMBump.html
  35. +3 −1 documentation/jsdoc/symbols/CAAT.IMPlasma.html
  36. +3 −1 documentation/jsdoc/symbols/CAAT.IMRotoZoom.html
  37. +3 −1 documentation/jsdoc/symbols/CAAT.ImagePreloader.html
  38. +3 −1 documentation/jsdoc/symbols/CAAT.ImageProcessor.html
  39. +3 −1 documentation/jsdoc/symbols/CAAT.Interpolator.html
  40. +4 −2 documentation/jsdoc/symbols/CAAT.InterpolatorActor.html
  41. +3 −1 documentation/jsdoc/symbols/CAAT.KeyEvent.html
  42. +3 −1 documentation/jsdoc/symbols/CAAT.LinearPath.html
  43. +3 −1 documentation/jsdoc/symbols/CAAT.Matrix3.html
  44. +3 −1 documentation/jsdoc/symbols/CAAT.MatrixStack.html
  45. +3 −1 documentation/jsdoc/symbols/CAAT.MouseEvent.html
  46. +3 −1 documentation/jsdoc/symbols/CAAT.Path.html
  47. +4 −2 documentation/jsdoc/symbols/CAAT.PathActor.html
  48. +3 −1 documentation/jsdoc/symbols/CAAT.PathBehavior.html
  49. +3 −1 documentation/jsdoc/symbols/CAAT.PathSegment.html
  50. +3 −1 documentation/jsdoc/symbols/CAAT.Point.html
  51. +3 −1 documentation/jsdoc/symbols/CAAT.Rectangle.html
  52. +3 −1 documentation/jsdoc/symbols/CAAT.RotateBehavior.html
  53. +3 −1 documentation/jsdoc/symbols/CAAT.Scale1Behavior.html
  54. +3 −1 documentation/jsdoc/symbols/CAAT.ScaleBehavior.html
  55. +4 −2 documentation/jsdoc/symbols/CAAT.Scene.html
  56. +4 −2 documentation/jsdoc/symbols/CAAT.ShapeActor.html
  57. +3 −1 documentation/jsdoc/symbols/CAAT.SpriteImage.html
  58. +4 −2 documentation/jsdoc/symbols/CAAT.StarActor.html
  59. +4 −2 documentation/jsdoc/symbols/CAAT.TextActor.html
  60. +3 −1 documentation/jsdoc/symbols/CAAT.TimerTask.html
  61. +3 −1 documentation/jsdoc/symbols/CAAT.TouchEvent.html
  62. +595 −0 documentation/jsdoc/symbols/CAAT.UI.GridLayout.html
  63. +57 −1 documentation/jsdoc/symbols/CAAT.html
  64. +3 −1 documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html
  65. +3 −1 documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html
  66. +3 −1 documentation/jsdoc/symbols/CAAT.modules.CircleManager.html
  67. +3 −1 documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html
  68. +3 −36 documentation/jsdoc/symbols/CAAT.modules.html
  69. +3 −1 documentation/jsdoc/symbols/Function.html
  70. +3 −1 documentation/jsdoc/symbols/_global_.html
  71. +21 −0 documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_dimension.js.html
  72. +3,455 −3,305 documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_actor.js.html
  73. +646 −0 documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_ui_layoutManager.js.html
  74. +8 −0 documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_ui_namespace.js.html
  75. +14 −0 src/math/dimension.js
  76. +191 −41 src/model/actor.js
  77. +216 −19 src/model/actorCSS.js
  78. +638 −0 src/ui/layoutManager.js
  79. +1 −0 src/ui/namespace.js
  80. +4 −1 version.compile.doc.sh
  81. +7 −1 version.compile.pack.sh
  82. +8 −1 version.compile.sh
  83. +1 −1 version.incremental
  84. +1 −1 version.nfo
View
6 build/caat-box2d-min.js
@@ -22,11 +22,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-Version: 0.4 build: 303
+Version: 0.4 build: 318
Created on:
-DATE: 2012-09-11
-TIME: 22:07:39
+DATE: 2012-09-15
+TIME: 16:50:46
*/
View
6 build/caat-box2d.js
@@ -21,11 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-Version: 0.4 build: 304
+Version: 0.4 build: 319
Created on:
-DATE: 2012-09-11
-TIME: 22:08:05
+DATE: 2012-09-15
+TIME: 16:51:26
*/
View
341 build/caat-css-min.js
3 additions, 338 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
959 build/caat-css.js
@@ -21,11 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-Version: 0.4 build: 304
+Version: 0.4 build: 319
Created on:
-DATE: 2012-09-11
-TIME: 22:08:05
+DATE: 2012-09-15
+TIME: 16:51:25
*/
@@ -2960,7 +2960,20 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
}
};
-})();/**
+})();(function() {
+
+ CAAT.Dimension= function(w,h) {
+ this.width= w;
+ this.height= h;
+ return this;
+ };
+
+ CAAT.Dimension.prototype= {
+ width : 0,
+ height : 0
+ };
+
+}());/**
* See LICENSE file.
*
* Generate interpolator.
@@ -5749,6 +5762,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
y: 0, // y position on parent. In parent's local coord. system.
width: 0, // Actor's width. In parent's local coord. system.
height: 0, // Actor's height. In parent's local coord. system.
+ preferredSize: null, // actor's preferred size for layout. {CAAT.Dimension}
+ minimumSize: null, // actor's minimum size for layout. {CAAT.Dimension},
start_time: 0, // Start time in Scene time.
duration: Number.MAX_VALUE, // Actor duration in Scene time
clip: false, // should clip the Actor's content against its contour.
@@ -5804,6 +5819,69 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
viewVertices: null, // model to view transformed vertices.
isAA : true,
+
+ invalidateLayout : function() {
+ if ( this.parent && !this.parent.layoutInvalidated ) {
+ this.parent.invalidateLayout();
+ }
+
+ return this;
+ },
+
+ __validateLayout : function() {
+
+ },
+
+ /**
+ * Set this actors preferred layout size.
+ *
+ * @param pw {number}
+ * @param ph {number}
+ * @return {*}
+ */
+ setPreferredSize : function( pw, ph ) {
+ if ( !this.preferredSize ) {
+ this.preferredSize= new CAAT.Dimension();
+ }
+ this.preferredSize.width= pw;
+ this.preferredSize.height= ph;
+ return this;
+ },
+
+ getPreferredSize : function() {
+ return this.preferredSize ? this.preferredSize :
+ this.getMinimumSize();
+ },
+
+ /**
+ * Set this actors minimum layout size.
+ *
+ * @param pw {number}
+ * @param ph {number}
+ * @return {*}
+ */
+ setMinimumSize : function( pw, ph ) {
+ if ( !this.minimumSize ) {
+ this.minimumSize= new CAAT.Dimension();
+ }
+
+ this.minimumSize.width= pw;
+ this.minimumSize.height= ph;
+ return this;
+ },
+
+ getMinimumSize : function() {
+ return this.minimumSize ? this.minimumSize :
+ new CAAT.Dimension(this.width, this.height);
+ },
+
+ /**
+ * @deprecated
+ * @return {*}
+ */
+ create : function() {
+ return this;
+ },
/**
* Move this actor to a position.
* It creates and adds a new PathBehavior.
@@ -5814,6 +5892,11 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @param interpolator {=CAAT.Interpolator} a CAAT.Interpolator instance
*/
moveTo : function( x, y, duration, delay, interpolator ) {
+
+ if ( x===this.x && y===this.y ) {
+ return;
+ }
+
var id= '__moveTo';
var b= this.getBehavior( id );
if ( !b ) {
@@ -5836,13 +5919,18 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
*
* @param angle {number} new rotation angle
* @param duration {number} time to rotate
- * @param delay {=number} millis to start rotation
- * @param anchorX {=number} rotation anchor x
- * @param anchorY {=number} rotation anchor y
- * @param interpolator {=CAAT.Interpolator}
+ * @param delay {number=} millis to start rotation
+ * @param anchorX {number=} rotation anchor x
+ * @param anchorY {number=} rotation anchor y
+ * @param interpolator {CAAT.Interpolator=}
* @return {*}
*/
rotateTo : function( angle, duration, delay, anchorX, anchorY, interpolator ) {
+
+ if ( angle===this.rotationAngle ) {
+ return;
+ }
+
var id= '__rotateTo';
var b= this.getBehavior( id );
if ( !b ) {
@@ -5874,6 +5962,11 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @return {*}
*/
scaleTo : function( scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator ) {
+
+ if ( this.scaleX===scaleX && this.scaleY===scaleY ) {
+ return;
+ }
+
var id= '__scaleTo';
var b= this.getBehavior( id );
if ( !b ) {
@@ -5883,7 +5976,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
this.addBehavior(b);
}
- b.setValues( this.scaleX, this.scaleY, scaleX, scaleY, anchorX, anchorY ).
+ b.setValues( this.scaleX, scaleX, this.scaleY, scaleY, anchorX, anchorY ).
setDelayTime( delay ? delay : 0, duration);
if ( interpolator ) {
@@ -5948,6 +6041,13 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @return {*}
*/
__scale1To : function( axis, scale, duration, delay, anchorX, anchorY, interpolator ) {
+
+ if (( axis === CAAT.Scale1Behavior.AXIS_X && scale===this.scaleX) ||
+ ( axis === CAAT.Scale1Behavior.AXIS_Y && scale===this.scaleY)) {
+
+ return;
+ }
+
var id= '__scaleXTo';
var b= this.getBehavior( id );
if ( !b ) {
@@ -5970,6 +6070,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
return this;
},
+
/**
* Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH
* @param e <CAAT.TouchEvent>
@@ -7687,6 +7788,59 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
boundingBox : null,
runion : new CAAT.Rectangle(), // Watch out. one for every container.
+ layoutManager : null, // a layout manager instance.
+ layoutInvalidated : true,
+
+
+ setLayout : function( layout ) {
+ this.layoutManager= layout;
+ return this;
+ },
+
+ setBounds : function( x,y,w,h ) {
+ CAAT.ActorContainer.superclass.setBounds.call( this,x,y,w,h );
+ if ( CAAT.currentDirector && !CAAT.currentDirector.inValidation ) {
+ this.invalidateLayout();
+ }
+ return this;
+ },
+
+ __validateLayout : function() {
+
+ this.__validateTree();
+ this.layoutInvalidated= false;
+ },
+
+ __validateTree : function() {
+ if ( this.layoutManager && this.layoutManager.isInvalidated() ) {
+
+ CAAT.currentDirector.inValidation= true;
+
+ this.layoutManager.doLayout( this );
+
+ for( var i=0; i<this.getNumChildren(); i+=1 ) {
+ this.getChildAt(i).__validateLayout();
+ }
+ }
+ },
+
+ invalidateLayout : function() {
+ this.layoutInvalidated= true;
+
+ if ( this.layoutManager ) {
+ this.layoutManager.invalidateLayout(this);
+
+ for( var i=0; i<this.getNumChildren(); i+=1 ) {
+ this.getChildAt(i).invalidateLayout();
+ }
+ }
+ },
+
+ getLayout : function() {
+ return this.layoutManager;
+ },
+
+
/**
* Removes all children from this ActorContainer.
*
@@ -7734,6 +7888,9 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
return false;
}
+ this.__validateLayout();
+ CAAT.currentDirector.inValidation= false;
+
var i,l;
var notActive= [];
@@ -7801,8 +7958,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @param child a CAAT.Actor instance.
* @return this.
*/
- addChildImmediately : function(child) {
- return this.addChild(child);
+ addChildImmediately : function(child, constraint) {
+ return this.addChild(child, constraint);
},
/**
* Adds an Actor to this ActorContainer.
@@ -7813,16 +7970,21 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @param child a CAAT.Actor object instance.
* @return this
*/
- addChild : function(child) {
+ addChild : function(child, constraint) {
child.setParent( this );
this.childrenList.push(child);
child.dirty= true;
- /**
- * if Conforming size, recalc new bountainer size.
- */
- if ( this.addHint===CAAT.ActorContainer.AddHint.CONFORM ) {
- this.recalcSize();
+ if ( this.layoutManager ) {
+ this.layoutManager.addChild( child, constraint );
+ this.invalidateLayout();
+ } else {
+ /**
+ * if Conforming size, recalc new bountainer size.
+ */
+ if ( this.addHint===CAAT.ActorContainer.AddHint.CONFORM ) {
+ this.recalcSize();
+ }
}
return this;
@@ -7872,6 +8034,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
child.parent= this;
child.dirty= true;
this.childrenList.splice( 0, 0, child );
+ this.invalidateLayout();
return this;
} else {
if ( index>=this.childrenList.length ) {
@@ -7883,12 +8046,29 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
this.childrenList.splice(index, 0, child);
this.domElement.insertBefore(child.domElement, this.domElement.childNodes[index]);
+ this.invalidateLayout();
child.dirty= true;
return this;
},
/**
+ * Find the first actor with the supplied ID.
+ * This method is not recommended to be used since executes a linear search.
+ * @param id
+ */
+ findActorById : function(id) {
+ var cl= this.childrenList;
+ for( var i=0, l=cl.length; i<l; i++ ) {
+ if ( cl[i].id===id ) {
+ return cl[i];
+ }
+ }
+
+ return null;
+ },
+
+ /**
* Private
* Gets a contained Actor z-index on this ActorContainer.
*
@@ -7906,6 +8086,19 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
}
return -1;
},
+
+ removeChildAt : function( pos ) {
+ var cl= this.childrenList;
+ var rm;
+ if ( -1!==pos ) {
+ cl[pos].setParent(null);
+ rm= cl.splice(pos,1);
+ this.invalidateLayout();
+ return rm[0];
+ }
+
+ return null;
+ },
/**
* Removed an Actor form this ActorContainer.
* If the Actor is not contained into this Container, nothing happends.
@@ -7915,14 +8108,29 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @return this
*/
removeChild : function(child) {
- var pos= this.findChild(child);
- if ( -1!==pos ) {
- this.childrenList[pos].setParent(null);
- this.childrenList.splice(pos,1);
- }
+ var pos= this.findChild(child);
+ var ret= this.removeChildAt(pos);
- return this;
+ return ret;
},
+ removeFirstChild : function() {
+ var first= this.childrenList.shift();
+ first.setParent( null );
+ this.invalidateLayout();
+
+ return first;
+ },
+ removeLastChild : function() {
+ if ( this.childrenList.length ) {
+ var last= this.childrenList.pop();
+ last.setParent( null );
+ this.invalidateLayout();
+ return last;
+ }
+
+ return null;
+ },
+
/**
* @private
*
@@ -8017,6 +8225,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
for( var i=0,l=cl.length; i<l; i++ ) {
cl[i].domElement.style.zIndex = i;
}
+
+ this.invalidateLayout();
}
}
};
@@ -14473,69 +14683,6 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
})();/**
* See LICENSE file.
- */
-
-(function() {
- CAAT.modules.LayoutUtils= {};
-
- CAAT.modules.LayoutUtils.row= function( dst, what_to_layout_array, constraint_object ) {
-
- var width= dst.width;
- var x=0, y=0, i=0, l=0;
- var actor_max_h= -Number.MAX_VALUE, actor_max_w= Number.MAX_VALUE;
-
- // compute max/min actor list size.
- for( i=what_to_layout_array.length-1; i; i-=1 ) {
- if ( actor_max_w<what_to_layout_array[i].width ) {
- actor_max_w= what_to_layout_array[i].width;
- }
- if ( actor_max_h<what_to_layout_array[i].height ) {
- actor_max_h= what_to_layout_array[i].height;
- }
- }
-
- if ( constraint_object.padding_left ) {
- x= constraint_object.padding_left;
- width-= x;
- }
- if ( constraint_object.padding_right ) {
- width-= constraint_object.padding_right;
- }
-
- if ( constraint_object.top ) {
- var top= parseInt(constraint_object.top, 10);
- if ( !isNaN(top) ) {
- y= top;
- } else {
- // not number
- switch(constraint_object.top) {
- case 'center':
- y= (dst.height-actor_max_h)/2;
- break;
- case 'top':
- y=0;
- break;
- case 'bottom':
- y= dst.height-actor_max_h;
- break;
- default:
- y= 0;
- }
- }
- }
-
- // space for each actor
- var actor_area= width / what_to_layout_array.length;
-
- for( i=0, l=what_to_layout_array.length; i<l; i++ ) {
- what_to_layout_array[i].setLocation(
- x + i * actor_area + (actor_area - what_to_layout_array[i].width) / 2,
- y);
- }
-
- };
-})();/**
- * See LICENSE file.
*
* This class generates an in-memory image with the representation of a drawn list of characters.
*
@@ -17200,4 +17347,642 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/**
};
extend( CAAT.PathActor, CAAT.ActorContainer, null);
-})();
+})();CAAT.UI= {};(function() {
+
+ CAAT.UI.Padding= function() {
+ return this;
+ };
+
+ CAAT.UI.Padding.prototype= {
+ left: 2,
+ right: 2,
+ top: 2,
+ bottom: 2
+ };
+
+ CAAT.UI.LayoutManager= function( ) {
+
+ this.newChildren= [];
+ this.padding= new CAAT.UI.Padding();
+ return this;
+ };
+
+ CAAT.UI.LayoutManager.newElementInterpolator= new CAAT.Interpolator().createElasticOutInterpolator(1.1,.7);
+ CAAT.UI.LayoutManager.moveElementInterpolator= new CAAT.Interpolator().createExponentialOutInterpolator(2);
+
+ CAAT.UI.LayoutManager.prototype= {
+
+ padding : null,
+ invalid : true,
+
+ hgap : 2,
+ vgap : 2,
+ animated : true,
+ newChildren : null,
+
+ setAnimated : function( animate ) {
+ this.animated= animate;
+ },
+
+ setHGap : function( gap ) {
+ this.hgap= gap;
+ this.invalidateLayout();
+ return this;
+ },
+
+ setVGap : function( gap ) {
+ this.vgap= gap;
+ this.invalidateLayout();
+ return this;
+ },
+
+ setAllPadding : function( s ) {
+ this.padding.left= s;
+ this.padding.right= s;
+ this.padding.top= s;
+ this.padding.bottom= s;
+ this.invalidateLayout();
+ return this;
+ },
+
+ setPadding : function( l,r, t,b ) {
+ this.padding.left= l;
+ this.padding.right= r;
+ this.padding.top= t;
+ this.padding.bottom= b;
+ this.invalidateLayout();
+ return this;
+ },
+
+ addChild : function( child, constraints ) {
+ this.newChildren.push( child );
+ },
+
+ removeChild : function( child ) {
+
+ },
+
+ doLayout : function( container ) {
+ this.newChildren= [];
+ this.invalid= false;
+ },
+
+ invalidateLayout : function( container ) {
+ this.invalid= true;
+ },
+
+ getMinimumLayoutSize : function( container ) {
+
+ },
+
+ getPreferredLayoutSize : function(container ) {
+
+ },
+
+ isValid : function() {
+ return !this.invalid;
+ },
+
+ isInvalidated : function() {
+ return this.invalid;
+ }
+ };
+}());
+
+(function() {
+
+ /**
+ *
+ * Layouts a container children in equal sized cells organized in rows by columns.
+ *
+ * @param container {CAAT.Actor}
+ * @param rows {number=} number of initial rows, defaults to 2.
+ * @param columns {number=} number of initial columns, defaults to 2.
+ * @return {*}
+ * @constructor
+ */
+ CAAT.UI.GridLayout= function( rows, columns ) {
+ CAAT.UI.GridLayout.superclass.constructor.call(this);
+ this.rows= rows;
+ this.columns= columns;
+
+ return this;
+ };
+
+ CAAT.UI.GridLayout.prototype= {
+ rows : 0,
+ columns : 2,
+
+ doLayout : function( container ) {
+
+ var nactors= container.getNumChildren();
+ if (nactors === 0) {
+ return;
+ }
+
+ var nrows = this.rows;
+ var ncols = this.columns;
+
+ if (nrows > 0) {
+ ncols = Math.floor( (nactors + nrows - 1) / nrows );
+ } else {
+ nrows = Math.floor( (nactors + ncols - 1) / ncols );
+ }
+
+ var totalGapsWidth = (ncols - 1) * this.hgap;
+ var widthWOInsets = container.width - (this.padding.left + this.padding.right);
+ var widthOnComponent = Math.floor( (widthWOInsets - totalGapsWidth) / ncols );
+ var extraWidthAvailable = Math.floor( (widthWOInsets - (widthOnComponent * ncols + totalGapsWidth)) / 2 );
+
+ var totalGapsHeight = (nrows - 1) * this.vgap;
+ var heightWOInsets = container.height - (this.padding.top + this.padding.bottom);
+ var heightOnComponent = Math.floor( (heightWOInsets - totalGapsHeight) / nrows );
+ var extraHeightAvailable = Math.floor( (heightWOInsets - (heightOnComponent * nrows + totalGapsHeight)) / 2 );
+
+ for (var c = 0, x = this.padding.left + extraWidthAvailable; c < ncols ; c++, x += widthOnComponent + this.hgap) {
+ for (var r = 0, y = this.padding.top + extraHeightAvailable; r < nrows ; r++, y += heightOnComponent + this.vgap) {
+ var i = r * ncols + c;
+ if (i < nactors) {
+ var child= container.getChildAt(i);
+ if ( !this.animated ) {
+ child.setBounds(x, y, widthOnComponent, heightOnComponent);
+ } else {
+ child.setSize(widthOnComponent, heightOnComponent);
+ if ( this.newChildren.indexOf( child ) !==-1 ) {
+ child.setPosition( x,y );
+ child.setScale(0.01,0.01);
+ child.scaleTo( 1,1, 500, 0,.5,.5, CAAT.UI.LayoutManager.newElementInterpolator );
+ } else {
+ child.moveTo( x, y, 500, 0, CAAT.UI.LayoutManager.moveElementInterpolator );
+ }
+ }
+ }
+ }
+ }
+
+ CAAT.UI.GridLayout.superclass.doLayout.call(this, container);
+ },
+
+ getMinimumLayoutSize : function( container ) {
+ var nrows = this.rows;
+ var ncols = this.columns;
+ var nchildren= container.getNumChildren();
+ var w=0, h=0, i;
+
+ if (nrows > 0) {
+ ncols = Math.ceil( (nchildren + nrows - 1) / nrows );
+ } else {
+ nrows = Math.ceil( (nchildren + ncols - 1) / ncols );
+ }
+
+ for ( i= 0; i < nchildren; i+=1 ) {
+ var actor= container.getChildAt(i);
+ var d = actor.getMinimumSize();
+ if (w < d.width) {
+ w = d.width;
+ }
+ if (h < d.height) {
+ h = d.height;
+ }
+ }
+
+ return new CAAT.Dimension(
+ this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap,
+ this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap
+ );
+ },
+
+ getPreferredLayoutSize : function( container ) {
+
+ var nrows = this.rows;
+ var ncols = this.columns;
+ var nchildren= container.getNumChildren();
+ var w=0, h=0, i;
+
+ if (nrows > 0) {
+ ncols = Math.ceil( (nchildren + nrows - 1) / nrows );
+ } else {
+ nrows = Math.ceil( (nchildren + ncols - 1) / ncols );
+ }
+
+ for ( i= 0; i < nchildren; i+=1 ) {
+ var actor= container.getChildAt(i);
+ var d = actor.getPreferredSize();
+ if (w < d.width) {
+ w = d.width;
+ }
+ if (h < d.height) {
+ h = d.height;
+ }
+ }
+
+ return new CAAT.Dimension(
+ this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap,
+ this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap
+ );
+ }
+
+ };
+
+ extend( CAAT.UI.GridLayout, CAAT.UI.LayoutManager );
+
+}());
+
+(function() {
+ CAAT.UI.BorderLayout= function() {
+ CAAT.UI.BorderLayout.superclass.constructor.call(this);
+ return this;
+ };
+
+ CAAT.UI.BorderLayout.prototype= {
+
+ left : null,
+ right : null,
+ top : null,
+ bottom : null,
+ center : null,
+
+ addChild : function( child, constraint ) {
+ CAAT.UI.BorderLayout.superclass.addChild.call( this, child, constraint );
+
+ if ( constraint === "center" ) {
+ this.center= child;
+ } else if ( constraint==="left" ) {
+ this.left= child;
+ } else if ( constraint==="right" ) {
+ this.right= child;
+ } else if ( constraint==="top" ) {
+ this.top= child;
+ } else if ( constraint==="bottom" ) {
+ this.bottom= child;
+ }
+ },
+
+ removeChild : function( child ) {
+ if ( this.center===child ) {
+ this.center=null;
+ } else if ( this.left===child ) {
+ this.left= null;
+ } else if ( this.right===child ) {
+ this.right= null;
+ } else if ( this.top===child ) {
+ this.top= null;
+ } else if ( this.bottom===child ) {
+ this.bottom= null;
+ }
+ },
+
+ __getChild : function( constraint ) {
+ if ( constraint==="center" ) {
+ return this.center;
+ } else if ( constraint==="left" ) {
+ return this.left;
+ } else if ( constraint==="right" ) {
+ return this.right;
+ } else if ( constraint==="top" ) {
+ return this.top;
+ } else if ( constraint==="bottom" ) {
+ return this.bottom;
+ }
+ },
+
+ getMinimumLayoutSize : function( container ) {
+ var c, d;
+ var dim= new CAAT.Dimension();
+
+ if ((c=this.__getChild("right")) != null) {
+ d = c.getMinimumSize();
+ dim.width += d.width + this.hgap;
+ dim.height = Math.max(d.height, dim.height);
+ }
+ if ((c=this.__getChild("left")) != null) {
+ d = c.getMinimumSize();
+ dim.width += d.width + this.hgap;
+ dim.height = Math.max(d.height, dim.height);
+ }
+ if ((c=this.__getChild("center")) != null) {
+ d = c.getMinimumSize();
+ dim.width += d.width;
+ dim.height = Math.max(d.height, dim.height);
+ }
+ if ((c=this.__getChild("top")) != null) {
+ d = c.getMinimumSize();
+ dim.width = Math.max(d.width, dim.width);
+ dim.height += d.height + this.vgap;
+ }
+ if ((c=this.__getChild("bottom")) != null) {
+ d = c.getMinimumSize();
+ dim.width = Math.max(d.width, dim.width);
+ dim.height += d.height + this.vgap;
+ }
+
+ dim.width += this.padding.left + this.padding.right;
+ dim.height += this.padding.top + this.padding.bottom;
+
+ return dim;
+ },
+
+ getPreferredLayoutSize : function( container ) {
+ var c, d;
+ var dim= new CAAT.Dimension();
+
+ if ((c=this.__getChild("left")) != null) {
+ d = c.getPreferredSize();
+ dim.width += d.width + this.hgap;
+ dim.height = Math.max(d.height, dim.height);
+ }
+ if ((c=this.__getChild("right")) != null) {
+ d = c.getPreferredSize();
+ dim.width += d.width + this.hgap;
+ dim.height = Math.max(d.height, dim.height);
+ }
+ if ((c=this.__getChild("center")) != null) {
+ d = c.getPreferredSize();
+ dim.width += d.width;
+ dim.height = Math.max(d.height, dim.height);
+ }
+ if ((c=this.__getChild("top")) != null) {
+ d = c.getPreferredSize();
+ dim.width = Math.max(d.width, dim.width);
+ dim.height += d.height + this.vgap;
+ }
+ if ((c=this.__getChild("bottom")) != null) {
+ d = c.getPreferredSize();
+ dim.width = Math.max(d.width, dim.width);
+ dim.height += d.height + this.vgap;
+ }
+
+ dim.width += this.padding.left + this.padding.right;
+ dim.height += this.padding.top + this.padding.bottom;
+
+ return dim;
+ },
+
+ doLayout : function( container ) {
+
+ var top = this.padding.top;
+ var bottom = container.height - this.padding.bottom;
+ var left = this.padding.left;
+ var right = container.width - this.padding.right;
+ var c = null, d;
+
+ if ((c=this.__getChild("top")) != null) {
+ c.setSize(right - left, c.height);
+ d = c.getPreferredSize();
+ c.setBounds(left, top, right - left, d.height);
+ top += d.height + this.vgap;
+ }
+ if ((c=this.__getChild("bottom")) != null) {
+ c.setSize(right - left, c.height);
+ d = c.getPreferredSize();
+ c.setBounds(left, bottom - d.height, right - left, d.height);
+ bottom -= d.height + this.vgap;
+ }
+ if ((c=this.__getChild("right")) != null) {
+ c.setSize(c.width, bottom - top);
+ d = c.getPreferredSize();
+ c.setBounds(right - d.width, top, d.width, bottom - top);
+ right -= d.width + this.hgap;
+ }
+ if ((c=this.__getChild("left")) != null) {
+ c.setSize(c.width, bottom - top);
+ d = c.getPreferredSize();
+ c.setBounds(left, top, d.width, bottom - top);
+ left += d.width + this.hgap;
+ }
+ if ((c=this.__getChild("center")) != null) {
+ c.setBounds(left, top, right - left, bottom - top);
+ }
+
+ CAAT.UI.BorderLayout.superclass.doLayout.call(this, container);
+ }
+
+
+ };
+
+ extend( CAAT.UI.BorderLayout, CAAT.UI.LayoutManager );
+}());
+
+(function() {
+
+ CAAT.UI.BoxLayout= function() {
+ CAAT.UI.BoxLayout.superclass.constructor.call(this);
+ return this;
+ };
+
+ CAAT.UI.BoxLayout.AXIS= {
+ X : 0,
+ Y : 1
+ };
+
+ CAAT.UI.BoxLayout.ALIGNMENT= {
+ LEFT : 0,
+ RIGHT: 1,
+ CENTER: 2,
+ TOP: 3,
+ BOTTOM: 4
+ };
+
+ CAAT.UI.BoxLayout.prototype= {
+
+ axis : CAAT.UI.BoxLayout.AXIS.Y,
+ valign : CAAT.UI.BoxLayout.ALIGNMENT.CENTER,
+ halign : CAAT.UI.BoxLayout.ALIGNMENT.CENTER,
+
+ setAxis : function( axis ) {
+ this.axis= axis;
+ this.invalidateLayout();
+ return this;
+ },
+
+ setHorizontalAlignment : function(align ) {
+ this.halign= align;
+ this.invalidateLayout();
+ return this;
+ },
+
+ setVerticalAlignment : function( align ) {
+ this.valign= align;
+ this.invalidateLayout();
+ return this;
+ },
+
+ doLayout : function( container ) {
+
+ if ( this.axis===CAAT.UI.BoxLayout.AXIS.Y ) {
+ this.doLayoutVertical( container );
+ } else {
+ this.doLayoutHorizontal( container );
+ }
+
+ CAAT.UI.BoxLayout.superclass.doLayout.call(this, container);
+ },
+
+ doLayoutHorizontal : function( container ) {
+
+ var computedW= 0, computedH=0;
+ var yoffset= 0, xoffset;
+ var i, l;
+
+ // calculamos ancho y alto de los elementos.
+ for( i= 0, l=container.getNumChildren(); i<l; i+=1 ) {
+
+ var actor= container.getChildAt(i);
+ if ( computedH < actor.height ) {
+ computedH= actor.height;
+ }
+
+ computedW += actor.width;
+ if ( i>0 ) {
+ computedW+= this.hgap;
+ }
+ }
+
+ switch( this.halign ) {
+ case CAAT.UI.BoxLayout.ALIGNMENT.LEFT:
+ xoffset= this.padding.left;
+ break;
+ case CAAT.UI.BoxLayout.ALIGNMENT.RIGHT:
+ xoffset= container.width - computedW - this.padding.right;
+ break;
+ default:
+ xoffset= (container.width - computedW) / 2;
+ }
+
+ for( i= 0, l=container.getNumChildren(); i<l; i+=1 ) {
+ var actor= container.getChildAt(i);
+
+ switch( this.valign ) {
+ case CAAT.UI.BoxLayout.ALIGNMENT.TOP:
+ yoffset= this.padding.top;
+ break;
+ case CAAT.UI.BoxLayout.ALIGNMENT.BOTTOM:
+ yoffset= container.height - this.padding.bottom - actor.height;
+ break;
+ default:
+ yoffset= (container.height - actor.height) / 2;
+ }
+
+ this.__setActorPosition( actor, xoffset, yoffset );
+
+ xoffset += actor.width + this.hgap;
+ }
+
+ },
+
+ __setActorPosition : function( actor, xoffset, yoffset ) {
+ if ( this.animated ) {
+ if ( this.newChildren.indexOf( actor )!==-1 ) {
+ actor.setPosition( xoffset, yoffset );
+ actor.setScale(0,0);
+ actor.scaleTo( 1,1, 500, 0,.5,.5, CAAT.UI.LayoutManager.newElementInterpolator );
+ } else {
+ actor.moveTo( xoffset, yoffset, 500, 0, CAAT.UI.LayoutManager.moveElementInterpolator );
+ }
+ } else {
+ actor.setPosition( xoffset, yoffset );
+ }
+ },
+
+ doLayoutVertical : function( container ) {
+
+ var computedW= 0, computedH=0;
+ var yoffset, xoffset;
+ var i, l;
+
+ // calculamos ancho y alto de los elementos.
+ for( i= 0, l=container.getNumChildren(); i<l; i+=1 ) {
+
+ var actor= container.getChildAt(i);
+ if ( computedW < actor.width ) {
+ computedW= actor.width;
+ }
+
+ computedH += actor.height;
+ if ( i>0 ) {
+ computedH+= this.vgap;
+ }
+ }
+
+ switch( this.valign ) {
+ case CAAT.UI.BoxLayout.ALIGNMENT.TOP:
+ yoffset= this.padding.top;
+ break;
+ case CAAT.UI.BoxLayout.ALIGNMENT.BOTTOM:
+ yoffset= container.height - computedH - this.padding.bottom;
+ break;
+ default:
+ yoffset= (container.height - computedH) / 2;
+ }
+
+ for( i= 0, l=container.getNumChildren(); i<l; i+=1 ) {
+ var actor= container.getChildAt(i);
+
+ switch( this.halign ) {
+ case CAAT.UI.BoxLayout.ALIGNMENT.LEFT:
+ xoffset= this.padding.left;
+ break;
+ case CAAT.UI.BoxLayout.ALIGNMENT.RIGHT:
+ xoffset= container.width - this.padding.right - actor.width;
+ break;
+ default:
+ xoffset= (container.width - actor.width) / 2;
+ }
+
+ this.__setActorPosition( actor, xoffset, yoffset );
+
+ yoffset += actor.height + this.vgap;
+
+ }
+ },
+
+ getPreferredLayoutSize : function( container ) {
+
+ var dim= new CAAT.Dimension();
+ var computedW= 0, computedH=0;
+ var i, l;
+
+ // calculamos ancho y alto de los elementos.
+ for( i= 0, l=container.getNumChildren(); i<l; i+=1 ) {
+
+ var actor= container.getChildAt(i);
+ var ps= actor.getPreferredSize();
+
+ if ( computedH < ps.height ) {
+ computedH= ps.height;
+ }
+ computedW += ps.width;
+ }
+
+ dim.width= computedW;
+ dim.height= computedH;
+
+ return dim;
+ },
+
+ getMinimumLayoutSize : function( container ) {
+ var dim= new CAAT.Dimension();
+ var computedW= 0, computedH=0;
+ var i, l;
+
+ // calculamos ancho y alto de los elementos.
+ for( i= 0, l=container.getNumChildren(); i<l; i+=1 ) {
+
+ var actor= container.getChildAt(i);
+ var ps= actor.getMinimumSize();
+
+ if ( computedH < ps.height ) {
+ computedH= ps.height;
+ }
+ computedW += ps.width;
+ }
+
+ dim.width= computedW;
+ dim.height= computedH;
+
+ return dim;
+ }
+ };
+
+ extend( CAAT.UI.BoxLayout, CAAT.UI.LayoutManager );
+}());
View
123 build/caat-min.js
@@ -22,11 +22,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-Version: 0.4 build: 303
+Version: 0.4 build: 318
Created on:
-DATE: 2012-09-11
-TIME: 22:07:39
+DATE: 2012-09-15
+TIME: 16:50:46
*/
@@ -86,7 +86,7 @@ b,c,i,this.bgActors);this.quadData[2]=(new CAAT.QuadTree).create(a,i,h,d,this.bg
this.rows;e++){this.xycache.push([]);for(c=0;c<this.columns;c++)this.xycache[e].push(c+e*d)}this.rectangle=(new CAAT.Rectangle).setBounds(0,0,a,b);this.r0=new CAAT.Rectangle;this.r1=new CAAT.Rectangle;return this},clearObject:function(){var a;for(a=0;a<this.rows*this.columns;a++)this.elements[a]=[];return this},addObject:function(a){for(var b=this.__getCells(a.x|0,a.y|0,a.width|0,a.height|0),c=0;c<b.length;c++)this.elements[b[c]].push(a)},__getCells:function(a,b,c,d){var e=[];this.rectangle.contains(a,
b)&&e.push(this.xycache[this.ycache[b]][this.xcache[a]]);if(this.rectangle.contains(a+c-1,b+d-1)){var f=this.xycache[this.ycache[b+d-1]][this.xcache[a+c-1]];if(f===e[0])return e;e.push(f)}if(this.rectangle.contains(a+c-1,b)){f=this.xycache[this.ycache[b]][this.xcache[a+c-1]];if(f===e[0]||f===e[1])return e;e.push(f)}this.rectangle.contains(a+c-1,b+d-1)&&(f=this.xycache[this.ycache[b+d-1]][this.xcache[a]],e.push(f));return e},solveCollision:function(a){var b;for(b=0;b<this.elements.length;b++){var c=
this.elements[b];c.length>1&&this._solveCollisionCell(c,a)}},_solveCollisionCell:function(a,b){var c,d;for(c=0;c<a.length;c++){var e=a[c];this.r0.setBounds(e.x,e.y,e.width,e.height);for(d=c+1;d<a.length;d++){var f=a[d];this.r0.intersects(this.r1.setBounds(f.x,f.y,f.width,f.height))&&b(e,f)}}},collide:function(a,b,c,d,e){a|=0;b|=0;c|=0;d|=0;var f=this.__getCells(a,b,c,d),g=this.elements;this.r0.setBounds(a,b,c,d);for(a=0;a<f.length;a++){d=g[f[a]];for(b=0,c=d.length;b<c;b++){var h=d[b];this.r1.setBounds(h.x,
-h.y,h.width,h.height);if(this.r0.intersects(this.r1)&&e(h))return}}}}})();(function(){CAAT.Interpolator=function(){this.interpolated=new CAAT.Point(0,0,0);return this};CAAT.Interpolator.prototype={interpolated:null,paintScale:90,createLinearInterpolator:function(a,b){this.getPosition=function(c){var d=c;a&&(c<0.5?c*=2:c=1-(c-0.5)*2);b!==null&&b&&(c=1-c);return this.interpolated.set(d,c)};return this},createBackOutInterpolator:function(a){this.getPosition=function(b){var c=b;a&&(b<0.5?b*=2:b=1-(b-0.5)*2);b-=1;return this.interpolated.set(c,b*b*(2.70158*b+1.70158)+1)};return this},
+h.y,h.width,h.height);if(this.r0.intersects(this.r1)&&e(h))return}}}}})();(function(){CAAT.Dimension=function(a,b){this.width=a;this.height=b;return this};CAAT.Dimension.prototype={width:0,height:0}})();(function(){CAAT.Interpolator=function(){this.interpolated=new CAAT.Point(0,0,0);return this};CAAT.Interpolator.prototype={interpolated:null,paintScale:90,createLinearInterpolator:function(a,b){this.getPosition=function(c){var d=c;a&&(c<0.5?c*=2:c=1-(c-0.5)*2);b!==null&&b&&(c=1-c);return this.interpolated.set(d,c)};return this},createBackOutInterpolator:function(a){this.getPosition=function(b){var c=b;a&&(b<0.5?b*=2:b=1-(b-0.5)*2);b-=1;return this.interpolated.set(c,b*b*(2.70158*b+1.70158)+1)};return this},
createExponentialInInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c<0.5?c*=2:c=1-(c-0.5)*2);return this.interpolated.set(d,Math.pow(c,a))};return this},createExponentialOutInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c<0.5?c*=2:c=1-(c-0.5)*2);return this.interpolated.set(d,1-Math.pow(1-c,a))};return this},createExponentialInOutInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c<0.5?c*=2:c=1-(c-0.5)*2);return c*2<1?this.interpolated.set(d,
Math.pow(c*2,a)/2):this.interpolated.set(d,1-Math.abs(Math.pow(c*2-2,a))/2)};return this},createQuadricBezierInterpolator:function(a,b,c,d){this.getPosition=function(e){var f=e;d&&(e<0.5?e*=2:e=1-(e-0.5)*2);e=(1-e)*(1-e)*a.y+2*(1-e)*e*b.y+e*e*c.y;return this.interpolated.set(f,e)};return this},createCubicBezierInterpolator:function(a,b,c,d,e){this.getPosition=function(f){var g=f;e&&(f<0.5?f*=2:f=1-(f-0.5)*2);var h=f*f,f=a.y+f*(-a.y*3+f*(3*a.y-a.y*f))+f*(3*b.y+f*(-6*b.y+b.y*3*f))+h*(c.y*3-c.y*3*f)+
d.y*f*h;return this.interpolated.set(g,f)};return this},createElasticOutInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d<0.5?d*=2:d=1-(d-0.5)*2);if(d===0)return{x:0,y:0};if(d===1)return{x:1,y:1};var e=b/(2*Math.PI)*Math.asin(1/a);return this.interpolated.set(d,a*Math.pow(2,-10*d)*Math.sin((d-e)*2*Math.PI/b)+1)};return this},createElasticInInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d<0.5?d*=2:d=1-(d-0.5)*2);if(d===0)return{x:0,y:0};if(d===1)return{x:1,y:1};var e=b/
@@ -138,51 +138,55 @@ CAAT.RAF,this.framerate.frames=0,this.paint(a);this.textEntitiesTotal.innerHTML=
b.moveTo(this.width-0.5,0);b.lineTo(this.width-0.5,this.height);b.stroke();b.strokeStyle="#a22";b.beginPath();c=this.height-(20/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();b.strokeStyle="#aa2";b.beginPath();c=this.height-(30/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();c=Math.min(this.height-this.framerate.fps/this.SCALE*this.height,59);if(-1===this.framerate.prevFps)this.framerate.prevFps=c|0;b.strokeStyle="#0ff";b.beginPath();
b.moveTo(this.width,(c|0)-0.5);b.lineTo(this.width,this.framerate.prevFps-0.5);b.stroke();this.framerate.prevFps=c;a=(this.height-a/this.SCALE*this.height>>0)-0.5;b.strokeStyle="#ff0";b.beginPath();b.moveTo(this.width,a);b.lineTo(this.width,a);b.stroke()}}})();(function(){var a=0;CAAT.Actor=function(){this.CLASS=CAAT.Actor;this.behaviorList=[];this.lifecycleListenerList=[];this.AABB=new CAAT.Rectangle;this.viewVertices=[new CAAT.Point(0,0,0),new CAAT.Point(0,0,0),new CAAT.Point(0,0,0),new CAAT.Point(0,0,0)];this.scaleAnchor=this.ANCHOR_CENTER;this.modelViewMatrix=new CAAT.Matrix;this.worldModelViewMatrix=new CAAT.Matrix;this.resetTransform();this.setScale(1,1);this.setRotation(0);this.id=a++;return this};CAAT.Actor.__reflectionInfo={x:"property:x, type:number",
y:"property:y, type:number",scaleX:"property:scaleX, type:number",scaleY:"property:scaleY, type:number",cached:"get:isCached(), type:boolean"};CAAT.Actor.ANCHOR_CENTER=0;CAAT.Actor.ANCHOR_TOP=1;CAAT.Actor.ANCHOR_BOTTOM=2;CAAT.Actor.ANCHOR_LEFT=3;CAAT.Actor.ANCHOR_RIGHT=4;CAAT.Actor.ANCHOR_TOP_LEFT=5;CAAT.Actor.ANCHOR_TOP_RIGHT=6;CAAT.Actor.ANCHOR_BOTTOM_LEFT=7;CAAT.Actor.ANCHOR_BOTTOM_RIGHT=8;CAAT.Actor.ANCHOR_CUSTOM=9;CAAT.Actor.CACHE_SIMPLE=1;CAAT.Actor.CACHE_DEEP=2;CAAT.Actor.prototype={lifecycleListenerList:null,
-behaviorList:null,parent:null,x:0,y:0,width:0,height:0,start_time:0,duration:Number.MAX_VALUE,clip:false,clipPath:null,tAnchorX:0,tAnchorY:0,scaleX:0,scaleY:0,scaleTX:0.5,scaleTY:0.5,scaleAnchor:0,rotationAngle:0,rotationY:0.5,rotationX:0.5,alpha:1,isGlobalAlpha:false,frameAlpha:1,expired:false,discardable:false,pointed:false,mouseEnabled:true,visible:true,ANCHOR_CENTER:0,ANCHOR_TOP:1,ANCHOR_BOTTOM:2,ANCHOR_LEFT:3,ANCHOR_RIGHT:4,ANCHOR_TOP_LEFT:5,ANCHOR_TOP_RIGHT:6,ANCHOR_BOTTOM_LEFT:7,ANCHOR_BOTTOM_RIGHT:8,
-ANCHOR_CUSTOM:9,fillStyle:null,strokeStyle:null,time:0,AABB:null,viewVertices:null,inFrame:false,dirty:true,wdirty:true,oldX:-1,oldY:-1,modelViewMatrix:null,worldModelViewMatrix:null,modelViewMatrixI:null,worldModelViewMatrixI:null,glEnabled:false,backgroundImage:null,id:null,size_active:1,size_total:1,__d_ax:-1,__d_ay:-1,gestureEnabled:false,invalid:true,cached:0,collides:false,collidesAsRect:true,isAA:true,create:function(){return this},moveTo:function(a,c,d,e,f){var g=this.getBehavior("__moveTo");
-g||(g=(new CAAT.PathBehavior).setId("__moveTo").setValues(new CAAT.LinearPath),this.addBehavior(g));g.path.setInitialPosition(this.x,this.y).setFinalPosition(a,c);g.setDelayTime(e?e:0,d);f&&g.setInterpolator(f);return this},rotateTo:function(a,c,d,e,f,g){var h=this.getBehavior("__rotateTo");h||(h=(new CAAT.RotateBehavior).setId("__rotateTo").setValues(0,0,0.5,0.5),this.addBehavior(h));h.setValues(this.rotationAngle,a,e,f).setDelayTime(d?d:0,c);g&&h.setInterpolator(g);return this},scaleTo:function(a,
-c,d,e,f,g,h){var i=this.getBehavior("__scaleTo");i||(i=(new CAAT.ScaleBehavior).setId("__scaleTo").setValues(1,1,1,1,0.5,0.5),this.addBehavior(i));i.setValues(this.scaleX,this.scaleY,a,c,f,g).setDelayTime(e?e:0,d);h&&i.setInterpolator(h);return this},scaleXTo:function(a,c,d,e,f,g){return this.__scale1To(CAAT.Scale1Behavior.AXIS_X,a,c,d,e,f,g)},scaleYTo:function(a,c,d,e,f,g){return this.__scale1To(CAAT.Scale1Behavior.AXIS_Y,a,c,d,e,f,g)},__scale1To:function(a,c,d,e,f,g,h){var i=this.getBehavior("__scaleXTo");
-i||(i=(new CAAT.Scale1Behavior).setId("__scaleXTo").setValues(1,1,a===CAAT.Scale1Behavior.AXIS_X,0.5,0.5),this.addBehavior(i));i.setValues(a?this.scaleX:this.scaleY,c,f,g).setDelayTime(e?e:0,d);h&&i.setInterpolator(h);return this},touchStart:function(){},touchMove:function(){},touchEnd:function(){},gestureStart:function(){},gestureChange:function(a,c,d){this.gestureEnabled&&(this.setRotation(a),this.setScale(c,d));return this},gestureEnd:function(){},isVisible:function(){return this.isVisible},setupCollission:function(a,
-c){this.collides=a;this.collidesAsRect=!c},invalidate:function(){this.invalid=true},setGestureEnabled:function(a){this.gestureEnabled=!!a;return this},isGestureEnabled:function(){return this.gestureEnabled},getId:function(){return this.id},setId:function(a){this.id=a;return this},setParent:function(a){this.parent=a;return this},setBackgroundImage:function(a,c){if(a){a instanceof CAAT.SpriteImage||(a=(new CAAT.SpriteImage).initialize(a,1,1));a.setOwner(this);this.backgroundImage=a;if(typeof c==="undefined"||
-c)this.width=a.getWidth(),this.height=a.getHeight();this.glEnabled=true;this.invalidate()}else this.backgroundImage=null;return this},setSpriteIndex:function(a){this.backgroundImage&&(this.backgroundImage.setSpriteIndex(a),this.invalidate());return this},setBackgroundImageOffset:function(a,c){this.backgroundImage&&this.backgroundImage.setOffset(a,c);return this},setAnimationImageIndex:function(a){this.backgroundImage&&(this.backgroundImage.resetAnimationTime(),this.backgroundImage.setAnimationImageIndex(a),
-this.invalidate());return this},resetAnimationTime:function(){this.backgroundImage&&(this.backgroundImage.resetAnimationTime(),this.invalidate());return this},setChangeFPS:function(a){this.backgroundImage&&this.backgroundImage.setChangeFPS(a);return this},setImageTransformation:function(a){this.backgroundImage&&this.backgroundImage.setSpriteTransformation(a);return this},centerOn:function(a,c){this.setLocation(a-this.width/2,c-this.height/2);return this},centerAt:function(a,c){return this.centerOn(a,
-c)},getTextureGLPage:function(){return this.backgroundImage.image.__texturePage},setVisible:function(a){this.invalidate();CAAT.currentDirector&&CAAT.currentDirector.dirtyRectsEnabled&&!a&&this.visible&&CAAT.currentDirector.scheduleDirtyRect(this.AABB);this.visible=a;return this},setOutOfFrameTime:function(){this.setFrameTime(-1,0);return this},addListener:function(a){this.lifecycleListenerList.push(a);return this},removeListener:function(a){for(var c=this.lifecycleListenerList.length;c--;)if(this.lifecycleListenerList[c]===
-a){this.lifecycleListenerList.splice(c,1);break}},setGlobalAlpha:function(a){this.isGlobalAlpha=a;return this},fireEvent:function(a,c){for(var d=0;d<this.lifecycleListenerList.length;d++)this.lifecycleListenerList[d].actorLifeCycleEvent(this,a,c)},setExpired:function(a){this.expired=true;this.fireEvent("expired",a);return this},enableEvents:function(a){this.mouseEnabled=a;return this},emptyBehaviorList:function(){this.behaviorList=[];return this},setFillStyle:function(a){this.fillStyle=a;this.invalidate();
-return this},setStrokeStyle:function(a){this.strokeStyle=a;this.invalidate();return this},setPaint:function(a){return this.setFillStyle(a)},setAlpha:function(a){this.alpha=a;this.invalidate();return this},resetTransform:function(){this.rotationAngle=0;this.rotationY=this.rotationX=0.5;this.scaleY=this.scaleX=1;this.scaleTY=this.scaleTX=0.5;this.scaleAnchor=0;this.oldY=this.oldX=-1;this.dirty=true;return this},setFrameTime:function(a,c){this.start_time=a;this.duration=c;this.expired=false;this.dirty=
-true;return this},paint:function(a,c){if(this.backgroundImage)this.backgroundImage.paint(a,c,0,0);else if(this.fillStyle){var d=a.crc;d.fillStyle=this.fillStyle;d.fillRect(0,0,this.width,this.height)}},setScale:function(a,c){this.scaleX=a;this.scaleY=c;this.dirty=true;return this},getAnchorPercent:function(a){var c=[0.5,0.5,0.5,0,0.5,1,0,0.5,1,0.5,0,0,1,0,0,1,1,1];return{x:c[a*2],y:c[a*2+1]}},getAnchor:function(a){var c=0,d=0;switch(a){case this.ANCHOR_CENTER:d=c=0.5;break;case this.ANCHOR_TOP:c=
-0.5;d=0;break;case this.ANCHOR_BOTTOM:c=0.5;d=1;break;case this.ANCHOR_LEFT:c=0;d=0.5;break;case this.ANCHOR_RIGHT:c=1;d=0.5;break;case this.ANCHOR_TOP_RIGHT:c=1;d=0;break;case this.ANCHOR_BOTTOM_LEFT:c=0;d=1;break;case this.ANCHOR_BOTTOM_RIGHT:d=c=1;break;case this.ANCHOR_TOP_LEFT:d=c=0}return{x:c,y:d}},setGlobalAnchor:function(a,c){this.scaleTX=this.rotationX=this.tAnchorX=a;this.scaleTY=this.rotationY=this.tAnchorY=c;this.dirty=true;return this},setScaleAnchor:function(a,c){this.scaleTX=a;this.scaleTY=
-c;this.dirty=true;return this},setScaleAnchored:function(a,c,d,e){this.scaleTX=d;this.scaleTY=e;this.scaleX=a;this.scaleY=c;this.dirty=true;return this},setRotationAnchor:function(a,c){this.rotationX=c;this.rotationY=a;this.dirty=true;return this},setRotation:function(a){this.rotationAngle=a;this.dirty=true;return this},setRotationAnchored:function(a,c,d){this.rotationAngle=a;this.rotationX=c;this.rotationY=d;this.dirty=true;return this},setSize:function(a,c){this.width=a;this.height=c;this.dirty=
-true;return this},setBounds:function(a,c,d,e){this.x=a;this.y=c;this.width=d;this.height=e;this.dirty=true;return this},setLocation:function(a,c){this.x=a;this.y=c;this.oldX=a;this.oldY=c;this.dirty=true;return this},setPosition:function(a,c){return this.setLocation(a,c)},setPositionAnchor:function(a,c){this.tAnchorX=a;this.tAnchorY=c;return this},setPositionAnchored:function(a,c,d,e){this.setLocation(a,c);this.tAnchorX=d;this.tAnchorY=e;return this},isInAnimationFrame:function(a){if(this.expired)return false;
-if(this.duration===Number.MAX_VALUE)return this.start_time<=a;return a>=this.start_time+this.duration?(this.expired||this.setExpired(a),false):this.start_time<=a&&a<this.start_time+this.duration},contains:function(a,c){return a>=0&&c>=0&&a<this.width&&c<this.height},addBehavior:function(a){this.behaviorList.push(a);return this},removeBehaviour:function(a){for(var c=this.behaviorList,d=c.length-1;d;)if(c[d]===a){c.splice(d,1);break}return this},removeBehaviorById:function(a){for(var c=this.behaviorList,
-d=0;d<c.length;d++)c[d].id===a&&c.splice(d,1);return this},getBehavior:function(a){for(var c=this.behaviorList,d=0;d<c.length;d++){var e=c[d];if(e.id===a)return e}return null},setDiscardable:function(a){this.discardable=a;return this},destroy:function(a){this.parent&&this.parent.removeChild(this);this.fireEvent("destroyed",a)},modelToView:function(a){var c,d,e,f;this.dirty&&this.setModelViewMatrix();f=this.worldModelViewMatrix.matrix;if(a instanceof Array)for(var g=0;g<a.length;g++)e=a[g],c=e.x,d=
-e.y,e.x=c*f[0]+d*f[1]+f[2],e.y=c*f[3]+d*f[4]+f[5];else c=a.x,d=a.y,a.x=c*f[0]+d*f[1]+f[2],a.y=c*f[3]+d*f[4]+f[5];return a},modelToModel:function(a,c){this.dirty&&this.setModelViewMatrix();return c.viewToModel(this.modelToView(a))},viewToModel:function(a){this.dirty&&this.setModelViewMatrix();this.worldModelViewMatrixI=this.worldModelViewMatrix.getInverse();this.worldModelViewMatrixI.transformCoord(a);return a},findActorAtPosition:function(a){if(!this.visible||!this.mouseEnabled||!this.isInAnimationFrame(this.time))return null;
-this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(a);return this.contains(a.x,a.y)?this:null},enableDrag:function(){this.ay=this.ax=0;this.asy=this.asx=1;this.screeny=this.screenx=this.ara=0;this.mouseEnter=function(){this.__d_ay=this.__d_ax=-1;this.pointed=true;CAAT.setCursor("move")};this.mouseExit=function(){this.__d_ay=this.__d_ax=-1;this.pointed=false;CAAT.setCursor("default")};this.mouseMove=function(){};this.mouseUp=function(){this.__d_ay=this.__d_ax=
--1};this.mouseDrag=function(a){var c;c=this.modelToView(new CAAT.Point(a.x,a.y));this.parent.viewToModel(c);if(this.__d_ax===-1||this.__d_ay===-1)this.__d_ax=c.x,this.__d_ay=c.y,this.__d_asx=this.scaleX,this.__d_asy=this.scaleY,this.__d_ara=this.rotationAngle,this.__d_screenx=a.screenPoint.x,this.__d_screeny=a.screenPoint.y;if(a.isShiftDown()){var d=(a.screenPoint.x-this.__d_screenx)/100,e=(a.screenPoint.y-this.__d_screeny)/100;a.isAltDown()||(e=d=a=Math.max(d,e));this.setScale(d+this.__d_asx,e+this.__d_asy)}else a.isControlDown()?
-this.setRotation(-Math.atan2(a.screenPoint.x-this.__d_screenx,a.screenPoint.y-this.__d_screeny)+this.__d_ara):(this.x+=c.x-this.__d_ax,this.y+=c.y-this.__d_ay);this.__d_ax=c.x;this.__d_ay=c.y};return this},disableDrag:function(){this.mouseEnter=function(){};this.mouseExit=function(){};this.mouseMove=function(){};this.mouseUp=function(){};this.mouseDrag=function(){};return this},mouseClick:function(){},mouseDblClick:function(){},mouseEnter:function(){this.pointed=true},mouseExit:function(){this.pointed=
-false},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseOut:function(){},mouseOver:function(){},mouseDrag:function(){},drawScreenBoundingBox:function(a){if(null!==this.AABB&&this.inFrame){var c=this.AABB,a=a.ctx;a.strokeStyle=CAAT.DEBUGAABBCOLOR;a.strokeRect(0.5+(c.x|0),0.5+(c.y|0),c.width|0,c.height|0);if(CAAT.DEBUGBB)c=this.viewVertices,a.beginPath(),a.lineTo(c[0].x,c[0].y),a.lineTo(c[1].x,c[1].y),a.lineTo(c[2].x,c[2].y),a.lineTo(c[3].x,c[3].y),a.closePath(),a.strokeStyle=
-CAAT.DEBUGBBCOLOR,a.stroke()}},animate:function(a,c){if(!this.visible)return false;var d;if(!this.isInAnimationFrame(c))return this.inFrame=false,this.dirty=true,false;if(this.x!==this.oldX||this.y!==this.oldY)this.dirty=true,this.oldX=this.x,this.oldY=this.y;for(d=0;d<this.behaviorList.length;d++)this.behaviorList[d].apply(c,this);this.clipPath&&this.clipPath.applyBehaviors(c);this.setModelViewMatrix();if(this.dirty||this.wdirty||this.invalid)a.dirtyRectsEnabled&&a.addDirtyRect(this.AABB),this.setScreenBounds(),
-a.dirtyRectsEnabled&&a.addDirtyRect(this.AABB);this.invalid=this.dirty=false;this.inFrame=true;return this.AABB.intersects(a.AABB)},setModelViewMatrix:function(){var a,c,d,e,f,g,h,i,j,l,k;this.wdirty=false;k=this.modelViewMatrix.matrix;if(this.dirty){h=1;j=e=0;g=1;i=this.x-this.tAnchorX*this.width;l=this.y-this.tAnchorY*this.height;if(this.rotationAngle){var n=this.rotationX*this.width,m=this.rotationY*this.height;i+=h*n+e*m;l+=j*n+g*m;a=Math.cos(this.rotationAngle);c=Math.sin(this.rotationAngle);
-d=h;f=j;h=d*a+e*c;e=-d*c+e*a;j=f*a+g*c;g=-f*c+g*a;i+=-h*n-e*m;l+=-j*n-g*m}if(this.scaleX!=1||this.scaleY!=1)a=this.scaleTX*this.width,c=this.scaleTY*this.height,i+=h*a+e*c,l+=j*a+g*c,h*=this.scaleX,e*=this.scaleY,j*=this.scaleX,g*=this.scaleY,i+=-h*a-e*c,l+=-j*a-g*c;k[0]=h;k[1]=e;k[2]=i;k[3]=j;k[4]=g;k[5]=l}if(this.parent){if(this.isAA=this.rotationAngle===0&&this.scaleX===1&&this.scaleY===1&&this.parent.isAA,this.dirty||this.parent.wdirty)this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix),
-this.isAA?(h=this.worldModelViewMatrix.matrix,h[2]+=k[2],h[5]+=k[5]):this.worldModelViewMatrix.multiply(this.modelViewMatrix),this.wdirty=true}else{if(this.dirty)this.wdirty=true;this.worldModelViewMatrix.identity();this.isAA=this.rotationAngle===0&&this.scaleX===1&&this.scaleY===1}},setScreenBounds:function(){var a=this.AABB,c=this.viewVertices;if(this.isAA){var d=this.worldModelViewMatrix.matrix,e=d[2],f=d[5],g=this.width,h=this.height;a.x=e;a.y=f;a.x1=e+g;a.y1=f+h;a.width=g;a.height=h;if(CAAT.GLRENDER)d=
-c[0],d.x=e,d.y=f,d=c[1],d.x=e+g,d.y=f,d=c[2],d.x=e+g,d.y=f+h,d=c[3],d.x=e,d.y=f+h;return this}d=c[0];d.x=0;d.y=0;d=c[1];d.x=this.width;d.y=0;d=c[2];d.x=this.width;d.y=this.height;d=c[3];d.x=0;d.y=this.height;this.modelToView(this.viewVertices);e=Number.MAX_VALUE;f=-Number.MAX_VALUE;g=Number.MAX_VALUE;h=-Number.MAX_VALUE;d=c[0];if(d.x<e)e=d.x;if(d.x>f)f=d.x;if(d.y<g)g=d.y;if(d.y>h)h=d.y;d=c[1];if(d.x<e)e=d.x;if(d.x>f)f=d.x;if(d.y<g)g=d.y;if(d.y>h)h=d.y;d=c[2];if(d.x<e)e=d.x;if(d.x>f)f=d.x;if(d.y<g)g=
-d.y;if(d.y>h)h=d.y;d=c[3];if(d.x<e)e=d.x;if(d.x>f)f=d.x;if(d.y<g)g=d.y;if(d.y>h)h=d.y;a.x=e;a.y=g;a.x1=f;a.y1=h;a.width=f-e;a.height=h-g;return this},paintActor:function(a,c){if(!this.visible||!a.inDirtyRect(this))return true;var d=a.ctx;this.frameAlpha=this.parent?this.parent.frameAlpha*this.alpha:1;d.globalAlpha=this.frameAlpha;a.modelViewMatrix.transformRenderingContextSet(d);this.worldModelViewMatrix.transformRenderingContext(d);this.clip&&(d.beginPath(),this.clipPath?this.clipPath.applyAsPath(a):
-d.rect(0,0,this.width,this.height),d.clip());this.paint(a,c);return true},__paintActor:function(a,c){if(!this.visible)return true;var d=a.ctx;this.frameAlpha=this.alpha;var e=this.worldModelViewMatrix.matrix;d.setTransform(e[0],e[3],e[1],e[4],e[2],e[5],this.frameAlpha);this.paint(a,c);return true},paintActorGL:function(a){this.frameAlpha=this.parent.frameAlpha*this.alpha;if(this.glEnabled&&this.visible)if(this.glNeedsFlush(a)){a.glFlush();this.glSetShader(a);if(!this.__uv)this.__uv=new Float32Array(8);
-if(!this.__vv)this.__vv=new Float32Array(12);this.setGLCoords(this.__vv,0);this.setUV(this.__uv,0);a.glRender(this.__vv,12,this.__uv)}else{var c=a.coordsIndex;this.setGLCoords(a.coords,c);a.coordsIndex=c+12;this.setUV(a.uv,a.uvIndex);a.uvIndex+=8}},setGLCoords:function(a,c){var d=this.viewVertices;a[c++]=d[0].x;a[c++]=d[0].y;a[c++]=0;a[c++]=d[1].x;a[c++]=d[1].y;a[c++]=0;a[c++]=d[2].x;a[c++]=d[2].y;a[c++]=0;a[c++]=d[3].x;a[c++]=d[3].y;a[c++]=0},setUV:function(a,c){this.backgroundImage.setUV(a,c)},
-glNeedsFlush:function(a){return this.getTextureGLPage()!==a.currentTexturePage?true:this.frameAlpha!==a.currentOpacity?true:false},glSetShader:function(a){var c=this.getTextureGLPage();c!==a.currentTexturePage&&a.setGLTexturePage(c);this.frameAlpha!==a.currentOpacity&&a.setGLCurrentOpacity(this.frameAlpha)},endAnimate:function(){return this},initialize:function(a){if(a)for(var c in a)this[c]=a[c];return this},setClip:function(a,c){this.clip=a;this.clipPath=c;return this},cacheAsBitmap:function(a,
-c){var a=a||0,d=document.createElement("canvas");d.width=this.width;d.height=this.height;var e=d.getContext("2d"),e={ctx:e,crc:e,modelViewMatrix:new CAAT.Matrix,dirtyRectsEnabled:false,inDirtyRect:function(){return true}};this.cached=false;this.paintActor(e,a);this.setBackgroundImage(d);this.cached=c?c:CAAT.Actor.CACHE_SIMPLE;return this},setAsButton:function(a,c,d,e,f,g){this.setBackgroundImage(a,true);this.iNormal=c||0;this.iOver=d||this.iNormal;this.iPress=e||this.iNormal;this.iDisabled=f||this.iNormal;
-this.fnOnClick=g;this.enabled=true;this.setSpriteIndex(c);this.setEnabled=function(a){this.enabled=a;this.setSpriteIndex(this.enabled?this.iNormal:this.iDisabled);return this};this.actionPerformed=function(){this.enabled&&this.fnOnClick&&this.fnOnClick(this)};this.mouseEnter=function(){this.enabled&&(this.dragging?this.setSpriteIndex(this.iPress):this.setSpriteIndex(this.iOver),CAAT.setCursor("pointer"))};this.mouseExit=function(){this.enabled&&(this.setSpriteIndex(this.iNormal),CAAT.setCursor("default"))};
-this.mouseDown=function(){this.enabled&&this.setSpriteIndex(this.iPress)};this.mouseUp=function(){if(this.enabled)this.setSpriteIndex(this.iNormal),this.dragging=false};this.mouseClick=function(){};this.mouseDrag=function(){if(this.enabled)this.dragging=true};this.setButtonImageIndex=function(a,b,c,d){this.iNormal=a||0;this.iOver=b||this.iNormal;this.iPress=c||this.iNormal;this.iDisabled=d||this.iNormal;this.setSpriteIndex(this.iNormal);return this};return this}}})();
-(function(){CAAT.ActorContainer=function(a){CAAT.ActorContainer.superclass.constructor.call(this);this.CLASS=CAAT.ActorContainer;this.childrenList=[];this.activeChildren=[];this.pendingChildrenList=[];if(typeof a!=="undefined")this.addHint=a,this.boundingBox=new CAAT.Rectangle;return this};CAAT.ActorContainer.AddHint={CONFORM:1};CAAT.ActorContainer.prototype={childrenList:null,activeChildren:null,pendingChildrenList:null,addHint:0,boundingBox:null,runion:new CAAT.Rectangle,drawScreenBoundingBox:function(b,
-c){if(this.inFrame){for(var d=this.childrenList,e=0;e<d.length;e++)d[e].drawScreenBoundingBox(b,c);a.call(this,b,c)}},emptyChildren:function(){this.childrenList=[];return this},paintActor:function(a,c){if(!this.visible)return false;var d=a.ctx;d.save();if(!b.call(this,a,c))return false;if(this.cached===2)return false;if(!this.isGlobalAlpha)this.frameAlpha=this.parent?this.parent.frameAlpha:1;for(var e=0,f=this.activeChildren.length;e<f;++e){var k=this.activeChildren[e];k.visible&&(d.save(),k.paintActor(a,
-c),d.restore())}d.restore();return true},__paintActor:function(a,b){if(!this.visible)return true;var c=a.ctx;this.frameAlpha=this.parent?this.parent.frameAlpha*this.alpha:1;var d=this.worldModelViewMatrix.matrix;c.setTransform(d[0],d[3],d[1],d[4],d[2],d[5],this.frameAlpha);this.paint(a,b);if(!this.isGlobalAlpha)this.frameAlpha=this.parent?this.parent.frameAlpha:1;c=0;for(d=this.activeChildren.length;c<d;++c)this.activeChildren[c].paintActor(a,b);return true},paintActorGL:function(a,b){var d,e;if(!this.visible)return true;
-c.call(this,a,b);if(!this.isGlobalAlpha)this.frameAlpha=this.parent.frameAlpha;d=0;for(var f=this.activeChildren.length;d<f;++d)e=this.activeChildren[d],e.paintActorGL(a,b)},animate:function(a,b){if(!this.visible)return false;this.activeChildren=[];if(false===d.call(this,a,b))return false;if(this.cached===2)return true;var c,e,f=this.pendingChildrenList;for(c=0;c<f.length;c++)this.addChildImmediately(f[c]);this.pendingChildrenList=[];f=[];e=this.childrenList;this.size_total=this.size_active=1;for(c=
-0;c<e.length;c++){var k=e[c];k.time=b;this.size_total+=k.size_total;k.animate(a,b)?(this.activeChildren.push(k),this.size_active+=k.size_active):k.expired&&k.discardable&&f.push(k)}for(c=0,e=f.length;c<e;c++)k=f[c],k.destroy(b),a.dirtyRectsEnabled&&a.addDirtyRect(k.AABB);return true},endAnimate:function(){},addChildImmediately:function(a){return this.addChild(a)},addChild:function(a){if(a.parent!=null)throw"adding to a container an element with parent.";a.parent=this;this.childrenList.push(a);a.dirty=
-true;this.addHint===CAAT.ActorContainer.AddHint.CONFORM&&this.recalcSize();return this},recalcSize:function(){var a=this.boundingBox;a.setEmpty();for(var b=this.childrenList,c,d=0;d<b.length;d++)c=b[d],this.runion.setBounds(c.x<0?0:c.x,c.y<0?0:c.y,c.width,c.height),a.unionRectangle(this.runion);this.setSize(a.x1,a.y1);return this},addChildDelayed:function(a){this.pendingChildrenList.push(a);return this},addChildAt:function(a,b){if(b<=0)return a.parent=this,a.dirty=true,this.childrenList.splice(0,
-0,a),this;else if(b>=this.childrenList.length)b=this.childrenList.length;a.parent=this;a.dirty=true;this.childrenList.splice(b,0,a);return this},findActorById:function(a){for(var b=this.childrenList,c=0,d=b.length;c<d;c++)if(b[c].id===a)return b[c];return null},findChild:function(a){for(var b=this.childrenList,c=0,d=b.length,c=0;c<d;c++)if(b[c]===a)return c;return-1},removeChildAt:function(a){var b=this.childrenList;return-1!==a?(b[a].setParent(null),a=b.splice(a,1),a[0].isVisible()&&CAAT.currentDirector.dirtyRectsEnabled&&
-CAAT.currentDirector.scheduleDirtyRect(a[0].AABB),a[0]):null},removeChild:function(a){return this.removeChildAt(this.findChild(a))},removeFirstChild:function(){var a=this.childrenList.shift();a.parent=null;a.isVisible()&&CAAT.currentDirector.dirtyRectsEnabled&&CAAT.currentDirector.scheduleDirtyRect(a.AABB);return a},removeLastChild:function(){if(this.childrenList.length){var a=this.childrenList.pop();a.parent=null;a.isVisible()&&CAAT.currentDirector.dirtyRectsEnabled&&CAAT.currentDirector.scheduleDirtyRect(a.AABB);
-return a}},findActorAtPosition:function(a){if(null===e.call(this,a))return null;for(var b=this.childrenList.length-1;b>=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},destroy:function(){for(var a=this.childrenList,b=a.length-1;b>=0;b--)a[b].destroy();f.call(this);return this},getNumChildren:function(){return this.childrenList.length},getNumActiveChildren:function(){return this.activeChildren.length},getChildAt:function(a){return this.childrenList[a]},
-setZOrder:function(a,b){var c=this.findChild(a);if(-1!==c){var d=this.childrenList;if(b!==c)if(b>=d.length)d.splice(c,1),d.push(a);else{c=d.splice(c,1);if(b<0)b=0;else if(b>d.length)b=d.length;d.splice(b,0,c[0])}}}};extend(CAAT.ActorContainer,CAAT.Actor,null);var a=CAAT.ActorContainer.superclass.drawScreenBoundingBox,b=CAAT.ActorContainer.superclass.paintActor,c=CAAT.ActorContainer.superclass.paintActorGL,d=CAAT.ActorContainer.superclass.animate,e=CAAT.ActorContainer.superclass.findActorAtPosition,
-f=CAAT.ActorContainer.superclass.destroy})();
+behaviorList:null,parent:null,x:0,y:0,width:0,height:0,preferredSize:null,minimumSize:null,start_time:0,duration:Number.MAX_VALUE,clip:false,clipPath:null,tAnchorX:0,tAnchorY:0,scaleX:0,scaleY:0,scaleTX:0.5,scaleTY:0.5,scaleAnchor:0,rotationAngle:0,rotationY:0.5,rotationX:0.5,alpha:1,isGlobalAlpha:false,frameAlpha:1,expired:false,discardable:false,pointed:false,mouseEnabled:true,visible:true,ANCHOR_CENTER:0,ANCHOR_TOP:1,ANCHOR_BOTTOM:2,ANCHOR_LEFT:3,ANCHOR_RIGHT:4,ANCHOR_TOP_LEFT:5,ANCHOR_TOP_RIGHT:6,
+ANCHOR_BOTTOM_LEFT:7,ANCHOR_BOTTOM_RIGHT:8,ANCHOR_CUSTOM:9,fillStyle:null,strokeStyle:null,time:0,AABB:null,viewVertices:null,inFrame:false,dirty:true,wdirty:true,oldX:-1,oldY:-1,modelViewMatrix:null,worldModelViewMatrix:null,modelViewMatrixI:null,worldModelViewMatrixI:null,glEnabled:false,backgroundImage:null,id:null,size_active:1,size_total:1,__d_ax:-1,__d_ay:-1,gestureEnabled:false,invalid:true,cached:0,collides:false,collidesAsRect:true,isAA:true,invalidateLayout:function(){this.parent&&!this.parent.layoutInvalidated&&
+this.parent.invalidateLayout();return this},__validateLayout:function(){},setPreferredSize:function(a,c){if(!this.preferredSize)this.preferredSize=new CAAT.Dimension;this.preferredSize.width=a;this.preferredSize.height=c;return this},getPreferredSize:function(){return this.preferredSize?this.preferredSize:this.getMinimumSize()},setMinimumSize:function(a,c){if(!this.minimumSize)this.minimumSize=new CAAT.Dimension;this.minimumSize.width=a;this.minimumSize.height=c;return this},getMinimumSize:function(){return this.minimumSize?
+this.minimumSize:new CAAT.Dimension(this.width,this.height)},create:function(){return this},moveTo:function(a,c,d,e,f){if(!(a===this.x&&c===this.y)){var g=this.getBehavior("__moveTo");g||(g=(new CAAT.PathBehavior).setId("__moveTo").setValues(new CAAT.LinearPath),this.addBehavior(g));g.path.setInitialPosition(this.x,this.y).setFinalPosition(a,c);g.setDelayTime(e?e:0,d);f&&g.setInterpolator(f);return this}},rotateTo:function(a,c,d,e,f,g){if(a!==this.rotationAngle){var h=this.getBehavior("__rotateTo");
+h||(h=(new CAAT.RotateBehavior).setId("__rotateTo").setValues(0,0,0.5,0.5),this.addBehavior(h));h.setValues(this.rotationAngle,a,e,f).setDelayTime(d?d:0,c);g&&h.setInterpolator(g);return this}},scaleTo:function(a,c,d,e,f,g,h){if(!(this.scaleX===a&&this.scaleY===c)){var i=this.getBehavior("__scaleTo");i||(i=(new CAAT.ScaleBehavior).setId("__scaleTo").setValues(1,1,1,1,0.5,0.5),this.addBehavior(i));i.setValues(this.scaleX,a,this.scaleY,c,f,g).setDelayTime(e?e:0,d);h&&i.setInterpolator(h);return this}},
+scaleXTo:function(a,c,d,e,f,g){return this.__scale1To(CAAT.Scale1Behavior.AXIS_X,a,c,d,e,f,g)},scaleYTo:function(a,c,d,e,f,g){return this.__scale1To(CAAT.Scale1Behavior.AXIS_Y,a,c,d,e,f,g)},__scale1To:function(a,c,d,e,f,g,h){if(!(a===CAAT.Scale1Behavior.AXIS_X&&c===this.scaleX||a===CAAT.Scale1Behavior.AXIS_Y&&c===this.scaleY)){var i=this.getBehavior("__scaleXTo");i||(i=(new CAAT.Scale1Behavior).setId("__scaleXTo").setValues(1,1,a===CAAT.Scale1Behavior.AXIS_X,0.5,0.5),this.addBehavior(i));i.setValues(a?
+this.scaleX:this.scaleY,c,f,g).setDelayTime(e?e:0,d);h&&i.setInterpolator(h);return this}},touchStart:function(){},touchMove:function(){},touchEnd:function(){},gestureStart:function(){},gestureChange:function(a,c,d){this.gestureEnabled&&(this.setRotation(a),this.setScale(c,d));return this},gestureEnd:function(){},isVisible:function(){return this.isVisible},setupCollission:function(a,c){this.collides=a;this.collidesAsRect=!c},invalidate:function(){this.invalid=true},setGestureEnabled:function(a){this.gestureEnabled=
+!!a;return this},isGestureEnabled:function(){return this.gestureEnabled},getId:function(){return this.id},setId:function(a){this.id=a;return this},setParent:function(a){this.parent=a;return this},setBackgroundImage:function(a,c){if(a){a instanceof CAAT.SpriteImage||(a=(new CAAT.SpriteImage).initialize(a,1,1));a.setOwner(this);this.backgroundImage=a;if(typeof c==="undefined"||c)this.width=a.getWidth(),this.height=a.getHeight();this.glEnabled=true;this.invalidate()}else this.backgroundImage=null;return this},
+setSpriteIndex:function(a){this.backgroundImage&&(this.backgroundImage.setSpriteIndex(a),this.invalidate());return this},setBackgroundImageOffset:function(a,c){this.backgroundImage&&this.backgroundImage.setOffset(a,c);return this},setAnimationImageIndex:function(a){this.backgroundImage&&(this.backgroundImage.resetAnimationTime(),this.backgroundImage.setAnimationImageIndex(a),this.invalidate());return this},resetAnimationTime:function(){this.backgroundImage&&(this.backgroundImage.resetAnimationTime(),
+this.invalidate());return this},setChangeFPS:function(a){this.backgroundImage&&this.backgroundImage.setChangeFPS(a);return this},setImageTransformation:function(a){this.backgroundImage&&this.backgroundImage.setSpriteTransformation(a);return this},centerOn:function(a,c){this.setPosition(a-this.width/2,c-this.height/2);return this},centerAt:function(a,c){this.setPosition(a-this.width/2,c-this.height/2);return this},getTextureGLPage:function(){return this.backgroundImage.image.__texturePage},setVisible:function(a){this.invalidate();
+CAAT.currentDirector&&CAAT.currentDirector.dirtyRectsEnabled&&!a&&this.visible&&CAAT.currentDirector.scheduleDirtyRect(this.AABB);this.visible=a;return this},setOutOfFrameTime:function(){this.setFrameTime(-1,0);return this},addListener:function(a){this.lifecycleListenerList.push(a);return this},removeListener:function(a){for(var c=this.lifecycleListenerList.length;c--;)if(this.lifecycleListenerList[c]===a){this.lifecycleListenerList.splice(c,1);break}},setGlobalAlpha:function(a){this.isGlobalAlpha=
+a;return this},fireEvent:function(a,c){for(var d=0;d<this.lifecycleListenerList.length;d++)this.lifecycleListenerList[d].actorLifeCycleEvent(this,a,c)},setExpired:function(a){this.expired=true;this.fireEvent("expired",a);return this},enableEvents:function(a){this.mouseEnabled=a;return this},emptyBehaviorList:function(){this.behaviorList=[];return this},setFillStyle:function(a){this.fillStyle=a;this.invalidate();return this},setStrokeStyle:function(a){this.strokeStyle=a;this.invalidate();return this},
+setPaint:function(a){return this.setFillStyle(a)},setAlpha:function(a){this.alpha=a;this.invalidate();return this},resetTransform:function(){this.rotationAngle=0;this.rotationY=this.rotationX=0.5;this.scaleY=this.scaleX=1;this.scaleTY=this.scaleTX=0.5;this.scaleAnchor=0;this.oldY=this.oldX=-1;this.dirty=true;return this},setFrameTime:function(a,c){this.start_time=a;this.duration=c;this.expired=false;this.dirty=true;return this},paint:function(a,c){if(this.backgroundImage)this.backgroundImage.paint(a,
+c,0,0);else if(this.fillStyle){var d=a.crc;d.fillStyle=this.fillStyle;d.fillRect(0,0,this.width,this.height)}},setScale:function(a,c){this.scaleX=a;this.scaleY=c;this.dirty=true;return this},getAnchorPercent:function(a){var c=[0.5,0.5,0.5,0,0.5,1,0,0.5,1,0.5,0,0,1,0,0,1,1,1];return{x:c[a*2],y:c[a*2+1]}},getAnchor:function(a){var c=0,d=0;switch(a){case this.ANCHOR_CENTER:d=c=0.5;break;case this.ANCHOR_TOP:c=0.5;d=0;break;case this.ANCHOR_BOTTOM:c=0.5;d=1;break;case this.ANCHOR_LEFT:c=0;d=0.5;break;
+case this.ANCHOR_RIGHT:c=1;d=0.5;break;case this.ANCHOR_TOP_RIGHT:c=1;d=0;break;case this.ANCHOR_BOTTOM_LEFT:c=0;d=1;break;case this.ANCHOR_BOTTOM_RIGHT:d=c=1;break;case this.ANCHOR_TOP_LEFT:d=c=0}return{x:c,y:d}},setGlobalAnchor:function(a,c){this.scaleTX=this.rotationX=this.tAnchorX=a;this.scaleTY=this.rotationY=this.tAnchorY=c;this.dirty=true;return this},setScaleAnchor:function(a,c){this.scaleTX=a;this.scaleTY=c;this.dirty=true;return this},setScaleAnchored:function(a,c,d,e){this.scaleTX=d;this.scaleTY=
+e;this.scaleX=a;this.scaleY=c;this.dirty=true;return this},setRotationAnchor:function(a,c){this.rotationX=c;this.rotationY=a;this.dirty=true;return this},setRotation:function(a){this.rotationAngle=a;this.dirty=true;return this},setRotationAnchored:function(a,c,d){this.rotationAngle=a;this.rotationX=c;this.rotationY=d;this.dirty=true;return this},setSize:function(a,c){this.width=a;this.height=c;this.dirty=true;return this},setBounds:function(a,c,d,e){this.x=a;this.y=c;this.width=d;this.height=e;this.dirty=
+true;return this},setLocation:function(a,c){this.x=a;this.y=c;this.oldX=a;this.oldY=c;this.dirty=true;return this},setPosition:function(a,c){return this.setLocation(a,c)},setPositionAnchor:function(a,c){this.tAnchorX=a;this.tAnchorY=c;return this},setPositionAnchored:function(a,c,d,e){this.setLocation(a,c);this.tAnchorX=d;this.tAnchorY=e;return this},isInAnimationFrame:function(a){if(this.expired)return false;if(this.duration===Number.MAX_VALUE)return this.start_time<=a;return a>=this.start_time+
+this.duration?(this.expired||this.setExpired(a),false):this.start_time<=a&&a<this.start_time+this.duration},contains:function(a,c){return a>=0&&c>=0&&a<this.width&&c<this.height},addBehavior:function(a){this.behaviorList.push(a);return this},removeBehaviour:function(a){for(var c=this.behaviorList,d=c.length-1;d;)if(c[d]===a){c.splice(d,1);break}return this},removeBehaviorById:function(a){for(var c=this.behaviorList,d=0;d<c.length;d++)c[d].id===a&&c.splice(d,1);return this},getBehavior:function(a){for(var c=
+this.behaviorList,d=0;d<c.length;d++){var e=c[d];if(e.id===a)return e}return null},setDiscardable:function(a){this.discardable=a;return this},destroy:function(a){this.parent&&this.parent.removeChild(this);this.fireEvent("destroyed",a)},modelToView:function(a){var c,d,e,f;this.dirty&&this.setModelViewMatrix();f=this.worldModelViewMatrix.matrix;if(a instanceof Array)for(var g=0;g<a.length;g++)e=a[g],c=e.x,d=e.y,e.x=c*f[0]+d*f[1]+f[2],e.y=c*f[3]+d*f[4]+f[5];else c=a.x,d=a.y,a.x=c*f[0]+d*f[1]+f[2],a.y=
+c*f[3]+d*f[4]+f[5];return a},modelToModel:function(a,c){this.dirty&&this.setModelViewMatrix();return c.viewToModel(this.modelToView(a))},viewToModel:function(a){this.dirty&&this.setModelViewMatrix();this.worldModelViewMatrixI=this.worldModelViewMatrix.getInverse();this.worldModelViewMatrixI.transformCoord(a);return a},findActorAtPosition:function(a){if(!this.visible||!this.mouseEnabled||!this.isInAnimationFrame(this.time))return null;this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(a);
+return this.contains(a.x,a.y)?this:null},enableDrag:function(){this.ay=this.ax=0;this.asy=this.asx=1;this.screeny=this.screenx=this.ara=0;this.mouseEnter=function(){this.__d_ay=this.__d_ax=-1;this.pointed=true;CAAT.setCursor("move")};this.mouseExit=function(){this.__d_ay=this.__d_ax=-1;this.pointed=false;CAAT.setCursor("default")};this.mouseMove=function(){};this.mouseUp=function(){this.__d_ay=this.__d_ax=-1};this.mouseDrag=function(a){var c;c=this.modelToView(new CAAT.Point(a.x,a.y));this.parent.viewToModel(c);
+if(this.__d_ax===-1||this.__d_ay===-1)this.__d_ax=c.x,this.__d_ay=c.y,this.__d_asx=this.scaleX,this.__d_asy=this.scaleY,this.__d_ara=this.rotationAngle,this.__d_screenx=a.screenPoint.x,this.__d_screeny=a.screenPoint.y;if(a.isShiftDown()){var d=(a.screenPoint.x-this.__d_screenx)/100,e=(a.screenPoint.y-this.__d_screeny)/100;a.isAltDown()||(e=d=a=Math.max(d,e));this.setScale(d+this.__d_asx,e+this.__d_asy)}else a.isControlDown()?this.setRotation(-Math.atan2(a.screenPoint.x-this.__d_screenx,a.screenPoint.y-
+this.__d_screeny)+this.__d_ara):(this.x+=c.x-this.__d_ax,this.y+=c.y-this.__d_ay);this.__d_ax=c.x;this.__d_ay=c.y};return this},disableDrag:function(){this.mouseEnter=function(){};this.mouseExit=function(){};this.mouseMove=function(){};this.mouseUp=function(){};this.mouseDrag=function(){};return this},mouseClick:function(){},mouseDblClick:function(){},mouseEnter:function(){this.pointed=true},mouseExit:function(){this.pointed=false},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},
+mouseOut:function(){},mouseOver:function(){},mouseDrag:function(){},drawScreenBoundingBox:function(a){if(null!==this.AABB&&this.inFrame){var c=this.AABB,a=a.ctx;a.strokeStyle=CAAT.DEBUGAABBCOLOR;a.strokeRect(0.5+(c.x|0),0.5+(c.y|0),c.width|0,c.height|0);if(CAAT.DEBUGBB)c=this.viewVertices,a.beginPath(),a.lineTo(c[0].x,c[0].y),a.lineTo(c[1].x,c[1].y),a.lineTo(c[2].x,c[2].y),a.lineTo(c[3].x,c[3].y),a.closePath(),a.strokeStyle=CAAT.DEBUGBBCOLOR,a.stroke()}},animate:function(a,c){if(!this.visible)return false;
+var d;if(!this.isInAnimationFrame(c))return this.inFrame=false,this.dirty=true,false;if(this.x!==this.oldX||this.y!==this.oldY)this.dirty=true,this.oldX=this.x,this.oldY=this.y;for(d=0;d<this.behaviorList.length;d++)this.behaviorList[d].apply(c,this);this.clipPath&&this.clipPath.applyBehaviors(c);this.setModelViewMatrix();if(this.dirty||this.wdirty||this.invalid)a.dirtyRectsEnabled&&a.addDirtyRect(this.AABB),this.setScreenBounds(),a.dirtyRectsEnabled&&a.addDirtyRect(this.AABB);this.invalid=this.dirty=
+false;this.inFrame=true;return this.AABB.intersects(a.AABB)},setModelViewMatrix:function(){var a,c,d,e,f,g,h,i,j,l,k;this.wdirty=false;k=this.modelViewMatrix.matrix;if(this.dirty){h=1;j=e=0;g=1;i=this.x-this.tAnchorX*this.width;l=this.y-this.tAnchorY*this.height;if(this.rotationAngle){var n=this.rotationX*this.width,m=this.rotationY*this.height;i+=h*n+e*m;l+=j*n+g*m;a=Math.cos(this.rotationAngle);c=Math.sin(this.rotationAngle);d=h;f=j;h=d*a+e*c;e=-d*c+e*a;j=f*a+g*c;g=-f*c+g*a;i+=-h*n-e*m;l+=-j*n-
+g*m}if(this.scaleX!=1||this.scaleY!=1)a=this.scaleTX*this.width,c=this.scaleTY*this.height,i+=h*a+e*c,l+=j*a+g*c,h*=this.scaleX,e*=this.scaleY,j*=this.scaleX,g*=this.scaleY,i+=-h*a-e*c,l+=-j*a-g*c;k[0]=h;k[1]=e;k[2]=i;k[3]=j;k[4]=g;k[5]=l}if(this.parent){if(this.isAA=this.rotationAngle===0&&this.scaleX===1&&this.scaleY===1&&this.parent.isAA,this.dirty||this.parent.wdirty)this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix),this.isAA?(h=this.worldModelViewMatrix.matrix,h[2]+=k[2],h[5]+=
+k[5]):this.worldModelViewMatrix.multiply(this.modelViewMatrix),this.wdirty=true}else{if(this.dirty)this.wdirty=true;this.worldModelViewMatrix.identity();this.isAA=this.rotationAngle===0&&this.scaleX===1&&this.scaleY===1}},setScreenBounds:function(){var a=this.AABB,c=this.viewVertices,d,e,f,g,h;if(this.isAA){d=this.worldModelViewMatrix.matrix;e=d[2];f=d[5];g=this.width;h=this.height;a.x=e;a.y=f;a.x1=e+g;a.y1=f+h;a.width=g;a.height=h;if(CAAT.GLRENDER)d=c[0],d.x=e,d.y=f,d=c[1],d.x=e+g,d.y=f,d=c[2],d.x=
+e+g,d.y=f+h,d=c[3],d.x=e,d.y=f+h;return this}d=c[0];d.x=0;d.y=0;d=c[1];d.x=this.width;d.y=0;d=c[2];d.x=this.width;d.y=this.height;d=c[3];d.x=0;d.y=this.height;this.modelToView(this.viewVertices);e=Number.MAX_VALUE;f=-Number.MAX_VALUE;g=Number.MAX_VALUE;h=-Number.MAX_VALUE;d=c[0];if(d.x<e)e=d.x;if(d.x>f)f=d.x;if(d.y<g)g=d.y;if(d.y>h)h=d.y;d=c[1];if(d.x<e)e=d.x;if(d.x>f)f=d.x;if(d.y<g)g=d.y;if(d.y>h)h=d.y;d=c[2];if(d.x<e)e=d.x;if(d.x>f)f=d.x;if(d.y<g)g=d.y;if(d.y>h)h=d.y;d=c[3];if(d.x<e)e=d.x;if(d.x>
+f)f=d.x;if(d.y<g)g=d.y;if(d.y>h)h=d.y;a.x=e;a.y=g;a.x1=f;a.y1=h;a.width=f-e;a.height=h-g;return this},paintActor:function(a,c){if(!this.visible||!a.inDirtyRect(this))return true;var d=a.ctx;this.frameAlpha=this.parent?this.parent.frameAlpha*this.alpha:1;d.globalAlpha=this.frameAlpha;a.modelViewMatrix.transformRenderingContextSet(d);this.worldModelViewMatrix.transformRenderingContext(d);this.clip&&(d.beginPath(),this.clipPath?this.clipPath.applyAsPath(a):d.rect(0,0,this.width,this.height),d.clip());
+this.paint(a,c);return true},__paintActor:function(a,c){if(!this.visible)return true;var d=a.ctx;this.frameAlpha=this.alpha;var e=this.worldModelViewMatrix.matrix;d.setTransform(e[0],e[3],e[1],e[4],e[2],e[5],this.frameAlpha);this.paint(a,c);return true},paintActorGL:function(a){this.frameAlpha=this.parent.frameAlpha*this.alpha;if(this.glEnabled&&this.visible)if(this.glNeedsFlush(a)){a.glFlush();this.glSetShader(a);if(!this.__uv)this.__uv=new Float32Array(8);if(!this.__vv)this.__vv=new Float32Array(12);
+this.setGLCoords(this.__vv,0);this.setUV(this.__uv,0);a.glRender(this.__vv,12,this.__uv)}else{var c=a.coordsIndex;this.setGLCoords(a.coords,c);a.coordsIndex=c+12;this.setUV(a.uv,a.uvIndex);a.uvIndex+=8}},setGLCoords:function(a,c){var d=this.viewVertices;a[c++]=d[0].x;a[c++]=d[0].y;a[c++]=0;a[c++]=d[1].x;a[c++]=d[1].y;a[c++]=0;a[c++]=d[2].x;a[c++]=d[2].y;a[c++]=0;a[c++]=d[3].x;a[c++]=d[3].y;a[c]=0},setUV:function(a,c){this.backgroundImage.setUV(a,c)},glNeedsFlush:function(a){return this.getTextureGLPage()!==
+a.currentTexturePage?true:this.frameAlpha!==a.currentOpacity?true:false},glSetShader:function(a){var c=this.getTextureGLPage();c!==a.currentTexturePage&&a.setGLTexturePage(c);this.frameAlpha!==a.currentOpacity&&a.setGLCurrentOpacity(this.frameAlpha)},endAnimate:function(){return this},initialize:function(a){if(a)for(var c in a)this[c]=a[c];return this},setClip:function(a,c){this.clip=a;this.clipPath=c;return this},cacheAsBitmap:function(a,c){var a=a||0,d=document.createElement("canvas");d.width=this.width;
+d.height=this.height;var e=d.getContext("2d"),e={ctx:e,crc:e,modelViewMatrix:new CAAT.Matrix,dirtyRectsEnabled:false,inDirtyRect:function(){return true}};this.cached=false;this.paintActor(e,a);this.setBackgroundImage(d);this.cached=c?c:CAAT.Actor.CACHE_SIMPLE;return this},setAsButton:function(a,c,d,e,f,g){this.setBackgroundImage(a,true);this.iNormal=c||0;this.iOver=d||this.iNormal;this.iPress=e||this.iNormal;this.iDisabled=f||this.iNormal;this.fnOnClick=g;this.enabled=true;this.setSpriteIndex(c);
+this.setEnabled=function(a){this.enabled=a;this.setSpriteIndex(this.enabled?this.iNormal:this.iDisabled);return this};this.actionPerformed=function(){this.enabled&&this.fnOnClick&&this.fnOnClick(this)};this.mouseEnter=function(){this.enabled&&(this.dragging?this.setSpriteIndex(this.iPress):this.setSpriteIndex(this.iOver),CAAT.setCursor("pointer"))};this.mouseExit=function(){this.enabled&&(this.setSpriteIndex(this.iNormal),CAAT.setCursor("default"))};this.mouseDown=function(){this.enabled&&this.setSpriteIndex(this.iPress)};
+this.mouseUp=function(){if(this.enabled)this.setSpriteIndex(this.iNormal),this.dragging=false};this.mouseClick=function(){};this.mouseDrag=function(){if(this.enabled)this.dragging=true};this.setButtonImageIndex=function(a,b,c,d){this.iNormal=a||0;this.iOver=b||this.iNormal;this.iPress=c||this.iNormal;this.iDisabled=d||this.iNormal;this.setSpriteIndex(this.iNormal);return this};return this}}})();
+(function(){CAAT.ActorContainer=function(a){CAAT.ActorContainer.superclass.constructor.call(this);this.CLASS=CAAT.ActorContainer;this.childrenList=[];this.activeChildren=[];this.pendingChildrenList=[];if(typeof a!=="undefined")this.addHint=a,this.boundingBox=new CAAT.Rectangle;return this};CAAT.ActorContainer.AddHint={CONFORM:1};CAAT.ActorContainer.prototype={childrenList:null,activeChildren:null,pendingChildrenList:null,addHint:0,boundingBox:null,runion:new CAAT.Rectangle,layoutManager:null,layoutInvalidated:true,
+setLayout:function(a){this.layoutManager=a;return this},setBounds:function(a,b,c,d){CAAT.ActorContainer.superclass.setBounds.call(this,a,b,c,d);CAAT.currentDirector&&!CAAT.currentDirector.inValidation&&this.invalidateLayout();return this},__validateLayout:function(){this.__validateTree();this.layoutInvalidated=false},__validateTree:function(){if(this.layoutManager&&this.layoutManager.isInvalidated()){CAAT.currentDirector.inValidation=true;this.layoutManager.doLayout(this);for(var a=0;a<this.getNumChildren();a+=
+1)this.getChildAt(a).__validateLayout()}},invalidateLayout:function(){this.layoutInvalidated=true;if(this.layoutManager){this.layoutManager.invalidateLayout(this);for(var a=0;a<this.getNumChildren();a+=1)this.getChildAt(a).invalidateLayout()}},getLayout:function(){return this.layoutManager},drawScreenBoundingBox:function(b,c){if(this.inFrame){for(var d=this.childrenList,e=0;e<d.length;e++)d[e].drawScreenBoundingBox(b,c);a.call(this,b,c)}},emptyChildren:function(){this.childrenList=[];return this},
+paintActor:function(a,c){if(!this.visible)return false;var d=a.ctx;d.save();if(!b.call(this,a,c))return false;if(this.cached===2)return false;if(!this.isGlobalAlpha)this.frameAlpha=this.parent?this.parent.frameAlpha:1;for(var e=0,f=this.activeChildren.length;e<f;++e){var k=this.activeChildren[e];k.visible&&(d.save(),k.paintActor(a,c),d.restore())}d.restore();return true},__paintActor:function(a,b){if(!this.visible)return true;var c=a.ctx;this.frameAlpha=this.parent?this.parent.frameAlpha*this.alpha:
+1;var d=this.worldModelViewMatrix.matrix;c.setTransform(d[0],d[3],d[1],d[4],d[2],d[5],this.frameAlpha);this.paint(a,b);if(!this.isGlobalAlpha)this.frameAlpha=this.parent?this.parent.frameAlpha:1;c=0;for(d=this.activeChildren.length;c<d;++c)this.activeChildren[c].paintActor(a,b);return true},paintActorGL:function(a,b){var d,e,f;if(!this.visible)return true;c.call(this,a,b);if(!this.isGlobalAlpha)this.frameAlpha=this.parent.frameAlpha;for(d=0,e=this.activeChildren.length;d<e;++d)f=this.activeChildren[d],
+f.paintActorGL(a,b)},animate:function(a,b){if(!this.visible)return false;this.activeChildren=[];if(false===d.call(this,a,b))return false;if(this.cached===2)return true;this.__validateLayout();CAAT.currentDirector.inValidation=false;var c,e,f=this.pendingChildrenList;for(c=0;c<f.length;c++)this.addChildImmediately(f[c]);this.pendingChildrenList=[];f=[];e=this.childrenList;this.size_total=this.size_active=1;for(c=0;c<e.length;c++){var k=e[c];k.time=b;this.size_total+=k.size_total;k.animate(a,b)?(this.activeChildren.push(k),
+this.size_active+=k.size_active):k.expired&&k.discardable&&f.push(k)}for(c=0,e=f.length;c<e;c++)k=f[c],k.destroy(b),a.dirtyRectsEnabled&&a.addDirtyRect(k.AABB);return true},endAnimate:function(){},addChildImmediately:function(a){return this.addChild(a)},addChild:function(a,b){if(a.parent!=null)throw"adding to a container an element with parent.";a.parent=this;this.childrenList.push(a);a.dirty=true;this.layoutManager?(this.layoutManager.addChild(a,b),this.invalidateLayout()):this.addHint===CAAT.ActorContainer.AddHint.CONFORM&&
+this.recalcSize();return this},recalcSize:function(){var a=this.boundingBox;a.setEmpty();for(var b=this.childrenList,c,d=0;d<b.length;d++)c=b[d],this.runion.setBounds(c.x<0?0:c.x,c.y<0?0:c.y,c.width,c.height),a.unionRectangle(this.runion);this.setSize(a.x1,a.y1);return this},addChildDelayed:function(a){this.pendingChildrenList.push(a);return this},addChildAt:function(a,b){if(b<=0)return a.parent=this,a.dirty=true,this.childrenList.splice(0,0,a),this.invalidateLayout(),this;else if(b>=this.childrenList.length)b=
+this.childrenList.length;a.parent=this;a.dirty=true;this.childrenList.splice(b,0,a);this.invalidateLayout();return this},findActorById:function(a){for(var b=this.childrenList,c=0,d=b.length;c<d;c++)if(b[c].id===a)return b[c];return null},findChild:function(a){var b=this.childrenList,c,d=b.length;for(c=0;c<d;c++)if(b[c]===a)return c;return-1},removeChildAt:function(a){var b=this.childrenList;if(-1!==a)return b[a].setParent(null),a=b.splice(a,1),a[0].isVisible()&&CAAT.currentDirector.dirtyRectsEnabled&&
+CAAT.currentDirector.scheduleDirtyRect(a[0].AABB),a[0];this.invalidateLayout();return null},removeChild:function(a){return this.removeChildAt(this.findChild(a))},removeFirstChild:function(){var a=this.childrenList.shift();a.parent=null;a.isVisible()&&CAAT.currentDirector.dirtyRectsEnabled&&CAAT.currentDirector.scheduleDirtyRect(a.AABB);this.invalidateLayout();return a},removeLastChild:function(){if(this.childrenList.length){var a=this.childrenList.pop();a.parent=null;a.isVisible()&&CAAT.currentDirector.dirtyRectsEnabled&&
+CAAT.currentDirector.scheduleDirtyRect(a.AABB);this.invalidateLayout();return a}return null},findActorAtPosition:function(a){if(null===e.call(this,a))return null;for(var b=this.childrenList.length-1;b>=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},destroy:function(){for(var a=this.childrenList,b=a.length-1;b>=0;b--)a[b].destroy();f.call(this);return this},getNumChildren:function(){return this.childrenList.length},getNumActiveChildren:function(){return this.activeChildren.length},
+getChildAt:function(a){return this.childrenList[a]},setZOrder:function(a,b){var c=this.findChild(a);if(-1!==c){var d=this.childrenList;if(b!==c){if(b>=d.length)d.splice(c,1),d.push(a);else{c=d.splice(c,1);if(b<0)b=0;else if(b>d.length)b=d.length;d.splice(b,0,c[0])}this.invalidateLayout()}}}};extend(CAAT.ActorContainer,CAAT.Actor,null);var a=CAAT.ActorContainer.superclass.drawScreenBoundingBox,b=CAAT.ActorContainer.superclass.paintActor,c=CAAT.ActorContainer.superclass.paintActorGL,d=CAAT.ActorContainer.superclass.animate,
+e=CAAT.ActorContainer.superclass.findActorAtPosition,f=CAAT.ActorContainer.superclass.destroy})();
(function(){CAAT.TextActor=function(){CAAT.TextActor.superclass.constructor.call(this);this.font="10px sans-serif";this.textAlign="left";this.textBaseline="top";this.outlineColor="black";this.clip=false;return this};CAAT.TextActor.TRAVERSE_PATH_FORWARD=1;CAAT.TextActor.TRAVERSE_PATH_BACKWARD=-1;CAAT.TextActor.prototype={font:null,textAlign:null,textBaseline:null,fill:true,textFillStyle:"#eee",text:null,textWidth:0,textHeight:0,outline:false,outlineColor:null,lineWidth:1,path:null,pathInterpolator:null,
pathDuration:1E4,sign:1,setFill:function(a){this.fill=a;return this},setLineWidth:function(a){this.lineWidth=a;return this},setTextFillStyle:function(a){this.textFillStyle=a;return this},setOutline:function(a){this.outline=a;return this},setPathTraverseDirection:function(a){this.sign=a;return this},setOutlineColor:function(a){this.outlineColor=a;return this},setText:function(a){this.text=a;if(null===this.text||this.text==="")this.width=this.height=0;this.calcTextSize(CAAT.director[0]);this.invalidate();
return this},setTextAlign:function(a){this.textAlign=a;this.__setLocation();return this},setAlign:function(a){return this.setTextAlign(a)},setTextBaseline:function(a){this.textBaseline=a;return this},setBaseline:function(a){return this.setTextBaseline(a)},setFont:function(a){a||(a="10px sans-serif");a instanceof CAAT.Font&&(a=a.setAsSpriteImage());this.font=a;this.calcTextSize(CAAT.director[0]);return this},setLocation:function(a,b){this.lx=a;this.ly=b;this.__setLocation();return this},setPosition:function(a,
@@ -441,4 +445,23 @@ if(c.criteria==="width")return a.width<b.width?1:a.width>b.width?-1:0;else if(c.
a.LINEAR_MIPMAP_NEAREST);a.generateMipmap(a.TEXTURE_2D)},deletePage:function(){for(var a=0;a<this.images.length;a++)delete this.images[a].__texturePage,delete this.images[a].__u,delete this.images[a].__v;this.gl.deleteTexture(this.texture)},toCanvas:function(a,b){a=a||document.createElement("canvas");a.width=this.width;a.height=this.height;var c=a.getContext("2d");c.fillStyle="rgba(0,0,0,0)";c.fillRect(0,0,this.width,this.height);for(var d=0;d<this.images.length;d++)if(c.drawImage(!this.images[d].inverted?
this.images[d]:CAAT.modules.ImageUtil.prototype.rotate(this.images[d],90),this.images[d].__tx,this.images[d].__ty),b)c.strokeStyle="red",c.strokeRect(this.images[d].__tx,this.images[d].__ty,this.images[d].__w,this.images[d].__h);if(b)c.strokeStyle="red",c.strokeRect(0,0,this.width,this.height);return a},packImage:function(a){var b,c;a.inverted?(b=a.height,c=a.width):(b=a.width,c=a.height);var d=b,e=c,f;if(d&&this.padding)f=this.padding,d+f<=this.width&&(d+=f);if(e&&this.padding)f=this.padding,e+f<=
this.height&&(e+=f);f=this.scan.whereFitsChunk(d,e);null!==f?(this.images.push(a),a.__tx=f.x,a.__ty=f.y,a.__u=f.x/this.width,a.__v=f.y/this.height,a.__u1=(f.x+b)/this.width,a.__v1=(f.y+c)/this.height,a.__texturePage=this,a.__w=b,a.__h=c,this.scan.substract(f.x,f.y,d,e)):CAAT.log("Imagen ",a.src," de tamano ",a.width,a.height," no cabe.")},changeHeuristic:function(a){this.criteria=a}}})();
-(function(){CAAT.GLTexturePageManager=function(){this.pages=[];return this};CAAT.GLTexturePageManager.prototype={pages:null,createPages:function(a,b,c,d){for(var e=false;!e;){e=new CAAT.GLTexturePage(b,c);e.create(d);e.initialize(a);e.endCreation();this.pages.push(e);for(var e=true,f=0;f<d.length;f++)if(!d[f].image.__texturePage){d[f].image.width<=b&&d[f].image.height<=c&&(e=false);break}}},deletePages:function(){for(var a=0;a<this.pages.length;a++)this.pages[a].deletePage();this.pages=null}}})();
+(function(){CAAT.GLTexturePageManager=function(){this.pages=[];return this};CAAT.GLTexturePageManager.prototype={pages:null,createPages:function(a,b,c,d){for(var e=false;!e;){e=new CAAT.GLTexturePage(b,c);e.create(d);e.initialize(a);e.endCreation();this.pages.push(e);for(var e=true,f=0;f<d.length;f++)if(!d[f].image.__texturePage){d[f].image.width<=b&&d[f].image.height<=c&&(e=false);break}}},deletePages:function(){for(var a=0;a<this.pages.length;a++)this.pages[a].deletePage();this.pages=null}}})();CAAT.UI={};(function(){CAAT.UI.Padding=function(){return this};CAAT.UI.Padding.prototype={left:2,right:2,top:2,bottom:2};CAAT.UI.LayoutManager=function(){this.newChildren=[];this.padding=new CAAT.UI.Padding;return this};CAAT.UI.LayoutManager.newElementInterpolator=(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.7);CAAT.UI.LayoutManager.moveElementInterpolator=(new CAAT.Interpolator).createExponentialOutInterpolator(2);CAAT.UI.LayoutManager.prototype={padding:null,invalid:true,hgap:2,vgap:2,animated:true,
+newChildren:null,setAnimated:function(a){this.animated=a},setHGap:function(a){this.hgap=a;this.invalidateLayout();return this},setVGap:function(a){this.vgap=a;this.invalidateLayout();return this},setAllPadding:function(a){this.padding.left=a;this.padding.right=a;this.padding.top=a;this.padding.bottom=a;this.invalidateLayout();return this},setPadding:function(a,b,c,d){this.padding.left=a;this.padding.right=b;this.padding.top=c;this.padding.bottom=d;this.invalidateLayout();return this},addChild:function(a){this.newChildren.push(a)},
+removeChild:function(){},doLayout:function(){this.newChildren=[];this.invalid=false},invalidateLayout:function(){this.invalid=true},getMinimumLayoutSize:function(){},getPreferredLayoutSize:function(){},isValid:function(){return!this.invalid},isInvalidated:function(){return this.invalid}}})();
+(function(){CAAT.UI.GridLayout=function(a,b){CAAT.UI.GridLayout.superclass.constructor.call(this);this.rows=a;this.columns=b;return this};CAAT.UI.GridLayout.prototype={rows:0,columns:2,doLayout:function(a){var b=a.getNumChildren();if(b!==0){var c=this.rows,d=this.columns;c>0?d=Math.floor((b+c-1)/c):c=Math.floor((b+d-1)/d);for(var e=(d-1)*this.hgap,f=a.width-(this.padding.left+this.padding.right),g=Math.floor((f-e)/d),h=(c-1)*this.vgap,i=a.height-(this.padding.top+this.padding.bottom),j=Math.floor((i-
+h)/c),h=Math.floor((i-(j*c+h))/2),i=0,e=this.padding.left+Math.floor((f-(g*d+e))/2);i<d;i++,e+=g+this.hgap)for(var f=0,l=this.padding.top+h;f<c;f++,l+=j+this.vgap){var k=f*d+i;k<b&&(k=a.getChildAt(k),this.animated?(k.setSize(g,j),this.newChildren.indexOf(k)!==-1?(k.setPosition(e,l),k.setScale(0.01,0.01),k.scaleTo(1,1,500,0,0.5,0.5,CAAT.UI.LayoutManager.newElementInterpolator)):k.moveTo(e,l,500,0,CAAT.UI.LayoutManager.moveElementInterpolator)):k.setBounds(e,l,g,j))}CAAT.UI.GridLayout.superclass.doLayout.call(this,
+a)}},getMinimumLayoutSize:function(a){var b=this.rows,c=this.columns,d=a.getNumChildren(),e=0,f=0,g;b>0?c=Math.ceil((d+b-1)/b):b=Math.ceil((d+c-1)/c);for(g=0;g<d;g+=1){var h=a.getChildAt(g).getMinimumSize();if(e<h.width)e=h.width;if(f<h.height)f=h.height}return new CAAT.Dimension(this.padding.left+this.padding.right+c*e+(c-1)*this.hgap,this.padding.top+this.padding.bottom+b*f+(b-1)*this.vgap)},getPreferredLayoutSize:function(a){var b=this.rows,c=this.columns,d=a.getNumChildren(),e=0,f=0,g;b>0?c=Math.ceil((d+
+b-1)/b):b=Math.ceil((d+c-1)/c);for(g=0;g<d;g+=1){var h=a.getChildAt(g).getPreferredSize();if(e<h.width)e=h.width;if(f<h.height)f=h.height}return new CAAT.Dimension(this.padding.left+this.padding.right+c*e+(c-1)*this.hgap,this.padding.top+this.padding.bottom+b*f+(b-1)*this.vgap)}};extend(CAAT.UI.GridLayout,CAAT.UI.LayoutManager)})();
+(function(){CAAT.UI.BorderLayout=function(){CAAT.UI.BorderLayout.superclass.constructor.call(this);return this};CAAT.UI.BorderLayout.prototype={left:null,right:null,top:null,bottom:null,center:null,addChild:function(a,b){CAAT.UI.BorderLayout.superclass.addChild.call(this,a,b);if(b==="center")this.center=a;else if(b==="left")this.left=a;else if(b==="right")this.right=a;else if(b==="top")this.top=a;else if(b==="bottom")this.bottom=a},removeChild:function(a){if(this.center===a)this.center=null;else if(this.left===
+a)this.left=null;else if(this.right===a)this.right=null;else if(this.top===a)this.top=null;else if(this.bottom===a)this.bottom=null},__getChild:function(a){if(a==="center")return this.center;else if(a==="left")return this.left;else if(a==="right")return this.right;else if(a==="top")return this.top;else if(a==="bottom")return this.bottom},getMinimumLayoutSize:function(){var a,b=new CAAT.Dimension;if((a=this.__getChild("right"))!=null)a=a.getMinimumSize(),b.width+=a.width+this.hgap,b.height=Math.max(a.height,
+b.height);if((a=this.__getChild("left"))!=null)a=a.getMinimumSize(),b.width+=a.width+this.hgap,b.height=Math.max(a.height,b.height);if((a=this.__getChild("center"))!=null)a=a.getMinimumSize(),b.width+=a.width,b.height=Math.max(a.height,b.height);if((a=this.__getChild("top"))!=null)a=a.getMinimumSize(),b.width=Math.max(a.width,b.width),b.height+=a.height+this.vgap;if((a=this.__getChild("bottom"))!=null)a=a.getMinimumSize(),b.width=Math.max(a.width,b.width),b.height+=a.height+this.vgap;b.width+=this.padding.left+
+this.padding.right;b.height+=this.padding.top+this.padding.bottom;return b},getPreferredLayoutSize:function(){var a,b=new CAAT.Dimension;if((a=this.__getChild("left"))!=null)a=a.getPreferredSize(),b.width+=a.width+this.hgap,b.height=Math.max(a.height,b.height);if((a=this.__getChild("right"))!=null)a=a.getPreferredSize(),b.width+=a.width+this.hgap,b.height=Math.max(a.height,b.height);if((a=this.__getChild("center"))!=null)a=a.getPreferredSize(),b.width+=a.width,b.height=Math.max(a.height,b.height);
+if((a=this.__getChild("top"))!=null)a=a.getPreferredSize(),b.width=Math.max(a.width,b.width),b.height+=a.height+this.vgap;if((a=this.__getChild("bottom"))!=null)a=a.getPreferredSize(),b.width=Math.max(a.width,b.width),b.height+=a.height+this.vgap;b.width+=this.padding.left+this.padding.right;b.height+=this.padding.top+this.padding.bottom;return b},doLayout:function(a){var b=this.padding.top,c=a.height-this.padding.bottom,d=this.padding.left,e=a.width-this.padding.right,f=null,g;if((f=this.__getChild("top"))!=
+null)f.setSize(e-d,f.height),g=f.getPreferredSize(),f.setBounds(d,b,e-d,g.height),b+=g.height+this.vgap;if((f=this.__getChild("bottom"))!=null)f.setSize(e-d,f.height),g=f.getPreferredSize(),f.setBounds(d,c-g.height,e-d,g.height),c-=g.height+this.vgap;if((f=this.__getChild("right"))!=null)f.setSize(f.width,c-b),g=f.getPreferredSize(),f.setBounds(e-g.width,b,g.width,c-b),e-=g.width+this.hgap;if((f=this.__getChild("left"))!=null)f.setSize(f.width,c-b),g=f.getPreferredSize(),f.setBounds(d,b,g.width,c-
+b),d+=g.width+this.hgap;(f=this.__getChild("center"))!=null&&f.setBounds(d,b,e-d,c-b);CAAT.UI.BorderLayout.superclass.doLayout.call(this,a)}};extend(CAAT.UI.BorderLayout,CAAT.UI.LayoutManager)})();
+(function(){CAAT.UI.BoxLayout=function(){CAAT.UI.BoxLayout.superclass.constructor.call(this);return this};CAAT.UI.BoxLayout.AXIS={X:0,Y:1};CAAT.UI.BoxLayout.ALIGNMENT={LEFT:0,RIGHT:1,CENTER:2,TOP:3,BOTTOM:4};CAAT.UI.BoxLayout.prototype={axis:CAAT.UI.BoxLayout.AXIS.Y,valign:CAAT.UI.BoxLayout.ALIGNMENT.CENTER,halign:CAAT.UI.BoxLayout.ALIGNMENT.CENTER,setAxis:function(a){this.axis=a;this.invalidateLayout();return this},setHorizontalAlignment:function(a){this.halign=a;this.invalidateLayout();return this},
+setVerticalAlignment:function(a){this.valign=a;this.invalidateLayout();return this},doLayout:function(a){this.axis===CAAT.UI.BoxLayout.AXIS.Y?this.doLayoutVertical(a):this.doLayoutHorizontal(a);CAAT.UI.BoxLayout.superclass.doLayout.call(this,a)},doLayoutHorizontal:function(a){var b=0,c=0,d=0,e,f;for(e=0,f=a.getNumChildren();e<f;e+=1){var g=a.getChildAt(e);if(c<g.height)c=g.height;b+=g.width;e>0&&(b+=this.hgap)}switch(this.halign){case CAAT.UI.BoxLayout.ALIGNMENT.LEFT:b=this.padding.left;break;case CAAT.UI.BoxLayout.ALIGNMENT.RIGHT:b=
+a.width-b-this.padding.right;break;default:b=(a.width-b)/2}for(e=0,f=a.getNumChildren();e<f;e+=1){g=a.getChildAt(e);switch(this.valign){case CAAT.UI.BoxLayout.ALIGNMENT.TOP:d=this.padding.top;break;case CAAT.UI.BoxLayout.ALIGNMENT.BOTTOM:d=a.height-this.padding.bottom-g.height;break;default:d=(a.height-g.height)/2}this.__setActorPosition(g,b,d);b+=g.width+this.hgap}},__setActorPosition:function(a,b,c){this.animated?this.newChildren.indexOf(a)!==-1?(a.setPosition(b,c),a.setScale(0,0),a.scaleTo(1,1,
+500,0,0.5,0.5,CAAT.UI.LayoutManager.newElementInterpolator)):a.moveTo(b,c,500,0,CAAT.UI.LayoutManager.moveElementInterpolator):a.setPosition(b,c)},doLayoutVertical:function(a){var b=0,c=0,d,e;for(d=0,e=a.getNumChildren();d<e;d+=1){var f=a.getChildAt(d);if(b<f.width)b=f.width;c+=f.height;d>0&&(c+=this.vgap)}switch(this.valign){case CAAT.UI.BoxLayout.ALIGNMENT.TOP:b=this.padding.top;break;case CAAT.UI.BoxLayout.ALIGNMENT.BOTTOM:b=a.height-c-this.padding.bottom;break;default:b=(a.height-c)/2}for(d=0,
+e=a.getNumChildren();d<e;d+=1){f=a.getChildAt(d);switch(this.halign){case CAAT.UI.BoxLayout.ALIGNMENT.LEFT:c=this.padding.left;break;case CAAT.UI.BoxLayout.ALIGNMENT.RIGHT:c=a.width-this.padding.right-f.width;break;default:c=(a.width-f.width)/2}this.__setActorPosition(f,c,b);b+=f.height+this.vgap}},getPreferredLayoutSize:function(a){var b=new CAAT.Dimension,c=0,d=0,e,f;for(e=0,f=a.getNumChildren();e<f;e+=1){var g=a.getChildAt(e).getPreferredSize();if(d<g.height)d=g.height;c+=g.width}b.width=c;b.height=
+d;return b},getMinimumLayoutSize:function(a){var b=new CAAT.Dimension,c=0,d=0,e,f;for(e=0,f=a.getNumChildren();e<f;e+=1){var g=a.getChildAt(e).getMinimumSize();if(d<g.height)d=g.height;c+=g.width}b.width=c;b.height=d;return b}};extend(CAAT.UI.BoxLayout,CAAT.UI.LayoutManager)})();
View
893 build/caat.js
@@ -21,11 +21,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-Version: 0.4 build: 304
+Version: 0.4 build: 319
Created on:
-DATE: 2012-09-11
-TIME: 22:08:04
+DATE: 2012-09-15
+TIME: 16:51:25
*/
@@ -2959,7 +2959,20 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
}
};
-})();/**
+})();(function() {
+
+ CAAT.Dimension= function(w,h) {
+ this.width= w;
+ this.height= h;
+ return this;
+ };
+
+ CAAT.Dimension.prototype= {
+ width : 0,
+ height : 0
+ };
+
+}());/**
* See LICENSE file.
*
* Generate interpolator.
@@ -5786,6 +5799,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
y: 0, // y position on parent. In parent's local coord. system.
width: 0, // Actor's width. In parent's local coord. system.
height: 0, // Actor's height. In parent's local coord. system.
+ preferredSize: null, // actor's preferred size for layout. {CAAT.Dimension}
+ minimumSize: null, // actor's minimum size for layout. {CAAT.Dimension},
start_time: 0, // Start time in Scene time.
duration: Number.MAX_VALUE, // Actor duration in Scene time
clip: false, // should clip the Actor's content against its contour.
@@ -5861,6 +5876,61 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
isAA : true, // is this actor/container Axis aligned ? if so, much faster inverse matrices
// can be calculated.
+ invalidateLayout : function() {
+ if ( this.parent && !this.parent.layoutInvalidated ) {
+ this.parent.invalidateLayout();
+ }
+
+ return this;
+ },
+
+ __validateLayout : function() {
+
+ },
+
+ /**
+ * Set this actors preferred layout size.
+ *
+ * @param pw {number}
+ * @param ph {number}
+ * @return {*}
+ */
+ setPreferredSize : function( pw, ph ) {
+ if ( !this.preferredSize ) {
+ this.preferredSize= new CAAT.Dimension();
+ }
+ this.preferredSize.width= pw;
+ this.preferredSize.height= ph;
+ return this;
+ },
+
+ getPreferredSize : function() {
+ return this.preferredSize ? this.preferredSize :
+ this.getMinimumSize();
+ },
+
+ /**
+ * Set this actors minimum layout size.
+ *
+ * @param pw {number}
+ * @param ph {number}
+ * @return {*}
+ */
+ setMinimumSize : function( pw, ph ) {
+ if ( !this.minimumSize ) {
+ this.minimumSize= new CAAT.Dimension();
+ }
+
+ this.minimumSize.width= pw;
+ this.minimumSize.height= ph;
+ return this;
+ },
+
+ getMinimumSize : function() {
+ return this.minimumSize ? this.minimumSize :
+ new CAAT.Dimension(this.width, this.height);
+ },
+
/**
* @deprecated
* @return {*}
@@ -5878,6 +5948,11 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @param interpolator {=CAAT.Interpolator} a CAAT.Interpolator instance
*/
moveTo : function( x, y, duration, delay, interpolator ) {
+
+ if ( x===this.x && y===this.y ) {
+ return;
+ }
+
var id= '__moveTo';
var b= this.getBehavior( id );
if ( !b ) {
@@ -5900,13 +5975,18 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
*
* @param angle {number} new rotation angle
* @param duration {number} time to rotate
- * @param delay {=number} millis to start rotation
- * @param anchorX {=number} rotation anchor x
- * @param anchorY {=number} rotation anchor y
- * @param interpolator {=CAAT.Interpolator}
+ * @param delay {number=} millis to start rotation
+ * @param anchorX {number=} rotation anchor x
+ * @param anchorY {number=} rotation anchor y
+ * @param interpolator {CAAT.Interpolator=}
* @return {*}
*/
rotateTo : function( angle, duration, delay, anchorX, anchorY, interpolator ) {
+
+ if ( angle===this.rotationAngle ) {
+ return;
+ }
+
var id= '__rotateTo';
var b= this.getBehavior( id );
if ( !b ) {
@@ -5938,6 +6018,11 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @return {*}
*/
scaleTo : function( scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator ) {
+
+ if ( this.scaleX===scaleX && this.scaleY===scaleY ) {
+ return;
+ }
+
var id= '__scaleTo';
var b= this.getBehavior( id );
if ( !b ) {
@@ -5947,7 +6032,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
this.addBehavior(b);
}
- b.setValues( this.scaleX, this.scaleY, scaleX, scaleY, anchorX, anchorY ).
+ b.setValues( this.scaleX, scaleX, this.scaleY, scaleY, anchorX, anchorY ).
setDelayTime( delay ? delay : 0, duration);
if ( interpolator ) {
@@ -6012,6 +6097,13 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @return {*}
*/
__scale1To : function( axis, scale, duration, delay, anchorX, anchorY, interpolator ) {
+
+ if (( axis === CAAT.Scale1Behavior.AXIS_X && scale===this.scaleX) ||
+ ( axis === CAAT.Scale1Behavior.AXIS_Y && scale===this.scaleY)) {
+
+ return;
+ }
+
var id= '__scaleXTo';
var b= this.getBehavior( id );
if ( !b ) {
@@ -6220,7 +6312,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @deprecated
*/
centerOn : function( x,y ) {
- this.setLocation( x-this.width/2, y-this.height/2 );
+ this.setPosition( x-this.width/2, y-this.height/2 );
return this;
},
/**
@@ -6231,7 +6323,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @return this
*/
centerAt : function(x,y) {
- return this.centerOn(x,y);
+ this.setPosition( x-this.width/2, y-this.height/2 );
+ return this;
},
/**
* If GL is enables, get this background image's texture page, otherwise it will fail.
@@ -6590,6 +6683,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
setSize : function( w, h ) {
this.width= w;
this.height= h;
+
this.dirty= true;
return this;
@@ -7272,13 +7366,14 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
var AABB= this.AABB;
var vv= this.viewVertices;
+ var vvv, m, x, y, w, h;
if ( this.isAA ) {
- var m= this.worldModelViewMatrix.matrix;
- var x= m[2];
- var y= m[5];
- var w= this.width;
- var h= this.height;
+ m= this.worldModelViewMatrix.matrix;
+ x= m[2];
+ y= m[5];
+ w= this.width;
+ h= this.height;
AABB.x= x;
AABB.y= y;
AABB.x1= x + w;
@@ -7287,7 +7382,6 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
AABB.height= h;
if ( CAAT.GLRENDER ) {
- var vvv;
vvv= vv[0];
vvv.x=x;
vvv.y=y;
@@ -7305,9 +7399,6 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
return this;
}
-
- var vvv;
-
vvv= vv[0];
vvv.x=0;
vvv.y=0;
@@ -7339,7 +7430,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
if ( vvv.y > ymax ) {
ymax=vvv.y;
}
- var vvv= vv[1];
+ vvv= vv[1];
if ( vvv.x < xmin ) {
xmin=vvv.x;
}
@@ -7352,7 +7443,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
if ( vvv.y > ymax ) {
ymax=vvv.y;
}
- var vvv= vv[2];
+ vvv= vv[2];
if ( vvv.x < xmin ) {
xmin=vvv.x;
}
@@ -7365,7 +7456,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
if ( vvv.y > ymax ) {
ymax=vvv.y;
}
- var vvv= vv[3];
+ vvv= vv[3];
if ( vvv.x < xmin ) {
xmin=vvv.x;
}
@@ -7490,9 +7581,9 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
},
/**
* TODO: set GLcoords for different image transformations.
+ *
* @param glCoords
* @param glCoordsIndex
- * @param z
*/
setGLCoords : function( glCoords, glCoordsIndex ) {
@@ -7511,7 +7602,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
glCoords[glCoordsIndex++]= vv[3].x;
glCoords[glCoordsIndex++]= vv[3].y;
- glCoords[glCoordsIndex++]= 0;
+ glCoords[glCoordsIndex ]= 0;
},
/**
@@ -7619,10 +7710,10 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* single size.
*
* @param buttonImage {CAAT.SpriteImage} sprite image with button's state images.
- * @param _iNormal {number} button's normal state image index
- * @param _iOver {number} button's mouse over state image index
- * @param _iPress {number} button's pressed state image index
- * @param _iDisabled {number} button's disabled state image index
+ * @param iNormal {number} button's normal state image index
+ * @param iOver {number} button's mouse over state image index
+ * @param iPress {number} button's pressed state image index
+ * @param iDisabled {number} button's disabled state image index
* @param fn {function(button{CAAT.Actor})} callback function
*/
setAsButton : function( buttonImage, iNormal, iOver, iPress, iDisabled, fn ) {
@@ -7799,14 +7890,64 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
CAAT.ActorContainer.prototype= {
- childrenList : null, // the list of children contained.
+ childrenList : null, // the list of children contained.
activeChildren : null,
pendingChildrenList : null,
-
addHint : 0,
boundingBox : null,
runion : new CAAT.Rectangle(), // Watch out. one for every container.
+ layoutManager : null, // a layout manager instance.
+ layoutInvalidated : true,
+
+ setLayout : function( layout ) {
+ this.layoutManager= layout;
+ return this;
+ },
+
+ setBounds : function( x,y,w,h ) {
+ CAAT.ActorContainer.superclass.setBounds.call( this,x,y,w,h );
+ if ( CAAT.currentDirector && !CAAT.currentDirector.inValidation ) {
+ this.invalidateLayout();
+ }
+ return this;
+ },
+
+ __validateLayout : function() {
+
+ this.__validateTree();
+ this.layoutInvalidated= false;
+ },
+
+ __validateTree : function() {
+ if ( this.layoutManager && this.layoutManager.isInvalidated() ) {
+
+ CAAT.currentDirector.inValidation= true;
+
+ this.layoutManager.doLayout( this );
+
+ for( var i=0; i<this.getNumChildren(); i+=1 ) {
+ this.getChildAt(i).__validateLayout();
+ }
+ }
+ },
+
+ invalidateLayout : function() {
+ this.layoutInvalidated= true;
+
+ if ( this.layoutManager ) {
+ this.layoutManager.invalidateLayout(this);
+
+ for( var i=0; i<this.getNumChildren(); i+=1 ) {
+ this.getChildAt(i).invalidateLayout();
+ }
+ }
+ },
+
+ getLayout : function() {
+ return this.layoutManager;
+ },
+
/**
* Draws this ActorContainer and all of its children screen bounding box.
*
@@ -7902,7 +8043,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
},
paintActorGL : function(director,time) {
- var i, c;
+ var i, l, c;
+
if (!this.visible) {
return true;
}
@@ -7913,8 +8055,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
this.frameAlpha= this.parent.frameAlpha;
}
- for( var i= 0, l= this.activeChildren.length; i<l; ++i ) {
- var c= this.activeChildren[i];
+ for( i= 0, l= this.activeChildren.length; i<l; ++i ) {
+ c= this.activeChildren[i];
c.paintActorGL(director,time);
}
@@ -7945,6 +8087,9 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
return true;
}
+ this.__validateLayout();
+ CAAT.currentDirector.inValidation= false;
+
var i,l;
/**
@@ -8007,7 +8152,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @param child a CAAT.Actor instance.
* @return this.
*/
- addChildImmediately : function(child) {
+ addChildImmediately : function(child, constraint) {
return this.addChild(child);
},
/**
@@ -8024,7 +8169,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
* @param child a CAAT.Actor object instance.
* @return this
*/
- addChild : function(child) {
+ addChild : function(child, constraint) {
if ( child.parent!=null ) {
throw('adding to a container an element with parent.');
@@ -8034,11 +8179,16 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
this.childrenList.push(child);
child.dirty= true;
- /**
- * if Conforming size, recalc new bountainer size.
- */
- if ( this.addHint===CAAT.ActorContainer.AddHint.CONFORM ) {
- this.recalcSize();
+ if ( this.layoutManager ) {
+ this.layoutManager.addChild( child, constraint );
+ this.invalidateLayout();
+ } else {
+ /**
+ * if Conforming size, recalc new bountainer size.
+ */
+ if ( this.addHint===CAAT.ActorContainer.AddHint.CONFORM ) {
+ this.recalcSize();
+ }
}
return this;
@@ -8086,8 +8236,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
if( index <= 0 ) {
child.parent= this;
child.dirty= true;
- //this.childrenList.unshift(child); // unshift unsupported on IE
this.childrenList.splice( 0, 0, child );
+ this.invalidateLayout();
return this;
} else {
if ( index>=this.childrenList.length ) {
@@ -8098,6 +8248,7 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
child.parent= this;
child.dirty= true;
this.childrenList.splice(index, 0, child);
+ this.invalidateLayout();
return this;
},
@@ -8122,11 +8273,11 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
*
* @param child a CAAT.Actor object instance.
*
- * @return an integer indicating the Actor's z-order.
+ * @return {number}
*/
findChild : function(child) {
var cl= this.childrenList;
- var i=0;
+ var i;
var len = cl.length;
for( i=0; i<len; i++ ) {
@@ -8149,6 +8300,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
return rm[0];
}
+ this.invalidateLayout();
+
return null;
},
/**
@@ -8161,7 +8314,9 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
*/
removeChild : function(child) {
var pos= this.findChild(child);
- return this.removeChildAt(pos);
+ var ret= this.removeChildAt(pos);
+
+ return ret;
},
removeFirstChild : function() {
var first= this.childrenList.shift();
@@ -8170,6 +8325,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
CAAT.currentDirector.scheduleDirtyRect( first.AABB );
}
+ this.invalidateLayout();
+
return first;
},
removeLastChild : function() {
@@ -8180,8 +8337,12 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
CAAT.currentDirector.scheduleDirtyRect( last.AABB );
}
+ this.invalidateLayout();
+
return last;
}
+
+ return null;
},
/**
* @private
@@ -8274,6 +8435,8 @@ function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter)
cl.splice( index, 0, nActor[0] );
}
+
+ this.invalidateLayout();
}
}
};
@@ -20201,4 +20364,642 @@ function makeOrtho(left, right, bottom, top, znear, zfar) {
}
};
-})();
+})();CAAT.UI= {};(function() {
+
+ CAAT.UI.Padding= function() {
+ return this;
+ };
+
+ CAAT.UI.Padding.prototype= {
+ left: 2,
+ right: 2,
+ top: 2,
+ bottom: 2
+ };
+
+ CAAT.UI.LayoutManager= function( ) {
+
+ this.newChildren= [];
+ this.padding= new CAAT.UI.Padding();
+ return this;
+ };
+
+ CAAT.UI.LayoutManager.newElementInterpolator= new CAAT.Interpolator().createElasticOutInterpolator(1.1,.7);
+ CAAT.UI.LayoutManager.moveElementInterpolator= new CAAT.Interpolator().createExponentialOutInterpolator(2);
+
+ CAAT.UI.LayoutManager.prototype= {
+
+ padding : null,
+ invalid : true,
+
+ hgap : 2,
+ vgap : 2,
+ animated : true,
+ newChildren : null,
+
+ setAnimated : function( animate ) {
+ this.animated= animate;
+ },
+
+ setHGap : function( gap ) {
+ this.hgap= gap;
+ this.invalidateLayout();
+ return this;
+ },
+
+ setVGap : function( gap ) {
+ this.vgap= gap;
+ this.invalidateLayout();
+ return this;
+ },
+
+ setAllPadding : function( s ) {
+ this.padding.left= s;
+ this.padding.right= s;
+ this.padding.top= s;
+ this.padding.bottom= s;
+ this.invalidateLayout();
+ return this;
+ },
+
+ setPadding : function( l,r, t,b ) {
+ this.padding.left= l;
+ this.padding.right= r;
+ this.padding.top= t;
+ this.padding.bottom= b;
+ this.invalidateLayout();
+ return this;
+ },
+
+ addChild : function( child, constraints ) {
+ this.newChildren.push( child );
+ },
+
+ removeChild : function( child ) {
+
+ },
+
+ doLayout : function( container ) {
+ this.newChildren= [];
+ this.invalid= false;
+ },
+
+ invalidateLayout : function( container ) {
+ this.invalid= true;
+ },
+
+ getMinimumLayoutSize : function( container ) {
+
+ },
+
+ getPreferredLayoutSize : function(container ) {
+
+ },
+
+ isValid : function() {
+ return !this.invalid;
+ },
+
+ isInvalidated : function() {
+ return this.invalid;
+ }
+ };
+}());
+
+(function() {
+
+ /**
+ *
+ * Layouts a container children in equal sized cells organized in rows by columns.
+ *
+ * @param container {CAAT.Actor}
+ * @param rows {number=} number of initial rows, defaults to 2.
+ * @param columns {number=} number of initial columns, defaults to 2.
+ * @return {*}
+ * @constructor
+ */
+ CAAT.UI.GridLayout= function( rows, columns ) {
+ CAAT.UI.GridLayout.superclass.constructor.call(this);
+ this.rows= rows;
+ this.columns= columns;
+
+ return this;
+ };
+
+ CAAT.UI.GridLayout.prototype= {
+ rows : 0,
+ columns : 2,
+
+ doLayout : function( container ) {
+
+ var nactors= container.getNumChildren();
+ if (nactors === 0) {
+ return;
+ }
+
+ var nrows = this.rows;
+ var ncols = this.columns;
+
+ if (nrows > 0) {
+ ncols = Math.floor( (nactors + nrows - 1) / nrows );
+ } else {
+ nrows = Math.floor( (nactors + ncols - 1) / ncols );
+ }
+
+ var totalGapsWidth = (ncols - 1) * this.hgap;
+ var widthWOInsets = container.width - (this.padding.left + this.padding.right);
+ var widthOnComponent = Math.floor( (widthWOInsets - totalGapsWidth) / ncols );
+ var extraWidthAvailable = Math.floor( (widthWOInsets - (widthOnComponent * ncols + totalGapsWidth)) / 2 );
+
+ var totalGapsHeight = (nrows - 1) * this.vgap;
+ var heightWOInsets = container.height - (this.padding.top + this.padding.bottom);
+ var heightOnComponent = Math.floor( (heightWOInsets - totalGapsHeight) / nrows );
+ var extraHeightAvailable = Math.floor( (heightWOInsets - (heightOnComponent * nrows + totalGapsHeight)) / 2 );
+
+ for (var c = 0, x = this.padding.left + extraWidthAvailable; c < ncols ; c++, x += widthOnComponent + this.hgap) {
+ for (var r = 0, y = this.padding.top + extraHeightAvailable; r < nrows ; r++, y += heightOnComponent + this.vgap) {
+ var i = r * ncols + c;
+ if (i < nactors) {
+ var child= container.getChildAt(i);
+ if ( !this.animated ) {
+ child.setBounds(x, y, widthOnComponent, heightOnComponent);
+ } else {
+ child.setSize(widthOnComponent, heightOnComponent);
+ if ( this.newChildren.indexOf( child ) !==-1 ) {
+ child.setPosition( x,y );
+ child.setScale(0.01,0.01);
+ child.scaleTo( 1,1, 500, 0,.5,.5, CAAT.UI.LayoutManager.newElementInterpolator );
+ } else {
+ child.moveTo( x, y, 500, 0, CAAT.UI.LayoutManager.moveElementInterpolator );
+ }
+ }
+ }
+ }
+ }
+
+ CAAT.UI.GridLayout.superclass.doLayout.call(this, container);
+ },
+
+ getMinimumLayoutSize : function( container ) {
+ var nrows = this.rows;
+ var ncols = this.columns;
+ var nchildren= container.getNumChildren();
+ var w=0, h=0, i;
+
+ if (nrows > 0) {
+ ncols = Math.ceil( (nchildren + nrows - 1) / nrows );
+ } else {
+ nrows = Math.ceil( (nchildren + ncols - 1) / ncols );
+ }
+
+ for ( i= 0; i < nchildren; i+=1 ) {
+ var actor= container.getChildAt(i);
+ var d = actor.getMinimumSize();
+ if (w < d.width) {
+ w = d.width;
+ }
+ if (h < d.height) {
+ h = d.height;
+ }
+ }
+
+ return new CAAT.Dimension(
+ this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap,
+ this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap
+ );
+ },
+
+ getPreferredLayoutSize : function( container ) {
+
+ var nrows = this.rows;
+ var ncols = this.columns;
+ var nchildren= container.getNumChildren();
+ var w=0, h=0, i;
+
+ if (nrows > 0) {
+ ncols = Math.ceil( (nchildren + nrows - 1) / nrows );
+ } else {
+ nrows = Math.ceil( (nchildren + ncols - 1) / ncols );
+ }
+
+ for ( i= 0; i < nchildren; i+=1 ) {
+ var actor= container.getChildAt(i);
+ var d = actor.getPreferredSize();
+ if (w < d.width) {
+ w = d.width;
+ }
+ if (h < d.height) {
+ h = d.height;
+ }
+ }
+
+ return new CAAT.Dimension(
+ this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap,
+ this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap
+ );
+ }
+
+ };
+
+ extend( CAAT.UI.GridLayout, CAAT.UI.LayoutManager );
+
+}());
+
+(function() {
+ CAAT.UI.BorderLayout= function() {
+ CAAT.UI.BorderLayout.superclass.constructor.call(this);
+ return this;
+ };
+
+ CAAT.UI.BorderLayout.prototype= {
+
+ left : null,
+ right : null,
+ top : null,
+ bottom : null,
+ center : null,
+
+ addChild : function( child, constraint ) {
+ CAAT.UI.BorderLayout.superclass.addChild.call( this, child, constraint );
+
+ if ( constraint === "center" ) {
+ this.center= child;
+ } else if ( constraint==="left" ) {
+ this.left= child;
+ } else if ( constraint==="right" ) {
+ this.right= child;
+ } else if ( constraint==="top" ) {
+ this.top= child;
+ } else if ( constraint==="bottom" ) {
+ this.bottom= child;
+ }
+ },
+
+ removeChild : function( child ) {
+ if ( this.center===child ) {
+ this.center=null;
+ } else if ( this.left===child ) {
+ this.left= null;
+ } else if ( this.right===child ) {
+ this.right= null;
+ } else if ( this.top===child ) {
+ this.top= null;
+ } else if ( this.bottom===child ) {
+ this.bottom= null;
+ }
+ },
+
+ __getChild : function( constraint ) {
+ if ( constraint==="center" ) {
+ return this.center;
+ } else if ( constraint==="left" ) {
+ return this.left;
+ } else if ( constraint==="right" ) {
+ return this.right;
+ } else if ( constraint==="top" ) {
+ return this.top;
+ } else if ( constraint==="bottom" ) {
+ return this.bottom;
+ }
+ },
+
+ getMinimumLayoutSize : function( container ) {
+ var c, d;
+ var dim= new CAAT.Dimension();
+
+ if ((c=this.__getChild("right")) != null) {
+ d = c.getMinimumSize();
+ dim.width += d.width + this.hgap;
+ dim.height = Math.max(d.height, dim.height);
+ }
+ if ((c=this.__getChild("left")) != null) {
+ d = c.getMinimumSize();
+ dim.width += d.width + this.hgap;