OSDN Git Service

Version 0.6.46, bugfix for X.UI.
authoritozyun <itozyun@user.sourceforge.jp>
Thu, 5 Jun 2014 12:34:51 +0000 (21:34 +0900)
committeritozyun <itozyun@user.sourceforge.jp>
Thu, 5 Jun 2014 12:34:51 +0000 (21:34 +0900)
0.6.x/js/main.js
0.6.x/js/ui/06_AbstractUINode.js
0.6.x/js/ui/11_VBox.js
0.6.x/js/ui/12_HBox.js
0.6.x/js/ui/17_Text.js

index 843ba40..6eb6d97 100644 (file)
@@ -1,18 +1,17 @@
-\r
 PageRoot(\r
-       VBox({\r
-               width   : '30%',\r
-               height  : 10,\r
-               left    : '10%',\r
-               top     : 12,\r
-               bgColor : 0xcccccc\r
+       Box({\r
+               width   : '10%',\r
+               height  : '10%',\r
+               left    : 5,\r
+               top     : 1,\r
+               bgColor : 0x0000ff\r
        }),\r
-       VBox({\r
-               width       : '50%',\r
-               height      : 10,\r
-               left        : '30%',\r
-               bottom      : 12,\r
-               bgColor     : 0x999999\r
+       Box({\r
+               width       : 5,\r
+               height      : 5,\r
+               left        : '10%',\r
+               bottom      : '70%',\r
+               bgColor     : 0xff0000\r
        }),\r
        VBox(\r
                {\r
@@ -22,10 +21,19 @@ PageRoot(
                        bottom      : 5,\r
                        bgColor     : 0x666666,\r
                        borderColor : 0x111111,\r
-                       borderWidth : [ 0.5, 1, 5 ],\r
+                       borderWidth : [ 0, 1, 0, 0 ],\r
                        borderStyle : 'solid dotted',\r
+                       padding     : [ 2, 1.5 ],\r
                        sizing      : 'border'\r
                },\r
-               Text( 'Hello,world' )\r
+               Box({\r
+                       width       : '50%',\r
+                       height      : 2,\r
+                       left        : '30%',\r
+                       bgColor     : 0x999999\r
+               }),\r
+               Text( 'Hello,world!' ),\r
+               Text( '----------------------------' ),\r
+               Text( 'PettanR team' )\r
        )\r
 );
\ No newline at end of file
index c96bed5..8a356d0 100644 (file)
@@ -3,6 +3,8 @@ var _AbstractUINode = X.EventDispatcher.inherits(
        X.Class.ABSTRACT | X.Class.PRIVATE_DATA,\r
        {\r
                phase             : 0,\r
+               dirty             : X.UI.Dirty.CLEAN,\r
+               \r
                root              : null,\r
                rootData          : null,\r
                hoverList         : null,\r
@@ -337,6 +339,10 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                                if( numerical ) return v;\r
                                if( list && list[ v ] ) return list[ v ];\r
                                if( color ){\r
+                                       if( v < 0x100000 ){\r
+                                               v = '00000' + v.toString( 16 );\r
+                                               return '#' + v.substr( v.length - 6 );\r
+                                       };\r
                                        return '#' + v.toString( 16 );\r
                                };\r
                        };\r
@@ -385,8 +391,10 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                                case 3:\r
 \r
                                case 2:\r
-                                       this.xnode.destroy();\r
+                                       \r
                                case 1:\r
+                                       this.xnode.destroy();\r
+                               \r
                                        delete this.root;\r
                                        delete this.rootData;\r
                                        delete this.parent;\r
@@ -399,8 +407,8 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                },\r
                //killed\r
 \r
-               calculate : function( isNeedsDetection, x, y, allowW, allowH ){\r
-                       this.preMesure( allowW, allowH );\r
+               calculate : function( isNeedsDetection, x, y, allowedW, allowedH ){\r
+                       this.preMesure( allowedW, allowedH );\r
                        \r
                        if( this.boxWidth === X.UI.Attr.AUTO || this.boxHeight === X.UI.Attr.AUTO ){\r
                                this.mesure();\r
@@ -428,7 +436,7 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                /*\r
                 * 親の サイズを元に自身のサイズを計算していく\r
                 */\r
-               preMesure : function( allowW, allowH ){\r
+               preMesure : function( allowedW, allowedH ){\r
                        var attrs = this.attrObject || this.attrClass.prototype || X.UI.AttrClass,\r
                                calc  = _AbstractUINode.calcValue,\r
                                box   = attrs[ X.UI.Attr.Support.sizing.No ],\r
@@ -442,10 +450,10 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                        // 自身が constraintW の場合 親が AUTO ではない\r
                        // 自身が constraintW でない場合自身が  AUTO はなくかつ親 が AUTO の場合 or 自身は % でない\r
                        \r
-                       paddingR = calc( attrs[ X.UI.Attr.Support.padding.No + 1 ], allowW );\r
-                       paddingL = calc( attrs[ X.UI.Attr.Support.padding.No + 3 ], allowW );\r
-                       borderR  = calc( attrs[ X.UI.Attr.Support.borderWidth.No + 1 ], allowW );\r
-                       borderL  = calc( attrs[ X.UI.Attr.Support.borderWidth.No + 3 ], allowW );\r
+                       paddingR = calc( attrs[ X.UI.Attr.Support.padding.No + 1 ], allowedW );\r
+                       paddingL = calc( attrs[ X.UI.Attr.Support.padding.No + 3 ], allowedW );\r
+                       borderR  = calc( attrs[ X.UI.Attr.Support.borderWidth.No + 1 ], allowedW );\r
+                       borderL  = calc( attrs[ X.UI.Attr.Support.borderWidth.No + 3 ], allowedW );\r
                        boxMinus = 0;\r
                        switch( box ){\r
                                case 3 : // border-box\r
@@ -457,11 +465,11 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                        this.contentL = borderL + paddingL;\r
                        this.contentR = borderR + paddingR;\r
                        \r
-                       if( this.constraintW ? allowW !== X.UI.Attr.AUTO : !this.autoWidth && ( allowW !== X.UI.Attr.AUTO || !this.percentWidth ) ){\r
+                       if( this.constraintW ? allowedW !== X.UI.Attr.AUTO : !this.autoWidth && ( allowedW !== X.UI.Attr.AUTO || !this.percentWidth ) ){\r
                                if( this.constraintW ){ // 制約レイアウト\r
-                                       contentW = allowW - ( boxL = calc( attrs[ X.UI.Attr.Support.left.No ], allowW ) ) - ( boxR = calc( attrs[ X.UI.Attr.Support.right.No ], allowW ) );\r
+                                       contentW = allowedW - ( boxL = calc( attrs[ X.UI.Attr.Support.left.No ], allowedW ) ) - ( boxR = calc( attrs[ X.UI.Attr.Support.right.No ], allowedW ) );\r
                                } else {\r
-                                       contentW = _AbstractUINode.finalValue( attrs[ X.UI.Attr.Support.width.No ], attrs[ X.UI.Attr.Support.minWidth.No ], attrs[ X.UI.Attr.Support.maxWidth.No ], allowW );                                   \r
+                                       contentW = _AbstractUINode.finalValue( attrs[ X.UI.Attr.Support.width.No ], attrs[ X.UI.Attr.Support.minWidth.No ], attrs[ X.UI.Attr.Support.maxWidth.No ], allowedW );                                 \r
                                };\r
                                this.contentWidth = contentW + boxMinus;\r
                                this.scrollWidth  = this.contentWidth + this.contentL + this.contentR;\r
@@ -472,21 +480,21 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                                delete this.minBoxWidth;\r
                                delete this.maxBoxWidth;\r
                        } else {        \r
-                               this.minContentWidth = calc( attrs[ X.UI.Attr.Support.minWidth.No ], allowW ) + boxMinus;\r
-                               this.maxContentWidth = calc( attrs[ X.UI.Attr.Support.maxWidth.No ], allowW ) + boxMinus;\r
+                               this.minContentWidth = calc( attrs[ X.UI.Attr.Support.minWidth.No ], allowedW ) + boxMinus;\r
+                               this.maxContentWidth = calc( attrs[ X.UI.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
+                               //delete this.contentWidth;\r
+                               //delete this.scrollWidth;\r
+                               //delete this.boxWidth;\r
+                               //delete this.boxSizingOffsetLR;\r
                        };\r
                        \r
-                       paddingT  = calc( attrs[ X.UI.Attr.Support.padding.No + 0 ], allowH );// paddingTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
-                       paddingB  = calc( attrs[ X.UI.Attr.Support.padding.No + 2 ], allowH );\r
-                       borderT   = calc( attrs[ X.UI.Attr.Support.borderWidth.No  + 0 ], allowH );\r
-                       borderB   = calc( attrs[ X.UI.Attr.Support.borderWidth.No  + 2 ], allowH );\r
+                       paddingT  = calc( attrs[ X.UI.Attr.Support.padding.No + 0 ], allowedH );// paddingTRBL の % 指定は 最大幅に対して TB でも幅に対して\r
+                       paddingB  = calc( attrs[ X.UI.Attr.Support.padding.No + 2 ], allowedH );\r
+                       borderT   = calc( attrs[ X.UI.Attr.Support.borderWidth.No  + 0 ], allowedH );\r
+                       borderB   = calc( attrs[ X.UI.Attr.Support.borderWidth.No  + 2 ], allowedH );\r
                        boxMinus = 0;\r
                        switch( box ){\r
                                case 3 : // border-box\r
@@ -496,43 +504,43 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                                // case 1 : // content-box\r
                        };\r
                        this.contentT = borderT + paddingT;\r
-                       this.conetntB = borderB + paddingB;\r
+                       this.contentB = borderB + paddingB;\r
                        \r
                        // Height\r
-                       if( this.constraintH ? allowH !== X.UI.Attr.AUTO : !this.autoHeight && ( allowH !== X.UI.Attr.AUTO || !this.percentHeight ) ){\r
+                       if( this.constraintH ? allowedH !== X.UI.Attr.AUTO : !this.autoHeight && ( allowedH !== X.UI.Attr.AUTO || !this.percentHeight ) ){\r
                                if( this.constraintH ){ // 制約レイアウト\r
-                                       contentH = allowH - ( boxT = calc( attrs[ X.UI.Attr.Support.top.No ], allowH ) ) - ( boxB = calc( attrs[ X.UI.Attr.Support.bottom.No ], allowH ) );\r
+                                       contentH = allowedH - ( boxT = calc( attrs[ X.UI.Attr.Support.top.No ], allowedH ) ) - ( boxB = calc( attrs[ X.UI.Attr.Support.bottom.No ], allowedH ) );\r
                                } else {\r
-                                       contentH = _AbstractUINode.finalValue( attrs[ X.UI.Attr.Support.height.No ], attrs[ X.UI.Attr.Support.minHeight.No ], attrs[ X.UI.Attr.Support.maxHeight.No ], allowH );\r
+                                       contentH = _AbstractUINode.finalValue( attrs[ X.UI.Attr.Support.height.No ], attrs[ X.UI.Attr.Support.minHeight.No ], attrs[ X.UI.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.conetntB; // padding-box の場合 border だけ足される\r
+                               this.boxHeight     = contentH - boxMinus + 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 = calc( attrs[ X.UI.Attr.Support.minHeight.No ], allowH ) + boxMinus;\r
-                               this.maxContentHeight = calc( attrs[ X.UI.Attr.Support.maxHeight.No ], allowH ) + boxMinus;                             \r
-                               this.minBoxHeight = this.minContentHeight - boxMinus + this.contentT + this.conetntB;\r
-                               this.maxBoxHeight = this.maxContentHeight - boxMinus + this.contentT + this.conetntB;\r
+                               this.minContentHeight = calc( attrs[ X.UI.Attr.Support.minHeight.No ], allowedH ) + boxMinus;\r
+                               this.maxContentHeight = calc( attrs[ X.UI.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
+                               //delete this.contentHeight;\r
+                               //delete this.scrollHeight;\r
+                               //delete this.boxHeight;\r
+                               //delete this.boxSizingOffsetTB;\r
                        };\r
                        \r
                        if( this.parentData && this.parentData.layout.overrideAttrsForChild.left ){\r
                                if( this.constraintW ){\r
-                                       this.boxX = ( boxL || boxL === 0 ) ? boxL : calc( attrs[ X.UI.Attr.Support.left.No ], allowW );\r
+                                       this.boxX = ( boxL || boxL === 0 ) ? boxL : calc( attrs[ X.UI.Attr.Support.left.No ], allowedW );\r
                                } else\r
                                if( attrs[ X.UI.Attr.Support.right.No ] === null ){\r
-                                       this.boxX = ( boxL || boxL === 0 ) ? boxL : calc( attrs[ X.UI.Attr.Support.left.No ], allowW );\r
+                                       this.boxX = ( boxL || boxL === 0 ) ? boxL : calc( attrs[ X.UI.Attr.Support.left.No ], allowedW );\r
                                } else {\r
-                                       this.boxX = alllowW - this.boxWidth - ( ( boxR || boxR === 0 ) ? boxR : calc( attrs[ X.UI.Attr.Support.right.No ], allowW ) );\r
+                                       this.boxX = alllowW - this.boxWidth - ( ( boxR || boxR === 0 ) ? boxR : calc( attrs[ X.UI.Attr.Support.right.No ], allowedW ) );\r
                                };\r
                        } else {\r
                                delete this.boxX;\r
@@ -540,12 +548,12 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                        \r
                        if( this.parentData && this.parentData.layout.overrideAttrsForChild.top ){\r
                                if( this.constraintH ){\r
-                                       this.boxY = ( boxT || boxT === 0 ) ? boxT : calc( attrs[ X.UI.Attr.Support.top.No ], allowH );\r
+                                       this.boxY = ( boxT || boxT === 0 ) ? boxT : calc( attrs[ X.UI.Attr.Support.top.No ], allowedH );\r
                                } else\r
                                if( attrs[ X.UI.Attr.Support.bottom.No ] === null ){\r
-                                       this.boxY = ( boxT || boxT === 0 ) ? boxT : calc( attrs[ X.UI.Attr.Support.top.No ], allowH );\r
+                                       this.boxY = ( boxT || boxT === 0 ) ? boxT : calc( attrs[ X.UI.Attr.Support.top.No ], allowedH );\r
                                } else {\r
-                                       this.boxY = allowH - this.boxHeight - ( ( boxB || boxB === 0 ) ? boxB : calc( attrs[ X.UI.Attr.Support.bottom.No ], allowH ) );\r
+                                       this.boxY = allowedH - this.boxHeight - ( ( boxB || boxB === 0 ) ? boxB : calc( attrs[ X.UI.Attr.Support.bottom.No ], allowedH ) );\r
                                };\r
                        } else {\r
                                delete this.boxY;\r
@@ -564,6 +572,9 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                                case X.UI.Dirty.FONT   : // フォントサイズが変更された\r
                                        delete this.lastContentWidth;\r
                                case X.UI.Dirty.LAYOUT : // レイアウトの再計算が必要\r
+                               \r
+                               default : // TODO レイアウト崩れに対処 パフォーマンス悪い!\r
+                               \r
                                        w     = this.contentWidth;\r
                                        h     = this.contentHeight;\r
                                        xnode = this.xnode;\r
@@ -589,6 +600,7 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                                        if( xnode._xnodes && xnode._xnodes.length ){\r
                                                if( w === X.UI.Attr.AUTO ){\r
                                                        w = this.contentWidth = xnode.width() / xnode._getCharSize();\r
+                                                       \r
                                                        this.scrollWidth = w + this.contentL + this.contentR;\r
                                                        if( this.maxContentWidth < w - this.boxSizingOffsetLR ) this.contentWidth = this.maxContentWidth + this.boxSizingOffsetLR;\r
                                                        if( w - this.boxSizingOffsetLR < this.minContentWidth ) this.contentWidth = this.minContentWidth + this.boxSizingOffsetLR;\r
@@ -597,7 +609,7 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                                                        w !== this.contentWidth && xnode.css( 'width', this.contentWidth + 'em' );\r
                                                        \r
                                                        if( h === X.UI.Attr.AUTO ){\r
-                                                               this.conetntHeight = h = xnode.height() / xnode._getCharSize();\r
+                                                               this.contentHeight = h = xnode.height() / xnode._getCharSize();\r
                                                                this.scrollHeight  = h + this.contentT + this.contentB;\r
                                                                if( this.maxContentHeight < h - this.boxSizingOffsetTB ) this.contentHeight = this.maxContentHeight + this.boxSizingOffsetTB;\r
                                                                if( h - this.boxSizingOffsetTB < this.minContentHeight ) this.contentHeight = this.minContentHeight + this.boxSizingOffsetTB;\r
@@ -608,8 +620,9 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                                                if( h === X.UI.Attr.AUTO ){\r
                                                        if( w !== this.lastContentWidth ){\r
                                                                xnode.css( 'width', w + 'em' );\r
+                                                               \r
                                                                this.lastContentWidth  = w;\r
-                                                               this.conetntHeight = h = xnode.height() / xnode._getCharSize();\r
+                                                               this.contentHeight = h = xnode.height() / xnode._getCharSize();\r
                                                                this.scrollWidth       = w + this.contentL + this.contentR;\r
                                                                this.scrollHeight      = h + this.contentT + this.contentB;\r
                                                                if( this.maxContentHeight < h - this.boxSizingOffsetTB ) this.contentHeight = this.maxContentHeight + this.boxSizingOffsetTB;\r
@@ -635,6 +648,8 @@ var _AbstractUINode = X.EventDispatcher.inherits(
                                                this.scrollWidth  = w + this.contentL + this.contentR;\r
                                                this.scrollHeight = h + this.contentT + this.contentB;\r
                                        };\r
+                                       \r
+                                       delete this.dirty;\r
                                        break;                  \r
                                //case X.UI.Dirty.PAINT : // 再描画のみ必要\r
                                //      break;\r
index de3cd63..87b2009 100644 (file)
@@ -59,7 +59,7 @@ X.UI.Layout.Vertical = X.UI.Layout.create( {
 \r
                if( detectionPhase ){\r
                        if( autoW ) data.contentWidth  = _w;\r
-                       if( autoH ) data.conetntHeight = _y;\r
+                       if( autoH ) data.contentHeight = _y;\r
                        data.postMesure();\r
                } else {\r
                        //data.postMesure();\r
index 28583a1..c29b084 100644 (file)
@@ -57,7 +57,7 @@ X.UI.Layout.Horizontal = X.UI.Layout.create( {
 \r
                if( detectionPhase ){\r
                        if( autoW ) data.contentWidth  = _x;\r
-                       if( autoH ) data.conetntHeight = _h;\r
+                       if( autoH ) data.contentHeight = _h;\r
                        data.postMesure();\r
                } else {\r
                        //data.postMesure();\r
index 72eb17a..bc02512 100644 (file)
@@ -10,7 +10,10 @@ var _Text = _AbstractUINode.inherits(
                        };\r
                        this.xnode      = X.Dom.Node.create( 'div' );\r
                        \r
-                       if( X.Type.isString( content ) ) this.content = content;\r
+                       if( X.Type.isString( content ) ){\r
+                               this.content = content;\r
+                               this.dirty   = X.UI.Dirty.CONTENT;\r
+                       };\r
                },\r
                creationComplete : function(){\r
                        this.content && this.xnode.text( this.content );\r