OSDN Git Service

Version 0.6.90, performance fix for HTML5Audio & rename SilverLight -> Silverlight.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 12_HBox.js
1 X.UI.Layout.Horizontal = X.UI.Layout.create( {  \r
2         name : 'HorizontalLayout',\r
3         \r
4         overrideAttrsForSelf : {\r
5                 selectable  : false,\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
10         },\r
11         \r
12         overrideAttrsForChild : {\r
13                 left   : false,\r
14                 right  : false,\r
15                 top    : true,\r
16                 bottom : true\r
17         },\r
18         \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
24                         i,\r
25             contentW, contentH, autoW, autoH, detectionPhase, gapX,             \r
26                         childW, childH, _x, _y, _h, node, minFlag;\r
27 \r
28                 data.preMesure( w, h );\r
29                 \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
38                 _x             = data.contentL;\r
39                 _y             = data.contentT;         \r
40 \r
41                 if( !detectionPhase ) ret = false;\r
42 \r
43                 if( l ){\r
44                         _h = 0;\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
49                                 if( autoH ){\r
50                                         if( node.boxHeight !== X.UI.Attr.AUTO ){\r
51                                                 h = node.boxHeight;\r
52                                         } else\r
53                                         if( node.minBoxHeight !== X.UI.Attr.AUTO ){\r
54                                                 h = node.minBoxHeight;\r
55                                                 minFlag = true;\r
56                                         } else {\r
57                                                 h = 0;\r
58                                         };\r
59                                         if( _h < h ) _h = h;                            \r
60                                 };\r
61                         };\r
62                         _x -= gapX;\r
63                 } else {\r
64                         _h = data.minContentHeight !== X.UI.Attr.AUTO ? data.minContentHeight : 0;\r
65                 };\r
66 \r
67                 if( detectionPhase ){\r
68                         if( autoW ) data.contentWidth  = _x;\r
69                         if( autoH ) data.contentHeight = _h;\r
70                         _x = data.contentL;\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
75                         };\r
76                         data.postMesure();\r
77                 };\r
78                 \r
79                 !isNeedsDetection && data.updateLayout( x + data.boxX, y + data.boxY );\r
80                 \r
81                 return !ret;\r
82         }\r
83 });\r
84 \r
85 X.UI.HBox = X.UI.Box.presets(\r
86         X.UI.Layout.Horizontal,\r
87         'HBox',\r
88         {\r
89                 gapX : '0.2em'\r
90         }\r
91 );\r