OSDN Git Service

Version 0.6.138, working X.UI.ScrollBox!, fix Node.prev & Node.next.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 11_VBox.js
1 X.UI.Layout.Vertical = X.UI.Layout.create( {\r
2         \r
3         name : 'VerticalLayout',\r
4         \r
5         overrideAttrsForSelf : {\r
6                 selectable  : false,\r
7                 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
8                 width       : [ '100%',         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                 height      : [ 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
10                 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
11                 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
12                 gapY        : [ 0,              X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH ]\r
13         },\r
14         \r
15         overrideAttrsForChild : {\r
16                 left   : true,\r
17                 right  : true,\r
18                 top    : false,\r
19                 bottom : false\r
20         },\r
21         \r
22         calculate : function( data, isNeedsDetection, x, y, w, h ){\r
23                 var ret     = isNeedsDetection,\r
24                         attrs   = data.attrObject || data.attrClass.prototype,\r
25                         uinodes = data.uinodes,\r
26                         l       = uinodes && uinodes.length,\r
27                         minFlag = false,\r
28                         childW, childH, gapY,\r
29                         i, _x, _y, _w, node,\r
30             contentW, contentH, autoW, autoH, detectionPhase;\r
31 \r
32                 data.preMesure( w, h );\r
33                 \r
34                 contentW       = data.contentWidth;\r
35                 contentH       = data.contentHeight;\r
36                 autoW          = contentW === X.UI.Attr.AUTO;\r
37                 autoH          = contentH === X.UI.Attr.AUTO;\r
38                 detectionPhase = autoW || autoH;\r
39                 gapY           = XUI_AbstractUINode_calcValue( attrs[ data.supportAttrs.gapY.No ], contentH );\r
40                 childW         = XUI_AbstractUINode_calcValue( attrs[ data.supportAttrs.childWidth.No ], contentW );\r
41                 childH         = XUI_AbstractUINode_calcValue( attrs[ data.supportAttrs.childHeight.No ], contentH );\r
42                 _x             = data.contentL;\r
43                 _y             = data.contentT;\r
44 \r
45                 if( !detectionPhase ) ret = false;\r
46 \r
47                 if( l ){\r
48                         _w = 0;\r
49                         for( i = 0; i < l; ++i ){\r
50                                 node = uinodes[ i ];\r
51                                 node.calculate( detectionPhase, _x, _y, contentW, childH );\r
52                                 _y += node.boxHeight + gapY;\r
53                                 // 概算のみ\r
54                                 if( autoW ){\r
55                                         if( node.boxWidth !== X.UI.Attr.AUTO ){\r
56                                                 w = node.boxWidth;\r
57                                         } else\r
58                                         if( node.minBoxWidth !== X.UI.Attr.AUTO ){\r
59                                                 w = node.minBoxWidth;\r
60                                                 minFlag = true;\r
61                                         } else {\r
62                                                 w = 0;\r
63                                         };\r
64                                         if( _w < w ) _w = w;                            \r
65                                 };      \r
66                         };\r
67                         _y -= gapY;\r
68                 } else {\r
69                         _y = data.minContentHeight !== X.UI.Attr.AUTO ? data.minContentHeight : 0;\r
70                 };\r
71 \r
72                 if( detectionPhase ){\r
73                         if( autoW ) data.contentWidth  = _w;\r
74                         if( autoH ) data.contentHeight = _y;\r
75                         _y = data.contentT;\r
76                         for( i = 0; i < l; ++i ){\r
77                                 node = uinodes[ i ];\r
78                                 node.calculate( false, _x, _y, data.contentWidth, data.contentHeight );\r
79                                 _y += node.boxHeight + gapY;\r
80                         };\r
81                         data.postMesure();\r
82                 };\r
83                 \r
84                 !isNeedsDetection && data.updateLayout( x + data.boxX, y + data.boxY );\r
85                 \r
86                 return !ret;\r
87         }\r
88 });\r
89 \r
90 X.UI.VBox = X.UI.Box.presets(\r
91         X.UI.Layout.Vertical,\r
92         'VBox',\r
93         {\r
94                 gapY       : '0.2em',\r
95                 childWidth : '100%'\r
96         }\r
97 );\r