OSDN Git Service

Version 0.6.153, fix layout @X.UI.
[pettanr/clientJs.git] / 0.6.x / js / 20_ui / 06_AbstractUINode.js
index 5bfc6c9..b2dfe24 100644 (file)
@@ -42,6 +42,10 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                contentT          : 0,\r
                contentR          : 0,\r
                contentB          : 0,\r
+               paddingL          : 0,\r
+               paddingT          : 0,\r
+               borderL           : 0,\r
+               borderT           : 0,\r
                boxSizingOffsetLR : 0,\r
                boxSizingOffsetTB : 0,          \r
                contentWidth      : XUI_Attr_AUTO,\r
@@ -352,14 +356,16 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                 * X_Node_BoxModel の情報を引きながら top,left,width,height,padding,border の設定\r
                 */\r
                updateLayout : function(){\r
-                       var x = this.boxX,\r
-                               y = this.boxY;\r
+                       var x = this.boxX + ( this.parentData ? this.parentData.paddingL : 0 ),\r
+                               y = this.boxY + ( this.parentData ? this.parentData.paddingT : 0 ),\r
+                               w = X_UA[ 'IE5x' ] ? this.boxWidth  : this.contentWidth,\r
+                               h = X_UA[ 'IE5x' ] ? this.boxHeight : this.contentHeight;\r
 \r
                        this.xnode\r
-                               [ 'css' ]( 'left',        x ? x + 'em' : 0 )\r
-                               [ 'css' ]( 'top',         y ? y + 'em' : 0 )\r
-                               [ 'css' ]( 'width',       this.noWidth  ? 'auto' : this.contentWidth  ? this.contentWidth  + 'em' : 0 )\r
-                               [ 'css' ]( 'height',      this.noHeight ? 'auto' : this.contentHeight ? this.contentHeight + 'em' : 0 )\r
+                               [ 'css' ]( 'left',        x ? x + 'em' : 0 ) // 親の padding 分ずらす\r
+                               [ 'css' ]( 'top',         y ? y + 'em' : 0 ) // 親の padding 分ずらす\r
+                               [ 'css' ]( 'width',       this.noWidth  ? 'auto' : w ? w + 'em' : 0 )\r
+                               [ 'css' ]( 'height',      this.noHeight ? 'auto' : h ? h + 'em' : 0 )\r
                                [ 'css' ]( 'padding',     XUI_AbstractUINode_createCssText( this, 'padding' ) )\r
                                [ 'css' ]( 'borderWidth', XUI_AbstractUINode_createCssText( this, 'borderWidth' ) );\r
                },\r
@@ -394,6 +400,8 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                        };\r
                        this.contentL = borderL + paddingL;\r
                        this.contentR = borderR + paddingR;\r
+                       this.paddingL = paddingL;\r
+                       this.borderL  = borderL;\r
                        \r
                        if( this.constraintW ? allowedW !== XUI_Attr_AUTO : !this.autoWidth && ( allowedW !== XUI_Attr_AUTO || !this.percentWidth ) ){\r
                                if( this.constraintW ){ // 制約レイアウト\r
@@ -401,24 +409,21 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                } else {\r
                                        contentW = XUI_AbstractUINode_calcFinalValue( attrs[ XUI_Attr_Support.width.No ], attrs[ XUI_Attr_Support.minWidth.No ], attrs[ XUI_Attr_Support.maxWidth.No ], allowedW );                                     \r
                                };\r
-                               this.contentWidth = contentW + boxMinus;\r
-                               //this.scrollWidth  = this.contentWidth + this.contentL + this.contentR;\r
-                               this.boxWidth     = contentW - boxMinus + this.contentL + this.contentR;\r
+                               this.contentWidth      = contentW + boxMinus;\r
+                               this.boxWidth          = this.contentWidth + this.contentL + this.contentR;\r
                                this.boxSizingOffsetLR = boxMinus;\r
                                delete this.minContentWidth;\r
                                delete this.maxContentWidth;\r
                                delete this.minBoxWidth;\r
                                delete this.maxBoxWidth;\r
                        } else {        \r
-                               this.minContentWidth = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minWidth.No ], allowedW ) + boxMinus );\r
-                               this.maxContentWidth = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxWidth.No ], allowedW ) + boxMinus );\r
-                               //this.scrollWidth     = this.contentWidth + this.contentL + this.contentR;\r
-                               this.minBoxWidth     = this.minContentWidth - boxMinus + this.contentL + this.contentR;\r
-                               this.maxBoxWidth     = this.maxContentWidth - boxMinus + this.contentL + this.contentR;\r
-                               //delete this.contentWidth;\r
-                               //delete this.scrollWidth;\r
-                               //delete this.boxWidth;\r
-                               //delete this.boxSizingOffsetLR;\r
+                               this.minContentWidth   = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minWidth.No ], allowedW ) + boxMinus );\r
+                               this.maxContentWidth   = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxWidth.No ], allowedW ) + boxMinus );\r
+                               this.minBoxWidth       = this.minContentWidth + this.contentL + this.contentR;\r
+                               this.maxBoxWidth       = this.maxContentWidth + this.contentL + this.contentR;\r
+                               this.contentWidth      = this.minContentWidth;\r
+                               this.boxWidth          = this.minBoxWidth;\r
+                               this.boxSizingOffsetLR = boxMinus;\r
                        };\r
                        \r
                        paddingT  = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.padding.No + 0 ], allowedH );// paddingTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
@@ -435,6 +440,8 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                        };\r
                        this.contentT = borderT + paddingT;\r
                        this.contentB = borderB + paddingB;\r
+                       this.paddingT = paddingT;\r
+                       this.borderT  = borderT;\r
                        \r
                        // Height\r
                        if( this.constraintH ? allowedH !== XUI_Attr_AUTO : !this.autoHeight && ( allowedH !== XUI_Attr_AUTO || !this.percentHeight ) ){\r
@@ -443,24 +450,21 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                } else {\r
                                        contentH = XUI_AbstractUINode_calcFinalValue( attrs[ XUI_Attr_Support.height.No ], attrs[ XUI_Attr_Support.minHeight.No ], attrs[ XUI_Attr_Support.maxHeight.No ], allowedH );\r
                                };                      \r
-                               this.contentHeight = contentH + boxMinus;\r
-                               //this.scrollHeight  = this.contentHeight + this.contentT + this.contentB;\r
-                               this.boxHeight     = contentH - boxMinus + this.contentT + this.contentB; // padding-box の場合 border だけ足される\r
+                               this.contentHeight     = contentH + boxMinus;\r
+                               this.boxHeight         = this.contentHeight + this.contentT + this.contentB; // padding-box の場合 border だけ足される\r
                                this.boxSizingOffsetTB = boxMinus;\r
                                delete this.minContentHeight;\r
                                delete this.maxContentHeight;\r
                                delete this.minBoxHeight;\r
                                delete this.maxBoxHeight;\r
                        } else {\r
-                               this.minContentHeight = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minHeight.No ], allowedH ) + boxMinus );\r
-                               this.maxContentHeight = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxHeight.No ], allowedH ) + boxMinus );                         \r
-                               this.minBoxHeight = this.minContentHeight - boxMinus + this.contentT + this.contentB;\r
-                               this.maxBoxHeight = this.maxContentHeight - boxMinus + this.contentT + this.contentB;\r
-               \r
-                               //delete this.contentHeight;\r
-                               //delete this.scrollHeight;\r
-                               //delete this.boxHeight;\r
-                               //delete this.boxSizingOffsetTB;\r
+                               this.minContentHeight  = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minHeight.No ], allowedH ) + boxMinus );\r
+                               this.maxContentHeight  = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxHeight.No ], allowedH ) + boxMinus );                                \r
+                               this.minBoxHeight      = this.minContentHeight + this.contentT + this.contentB;\r
+                               this.maxBoxHeight      = this.maxContentHeight + this.contentT + this.contentB;\r
+                               this.contentHeight     = this.minContentHeight;\r
+                               this.boxHeight         = this.minBoxHeight;\r
+                               this.boxSizingOffsetTB = boxMinus;\r
                        };\r
                        \r
                        if( this.parentData && this.parentData.layout.overrideAttrsForChild.left ){\r
@@ -623,17 +627,17 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                borderL  = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.borderWidth.No + 3 ], contentW );\r
                                contentPlus = 0;\r
                                switch( box ){\r
-                                       case 3 : // border-box\r
-                                                contentPlus  = borderR + borderL;\r
+                                       case 1 : // content-box\r
+                                                contentPlus  = paddingR + paddingL;\r
                                        case 2 : // padding-box\r
-                                                contentPlus += paddingR + paddingL;\r
-                                       // case 1 : // content-box\r
+                                                contentPlus += borderR + borderL;\r
+                                       // case 3 : // border-box\r
                                };\r
                                \r
                                if( !this.constraintW ){\r
                                        contentW += contentPlus;\r
-                                       min = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minWidth.No ], contentW );\r
-                                       max = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxWidth.No ], contentW );\r
+                                       min = this.minBoxWidth = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minWidth.No ], contentW );\r
+                                       max = this.maxBoxWidth = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxWidth.No ], contentW );\r
                                        if( contentW < min && contentPlus < min ){\r
                                                this.contentWidth = min - contentPlus;\r
                                        } else\r
@@ -643,6 +647,8 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                };\r
                                this.contentL = borderL + paddingL;\r
                                this.contentR = borderR + paddingR;\r
+                               this.paddingL = paddingL;\r
+                               this.borderL  = borderL;\r
                                this.boxWidth = this.contentWidth + this.contentL + this.contentR;\r
                        };\r
                        // Height\r
@@ -654,16 +660,16 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                borderB     = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.borderWidth.No  + 2 ], contentH );\r
                                contentPlus = 0;\r
                                switch( box ){\r
-                                       case 3 : // border-box\r
-                                                contentPlus  = borderT + borderB;\r
+                                       case 1 : // content-box\r
+                                                contentPlus  = paddingT + paddingB;\r
                                        case 2 : // padding-box\r
-                                                contentPlus += paddingT + paddingB;\r
-                                       // case 1 : // content-box\r
+                                                contentPlus += borderT + borderB;\r
+                                       // case 3 : // border-box\r
                                };\r
                                if( !this.constraintH ){\r
                                        contentH += contentPlus;\r
-                                       min = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minHeight.No ], contentH );\r
-                                       max = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxHeight.No ], contentH );\r
+                                       min = this.minBoxHeight = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minHeight.No ], contentH );\r
+                                       max = this.maxBoxHeight = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxHeight.No ], contentH );\r
                                        if( contentH < min && contentPlus < min ){\r
                                                this.contentHeight = min - contentPlus;\r
                                        } else\r
@@ -673,6 +679,8 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ](
                                };\r
                                this.contentT  = borderT + paddingT;\r
                                this.contentB  = borderB + paddingB;\r
+                               this.paddingT  = paddingT;\r
+                               this.borderT   = borderT;\r
                                this.boxHeight = this.contentHeight + this.contentT + this.contentB;\r
                        };\r
                },\r