-var VerticalLayoutManager = ( new LayoutManagerBase() ).define( {\r
+X.UI.Layout.Vertical = X.UI.Layout.create( {\r
+ \r
name : 'VerticalLayout',\r
- allowForSelf : {\r
- childX : false,\r
- childY : false,\r
- childW : false,\r
- childH : true,\r
- gapX : false,\r
- gapY : true,\r
- padding : true\r
+ \r
+ overrideAttrsForSelf : {\r
+ selectable : false,\r
+ 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
+ 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
+ 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
+ gapY : [ 0, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH ]\r
},\r
- allowForChild : {\r
- x : false,\r
- y : false,\r
- w : true,\r
- h : true\r
+ \r
+ overrideAttrsForChild : {\r
+ left : true,\r
+ right : true,\r
+ top : false,\r
+ bottom : false\r
},\r
- calculate : function( data, x, y, w, h ){\r
- var nodes = data.nodes,\r
- styleData = data.styleData,\r
- cssObj = styleData._cssObj,\r
- //childW = cssObj.childW,\r
- childH = cssObj.childH,\r
- gapX = cssObj.gapX || 0,\r
- gapY = cssObj.gapY || 0,\r
- padding = cssObj.padding || 0,\r
- _x = padding,\r
- _y = padding,\r
- i = 0, l = nodes.length, node;\r
+ \r
+ calculate : function( data, isNeedsDetection, x, y, w, h ){\r
+ var attrs = data.attrObject || data.attrClass.prototype,\r
+ uinodes = data.uinodes,\r
+ l = uinodes && uinodes.length, \r
+ childW, childH, gapY,\r
+ i, _x, _y, _w, node;\r
\r
- if( childH || childH === 0 ){\r
- for( ; i < l; ++i ){\r
- node = nodes[ i ];\r
- if( node.instanceOf( _Box ) ){\r
- node.calculate( 0, _y, w - x, childH );\r
- } else {\r
- node.styleData.layout( 0, _y, w - x, childH );\r
- };\r
- _y += childH + gapY;\r
+ data.preMesure( w, h );\r
+ \r
+ contentW = data.contentWidth;\r
+ contentH = data.contentHeight;\r
+ autoW = contentW === X.UI.Attr.AUTO;\r
+ autoH = contentH === X.UI.Attr.AUTO;\r
+ detectionPhase = autoW || autoH;\r
+ gapY = _AbstractUINode.calcValue( attrs[ data.supportAttrs.gapY.No ], contentH );\r
+ childW = _AbstractUINode.calcValue( attrs[ data.supportAttrs.childWidth.No ], contentW );\r
+ childH = _AbstractUINode.calcValue( attrs[ data.supportAttrs.childHeight.No ], contentH );\r
+ _x = data.contentL;\r
+ _y = data.contentT;\r
+\r
+ if( l ){\r
+ _w = 0;\r
+ for( i = 0; i < l; ++i ){\r
+ node = uinodes[ i ];\r
+ node.calculate( detectionPhase, _x, _y, contentW, childH );\r
+ _y += node.boxHeight + gapY;\r
+ // 概算のみ\r
+ if( autoW ){\r
+ w = node.boxWidth !== X.UI.Attr.AUTO ?\r
+ node.boxWidth :\r
+ node.minBoxWidth !== X.UI.Attr.AUTO ?\r
+ node.minBoxWidth : 0;\r
+ if( _w < w ) _w = w; \r
+ }; \r
};\r
+ _y -= gapY;\r
} else {\r
- for( ; i < l; ++i ){\r
- node = nodes[ i ];\r
- if( node.instanceOf( _Box ) ){\r
- node.calculate( 0, _y, w - x );\r
- } else {\r
- node.styleData.layout( 0, _y, w - x );\r
- };\r
- //_y += node.rawElement.offsetHeight + gapY;\r
- _y += node.rawElement.height() + gapY;\r
- };\r
+ _y = data.minContentHeight !== X.UI.Attr.AUTO ? data.minContentHeight : 0;\r
};\r
- data.styleData.layout( x, y, w, _y + gapY + padding );\r
+\r
+ if( detectionPhase ){\r
+ if( autoW ) data.contentWidth = _w;\r
+ if( autoH ) data.contentHeight = _y;\r
+ data.postMesure();\r
+ } else {\r
+ //data.postMesure();\r
+ };\r
+ \r
+ !isNeedsDetection && data.updateLayout( x, y );\r
}\r
});\r
\r
-/*\r
-var VBox = function(){\r
- var arg = arguments;\r
- arg[ arg.length ] = VerticalLayoutManager;\r
- ++arg.length;\r
- return Box.apply( null, arg );\r
-}; */\r
-\r
-\r
-var VBox = Box.inherits(\r
+var VBox = Box.presets(\r
+ X.UI.Layout.Vertical,\r
'VBox',\r
- X.Class.SUPER_ACCESS,\r
{\r
- Constructor : function(){\r
- this.style = DisplayNodeStyle( this, X.Class._newPrivate( this, VerticalLayoutManager, arguments ) );\r
- this.style.addName( 'VBox' );\r
- }\r
+ gapY : '0.2em',\r
+ childWidth : '100%'\r
}\r
-);
\ No newline at end of file
+);\r