OSDN Git Service

Version 0.6.169, add doc comment.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 12_HBox.js
index 52b9bdf..6639a7c 100644 (file)
@@ -1,14 +1,14 @@
-X.UI.Layout.Horizontal = X.UI.Layout.create( { \r
+var XUI_Layout_Horizontal = X[ 'UI' ][ 'Layout' ][ 'Horizontal' ] = XUI_createLayout( {        \r
        name : 'HorizontalLayout',\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
-               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
-               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
-               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
-               gapX        : [ 0,              X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH ]\r
+               role        : [ 0,              XUI_Dirty.CLEAN,  XUI_Attr_USER.UINODE, XUI_Attr_Type.INIT_ONLY | XUI_Attr_Type.LIST, 'none,chrome,container' ],\r
+               width       : [ '100%',         XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT | XUI_Attr_Type.AUTO ],\r
+               height      : [ XUI_Attr_AUTO, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT | XUI_Attr_Type.AUTO ],\r
+               childWidth  : [ XUI_Attr_AUTO, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT | XUI_Attr_Type.AUTO ],\r
+               childHeight : [ XUI_Attr_AUTO, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT | XUI_Attr_Type.AUTO ],\r
+               gapX        : [ 0,              XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH ]\r
        },\r
        \r
        overrideAttrsForChild : {\r
@@ -31,14 +31,14 @@ X.UI.Layout.Horizontal = X.UI.Layout.create( {
                \r
                contentW       = data.contentWidth;\r
                contentH       = data.contentHeight;\r
-               autoW          = contentW === X.UI.Attr.AUTO;\r
-               autoH          = contentH === X.UI.Attr.AUTO;\r
+               autoW          = contentW === XUI_Attr_AUTO;\r
+               autoH          = contentH === XUI_Attr_AUTO;\r
                detectionPhase = autoW || autoH;\r
-               gapX           = XUI_AbstractUINode_calcValue( attrs[ data.supportAttrs.gapX.No ], contentW );\r
-               childW         = XUI_AbstractUINode_calcValue( attrs[ data.supportAttrs.childWidth.No ], contentW );\r
-               childH         = XUI_AbstractUINode_calcValue( attrs[ data.supportAttrs.childHeight.No ], contentH );\r
-               _x             = data.contentL;\r
-               _y             = data.contentT;         \r
+               gapX           = XUI_AbstractUINode_calcValue( attrs[ data.usableAttrs.gapX.No ], contentW );\r
+               childW         = XUI_AbstractUINode_calcValue( attrs[ data.usableAttrs.childWidth.No ], contentW );\r
+               childH         = XUI_AbstractUINode_calcValue( attrs[ data.usableAttrs.childHeight.No ], contentH );\r
+               _x             = 0; //data.contentL;\r
+               _y             = 0; //data.contentT;            \r
 \r
                if( !detectionPhase ) ret = false;\r
 \r
@@ -46,14 +46,14 @@ X.UI.Layout.Horizontal = X.UI.Layout.create( {
                        _h = 0;\r
                        for( i = 0; i < l; ++i ){\r
                                node = uinodes[ i ];\r
-                               node.calculate( detectionPhase, _x, _y, childW, childH );\r
+                               node.calculate( detectionPhase, _x, 0, childW, childH );\r
                                _x += node.boxWidth + gapX;\r
                                if( autoH ){\r
-                                       if( node.boxHeight !== X.UI.Attr.AUTO ){\r
+                                       if( node.boxHeight !== XUI_Attr_AUTO ){\r
                                                h = node.boxHeight;\r
                                        } else\r
-                                       if( node.minBoxHeight !== X.UI.Attr.AUTO ){\r
-                                               h = node.minBoxHeight;\r
+                                       if( node.boxHeightMin !== XUI_Attr_AUTO ){\r
+                                               h = node.boxHeightMin;\r
                                                minFlag = true;\r
                                        } else {\r
                                                h = 0;\r
@@ -63,31 +63,60 @@ X.UI.Layout.Horizontal = X.UI.Layout.create( {
                        };\r
                        _x -= gapX;\r
                } else {\r
-                       _h = data.minContentHeight !== X.UI.Attr.AUTO ? data.minContentHeight : 0;\r
+                       _h = data.contentHeightMin !== XUI_Attr_AUTO ? data.contentHeightMin : 0;\r
                };\r
 \r
                if( detectionPhase ){\r
                        if( autoW ) data.contentWidth  = _x;\r
                        if( autoH ) data.contentHeight = _h;\r
-                       _x = data.contentL;\r
+                       _x = 0; //data.contentL;\r
                        for( i = 0; i < l; ++i ){\r
                                node = uinodes[ i ];\r
-                               node.calculate( false, _x, _y, data.contentWidth, data.contentHeight );\r
+                               node.calculate( false, _x, 0, data.contentWidth, data.contentHeight );\r
                                _x += node.boxWidth + gapX;\r
                        };\r
                        data.postMesure();\r
                };\r
                \r
-               !isNeedsDetection && data.updateLayout( x + data.boxX, y + data.boxY );\r
-               \r
+               if( !isNeedsDetection ){\r
+                       data.boxX += x;\r
+                       data.boxY += y;                 \r
+               };\r
                return !ret;\r
        }\r
 });\r
 \r
+/*\r
 X.UI.HBox = X.UI.Box.presets(\r
-       X.UI.Layout.Horizontal,\r
+       XUI_Layout_Horizontal,\r
        'HBox',\r
        {\r
                gapX : '0.2em'\r
        }\r
-);\r
+);*/\r
+\r
+var XUI_HBox;\r
+\r
+X.UI.HBox = X.UI.Box.inherits(\r
+       'HBox',\r
+       X_Class.NONE,\r
+       {\r
+               Constructor : function(){\r
+                       var supports;\r
+                       \r
+                       if( !XUI_HBox ){\r
+                               supports = XUI_Attr_createAttrDef( XUI_Box.prototype.usableAttrs, XUI_Layout_Horizontal.overrideAttrsForSelf );\r
+                               \r
+                               XUI_HBox = XUI_Box.inherits(\r
+                                                       {\r
+                                                               layout      : XUI_Layout_Horizontal,\r
+                                                               usableAttrs : supports,\r
+                                                               attrClass   : XUI_Attr_preset( XUI_Box.prototype.attrClass, supports, {\r
+                                                                               gapX       : '0.2em'\r
+                                                                       } )\r
+                                                       }\r
+                                               );      \r
+                       };\r
+                       X_Pair_create( this, XUI_HBox( this, XUI_Layout_Horizontal, arguments ) );\r
+               }\r
+       });
\ No newline at end of file