1 goog.provide('lime.ui.Container');
  2 
  3 goog.require('lime.Layer');
  4 
  5 /**
  6  * @constructor
  7  */
  8 lime.ui.Container = function(){
  9    goog.base(this);
 10 
 11    this.GAP = 10;
 12 
 13    this.toAdd_ = [];
 14    this.toRemove_ = [];
 15    
 16    this.setDirection(lime.ui.Container.Direction.HORIZONTAL);
 17 
 18 };
 19 goog.inherits(lime.ui.Container, lime.Layer);
 20 /*
 21 lime.ui.Container.prototype.appendChild = function(child,opt_pos,opt_animate){
 22     lime.Node.prototype.appendChild.apply(this, arguments);
 23     
 24    /* child.domElement.style['display'] = 'none';
 25     goog.array.insert(this.toAdd_,child);*/
 26 /*};
 27 
 28 
 29 lime.ui.Container.prototype.removeChild = function(child,opt_animate){
 30     lime.Node.prototype.appendChild.apply(this, arguments);
 31     
 32    /* child.domElement.style['display'] = 'none';
 33     goog.array.insert(this.toAdd_,child);*/
 34     
 35 //}
 36 
 37 /**
 38  * Directions of the scroller.
 39  * @enum number
 40  */
 41 lime.ui.Container.Direction = {
 42   HORIZONTAL: 0,
 43   VERTICAL: 1
 44 };
 45 
 46 /**
 47  * Returns the direction of the scroller (horizontal/vertical)
 48  * @return {lime.ui.Scroller.Direction} Scroll direction.
 49  */
 50 lime.ui.Container.prototype.getDirection = function() {
 51     return this.direction_;
 52 };
 53 
 54 /**
 55  * Set the direction of the scroller (horizontal/vertical)
 56  * @param {lime.ui.Scroller.Direction} direction Direction.
 57  * @return {lime.ui.Scroller} object itself.
 58  */
 59 lime.ui.Container.prototype.setDirection = function(direction) {
 60     this.direction_ = direction;
 61     return this;
 62 };
 63 
 64 lime.ui.Container.prototype.updateChildrenPositions = function(){
 65     var l = this.children_.length;
 66     var pos = new goog.math.Coordinate(0,0);
 67     for(var i=0;i<l;i++){
 68         var child = this.children_[i];
 69         var p2 = child.getPosition();;
 70         if(!goog.math.Coordinate.equals(pos,p2)){
 71             child.setPosition(pos.clone());
 72         }
 73         if(this.getDirection()==lime.ui.Container.Direction.HORIZONTAL)
 74         pos.x+=child.getSize().width+this.GAP;
 75         else pos.y+=child.getSize().height+this.GAP;
 76     }
 77     return this;
 78 }
 79 
 80 lime.ui.Container.prototype.update = function(opt_pass){
 81     if(!opt_pass){
 82         this.updateChildrenPositions();
 83     }
 84     
 85     lime.Node.prototype.update.apply(this, arguments);
 86 }
 87