reserveEvents : null,\r
gesture : null,\r
\r
- x : 0,\r
- y : 0,\r
- \r
- t : 0, // top\r
- l : 0, // left\r
- b : 0, // bottom\r
- r : 0, // right\r
absoluteX : 0,\r
absoluteY : 0,\r
\r
contentHeight : X.UI.Attr.AUTO,\r
minContentHeight : 0,\r
maxContentHeight : X.UI.Attr.AUTO,\r
+ lastContentHeight : -1,\r
\r
constraintW : false,\r
constraintH : false,\r
// :hover, :focus, :disabled\r
\r
initialize : function( root, rootData, parent, parentData ){\r
- var events = this.reserveEvents,\r
- l, i; \r
- \r
this.root = root;\r
this.rootData = rootData;\r
- this.hoverList = rootData.hoverList;\r
this.parent = parent;\r
this.parentData = parentData;\r
//this.xnode = X.Dom.Node.create( 'div' );\r
this.phase = 1;\r
\r
this.dispatch( { type : X.UI.Event.INIT } );\r
- \r
- // html 要素が親に追加されるまで控えていたイベントの登録\r
- if( events && ( l = events.length ) ){\r
- for( i = 0; i < l; ++i ){\r
- this.listen.apply( this, events[ i ] );\r
- };\r
- events.length = 0;\r
- delete this.reserveEvents;\r
- }; \r
},\r
\r
addToParent : function( parentElement ){\r
},\r
\r
creationComplete : function(){\r
+ var events = this.reserveEvents,\r
+ l, i;\r
+ \r
this.phase = 3;\r
this.User.dispatch( { type : X.UI.Event.CREATION_COMPLETE } );\r
+ \r
+ // html 要素が親に追加されるまで控えていたイベントの登録\r
+ if( events && ( l = events.length ) ){\r
+ for( i = 0; i < l; ++i ){\r
+ this.listen.apply( this, events[ i ] );\r
+ };\r
+ events.length = 0;\r
+ delete this.reserveEvents;\r
+ }; \r
},\r
\r
/*\r
getAttr : function( name ){\r
var attrs = this.attrObject || this.attrClass.prototype || X.UI.AttrClass,\r
support = this.supportAttrs[ name ],\r
- v;\r
+ v, type, list;\r
if( !support ) return;\r
\r
if( name.indexOf( 'border' ) === 0 ){\r
* X.Dom.BoxModel の情報を引きながら top,left,width,height,padding,border の設定\r
*/\r
updateLayout : function( x, y ){\r
- x += this.boxX;\r
- y += this.boxY;\r
+ this.boxX = x;\r
+ this.boxY = y;\r
this.xnode\r
.css( 'left', x ? x + 'em' : 0 )\r
.css( 'top', y ? y + 'em' : 0 )\r
- .css( 'width', this.contentWidth ? this.contentWidth + 'em' : 0 )\r
- .css( 'height', this.contentHeight ? this.contentHeight + 'em' : 0 )\r
+ .css( 'width', this.contentWidth ? _AbstractUINode.ceil( this.contentWidth ) + 'em' : 0 )\r
+ .css( 'height', this.contentHeight ? _AbstractUINode.ceil( this.contentHeight ) + 'em' : 0 )\r
.css( 'padding', this._createCssText( 'padding' ) )\r
.css( 'borderWidth', this._createCssText( 'borderWidth' ) );\r
},\r
mesure : function(){\r
var dirty = this.dirty,\r
w, h, xnode;\r
+ \r
+ if( dirty === X.UI.Dirty.CLEAN ){\r
+ if( this.percentWidth || this.percentHeight ){\r
+ \r
+ };\r
+ };\r
+ \r
switch( dirty ){\r
\r
case X.UI.Dirty.CONTENT : // コンテンツが変更された\r
- case X.UI.Dirty.FONT : // フォントサイズが変更された\r
+ case X.UI.Dirty.FONT : // フォントサイズが変更された\r
delete this.lastContentWidth;\r
+ delete this.lastContentHeight;\r
+ \r
case X.UI.Dirty.LAYOUT : // レイアウトの再計算が必要\r
\r
default : // TODO レイアウト崩れに対処 パフォーマンス悪い!\r
*/\r
if( xnode._xnodes && xnode._xnodes.length ){\r
if( w === X.UI.Attr.AUTO ){\r
- w = this.contentWidth = xnode.width() / xnode._getCharSize();\r
+ w = this.contentWidth = xnode.css( 'width', 'auto' ).width() / xnode._getCharSize();\r
+ console.log( xnode.width() + ' ' + xnode._getCharSize() + ' > ' + w );\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
this.lastContentWidth = this.contentWidth;\r
\r
- w !== this.contentWidth && xnode.css( 'width', this.contentWidth + 'em' );\r
+ w !== this.contentWidth && xnode.css( 'width', _AbstractUINode.ceil( this.contentWidth ) + 'em' );\r
\r
if( h === X.UI.Attr.AUTO ){\r
- this.contentHeight = h = xnode.height() / xnode._getCharSize();\r
+ this.contentHeight = h = xnode.css( 'height', 'auto' ).scrollHeight() / xnode._getCharSize(); // scrollHeight() ??\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
} else {\r
- this.scrollHeight = xnode.height() / xnode._getCharSize() + this.contentT + this.contentB;\r
+ this.scrollHeight = h + this.contentT + this.contentB;\r
};\r
+ \r
+ this.lastContentHeight = h;\r
} else\r
if( h === X.UI.Attr.AUTO ){\r
if( w !== this.lastContentWidth ){\r
- xnode.css( 'width', w + 'em' );\r
+ xnode.css( 'width', _AbstractUINode.ceil( w ) + 'em' );\r
\r
this.lastContentWidth = w;\r
- this.contentHeight = h = xnode.height() / xnode._getCharSize();\r
+ this.contentHeight = h = xnode.css( 'height', 'auto' ).scrollHeight() / 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
if( h - this.boxSizingOffsetTB < this.minContentHeight ) this.contentHeight = this.minContentHeight + this.boxSizingOffsetTB; \r
} else {\r
- this.scrollWidth = w + this.contentL + this.contentR;\r
- this.scrollHeight = h + this.contentT + this.contentB;\r
+ this.contentHeight = this.lastContentHeight = h =\r
+ this.lastContentHeight === -1 ? xnode.css( 'height', 'auto' ).scrollHeight() / xnode._getCharSize() : this.lastContentHeight;\r
+ this.scrollWidth = w + this.contentL + this.contentR;\r
+ this.scrollHeight = h + this.contentT + this.contentB;\r
};\r
} else\r
if( dirty !== X.UI.Dirty.LAYOUT ){\r
- this.contentWidth = this.lastContentWidth = w; //xnode.width();\r
- this.contentHeight = xnode.height() / xnode._getCharSize();\r
+ this.contentWidth = this.lastContentWidth = w; //xnode.width();\r
+ this.contentHeight = this.lastContentHeight = xnode.css( 'height', 'auto' ).scrollHeight() / xnode._getCharSize();\r
this.scrollWidth = this.contentWidth + this.contentL + this.contentR;\r
this.scrollHeight = this.contentHeight + this.contentT + this.contentB;\r
} else {\r
capcher : function( x, y ){\r
if( this.pointerDisabled ) return false;\r
\r
- x -= this.x;\r
- y -= this.y;\r
+ x -= this.boxX;\r
+ y -= this.boxY;\r
\r
if( 0 <= x && x < this.boxWidth && 0 <= y && y < this.boxHeight ){\r
- !this.hovering && ( this.hoverList[ this.hoverList.length ] = this );\r
+ \r
+ !this.hovering && ( this.rootData.hoverList[ this.rootData.hoverList.length ] = this );\r
this.rootData.targetNodeData = this;\r
return true;\r
};\r
this.gesture.listen( type );\r
};\r
} else {\r
+ console.log( type )\r
root = this.rootData;\r
counter = root.eventCounter;\r
if( counter[ type ] ){\r
++counter[ type ];\r
} else {\r
counter[ type ] = 1; \r
- root.elmMouseCatch.listen( X.UI.Event.IdToName[ type ], eventRellay );\r
+ root.xnodeInteractiveLayer.listen( X.UI.Event.IdToName[ type ], eventRellay );\r
};\r
};\r
};\r
if( !counter[ type ] ) return this;\r
--counter[ type ];\r
if( counter[ type ] === 0 ){\r
- X.Dom.Event.remove( root.elmMouseCatch, X.UI.Event.IdToName[ type ], eventRellay );\r
+ root.xnodeInteractiveLayer.unlisten( X.UI.Event.IdToName[ type ], eventRellay );\r
delete counter[ type ];\r
};\r
};\r
max = calc( styleMax, srcValue );\r
return v <= min ? min : max <= v ? max : v;\r
};\r
+_AbstractUINode.ceil = function( v ){\r
+ if( 0 <= v ){\r
+ return ( v * 10 + 0.999 | 0 ) / 10;\r
+ };\r
+ return ( -v * 10 + 0.999 | 0 ) / -10;\r
+};\r
\r
var AbstractUINode = X.Class.create(\r
'AbstractUINode',\r
},\r
getX : function(){\r
// dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).x;\r
+ return X.Class._getPrivate( this ).boxX;\r
},\r
getY : function(){\r
// dirty の場合、rootData.calculate\r
- return X.Class._getPrivate( this ).y;\r
+ return X.Class._getPrivate( this ).boxY;\r
},\r
getAbsoluteX : function(){\r
// dirty の場合、rootData.calculate\r