X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F20_ui%2F11_VBox.js;h=f11c592681a4b0f3e07dbeba09346e16c8e5fb63;hb=3d352d8bf476ab57cc333e8d02d0e6ea5efa69b7;hp=14febc5b92d83e764138cc3cff07d362fae5597c;hpb=51e22031f9629d4bc32444a0228930642144ee9e;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/20_ui/11_VBox.js b/0.6.x/js/20_ui/11_VBox.js index 14febc5..f11c592 100644 --- a/0.6.x/js/20_ui/11_VBox.js +++ b/0.6.x/js/20_ui/11_VBox.js @@ -1,13 +1,18 @@ -X.UI.Layout.Vertical = X.UI.Layout.create( { +var XUI_Layout_Vertical = X[ 'UI' ][ 'Layout' ][ 'Vertical' ] = XUI_createLayout( { name : 'VerticalLayout', + /* + * + */ overrideAttrsForSelf : { selectable : false, - 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' ], - 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 ], - 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 ], - gapY : [ 0, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH ] + role : [ 0, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.INIT_ONLY | XUI_Attr_Type.LIST, 'none,chrome,container' ], + width : [ '100%', XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT | XUI_Attr_Type.AUTO ], + height : [ XUI_Attr_AUTO, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT | XUI_Attr_Type.AUTO ], + childWidth : [ XUI_Attr_AUTO, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT | XUI_Attr_Type.AUTO ], + childHeight : [ XUI_Attr_AUTO, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT | XUI_Attr_Type.AUTO ], + gapY : [ 0, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH ] }, overrideAttrsForChild : { @@ -31,14 +36,14 @@ X.UI.Layout.Vertical = X.UI.Layout.create( { contentW = data.contentWidth; contentH = data.contentHeight; - autoW = contentW === X.UI.Attr.AUTO; - autoH = contentH === X.UI.Attr.AUTO; + autoW = contentW === XUI_Attr_AUTO; + autoH = contentH === XUI_Attr_AUTO; detectionPhase = autoW || autoH; - gapY = X.UI._AbstractUINode.calcValue( attrs[ data.supportAttrs.gapY.No ], contentH ); - childW = X.UI._AbstractUINode.calcValue( attrs[ data.supportAttrs.childWidth.No ], contentW ); - childH = X.UI._AbstractUINode.calcValue( attrs[ data.supportAttrs.childHeight.No ], contentH ); + gapY = XUI_AbstractUINode_calcValue( attrs[ data.usableAttrs.gapY.No ], contentH ); + childW = XUI_AbstractUINode_calcValue( attrs[ data.usableAttrs.childWidth.No ], contentW ); + childH = XUI_AbstractUINode_calcValue( attrs[ data.usableAttrs.childHeight.No ], contentH ); _x = data.contentL; - _y = data.contentT; + _y = 0; //data.contentT; if( !detectionPhase ) ret = false; @@ -46,50 +51,72 @@ X.UI.Layout.Vertical = X.UI.Layout.create( { _w = 0; for( i = 0; i < l; ++i ){ node = uinodes[ i ]; - node.calculate( detectionPhase, _x, _y, contentW, childH ); + node.calculate( detectionPhase, 0, _y, contentW, childH ); _y += node.boxHeight + gapY; - // 概算のみ + //console.dir( node ); + // 概算のみ, 子要素の最大幅を調べる _w if( autoW ){ - if( node.boxWidth !== X.UI.Attr.AUTO ){ + if( node.boxWidth !== XUI_Attr_AUTO ){ w = node.boxWidth; } else - if( node.minBoxWidth !== X.UI.Attr.AUTO ){ - w = node.minBoxWidth; + if( node.boxWidthMin !== XUI_Attr_AUTO ){ + w = node.boxWidthMin; minFlag = true; } else { w = 0; }; - if( _w < w ) _w = w; - }; + if( _w < w ) _w = w; + }; }; _y -= gapY; } else { - _y = data.minContentHeight !== X.UI.Attr.AUTO ? data.minContentHeight : 0; + _y = data.contentHeightMin !== XUI_Attr_AUTO ? data.contentHeightMin : 0; }; if( detectionPhase ){ if( autoW ) data.contentWidth = _w; - if( autoH ) data.contentHeight = _y; - _y = data.contentT; + if( autoH ) data.contentHeight = _y;// - data.contentT; + _y = 0;//data.contentT; for( i = 0; i < l; ++i ){ node = uinodes[ i ]; - node.calculate( false, _x, _y, data.contentWidth, data.contentHeight ); + node.calculate( false, 0, _y, data.contentWidth, data.contentHeight ); _y += node.boxHeight + gapY; }; data.postMesure(); }; - !isNeedsDetection && data.updateLayout( x + data.boxX, y + data.boxY ); - + if( !isNeedsDetection ){ + data.boxX += x; + data.boxY += y; + }; return !ret; } }); -X.UI.VBox = X.UI.Box.presets( - X.UI.Layout.Vertical, +var XUI_VBox; + +X.UI.VBox = X.UI.Box.inherits( 'VBox', + X_Class.NONE, { - gapY : '0.2em', - childWidth : '100%' - } -); + Constructor : function(){ + var supports; + + if( !XUI_VBox ){ + supports = XUI_Attr_createAttrDef( XUI_Box.prototype.usableAttrs, XUI_Layout_Vertical.overrideAttrsForSelf ); + + XUI_VBox = XUI_Box.inherits( + { + layout : XUI_Layout_Vertical, + usableAttrs : supports, + attrClass : XUI_Attr_preset( XUI_Box.prototype.attrClass, supports, { + gapY : '0.2em', + childWidth : '100%' + } ) + } + ); + }; + X_Pair_create( this, XUI_VBox( this, XUI_Layout_Vertical, arguments ) ); + } + }); +