X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F20_ui%2F13_TileBox.js;h=a01198e13268702f45e60a284e63883195400fd7;hb=3d352d8bf476ab57cc333e8d02d0e6ea5efa69b7;hp=d11856534b3cdd2e225d927f37414935f82556f3;hpb=51e22031f9629d4bc32444a0228930642144ee9e;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/20_ui/13_TileBox.js b/0.6.x/js/20_ui/13_TileBox.js index d118565..a01198e 100644 --- a/0.6.x/js/20_ui/13_TileBox.js +++ b/0.6.x/js/20_ui/13_TileBox.js @@ -1,15 +1,15 @@ -X.UI.Layout.Tile = X.UI.Layout.create( { +var XUI_Layout_Tile = X[ 'UI' ][ 'Layout' ][ 'Tile' ] = XUI_createLayout( { name : 'TileLayout', 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 : [ '8em', X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH | X.UI.Attr.Type.PERCENT ], - childHeight : [ '8em', X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH | X.UI.Attr.Type.PERCENT ], - gapX : [ 0, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH ], - gapY : [ 0, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.LENGTH ], - hCenter : [ true, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.BOOLEAN ], - vCenter : [ true, X.UI.Dirty.LAYOUT, X.UI.Attr.USER.LAYOUT, X.UI.Attr.Type.BOOLEAN ] + role : [ 0, XUI_Dirty.CLEAN, XUI_Attr_USER.UINODE, XUI_Attr_Type.INIT_ONLY | XUI_Attr_Type.LIST, 'none,chrome,container' ], + childWidth : [ '8em', XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT ], + childHeight : [ '8em', XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH | XUI_Attr_Type.PERCENT ], + gapX : [ 0, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH ], + gapY : [ 0, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.LENGTH ], + hCenter : [ true, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.BOOLEAN ], + vCenter : [ true, XUI_Dirty.LAYOUT, XUI_Attr_USER.LAYOUT, XUI_Attr_Type.BOOLEAN ] }, overrideAttrsForChild : { @@ -29,24 +29,24 @@ X.UI.Layout.Tile = X.UI.Layout.create( { data.preMesure( w, h ); - if( isNeedsDetection && ( data.boxWidth === X.UI.Attr.AUTO || data.boxHeight === X.UI.Attr.AUTO ) ) return; + if( isNeedsDetection && ( data.boxWidth === XUI_Attr_AUTO || data.boxHeight === XUI_Attr_AUTO ) ) return; if( ( uinodes = data.uinodes ) && ( l = uinodes.length ) ){ _x = data.contentL; _y = data.contentT; _w = data.contentWidth; - gapX = X.UI._AbstractUINode.calcValue( attrs[ data.supportAttrs.gapX.No ], contentW ); - 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 ); - numH = X.UI.Attr.FLOOR( ( _w + gapX ) / ( childW + gapX ) ); - numV = l % numH ? X.UI.Attr.FLOOR( l / numH ) + 1 : l / numH; + gapX = XUI_AbstractUINode_calcValue( attrs[ data.usableAttrs.gapX.No ], contentW ); + 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 ); + numH = XUI_Attr_FLOOR( ( _w + gapX ) / ( childW + gapX ) ); + numV = l % numH ? XUI_Attr_FLOOR( l / numH ) + 1 : l / numH; _h = _y + data.contentB + ( childH + gapY ) * numH - gapY; - startX = attrs[ data.supportAttrs.hCenter.No ] ? + startX = attrs[ data.usableAttrs.hCenter.No ] ? ( _w - ( childW + gapX ) * numH - gapX ) / 2 : _x; __x = startX; - __y = attrs[ data.supportAttrs.vCenter.No ] && _h <= h ? + __y = attrs[ data.usableAttrs.vCenter.No ] && _h <= h ? ( h - _h ) / 2 + _y : _y; for( i = 0; i < l; ++i ){ @@ -64,22 +64,55 @@ X.UI.Layout.Tile = X.UI.Layout.create( { data.contentHeight = _h; } else - if( data.contentHeight === X.UI.Attr.AUTO ){ - data.contentHeight = data.minContentHeight !== X.UI.Attr.AUTO ? data.minContentHeight : 0; + if( data.contentHeight === XUI_Attr_AUTO ){ + data.contentHeight = data.contentHeightMin !== XUI_Attr_AUTO ? data.contentHeightMin : 0; }; data.postMesure(); - data.updateLayout( x + data.boxX, y + data.boxY ); + + if( !isNeedsDetection ){ + data.boxX += x; + data.boxY += y; + }; + return true; } }); +/* X.UI.TileBox = X.UI.Box.presets( 'TileBox', - X.UI.Layout.Tile, + XUI_Layout_Tile, { gapX : '0.2em', gapY : '0.2em', hCenter : true, vCenter : true } -); +);*/ + +X.UI.TileBox = X.UI.Box.inherits( + 'TileBox', + X_Class.NONE, + { + Constructor : function(){ + var supports; + + if( !XUI_TileBox ){ + supports = XUI_Attr_createAttrDef( XUI_Box.prototype.usableAttrs, XUI_Layout_Tile.overrideAttrsForSelf ); + + XUI_TileBox = XUI_Box.inherits( + { + layout : XUI_Layout_Tile, + usableAttrs : supports, + attrClass : XUI_Attr_preset( XUI_Box.prototype.attrClass, supports, { + gapX : '0.2em', + gapY : '0.2em', + hCenter : true, + vCenter : true + }) + } + ); + }; + X_Pair_create( this, XUI_TileBox( this, XUI_Layout_Tile, arguments ) ); + } + }); \ No newline at end of file