From 8e63f506d14490e852fa557d326ca91f9cdd3baf Mon Sep 17 00:00:00 2001 From: itozyun Date: Fri, 22 May 2015 11:10:34 +0900 Subject: [PATCH] Version 0.6.153, fix layout @X.UI. --- 0.6.x/js/01_core/02_XUA.js | 4 +- 0.6.x/js/02_dom/02_XNode.js | 5 +- 0.6.x/js/02_dom/08_XNodeSelector.js | 20 ++++++- 0.6.x/js/02_dom/10_XNodeAnime.js | 16 ++++++ 0.6.x/js/06_net/00_XNet.js | 1 + 0.6.x/js/06_net/01_XNetXHR.js | 10 ++-- 0.6.x/js/06_net/10_XOAuth2.js | 55 +++++++++++++++---- 0.6.x/js/07_audio/00_XAudio.js | 102 +++++++++++++++++++++++++---------- 0.6.x/js/07_audio/02_XHTMLAudio.js | 3 +- 0.6.x/js/07_audio/10_XAudioSprite.js | 4 +- 0.6.x/js/20_ui/06_AbstractUINode.js | 92 ++++++++++++++++--------------- 0.6.x/js/20_ui/08_Box.js | 7 +-- 0.6.x/js/20_ui/11_VBox.js | 4 +- 0.6.x/js/20_ui/15_ScrollBox.js | 2 +- 14 files changed, 228 insertions(+), 97 deletions(-) diff --git a/0.6.x/js/01_core/02_XUA.js b/0.6.x/js/01_core/02_XUA.js index eda4818..948f78b 100644 --- a/0.6.x/js/01_core/02_XUA.js +++ b/0.6.x/js/01_core/02_XUA.js @@ -541,10 +541,10 @@ var X_UA = X[ 'UA' ] = {}, i = parseFloat(dua.split('WebKit\/')[1]); /** - * @alias X.UA.AndroidBrowserWebkit + * @alias X.UA.AndroidWebkit * @type {number} */ - X_UA[ 'AndroidBrowserWebkit' ] = i; + X_UA[ 'AndroidWebkit' ] = i; alert( 'AudioSprite調査:Android標準ブラウザ Webkit Version ' + i ); } else diff --git a/0.6.x/js/02_dom/02_XNode.js b/0.6.x/js/02_dom/02_XNode.js index d71a866..185074d 100644 --- a/0.6.x/js/02_dom/02_XNode.js +++ b/0.6.x/js/02_dom/02_XNode.js @@ -580,8 +580,9 @@ function X_Node_clone( opt_clone_children ){ * @alias Node.prototype.append * @param {Node|string|HTMLElement|TextNode} [v] HTMLElement と TextNode は内部のみ。 * @return {Node} 自身。チェインメソッド - * @example myNode.append( node ); - * myNode.append( nodeSprite, '
A
', 'B' ); + * @example // + * myNode.append( node ); + * myNode.append( node, '<span>Hello,</span>', 'world.' ); */ function X_Node_append( v ){ var i, l, xnodes, frg; diff --git a/0.6.x/js/02_dom/08_XNodeSelector.js b/0.6.x/js/02_dom/08_XNodeSelector.js index 00b0013..4b735e0 100644 --- a/0.6.x/js/02_dom/08_XNodeSelector.js +++ b/0.6.x/js/02_dom/08_XNodeSelector.js @@ -226,13 +226,29 @@ function X_Node_Selector__parse( query, last ){ }; /** - * selector を使って Node を取得する + * selector を使って Node, NodeList を取得する * @alias X.Doc.find * @function * @param {string} セレクター文字列 * @return {Node|NodeList} */ - X[ 'Doc' ][ 'find' ] = X_shortcutFunction = Node.prototype[ 'find' ] = X_NodeList.prototype[ 'find' ] = function ( queryString ){ + X[ 'Doc' ][ 'find' ] = X_shortcutFunction = + /** + * selector を使って Node, NodeList を取得する + * @alias Node.prototype.find + * @function + * @param {string} セレクター文字列 + * @return {Node|NodeList} + */ + Node.prototype[ 'find' ] = + /** + * selector を使って Node, NodeList を取得する + * @alias NodeList.prototype.find + * @function + * @param {string} セレクター文字列 + * @return {Node|NodeList} + */ + X_NodeList.prototype[ 'find' ] = function ( queryString ){ var HTML = X_Node_html, scope = this.constructor === X_NodeList && this.length ? this : [ this.constructor === Node ? this : X_Node_body ], parents = scope, // 探索元の親要素 XNodeList の場合あり diff --git a/0.6.x/js/02_dom/10_XNodeAnime.js b/0.6.x/js/02_dom/10_XNodeAnime.js index 3913195..325b955 100644 --- a/0.6.x/js/02_dom/10_XNodeAnime.js +++ b/0.6.x/js/02_dom/10_XNodeAnime.js @@ -88,6 +88,17 @@ var X_Node_ANIMATIONS = [], * TODO 前回位置からの継続 * TODO scrollLeft, scrollTop */ +/** + * GPU サポートの効いたアニメーションの設定 X.Event.ANIME_START, X.Event.ANIME_END, X.Event.GPU_RELEASED + * + * @alias Node.prototype.animate + * @param {object} start { x : 0, y : 0, opacity : 1 } + * @param {object} dest { x : 100, y : 100, opacity : 0 } + * @param {number=} duartion アニメーション時間 ms + * @param {string=} easing 'quadratic', 'circular', 'back', 'bounce', 'elastic' + * @param {number=} wait GPU レイヤーの遅延解除 ms + * @return {Node} メソッドチェーン + */ Node.prototype[ 'animate' ] = function( start, dest, duration, easing, wait ){ var isNew = !this[ '_anime' ], obj = this[ '_anime' ] || ( this[ '_anime' ] = {} ); @@ -146,6 +157,11 @@ Node.prototype[ 'animate' ] = function( start, dest, duration, easing, wait ){ return this; }; +/** + * アニメーションの停止。 + * @alias Node.prototype.stop + * @return {Node} メソッドチェーン + */ Node.prototype[ 'stop' ] = function(){ var obj = this[ '_anime' ]; diff --git a/0.6.x/js/06_net/00_XNet.js b/0.6.x/js/06_net/00_XNet.js index e400763..30a3034 100644 --- a/0.6.x/js/06_net/00_XNet.js +++ b/0.6.x/js/06_net/00_XNet.js @@ -41,6 +41,7 @@ *
dataType
'text', 'json', 'xml', 'blob', 'arraybuffer' 等。xhr.responseType に指定する値 *
mimeType
'text/xml', 'audio/mpeg' 等。xhr.overrideMimeType する値 *
auth
X.OAuth2 インスタンス(OAuth2 サービスの定義) + *
getFullHeaders
getAllResponseHeaders() をパースしたハッシュを返す。値は配列になっている。 * * * @alias X.Net diff --git a/0.6.x/js/06_net/01_XNetXHR.js b/0.6.x/js/06_net/01_XNetXHR.js index 2a12df8..efe8c94 100644 --- a/0.6.x/js/06_net/01_XNetXHR.js +++ b/0.6.x/js/06_net/01_XNetXHR.js @@ -409,8 +409,12 @@ X_TEMP.X_Net_XHR_init = function(){ status = raw.status; // TODO GET_FULL_HEADERS + // https://msdn.microsoft.com/en-us/library/ms766595%28v=vs.85%29.aspx // Implemented in: MSXML 3.0 and MSXML 6.0 - if( !X_NET_XHRWrapper._isXDR && ( ( !X_NET_XHRWrapper._isMsXML && raw.getAllResponseHeaders ) || 3 <= X_Net_XHR_msXMLVer ) && ( headers = raw.getAllResponseHeaders() ) ){ + if( X_NET_XHRWrapper._isXDR ){ + headers = { 'Content-Type' : raw.contentType }; + } else + if( ( X_NET_XHRWrapper._isMsXML ? 3 <= X_Net_XHR_msXMLVer : raw.setRequestHeader ) && ( headers = raw.getAllResponseHeaders() ) ){ headers = X_NET_XHR_parseResponseHeaders( headers ); }; @@ -422,7 +426,7 @@ X_TEMP.X_Net_XHR_init = function(){ ( 200 <= status && status < 400 ) || //status === 304 || ( status === 1223 && ( status = 204 ) ) || - ( X_UA[ 'Webkit' ] && status === undefined ) // safari: /webkit/.test(userAgent) + ( X_UA[ 'Webkit' ] && status === undefined && ( status = 200 ) ) // safari: /webkit/.test(userAgent) ){ /* * opera8, safari2, khtml3 で utf8 日本語文字列の文字化け @@ -511,7 +515,7 @@ X_TEMP.X_Net_XHR_init = function(){ }; -/** +/* * https://gist.github.com/mmazer/5404301 * * XmlHttpRequest's getAllResponseHeaders() method returns a string of response diff --git a/0.6.x/js/06_net/10_XOAuth2.js b/0.6.x/js/06_net/10_XOAuth2.js index 43a34d6..55c40ea 100644 --- a/0.6.x/js/06_net/10_XOAuth2.js +++ b/0.6.x/js/06_net/10_XOAuth2.js @@ -13,17 +13,33 @@ var X_NET_OAUTH2_detection = new Function( 'w', 'try{return w.location.sear *
X.Event.PROGRESS
コードを window から受け取った、リフレッシュトークンの開始、コードの認可を header -> params に切替 * * - * OAuth2 state - *
- *
0 :
disconnected - *
1 :
now authentication ... - *
2 :
authorization_code - *
3 :
refresh_token - *
4 :
hasAccessToken - *
- * * original : * oauth2.js , + * + * @alias X.OAuth2 + * @class OAuth2 サービスを定義し接続状況をモニタする。適宜にトークンのアップデートなどを行う + * @constructs OAuth2 + * @extends {EventDispatcher} + * @example // OAuth2 サービスの定義 +oauth2 = X.OAuth2({ + 'clientID' : 'xxxxxxxx.apps.googleusercontent.com', + 'clientSecret' : 'xxxxxxxx', + 'authorizeEndpoint' : 'https://accounts.google.com/o/oauth2/auth', + 'tokenEndpoint' : 'https://accounts.google.com/o/oauth2/token', + 'redirectURI' : X.URL.cleanup( document.location.href ), // 専用の軽量ページを用意してもよいが、現在のアドレスでも可能 + 'scopes' : [ 'https://www.googleapis.com/auth/blogger' ], + 'authorizeWindowWidth' : 500, + 'authorizeWindowHeight' : 500 +}).listen( [ X.Event.NEED_AUTH, X.Event.CANCELED, X.Event.SUCCESS, X.Event.ERROR, X.Event.PROGRESS ], updateOAuth2State ); + +// XHR 時に oauth2 を渡す +X.Net( { + xhr : 'https://www.googleapis.com/blogger/v3/users/self/blogs', + dataType : 'json', + auth : oauth2, + test : 'gadget' // http -> https:xProtocol なリクエストのため、google ガジェットを proxy に使用 + } ) + .listen( [ X.Event.SUCCESS, X.Event.ERROR, X.Event.PROGRESS ], updateOAuth2State ); */ X[ 'OAuth2' ] = X_EventDispatcher[ 'inherits' ]( 'X.OAuth2', @@ -50,12 +66,25 @@ X[ 'OAuth2' ] = X_EventDispatcher[ 'inherits' ]( // TODO kill の cancel }, + /** + * OAuth2 の状態。 + *
+ *
0 :
未接続 + *
1 :
認可用 window がポップアップ中 + *
2 :
コードを認可中 + *
3 :
トークンのリフレッシュ中 + *
4 :
接続 + *
+ * @return {number} + */ 'state' : function(){ return X_Pair_get( this ).oauth2State || 0; }, + /** + * 認可用 window をポップアップする。ポップアップブロックが働かないように必ず pointer event 内で呼ぶこと。 + */ 'requestAuth' : function(){ - // pointer event 内で呼ぶこと // 二つ以上の popup を作らない if( X_NET_OAUTH2_authorizationWindow ) return; @@ -85,6 +114,9 @@ X[ 'OAuth2' ] = X_EventDispatcher[ 'inherits' ]( this[ 'asyncDispatch' ]( { type : X_EVENT_PROGRESS, message : 'Start to auth.' } ); }, + /** + * 認可プロセスのキャンセル。ポップアップを閉じて認可用の通信は中断する。 + */ 'cancelAuth' : function(){ var pair = X_Pair_get( this ); @@ -103,6 +135,9 @@ X[ 'OAuth2' ] = X_EventDispatcher[ 'inherits' ]( this[ 'asyncDispatch' ]( X_EVENT_CANCELED ); }, + /** + * アクセストークンのリフレッシュ。 + */ 'refreshToken' : function(){ /* TODO 自動リフレッシュ * var expires_at = this._getAccessTokenExpiry(); diff --git a/0.6.x/js/07_audio/00_XAudio.js b/0.6.x/js/07_audio/00_XAudio.js index e923109..1e6d9e5 100644 --- a/0.6.x/js/07_audio/00_XAudio.js +++ b/0.6.x/js/07_audio/00_XAudio.js @@ -12,32 +12,56 @@ var X_Audio_BACKENDS = []; // Array. -/* - * X_EVENT_BACKEND_READY - * X_EVENT_BACKEND_NONE - * - * X_EVENT_READY 再生可能、実際の状態は canplay から loadeddata まで様々、、、 - * X_EVENT_ERROR - * 1 : ユーザーによってメディアの取得が中断された - * 2 : ネットワークエラー - * 3 : メディアのデコードエラー - * 4 : メディアがサポートされていない +/** + *

複数のバックエンドから、与えられた音声を再生可能なものを見つけ、音声を再生します。 + *

HTMLAudio の動作・機能がブラウザ毎にバラバラなのに業を煮やし、メソッドやイベントは独自に定義しています。 + *

バックエンドの種類

+ *

HTMLAudio, WebAudio, Silverlight + *

イベント

+ *
+ *
X.Event.BACKEND_READY
音声(src リスト)を再生可能なバックエンドが見つかった。 + *
X.Event.BACKEND_NONE
音声を再生可能なバックエンドが見つからなかった。 + *
X.Event.READY
再生可能、実際の状態は canplay から loadeddata まで様々、、、 + *
X.Event.ERROR
    + *
  • 1 : ユーザーによってメディアの取得が中断された + *
  • 2 : ネットワークエラー + *
  • 3 : メディアのデコードエラー + *
  • 4 : メディアがサポートされていない + *
+ *
X.Event.MEDIA_PLAYING
再生中に1秒以下のタイミングで発生.currentTime が取れる? + *
X.Event.MEDIA_LOOP
ループ直前に発生、キャンセル可能 + *
X.Event.MEDIA_LOOPED
ループ時に発生 + *
X.Event.MEDIA_ENDED
再生位置の(音声の)最後についた + *
X.Event.MEDIA_PAUSED
ポーズした + *
X.Event.MEDIA_WAITING
再生中に音声が待機状態に。間もなく X.Event.MEDIA_PLAYING に移行。 + *
X.Event.MEDIA_SEEKING
シーク中に音声が待機状態に。間もなく X.Event.MEDIA_PLAYING に移行。 + *
* - * X_EVENT_MEDIA_PLAYING 再生中に1秒以下のタイミングで発生.currentTime が取れる? - * X_EVENT_MEDIA_LOOP ループ直前に発生、キャンセル可能 - * X_EVENT_MEDIA_LOOPED ループ時に発生 - * X_EVENT_MEDIA_ENDED 再生位置の(音声の)最後についた - * X_EVENT_MEDIA_PAUSED ポーズした - * X_EVENT_MEDIA_WAITING 再生中に音声が待機状態に。間もなく X_EVENT_MEDIA_PLAYING に移行。 - * X_EVENT_MEDIA_SEEKING シーク中に音声が待機状態に。間もなく X_EVENT_MEDIA_PLAYING に移行。 + * @alias X.Audio + * @class 各種オーディオ機能をラップしインターフェイスを共通化する。 + * @constructs Audio + * @extends {EventDispatcher} + * @param {array|string} sourceList + * @param {object=} opt_option + * @example // + * var audio = X.Audio( [ 'etc/special.mp3', 'etc/special.ogg', 'etc/special.wav' ] ) + .listenOnce( X.Event.READY, onReady ); */ - -// TODO この内容は、AudioBackend の Abstract クラスにする。AudioSprite は Audio ではなく AudioBackend をマネージする X[ 'Audio' ] = X_EventDispatcher[ 'inherits' ]( 'X.Audio', X_Class.POOL_OBJECT, { + /** + * 音声の url。X.Event.BACKEND_READY で設定される。 + * @alias Audio.prototype.source + * @type {string} + */ 'source' : '', + /** + * 音声再生バックエンドの名前。X.Event.BACKEND_READY で設定される。 + * @alias Audio.prototype.backendName + * @type {string} + */ 'backendName' : '', 'Constructor' : function( sourceList, opt_option ){ @@ -48,24 +72,37 @@ X[ 'Audio' ] = X_EventDispatcher[ 'inherits' ]( this[ 'listenOnce' ]( [ X_EVENT_BACKEND_READY, X_EVENT_BACKEND_NONE, X_EVENT_KILL_INSTANCE ], X_Audio_handleEvent ); }, + /** + * 再生。開始位置・終了位置、ループの有無、ループ以降の開始位置、ループ以降の終了位置 + * @alias Audio.prototype.play + */ 'play' : function( startTime, endTime, loop, loopStartTime, loopEndTime ){ var pair = X_Pair_get( this ); pair && pair.play( startTime, endTime, loop, loopStartTime, loopEndTime ); return this; }, - + /** + * シーク + * @alias Audio.prototype.seek + */ 'seek' : function( seekTime ){ var pair = X_Pair_get( this ); pair && pair.seek( seekTime ); return this; }, - + /** + * ポーズ + * @alias Audio.prototype.pause + */ 'pause' : function(){ var pair = X_Pair_get( this ); pair && pair.pause(); return this; }, - + /** + * 状態の getter と setter + * @alias Audio.prototype.state + */ 'state' : function( obj ){ var pair = X_Pair_get( this ); if( obj === undefined ){ @@ -87,25 +124,37 @@ X[ 'Audio' ] = X_EventDispatcher[ 'inherits' ]( pair && pair.setState( obj ); return this; }, - + /** + * ループの getter と setter + * @alias Audio.prototype.loop + */ 'loop' : function( v ){ var pair = X_Pair_get( this ); pair && pair.loop( v ); return this; }, - + /** + * ボリュームの getter と setter 実装不十分! + * @alias Audio.prototype.volume + */ 'volume' : function( v ){ var pair = X_Pair_get( this ); pair && pair.volume( v ); return this; }, - + /** + * 再生位置。 + * @alias Audio.prototype.currentTime + */ 'currentTime' : function( v ){ var pair = X_Pair_get( this ); pair && pair.currentTime( v ); return this; }, - + /** + * 再生中か? + * @alias Audio.prototype.isPlaying + */ 'isPlaying' : function(){ var pair = X_Pair_get( this ); return pair && pair.playing; @@ -164,7 +213,6 @@ function X_Audio_onEndedDetection( e, xaudio, sourceList, option, source, ext, s var i = X_Audio_BACKENDS.indexOf( this ), backend; if( e.canPlay ){ - xaudio._backend = i; xaudio[ 'asyncDispatch' ]( { type : X_EVENT_BACKEND_READY, 'option' : option, diff --git a/0.6.x/js/07_audio/02_XHTMLAudio.js b/0.6.x/js/07_audio/02_XHTMLAudio.js index fcf91f4..c1258a3 100644 --- a/0.6.x/js/07_audio/02_XHTMLAudio.js +++ b/0.6.x/js/07_audio/02_XHTMLAudio.js @@ -30,8 +30,7 @@ var X_Audio_HTMLAudio_playTrigger = X_Audio_HTMLAudioWrapper_ieMobile9Fix = ( X_UA[ 'WinPhone' ] && X_UA[ 'IE9' ] ), X_Audio_HTMLAudioWrapper_durationFix = ( !X_Audio_HTMLAudioWrapper_currentTimeFix && 12 <= X_UA[ 'Opera' ] ), - X_Audio_HTMLAudioWrapper_shortPlayFix = //X_UA[ 'AndroidBrowser2' ], - X_UA[ 'AndroidBrowser' ] && X_UA[ 'AndroidBrowserWebkit' ] < 534.3, // Android 4.1.1 でも遭遇 + X_Audio_HTMLAudioWrapper_shortPlayFix = X_UA[ 'AndroidBrowser' ] && X_UA[ 'AndroidWebkit' ] <= 534.3, // Android 4.1.1 でも遭遇 X_Audio_codecs; diff --git a/0.6.x/js/07_audio/10_XAudioSprite.js b/0.6.x/js/07_audio/10_XAudioSprite.js index 45790ae..d6a40b6 100644 --- a/0.6.x/js/07_audio/10_XAudioSprite.js +++ b/0.6.x/js/07_audio/10_XAudioSprite.js @@ -5,10 +5,10 @@ * iframe 内で生成して、Audio Sprite の preset で再生できないか? */ var X_Audio_Sprite_shouldUse = window.HTMLAudioElement && ( X_UA[ 'iOS' ] || X_UA[ 'AndroidBrowser' ] || X_UA[ 'OperaMobile' ] || X_UA[ 'OperaTablet' ] ), // Flash がない - X_Audio_Sprite_useVideoForMulti = 4 <= X_UA[ 'AndroidBrowser' ] && 534.3 < X_UA[ 'AndroidBrowserWebkit' ], // ドスパラパッドはビデオのインライン再生が不可 + X_Audio_Sprite_useVideoForMulti = 4 <= X_UA[ 'AndroidBrowser' ] && 534.3 < X_UA[ 'AndroidWebkit' ], // ドスパラパッドはビデオのインライン再生が不可 X_Audio_Sprite_needTouchAndroid = X_Audio_Sprite_useVideoForMulti, X_Audio_Sprite_needTouchFirst = X_UA[ 'iOS' ] || X_Audio_Sprite_needTouchAndroid || ( X_UA[ 'WinPhone' ] && X_UA[ 'IE9' ] ), - X_Audio_Sprite_enableMultiTrack = !( X_UA[ 'iOS' ] && !X_Audio_WebAudio_context ) && !( X_UA[ 'AndroidBrowser4' ] && X_UA[ 'AndroidBrowserWebkit' ] <= 534.3 ), + X_Audio_Sprite_enableMultiTrack = !( X_UA[ 'iOS' ] && !X_Audio_WebAudio_context ) && !( X_UA[ 'AndroidBrowser4' ] && X_UA[ 'AndroidWebkit' ] <= 534.3 ), X_Audio_Sprite_enableVolume = window.HTMLAudioElement && ( !X_UA[ 'iOS' ] && !X_UA[ 'AndroidBrowser' ] && !X_UA[ 'OperaMobile' ] && !X_UA[ 'OperaTablet' ] ), // TODO fennec は 25以上 X_Audio_Sprite_maxTracks = !X_Audio_Sprite_enableMultiTrack ? 1 : X_Audio_Sprite_useVideoForMulti ? 2 : 9, X_Audio_Sprite_lengthSilence = 10000, // 一番最初の無音部分の長さ diff --git a/0.6.x/js/20_ui/06_AbstractUINode.js b/0.6.x/js/20_ui/06_AbstractUINode.js index 5bfc6c9..b2dfe24 100644 --- a/0.6.x/js/20_ui/06_AbstractUINode.js +++ b/0.6.x/js/20_ui/06_AbstractUINode.js @@ -42,6 +42,10 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( contentT : 0, contentR : 0, contentB : 0, + paddingL : 0, + paddingT : 0, + borderL : 0, + borderT : 0, boxSizingOffsetLR : 0, boxSizingOffsetTB : 0, contentWidth : XUI_Attr_AUTO, @@ -352,14 +356,16 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( * X_Node_BoxModel の情報を引きながら top,left,width,height,padding,border の設定 */ updateLayout : function(){ - var x = this.boxX, - y = this.boxY; + var x = this.boxX + ( this.parentData ? this.parentData.paddingL : 0 ), + y = this.boxY + ( this.parentData ? this.parentData.paddingT : 0 ), + w = X_UA[ 'IE5x' ] ? this.boxWidth : this.contentWidth, + h = X_UA[ 'IE5x' ] ? this.boxHeight : this.contentHeight; this.xnode - [ 'css' ]( 'left', x ? x + 'em' : 0 ) - [ 'css' ]( 'top', y ? y + 'em' : 0 ) - [ 'css' ]( 'width', this.noWidth ? 'auto' : this.contentWidth ? this.contentWidth + 'em' : 0 ) - [ 'css' ]( 'height', this.noHeight ? 'auto' : this.contentHeight ? this.contentHeight + 'em' : 0 ) + [ 'css' ]( 'left', x ? x + 'em' : 0 ) // 親の padding 分ずらす + [ 'css' ]( 'top', y ? y + 'em' : 0 ) // 親の padding 分ずらす + [ 'css' ]( 'width', this.noWidth ? 'auto' : w ? w + 'em' : 0 ) + [ 'css' ]( 'height', this.noHeight ? 'auto' : h ? h + 'em' : 0 ) [ 'css' ]( 'padding', XUI_AbstractUINode_createCssText( this, 'padding' ) ) [ 'css' ]( 'borderWidth', XUI_AbstractUINode_createCssText( this, 'borderWidth' ) ); }, @@ -394,6 +400,8 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( }; this.contentL = borderL + paddingL; this.contentR = borderR + paddingR; + this.paddingL = paddingL; + this.borderL = borderL; if( this.constraintW ? allowedW !== XUI_Attr_AUTO : !this.autoWidth && ( allowedW !== XUI_Attr_AUTO || !this.percentWidth ) ){ if( this.constraintW ){ // 制約レイアウト @@ -401,24 +409,21 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( } else { contentW = XUI_AbstractUINode_calcFinalValue( attrs[ XUI_Attr_Support.width.No ], attrs[ XUI_Attr_Support.minWidth.No ], attrs[ XUI_Attr_Support.maxWidth.No ], allowedW ); }; - this.contentWidth = contentW + boxMinus; - //this.scrollWidth = this.contentWidth + this.contentL + this.contentR; - this.boxWidth = contentW - boxMinus + this.contentL + this.contentR; + this.contentWidth = contentW + boxMinus; + this.boxWidth = this.contentWidth + this.contentL + this.contentR; this.boxSizingOffsetLR = boxMinus; delete this.minContentWidth; delete this.maxContentWidth; delete this.minBoxWidth; delete this.maxBoxWidth; } else { - this.minContentWidth = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minWidth.No ], allowedW ) + boxMinus ); - this.maxContentWidth = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxWidth.No ], allowedW ) + boxMinus ); - //this.scrollWidth = this.contentWidth + this.contentL + this.contentR; - this.minBoxWidth = this.minContentWidth - boxMinus + this.contentL + this.contentR; - this.maxBoxWidth = this.maxContentWidth - boxMinus + this.contentL + this.contentR; - //delete this.contentWidth; - //delete this.scrollWidth; - //delete this.boxWidth; - //delete this.boxSizingOffsetLR; + this.minContentWidth = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minWidth.No ], allowedW ) + boxMinus ); + this.maxContentWidth = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxWidth.No ], allowedW ) + boxMinus ); + this.minBoxWidth = this.minContentWidth + this.contentL + this.contentR; + this.maxBoxWidth = this.maxContentWidth + this.contentL + this.contentR; + this.contentWidth = this.minContentWidth; + this.boxWidth = this.minBoxWidth; + this.boxSizingOffsetLR = boxMinus; }; paddingT = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.padding.No + 0 ], allowedH );// paddingTRBL の % 指定は 最大幅に対して TB でも幅に対して @@ -435,6 +440,8 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( }; this.contentT = borderT + paddingT; this.contentB = borderB + paddingB; + this.paddingT = paddingT; + this.borderT = borderT; // Height if( this.constraintH ? allowedH !== XUI_Attr_AUTO : !this.autoHeight && ( allowedH !== XUI_Attr_AUTO || !this.percentHeight ) ){ @@ -443,24 +450,21 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( } else { contentH = XUI_AbstractUINode_calcFinalValue( attrs[ XUI_Attr_Support.height.No ], attrs[ XUI_Attr_Support.minHeight.No ], attrs[ XUI_Attr_Support.maxHeight.No ], allowedH ); }; - this.contentHeight = contentH + boxMinus; - //this.scrollHeight = this.contentHeight + this.contentT + this.contentB; - this.boxHeight = contentH - boxMinus + this.contentT + this.contentB; // padding-box の場合 border だけ足される + this.contentHeight = contentH + boxMinus; + this.boxHeight = this.contentHeight + this.contentT + this.contentB; // padding-box の場合 border だけ足される this.boxSizingOffsetTB = boxMinus; delete this.minContentHeight; delete this.maxContentHeight; delete this.minBoxHeight; delete this.maxBoxHeight; } else { - this.minContentHeight = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minHeight.No ], allowedH ) + boxMinus ); - this.maxContentHeight = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxHeight.No ], allowedH ) + boxMinus ); - this.minBoxHeight = this.minContentHeight - boxMinus + this.contentT + this.contentB; - this.maxBoxHeight = this.maxContentHeight - boxMinus + this.contentT + this.contentB; - - //delete this.contentHeight; - //delete this.scrollHeight; - //delete this.boxHeight; - //delete this.boxSizingOffsetTB; + this.minContentHeight = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minHeight.No ], allowedH ) + boxMinus ); + this.maxContentHeight = XUI_AbstractUINode_ceil( XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxHeight.No ], allowedH ) + boxMinus ); + this.minBoxHeight = this.minContentHeight + this.contentT + this.contentB; + this.maxBoxHeight = this.maxContentHeight + this.contentT + this.contentB; + this.contentHeight = this.minContentHeight; + this.boxHeight = this.minBoxHeight; + this.boxSizingOffsetTB = boxMinus; }; if( this.parentData && this.parentData.layout.overrideAttrsForChild.left ){ @@ -623,17 +627,17 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( borderL = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.borderWidth.No + 3 ], contentW ); contentPlus = 0; switch( box ){ - case 3 : // border-box - contentPlus = borderR + borderL; + case 1 : // content-box + contentPlus = paddingR + paddingL; case 2 : // padding-box - contentPlus += paddingR + paddingL; - // case 1 : // content-box + contentPlus += borderR + borderL; + // case 3 : // border-box }; if( !this.constraintW ){ contentW += contentPlus; - min = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minWidth.No ], contentW ); - max = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxWidth.No ], contentW ); + min = this.minBoxWidth = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minWidth.No ], contentW ); + max = this.maxBoxWidth = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxWidth.No ], contentW ); if( contentW < min && contentPlus < min ){ this.contentWidth = min - contentPlus; } else @@ -643,6 +647,8 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( }; this.contentL = borderL + paddingL; this.contentR = borderR + paddingR; + this.paddingL = paddingL; + this.borderL = borderL; this.boxWidth = this.contentWidth + this.contentL + this.contentR; }; // Height @@ -654,16 +660,16 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( borderB = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.borderWidth.No + 2 ], contentH ); contentPlus = 0; switch( box ){ - case 3 : // border-box - contentPlus = borderT + borderB; + case 1 : // content-box + contentPlus = paddingT + paddingB; case 2 : // padding-box - contentPlus += paddingT + paddingB; - // case 1 : // content-box + contentPlus += borderT + borderB; + // case 3 : // border-box }; if( !this.constraintH ){ contentH += contentPlus; - min = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minHeight.No ], contentH ); - max = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxHeight.No ], contentH ); + min = this.minBoxHeight = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.minHeight.No ], contentH ); + max = this.maxBoxHeight = XUI_AbstractUINode_calcValue( attrs[ XUI_Attr_Support.maxHeight.No ], contentH ); if( contentH < min && contentPlus < min ){ this.contentHeight = min - contentPlus; } else @@ -673,6 +679,8 @@ var XUI_AbstractUINode = X_EventDispatcher[ 'inherits' ]( }; this.contentT = borderT + paddingT; this.contentB = borderB + paddingB; + this.paddingT = paddingT; + this.borderT = borderT; this.boxHeight = this.contentHeight + this.contentT + this.contentB; }; }, diff --git a/0.6.x/js/20_ui/08_Box.js b/0.6.x/js/20_ui/08_Box.js index 1d01e5e..0725fc3 100644 --- a/0.6.x/js/20_ui/08_Box.js +++ b/0.6.x/js/20_ui/08_Box.js @@ -28,10 +28,11 @@ var XUI_Layout_Canvas = X[ 'UI' ][ 'Layout' ][ 'Canvas' ] = XUI_createLayout( { _x = data.contentL; _y = data.contentT; - _w = data.contentWidth; - _h = data.contentHeight; + _w = data.contentWidth// !== XUI_Attr_AUTO ? data.contentWidth : data.minContentWidth; + _h = data.contentHeight// !== XUI_Attr_AUTO ? data.contentHeight : data.minContentHeight; if( ( uinodes = data.uinodes ) && ( l = uinodes.length ) ){ + console.log( _w + ' x ' + _h + ' l:' + l ); for( i = 0; i < l; ++i ){ node = uinodes[ i ]; node.calculate( false, _x, _y, _w, _h ); @@ -45,7 +46,7 @@ var XUI_Layout_Canvas = X[ 'UI' ][ 'Layout' ][ 'Canvas' ] = XUI_createLayout( { if( !isNeedsDetection ){ data.boxX += x; - data.boxY += y; + data.boxY += y; }; return true; } diff --git a/0.6.x/js/20_ui/11_VBox.js b/0.6.x/js/20_ui/11_VBox.js index d56665b..2a6be63 100644 --- a/0.6.x/js/20_ui/11_VBox.js +++ b/0.6.x/js/20_ui/11_VBox.js @@ -49,10 +49,12 @@ var XUI_Layout_Vertical = X[ 'UI' ][ 'Layout' ][ 'Vertical' ] = XUI_createLayout if( l ){ _w = 0; + console.log( '-----------' ); for( i = 0; i < l; ++i ){ node = uinodes[ i ]; node.calculate( detectionPhase, _x, _y, contentW, childH ); _y += node.boxHeight + gapY; + console.dir( node ); // 概算のみ if( autoW ){ if( node.boxWidth !== XUI_Attr_AUTO ){ @@ -74,7 +76,7 @@ var XUI_Layout_Vertical = X[ 'UI' ][ 'Layout' ][ 'Vertical' ] = XUI_createLayout if( detectionPhase ){ if( autoW ) data.contentWidth = _w; - if( autoH ) data.contentHeight = _y; + if( autoH ) data.contentHeight = _y - data.contentT; _y = data.contentT; for( i = 0; i < l; ++i ){ node = uinodes[ i ]; diff --git a/0.6.x/js/20_ui/15_ScrollBox.js b/0.6.x/js/20_ui/15_ScrollBox.js index 1fe9486..73f62b6 100644 --- a/0.6.x/js/20_ui/15_ScrollBox.js +++ b/0.6.x/js/20_ui/15_ScrollBox.js @@ -515,7 +515,7 @@ X.UI.ScrollBox = X.UI.ChromeBox.inherits( { Constructor : function(){ var args = [ - XUI_Layout_Canvas, + XUI_Layout_Vertical, { name : 'ScrollBox-Scroller', role : 'container', -- 2.11.0