1 X.UI.Layout.Horizontal = X.UI.Layout.create( {
\r
2 name : 'HorizontalLayout',
\r
4 overrideAttrsForSelf : {
\r
6 role : [ 0, X.UI.Dirty.CLEAN, X.UI.Attr.USER.UINODE, X.UI.Attr.Type.INIT_ONLY | X.UI.Attr.Type.LIST, 'none,chrome,container' ],
\r
7 childWidth : [ X.UI.Attr.AUTO, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH | X.UI.Attr.Type.PERCENT | X.UI.Attr.Type.AUTO ],
\r
8 childHeight : [ X.UI.Attr.AUTO, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH | X.UI.Attr.Type.PERCENT | X.UI.Attr.Type.AUTO ],
\r
9 gapX : [ 0, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH ]
\r
12 overrideAttrsForChild : {
\r
19 calculate : function( data, isNeedsDetection, x, y, w, h ){
\r
20 var ret = isNeedsDetection,
\r
21 attrs = data.attrObject || data.attrClass.prototype,
\r
22 uinodes = data.uinodes,
\r
23 l = uinodes && uinodes.length,
\r
25 contentW, contentH, autoW, autoH, detectionPhase, gapX,
\r
26 childW, childH, _x, _y, _h, node, minFlag;
\r
28 data.preMesure( w, h );
\r
30 contentW = data.contentWidth;
\r
31 contentH = data.contentHeight;
\r
32 autoW = contentW === X.UI.Attr.AUTO;
\r
33 autoH = contentH === X.UI.Attr.AUTO;
\r
34 detectionPhase = autoW || autoH;
\r
35 gapX = X.UI._AbstractUINode.calcValue( attrs[ data.supportAttrs.gapX.No ], contentW );
\r
36 childW = X.UI._AbstractUINode.calcValue( attrs[ data.supportAttrs.childWidth.No ], contentW );
\r
37 childH = X.UI._AbstractUINode.calcValue( attrs[ data.supportAttrs.childHeight.No ], contentH );
\r
39 _y = data.contentT;
\r
41 if( !detectionPhase ) ret = false;
\r
45 for( i = 0; i < l; ++i ){
\r
46 node = uinodes[ i ];
\r
47 node.calculate( detectionPhase, _x, _y, childW, childH );
\r
48 _x += node.boxWidth + gapX;
\r
50 if( node.boxHeight !== X.UI.Attr.AUTO ){
\r
53 if( node.minBoxHeight !== X.UI.Attr.AUTO ){
\r
54 h = node.minBoxHeight;
\r
59 if( _h < h ) _h = h;
\r
64 _h = data.minContentHeight !== X.UI.Attr.AUTO ? data.minContentHeight : 0;
\r
67 if( detectionPhase ){
\r
68 if( autoW ) data.contentWidth = _x;
\r
69 if( autoH ) data.contentHeight = _h;
\r
71 for( i = 0; i < l; ++i ){
\r
72 node = uinodes[ i ];
\r
73 node.calculate( false, _x, _y, data.contentWidth, data.contentHeight );
\r
74 _x += node.boxWidth + gapX;
\r
79 !isNeedsDetection && data.updateLayout( x + data.boxX, y + data.boxY );
\r
85 X.UI.HBox = X.UI.Box.presets(
\r
86 X.UI.Layout.Horizontal,
\r