// draw
},
- reflow : function( nodeData ){
- var parent = nodeData.__parent,
- allowW = parent.contentWidth,
- allowH = parent.contentHeight,
- autoW = parent.autoWidth,
- autoH = parent.autoHeight,
- offsetX = parent.offsetX,
- offsetY = parent.offsetY,
- children = nodeData.children,
- style = nodeData.__style,
- x, y, w, minW, maxW, h, minH, maxH,
- contentW, contentH, boxW, boxH,
- autoSize, sizing, page,
- paddingT, paddingR, paddingB, paddingL,
- borderT, borderR, borderB, borderL,
- marginT, marginR, marginB, marginL,
- childW = 0,
- childH = 0,
- styles, child, calc, i;
+ reflow : function( nodeData, allowW, allowH ){
+ var children = nodeData.children,
+ contentW, contentH, autoW, autoH, auto, calc,
+ childW, childH, child, i, style, data,
+ t, r, b, l;
- nodeData.preSizing( allowW, allowH );
-
- if( nodeData.contentWidth !== contentW || nodeData.contentHeight === contentH ){
- if( autoSize === false ){
- nodeData.updateLayout();
- nodeData.contentWidth = contentW;
- nodeData.contentHeight = contentH;
- nodeData.boxWidth = boxW;
- nodeData.boxHeight = boxH;
- };
- if( node instanceof LayoutBoxPrivate ){
- nodeData.Super.reflow.call( nodeData );
- } else {
- node.reflow();
- };
- };
-
+ nodeData.preMesure( allowW, allowH );
if( children ){
+ contentW = nodeData.contentWidth;
+ contentH = nodeData.contentHeight;
+ childW = 0;
+ childH = 0;
+ autoW = contentW === AUTO;
+ autoH = contentH === AUTO;
+ auto = autoW && autoH;
+ calc = BasicLayoutManager.calcValue;
for( i = children.length; i; ){
child = children[ --i ];
+ style = child.__syule;
+ if( style ){
+ data = style.data;
+ t = calc( data[ ATTRS.top ], contentH );
+ r = calc( data[ ATTRS.right ], contentW );
+ b = calc( data[ ATTRS.bottom ], contentH );
+ l = calc( data[ ATTRS.left ], contentW );
+ } else {
+ t = r = b = l = 0;
+ };
if( child instanceof LayoutBoxPrivate ){
- child.layoutManager.reflow( child );
+ child.layoutManager.reflow( child, contentW - r - l, contentH - t - b );
} else {
- child.reflow();
+ child.preMesure( contentW - r - l, contentH - t - b );
+ child.mesure();
+ child.postMesure();
};
- if( autoSize === false ) continue;
- if( childW < child.rectRight ) childW = child.rectRight;
- if( childH < child.rectBottom ) childH = child.rectBottom;
+ if( !auto ) continue;
+ if( autoW && childW < child.contentWidth + r + l ) childW = child.contentWidth + r + l;
+ if( autoH && childH < child.contentHeight + t + b ) childH = child.contentHeight + t + b;
};
- if( autoSize === true ){
- if( w === AUTO && childW < contentW ) contentW = childW;
- if( h === AUTO && childH < contentH ) contentH = childH;
- if( contentW < minW ) contentW = minW;
- if( maxW < contentW ){
- nodeData.scrollWidth = contentW;
- contentW = maxW;
- };
- if( contentH < minH ) contentH = minH;
- if( maxH < contentH ){
- nodeData.scrollHeight = contentH;
- contentH = maxH;
- };
- nodeData.contentWidth = boxW = contentW;
- nodeData.contentHeight = boxH = contentH;
- switch( sizing ){
- case 3 : // margin-box
- boxW += ( marginR + marginL );
- boxH += ( marginT + marginR );
- case 2 : // border-box
- boxW += ( borderR + borderL );
- boxH += ( borderT + borderR );
- case 1 : // padding-box
- boxW += ( paddingR + paddingL );
- boxH += ( paddingT + paddingR );
- // case 0 : // content-box
- };
- nodeData.boxWidth = boxW;
- nodeData.boxHeight = boxH;
- };
+ if( autoW ) nodeData.contentWidth = childW;
+ if( autoH ) nodeData.contentHeight = childH;
};
+ auto && nodeData.postMesure();
+
delete nodeData.dirty;
}
}
roots = this.rootList;
if( roots ){
for( i = 0, l = roots.length; i < l; ++i ){
- roots[ i ].reflow();
+ roots[ i ].layoutManager.reflow();
};
};
};
Constructor : function( layoutManager, root, parent ){
this.layoutManager = layoutManager;
this._root = _root;
+ this.paintList = [];
if( _parent ) this._parent = _parent;
},
- reflow : function(){
+ mesure : function(){
this.layoutManager.reflow( this );
+ },
+ paintReserve : function( nodeData ){
+ var list = this.paintList;
+ if( Util.getIndex( list, nodeData ) === -1 ) list[ list.length - 1 ] = nodeData;
+ },
+ paintRelease : function( nodeData ){
+ var list = this.paintList,
+ i = Util.getIndex( list, nodeData );
+ i === -1 && list.splice( i, 1 );
+ },
+ paint : function(){
+ var list = this.paintList, i = list.length;
+ for( ; i; ){
+ list[ --i ].paint();
+ };
}
}
);
}
);
+ var RootNode = Node.inherits(
+ 'RootNode',
+ Class.POOL_OBJECT,
+ LayoutBoxPrivate,
+ {
+ Constructor : function(){
+ RootNode.newPrivateData( this, BasicLayoutManager );
+ }
+ }
+ );
+
})( window, document );
})( window, document );