laya.ui.js 122 KB

1
  1. !function(exports,Laya){"use strict";class UIConfig{}UIConfig.touchScrollEnable=!0,UIConfig.mouseWheelEnable=!0,UIConfig.showButtons=!0,UIConfig.popupBgColor="#000000",UIConfig.popupBgAlpha=.5,UIConfig.closeDialogOnSide=!0,window.UIConfig=UIConfig;class Styles{}Styles.defaultSizeGrid=[4,4,4,4,0],Styles.labelColor="#000000",Styles.labelPadding=[2,2,2,2],Styles.inputLabelPadding=[1,1,1,3],Styles.buttonStateNum=3,Styles.buttonLabelColors=["#32556b","#32cc6b","#ff0000","#C0C0C0"],Styles.comboBoxItemColors=["#5e95b6","#ffffff","#000000","#8fa4b1","#ffffff"],Styles.scrollBarMinNum=15,Styles.scrollBarDelayTime=500;class AutoBitmap extends Laya.Graphics{constructor(){super(...arguments),this.autoCacheCmd=!0,this._width=0,this._height=0,this.uv=null}destroy(){super.destroy(),this._source=null,this._sizeGrid=null,this._offset=null}get sizeGrid(){return this._sizeGrid}set sizeGrid(value){this._sizeGrid=value.map(v=>+v),this._setChanged()}get width(){return this._width?this._width:this._source?this._source.sourceWidth:0}set width(value){this._width!=value&&(this._width=value,this._setChanged())}get height(){return this._height?this._height:this._source?this._source.sourceHeight:0}set height(value){this._height!=value&&(this._height=value,this._setChanged())}get source(){return this._source}set source(value){value?(this._source=value,this._setChanged()):(this._source=null,this.clear())}_setChanged(){this._isChanged||(this._isChanged=!0,Laya.ILaya.timer.callLater(this,this.changeSource))}changeSource(){this._isChanged=!1;var source=this._source;if(source&&source.bitmap){var width=this.width,height=this.height,sizeGrid=this._sizeGrid,sw=source.sourceWidth,sh=source.sourceHeight;if(sizeGrid&&(sw!==width||sh!==height))return this.clear(),this.draw9Grid(source,0,0,width,height,sizeGrid),void this._repaint();this.clear(),this.drawTexture(source,this._offset?this._offset[0]:0,this._offset?this._offset[1]:0,width,height,null,1,null,null,this.uv),this._repaint()}}drawBitmap(repeat,tex,x,y,width=0,height=0){width<.1||height<.1||(!repeat||tex.width==width&&tex.height==height?this.drawImage(tex,x,y,width,height):this.fillTexture(tex,x,y,width,height))}static getTexture(tex,x,y,width,height){var texture;return width<=0&&(width=1),height<=0&&(height=1),tex.$_GID||(tex.$_GID=Laya.Utils.getGID()),texture&&texture._getSource()||(texture=Laya.Texture.createFromTexture(tex,x,y,width,height)),texture}}Laya.ClassUtils.regClass("laya.ui.AutoBitmap",AutoBitmap),Laya.ClassUtils.regClass("Laya.AutoBitmap",AutoBitmap);class Widget extends Laya.Component{constructor(){super(...arguments),this._top=NaN,this._bottom=NaN,this._left=NaN,this._right=NaN,this._centerX=NaN,this._centerY=NaN}onReset(){this._top=this._bottom=this._left=this._right=this._centerX=this._centerY=NaN}_onEnable(){this.owner.parent?this._onAdded():this.owner.once(Laya.Event.ADDED,this,this._onAdded)}_onDisable(){this.owner.off(Laya.Event.ADDED,this,this._onAdded),this.owner.parent&&this.owner.parent.off(Laya.Event.RESIZE,this,this._onParentResize)}_onAdded(){this.owner.parent&&this.owner.parent.on(Laya.Event.RESIZE,this,this._onParentResize),this.resetLayoutX(),this.resetLayoutY()}_onParentResize(){(this.resetLayoutX()||this.resetLayoutY())&&this.owner.event(Laya.Event.RESIZE)}resetLayoutX(){var owner=this.owner;if(!owner)return!1;var parent=owner.parent;if(parent)if(isNaN(this.centerX)){if(isNaN(this.left))isNaN(this.right)||(owner.x=Math.round(parent.width-owner.displayWidth-this.right+owner.pivotX*owner.scaleX));else if(owner.x=Math.round(this.left+owner.pivotX*owner.scaleX),!isNaN(this.right)){var temp=(parent._width-this.left-this.right)/(owner.scaleX||.01);if(temp!=owner.width)return owner.width=temp,!0}}else owner.x=Math.round(.5*(parent.width-owner.displayWidth)+this.centerX+owner.pivotX*owner.scaleX);return!1}resetLayoutY(){var owner=this.owner;if(!owner)return!1;var parent=owner.parent;if(parent)if(isNaN(this.centerY)){if(isNaN(this.top))isNaN(this.bottom)||(owner.y=Math.round(parent.height-owner.displayHeight-this.bottom+owner.pivotY*owner.scaleY));else if(owner.y=Math.round(this.top+owner.pivotY*owner.scaleY),!isNaN(this.bottom)){var temp=(parent._height-this.top-this.bottom)/(owner.scaleY||.01);if(temp!=owner.height)return owner.height=temp,!0}}else owner.y=Math.round(.5*(parent.height-owner.displayHeight)+this.centerY+owner.pivotY*owner.scaleY);return!1}resetLayout(){this.owner&&(this.resetLayoutX(),this.resetLayoutY())}get top(){return this._top}set top(value){this._top!=value&&(this._top=value,this.resetLayoutY())}get bottom(){return this._bottom}set bottom(value){this._bottom!=value&&(this._bottom=value,this.resetLayoutY())}get left(){return this._left}set left(value){this._left!=value&&(this._left=value,this.resetLayoutX())}get right(){return this._right}set right(value){this._right!=value&&(this._right=value,this.resetLayoutX())}get centerX(){return this._centerX}set centerX(value){this._centerX!=value&&(this._centerX=value,this.resetLayoutX())}get centerY(){return this._centerY}set centerY(value){this._centerY!=value&&(this._centerY=value,this.resetLayoutY())}}Widget.EMPTY=null,Laya.ILaya.regClass(Widget),Widget.EMPTY=new Widget,Laya.ClassUtils.regClass("laya.ui.Widget",Widget),Laya.ClassUtils.regClass("Laya.Widget",Widget);class UIEvent extends Laya.Event{}UIEvent.SHOW_TIP="showtip",UIEvent.HIDE_TIP="hidetip",Laya.ILaya.regClass(UIEvent),Laya.ClassUtils.regClass("laya.ui.UIEvent",UIEvent),Laya.ClassUtils.regClass("Laya.UIEvent",UIEvent);class UIUtils{static fillArray(arr,str,type=null){var temp=arr.concat();if(str)for(var a=str.split(","),i=0,n=Math.min(temp.length,a.length);i<n;i++){var value=a[i];temp[i]="true"==value||"false"!=value&&value,null!=type&&(temp[i]=type(value))}return temp}static toColor(color){return Laya.Utils.toHexColor(color)}static gray(traget,isGray=!0){isGray?UIUtils.addFilter(traget,UIUtils.grayFilter):UIUtils.clearFilter(traget,Laya.ColorFilter)}static addFilter(target,filter){var filters=target.filters||[];filters.push(filter),target.filters=filters}static clearFilter(target,filterType){var filters=target.filters;if(null!=filters&&filters.length>0){for(var i=filters.length-1;i>-1;i--){filters[i]instanceof filterType&&filters.splice(i,1)}target.filters=filters}}static _getReplaceStr(word){return UIUtils.escapeSequence[word]}static adptString(str){return str.replace(/\\(\w)/g,UIUtils._getReplaceStr)}static getBindFun(value){UIUtils._funMap||(UIUtils._funMap=new Laya.WeakObject);var fun=UIUtils._funMap.get(value);if(null==fun){var temp='"'+value+'"',str="(function(data){if(data==null)return;with(data){try{\nreturn "+(temp=temp.replace(/^"\${|}"$/g,"").replace(/\${/g,'"+').replace(/}/g,'+"'))+"\n}catch(e){}}})";fun=window.Laya._runScript(str),UIUtils._funMap.set(value,fun)}return fun}}UIUtils.grayFilter=new Laya.ColorFilter([.3086,.6094,.082,0,0,.3086,.6094,.082,0,0,.3086,.6094,.082,0,0,0,0,0,1,0]),UIUtils.escapeSequence={"\\n":"\n","\\t":"\t"},UIUtils._funMap=null,Laya.ClassUtils.regClass("laya.ui.UIUtils",UIUtils),Laya.ClassUtils.regClass("Laya.UIUtils",UIUtils);class UIComponent extends Laya.Sprite{constructor(createChildren=!0){super(),this._anchorX=NaN,this._anchorY=NaN,this._widget=Widget.EMPTY,createChildren&&(this.preinitialize(),this.createChildren(),this.initialize())}destroy(destroyChild=!0){super.destroy(destroyChild),this._dataSource=null,this._tag=null,this._toolTip=null}preinitialize(){}createChildren(){}initialize(){}get width(){return this.get_width()}get_width(){return this._width?this._width:this.measureWidth()}measureWidth(){var max=0;this.commitMeasure();for(var i=this.numChildren-1;i>-1;i--){var comp=this.getChildAt(i);comp._visible&&(max=Math.max(comp._x+comp.width*comp.scaleX,max))}return max}commitMeasure(){}get height(){return this.get_height()}get_height(){return this._height?this._height:this.measureHeight()}measureHeight(){var max=0;this.commitMeasure();for(var i=this.numChildren-1;i>-1;i--){var comp=this.getChildAt(i);comp._visible&&(max=Math.max(comp._y+comp.height*comp.scaleY,max))}return max}get dataSource(){return this.get_dataSource()}get_dataSource(){return this._dataSource}set dataSource(value){this.set_dataSource(value)}set_dataSource(value){for(var prop in this._dataSource=value,this._dataSource)prop in this&&"function"!=typeof this[prop]&&(this[prop]=this._dataSource[prop])}get top(){return this.get_top()}get_top(){return this._widget.top}set top(value){this.set_top(value)}set_top(value){value!=this._widget.top&&(this._getWidget().top=value)}get bottom(){return this.get_bottom()}get_bottom(){return this._widget.bottom}set bottom(value){this.set_bottom(value)}set_bottom(value){value!=this._widget.bottom&&(this._getWidget().bottom=value)}get left(){return this._widget.left}set left(value){value!=this._widget.left&&(this._getWidget().left=value)}get right(){return this._widget.right}set right(value){value!=this._widget.right&&(this._getWidget().right=value)}get centerX(){return this._widget.centerX}set centerX(value){value!=this._widget.centerX&&(this._getWidget().centerX=value)}get centerY(){return this._widget.centerY}set centerY(value){value!=this._widget.centerY&&(this._getWidget().centerY=value)}_sizeChanged(){isNaN(this._anchorX)||(this.pivotX=this.anchorX*this.width),isNaN(this._anchorY)||(this.pivotY=this.anchorY*this.height),this.event(Laya.Event.RESIZE),this._widget!==Widget.EMPTY&&this._widget.resetLayout()}get tag(){return this._tag}set tag(value){this._tag=value}get toolTip(){return this._toolTip}set toolTip(value){this._toolTip!=value&&(this._toolTip=value,null!=value?(this.on(Laya.Event.MOUSE_OVER,this,this.onMouseOver),this.on(Laya.Event.MOUSE_OUT,this,this.onMouseOut)):(this.off(Laya.Event.MOUSE_OVER,this,this.onMouseOver),this.off(Laya.Event.MOUSE_OUT,this,this.onMouseOut)))}onMouseOver(e){Laya.ILaya.stage.event(UIEvent.SHOW_TIP,this._toolTip)}onMouseOut(e){Laya.ILaya.stage.event(UIEvent.HIDE_TIP,this._toolTip)}get gray(){return this._gray}set gray(value){value!==this._gray&&(this._gray=value,UIUtils.gray(this,value))}get disabled(){return this._disabled}set disabled(value){value!==this._disabled&&(this.gray=this._disabled=value,this.mouseEnabled=!value)}_getWidget(){return this._widget===Widget.EMPTY&&(this._widget=this.addComponent(Widget)),this._widget}set scaleX(value){this.set_scaleX(value)}set_scaleX(value){super.get_scaleX()!=value&&(super.set_scaleX(value),this.event(Laya.Event.RESIZE))}get scaleX(){return super.scaleX}set scaleY(value){this.set_scaleY(value)}set_scaleY(value){super.get_scaleY()!=value&&(super.set_scaleY(value),this.event(Laya.Event.RESIZE))}get scaleY(){return super.scaleY}onCompResize(){this._sizeChanged()}set width(value){this.set_width(value)}set_width(value){super.get_width()!=value&&(super.set_width(value),this.callLater(this._sizeChanged))}set height(value){this.set_height(value)}set_height(value){super.get_height()!=value&&(super.set_height(value),this.callLater(this._sizeChanged))}get anchorX(){return this.get_anchorX()}get_anchorX(){return this._anchorX}set anchorX(value){this.set_anchorX(value)}set_anchorX(value){this._anchorX!=value&&(this._anchorX=value,this.callLater(this._sizeChanged))}get anchorY(){return this.get_anchorY()}get_anchorY(){return this._anchorY}set anchorY(value){this.set_anchorY(value)}set_anchorY(value){this._anchorY!=value&&(this._anchorY=value,this.callLater(this._sizeChanged))}_childChanged(child=null){this.callLater(this._sizeChanged),super._childChanged(child)}}Laya.ILaya.regClass(UIComponent),Laya.ClassUtils.regClass("laya.ui.UIComponent",UIComponent),Laya.ClassUtils.regClass("Laya.UIComponent",UIComponent);class Image extends UIComponent{constructor(skin=null){super(),this.skin=skin}destroy(destroyChild=!0){super.destroy(!0),this._bitmap&&this._bitmap.destroy(),this._bitmap=null}dispose(){this.destroy(!0),Laya.ILaya.loader.clearRes(this._skin)}createChildren(){this.graphics=this._bitmap=new AutoBitmap,this._bitmap.autoCacheCmd=!1}get skin(){return this._skin}set skin(value){if(this._skin!=value)if(this._skin=value,value){var source=Laya.Loader.getRes(value);source?(this.source=source,this.onCompResize()):Laya.ILaya.loader.load(this._skin,Laya.Handler.create(this,this.setSource,[this._skin]),null,Laya.Loader.IMAGE,1,!0,this._group)}else this.source=null}get source(){return this._bitmap.source}set source(value){this._bitmap&&(this._bitmap.source=value,this.event(Laya.Event.LOADED),this.repaint())}get group(){return this._group}set group(value){value&&this._skin&&Laya.Loader.setGroup(this._skin,value),this._group=value}setSource(url,img=null){url===this._skin&&img&&(this.source=img,this.onCompResize())}measureWidth(){return this._bitmap.width}measureHeight(){return this._bitmap.height}set width(value){super.width=value,this._bitmap.width=0==value?1e-7:value}get width(){return super.width}set height(value){super.height=value,this._bitmap.height=0==value?1e-7:value}get height(){return super.height}get sizeGrid(){return this._bitmap.sizeGrid?this._bitmap.sizeGrid.join(","):null}set sizeGrid(value){this._bitmap.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number)}set dataSource(value){this._dataSource=value,"string"==typeof value?this.skin=value:super.dataSource=value}get dataSource(){return super.dataSource}}Laya.ILaya.regClass(Image),Laya.ClassUtils.regClass("laya.ui.Image",Image),Laya.ClassUtils.regClass("Laya.Image",Image);class AdvImage extends Image{constructor(skin=null){super(),this.advsListArr=[],this.resUrl="https://unioncdn.layabox.com/config/iconlist.json",this._http=new Laya.Browser.window.XMLHttpRequest,this._data=[],this._resquestTime=36e4,this._playIndex=0,this._lunboTime=5e3,this.skin=skin,this.setLoadUrl(),this.init(),this.size(120,120)}setLoadUrl(){}init(){this.isSupportJump()?((Laya.Browser.onMiniGame||Laya.Browser.onBDMiniGame)&&Laya.ILaya.timer.loop(this._resquestTime,this,this.onGetAdvsListData),this.onGetAdvsListData(),this.initEvent()):this.visible=!1}initEvent(){this.on(Laya.Event.CLICK,this,this.onAdvsImgClick)}onAdvsImgClick(){this.getCurrentAppidObj()&&this.jumptoGame()}revertAdvsData(){this.advsListArr[this._playIndex]&&(this.visible=!0,this.skin=this.advsListArr[this._playIndex])}isSupportJump(){return Laya.Browser.onMiniGame?window.wx.navigateToMiniProgram instanceof Function:!!Laya.Browser.onBDMiniGame}jumptoGame(){var advsObj=this.advsListArr[this._playIndex];parseInt(advsObj.gameid),advsObj.extendInfo,advsObj.path;Laya.Browser.onMiniGame?this.isSupportJump()&&window.wx.navigateToMiniProgram({appId:this._appid,path:"",extraData:"",envVersion:"release",success:function(){console.log("-------------跳转成功--------------")},fail:function(){console.log("-------------跳转失败--------------")},complete:function(){console.log("-------------跳转接口调用成功--------------"),this.updateAdvsInfo()}.bind(this)}):Laya.Browser.onBDMiniGame||(this.visible=!1)}updateAdvsInfo(){this.visible=!1,this.onLunbo(),Laya.ILaya.timer.loop(this._lunboTime,this,this.onLunbo)}onLunbo(){this._playIndex>=this.advsListArr.length-1?this._playIndex=0:this._playIndex+=1,this.visible=!0,this.revertAdvsData()}getCurrentAppidObj(){return this.advsListArr[this._playIndex]}onGetAdvsListData(){var _this=this,random=AdvImage.randRange(1e4,1e6),url=this.resUrl+"?"+random;this._http.open("get",url,!0),this._http.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),this._http.responseType="text",this._http.onerror=function(e){_this._onError(e)},this._http.onload=function(e){_this._onLoad(e)},this._http.send(null)}static randRange(minNum,maxNum){return Math.floor(Math.random()*(maxNum-minNum+1))+minNum}_onError(e){this.error("Request failed Status:"+this._http.status+" text:"+this._http.statusText)}_onLoad(e){var http=this._http,status=void 0!==http.status?http.status:200;200===status||204===status||0===status?this.complete():this.error("["+http.status+"]"+http.statusText+":"+http.responseURL)}error(message){this.event(Laya.Event.ERROR,message)}complete(){try{this._data=this._http.response||this._http.responseText,this._data=JSON.parse(this._data),this.advsListArr=this._data.list,this._appid=this._data.appid,this.updateAdvsInfo(),this.revertAdvsData()}catch(e){this.error(e.message)}}getAdvsQArr(data){var tempArr=[],gameAdvsObj=Laya.LocalStorage.getJSON("gameObj");for(var key in data){var tempObj=data[key];gameAdvsObj&&gameAdvsObj[tempObj.gameid]&&!tempObj.isQiangZhi||tempArr.push(tempObj)}return tempArr}clear(){var http=this._http;http.onerror=http.onabort=http.onprogress=http.onload=null}destroy(destroyChild=!0){Laya.ILaya.timer.clear(this,this.onLunbo),super.destroy(!0),this.clear(),Laya.ILaya.timer.clear(this,this.onGetAdvsListData)}}Laya.ClassUtils.regClass("laya.ui.AdvImage",AdvImage),Laya.ClassUtils.regClass("Laya.AdvImage",AdvImage);class Box extends UIComponent{set dataSource(value){for(var name in this._dataSource=value,value){var comp=this.getChildByName(name);comp?comp.dataSource=value[name]:name in this&&!(this[name]instanceof Function)&&(this[name]=value[name])}}get dataSource(){return super.dataSource}get bgColor(){return this._bgColor}set bgColor(value){this._bgColor=value,value?(this._onResize(null),this.on(Laya.Event.RESIZE,this,this._onResize)):(this.graphics.clear(),this.off(Laya.Event.RESIZE,this,this._onResize))}_onResize(e){this.graphics.clear(),this.graphics.drawRect(0,0,this.width,this.height,this._bgColor)}}Laya.ILaya.regClass(Box),Laya.ClassUtils.regClass("laya.ui.Box",Box),Laya.ClassUtils.regClass("Laya.Box",Box);class Button extends UIComponent{constructor(skin=null,label=""){super(),this._labelColors=Styles.buttonLabelColors,this._state=0,this._autoSize=!0,this._stateNum=Styles.buttonStateNum,this._stateChanged=!1,this.skin=skin,this.label=label}destroy(destroyChild=!0){super.destroy(destroyChild),this._bitmap&&this._bitmap.destroy(),this._text&&this._text.destroy(destroyChild),this._bitmap=null,this._text=null,this._clickHandler=null,this._labelColors=this._sources=this._strokeColors=null}createChildren(){this.graphics=this._bitmap=new AutoBitmap}createText(){this._text||(this._text=new Laya.Text,this._text.overflow=Laya.Text.HIDDEN,this._text.align="center",this._text.valign="middle",this._text.width=this._width,this._text.height=this._height)}initialize(){1!==this._mouseState&&(this.mouseEnabled=!0,this._setBit(Laya.Const.HAS_MOUSE,!0)),this._createListener(Laya.Event.MOUSE_OVER,this,this.onMouse,null,!1,!1),this._createListener(Laya.Event.MOUSE_OUT,this,this.onMouse,null,!1,!1),this._createListener(Laya.Event.MOUSE_DOWN,this,this.onMouse,null,!1,!1),this._createListener(Laya.Event.MOUSE_UP,this,this.onMouse,null,!1,!1),this._createListener(Laya.Event.CLICK,this,this.onMouse,null,!1,!1)}onMouse(e){if(!1!==this.toggle||!this._selected)return e.type===Laya.Event.CLICK?(this.toggle&&(this.selected=!this._selected),void(this._clickHandler&&this._clickHandler.run())):void(!this._selected&&(this.state=Button.stateMap[e.type]))}get skin(){return this._skin}set skin(value){this._skin!=value&&(this._skin=value,value?Laya.Loader.getRes(value)?this._skinLoaded():Laya.ILaya.loader.load(this._skin,Laya.Handler.create(this,this._skinLoaded),null,Laya.Loader.IMAGE,1):this._skinLoaded())}_skinLoaded(){this.callLater(this.changeClips),this._setStateChanged(),this._sizeChanged(),this.event(Laya.Event.LOADED)}get stateNum(){return this._stateNum}set stateNum(value){"string"==typeof value&&(value=parseInt(value)),this._stateNum!=value&&(this._stateNum=value<1?1:value>3?3:value,this.callLater(this.changeClips))}changeClips(){var img=Laya.Loader.getRes(this._skin);if(img){var width=img.sourceWidth,height=img.sourceHeight/this._stateNum;img.$_GID||(img.$_GID=Laya.Utils.getGID());var key=img.$_GID+"-"+this._stateNum,clips=Laya.WeakObject.I.get(key);if(Laya.Utils.isOkTextureList(clips)||(clips=null),clips)this._sources=clips;else{if(this._sources=[],1===this._stateNum)this._sources.push(img);else for(var i=0;i<this._stateNum;i++)this._sources.push(Laya.Texture.createFromTexture(img,0,height*i,width,height));Laya.WeakObject.I.set(key,this._sources)}this._autoSize?(this._bitmap.width=this._width||width,this._bitmap.height=this._height||height,this._text&&(this._text.width=this._bitmap.width,this._text.height=this._bitmap.height)):this._text&&(this._text.x=width)}else console.log("lose skin",this._skin)}measureWidth(){return this.runCallLater(this.changeClips),this._autoSize?this._bitmap.width:(this.runCallLater(this.changeState),this._bitmap.width+(this._text?this._text.width:0))}measureHeight(){return this.runCallLater(this.changeClips),this._text?Math.max(this._bitmap.height,this._text.height):this._bitmap.height}get label(){return this._text?this._text.text:null}set label(value){(this._text||value)&&(this.createText(),this._text.text!=value&&(value&&!this._text.parent&&this.addChild(this._text),this._text.text=(value+"").replace(/\\n/g,"\n"),this._setStateChanged()))}get selected(){return this._selected}set selected(value){this._selected!=value&&(this._selected=value,this.state=this._selected?2:0,this.event(Laya.Event.CHANGE))}get state(){return this._state}set state(value){this._state!=value&&(this._state=value,this._setStateChanged())}changeState(){this._stateChanged=!1,this.runCallLater(this.changeClips);var index=this._state<this._stateNum?this._state:this._stateNum-1;this._sources&&(this._bitmap.source=this._sources[index]),this.label&&(this._text.color=this._labelColors[index],this._strokeColors&&(this._text.strokeColor=this._strokeColors[index]))}get labelColors(){return this._labelColors.join(",")}set labelColors(value){this._labelColors=UIUtils.fillArray(Styles.buttonLabelColors,value,String),this._setStateChanged()}get strokeColors(){return this._strokeColors?this._strokeColors.join(","):""}set strokeColors(value){this._strokeColors=UIUtils.fillArray(Styles.buttonLabelColors,value,String),this._setStateChanged()}get labelPadding(){return this.createText(),this._text.padding.join(",")}set labelPadding(value){this.createText(),this._text.padding=UIUtils.fillArray(Styles.labelPadding,value,Number)}get labelSize(){return this.createText(),this._text.fontSize}set labelSize(value){this.createText(),this._text.fontSize=value}get labelStroke(){return this.createText(),this._text.stroke}set labelStroke(value){this.createText(),this._text.stroke=value}get labelStrokeColor(){return this.createText(),this._text.strokeColor}set labelStrokeColor(value){this.createText(),this._text.strokeColor=value}get labelBold(){return this.createText(),this._text.bold}set labelBold(value){this.createText(),this._text.bold=value}get labelFont(){return this.createText(),this._text.font}set labelFont(value){this.createText(),this._text.font=value}get labelAlign(){return this.createText(),this._text.align}set labelAlign(value){this.createText(),this._text.align=value}get clickHandler(){return this._clickHandler}set clickHandler(value){this._clickHandler=value}get text(){return this.createText(),this._text}get sizeGrid(){return this._bitmap.sizeGrid?this._bitmap.sizeGrid.join(","):null}set sizeGrid(value){this._bitmap.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number)}set width(value){super.set_width(value),this._autoSize&&(this._bitmap.width=value,this._text&&(this._text.width=value))}get width(){return super.get_width()}set height(value){super.set_height(value),this._autoSize&&(this._bitmap.height=value,this._text&&(this._text.height=value))}get height(){return super.get_height()}set dataSource(value){this._dataSource=value,"number"==typeof value||"string"==typeof value?this.label=value+"":super.set_dataSource(value)}get dataSource(){return super.get_dataSource()}get iconOffset(){return this._bitmap._offset?this._bitmap._offset.join(","):null}set iconOffset(value){this._bitmap._offset=value?UIUtils.fillArray([1,1],value,Number):[]}_setStateChanged(){this._stateChanged||(this._stateChanged=!0,this.callLater(this.changeState))}}Button.stateMap={mouseup:0,mouseover:1,mousedown:2,mouseout:0},Laya.ILaya.regClass(Button),Laya.ClassUtils.regClass("laya.ui.Button",Button),Laya.ClassUtils.regClass("Laya.Button",Button);class CheckBox extends Button{constructor(skin=null,label=""){super(skin,label),this.toggle=!0,this._autoSize=!1}preinitialize(){super.preinitialize(),this.toggle=!0,this._autoSize=!1}initialize(){super.initialize(),this.createText(),this._text.align="left",this._text.valign="top",this._text.width=0}set dataSource(value){this._dataSource=value,value instanceof Boolean?this.selected=value:"string"==typeof value?this.selected="true"===value:super.dataSource=value}get dataSource(){return super.dataSource}}Laya.ILaya.regClass(CheckBox),Laya.ClassUtils.regClass("laya.ui.CheckBox",CheckBox),Laya.ClassUtils.regClass("Laya.CheckBox",CheckBox);class Clip extends UIComponent{constructor(url=null,clipX=1,clipY=1){super(),this._clipX=1,this._clipY=1,this._clipWidth=0,this._clipHeight=0,this._interval=50,this._index=0,this._toIndex=-1,this._clipX=clipX,this._clipY=clipY,this.skin=url}destroy(destroyChild=!0){super.destroy(!0),this._bitmap&&this._bitmap.destroy(),this._bitmap=null,this._sources=null}dispose(){this.destroy(!0),Laya.ILaya.loader.clearRes(this._skin)}createChildren(){this.graphics=this._bitmap=new AutoBitmap}_onDisplay(e){this._isPlaying?this._getBit(Laya.Const.DISPLAYED_INSTAGE)?this.play():this.stop():this._autoPlay&&this.play()}get skin(){return this._skin}set skin(value){this._skin!=value&&(this._skin=value,value?Laya.Loader.getRes(value)?this._skinLoaded():Laya.ILaya.loader.load(this._skin,Laya.Handler.create(this,this._skinLoaded),null,Laya.Loader.IMAGE,1):this._bitmap.source=null)}_skinLoaded(){this._setClipChanged(),this._sizeChanged(),this.event(Laya.Event.LOADED)}get clipX(){return this._clipX}set clipX(value){this._clipX=value||1,this._setClipChanged()}get clipY(){return this._clipY}set clipY(value){this._clipY=value||1,this._setClipChanged()}get clipWidth(){return this._clipWidth}set clipWidth(value){this._clipWidth=value,this._setClipChanged()}get clipHeight(){return this._clipHeight}set clipHeight(value){this._clipHeight=value,this._setClipChanged()}changeClip(){if(this._clipChanged=!1,this._skin){var img=Laya.Loader.getRes(this._skin);img?this.loadComplete(this._skin,img):Laya.ILaya.loader.load(this._skin,Laya.Handler.create(this,this.loadComplete,[this._skin]))}}loadComplete(url,img){if(url===this._skin&&img){var w=this._clipWidth||Math.ceil(img.sourceWidth/this._clipX),h=this._clipHeight||Math.ceil(img.sourceHeight/this._clipY),key=this._skin+w+h,clips=Laya.WeakObject.I.get(key);if(Laya.Utils.isOkTextureList(clips)||(clips=null),clips)this._sources=clips;else{this._sources=[];for(var i=0;i<this._clipY;i++)for(var j=0;j<this._clipX;j++)this._sources.push(Laya.Texture.createFromTexture(img,w*j,h*i,w,h));Laya.WeakObject.I.set(key,this._sources)}this.index=this._index,this.event(Laya.Event.LOADED),this.onCompResize()}}get sources(){return this._sources}set sources(value){this._sources=value,this.index=this._index,this.event(Laya.Event.LOADED)}get group(){return this._group}set group(value){value&&this._skin&&Laya.Loader.setGroup(this._skin,value),this._group=value}set width(value){super.width=value,this._bitmap.width=value}get width(){return super.width}set height(value){super.height=value,this._bitmap.height=value}get height(){return super.height}measureWidth(){return this.runCallLater(this.changeClip),this._bitmap.width}measureHeight(){return this.runCallLater(this.changeClip),this._bitmap.height}get sizeGrid(){return this._bitmap.sizeGrid?this._bitmap.sizeGrid.join(","):null}set sizeGrid(value){this._bitmap.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number)}get index(){return this._index}set index(value){this._index=value,this._bitmap&&this._sources&&(this._bitmap.source=this._sources[value]),this.event(Laya.Event.CHANGE)}get total(){return this.runCallLater(this.changeClip),this._sources?this._sources.length:0}get autoPlay(){return this._autoPlay}set autoPlay(value){this._autoPlay!=value&&(this._autoPlay=value,value?this.play():this.stop())}get interval(){return this._interval}set interval(value){this._interval!=value&&(this._interval=value,this._isPlaying&&this.play())}get isPlaying(){return this._isPlaying}set isPlaying(value){this._isPlaying=value}play(from=0,to=-1){this._isPlaying=!0,this.index=from,this._toIndex=to,this._index++,Laya.ILaya.timer.loop(this.interval,this,this._loop),this.on(Laya.Event.DISPLAY,this,this._onDisplay),this.on(Laya.Event.UNDISPLAY,this,this._onDisplay)}_loop(){this._visible&&this._sources&&(this._index++,this._toIndex>-1&&this._index>=this._toIndex?this.stop():this._index>=this._sources.length&&(this._index=0),this.index=this._index)}stop(){this._isPlaying=!1,Laya.ILaya.timer.clear(this,this._loop),this.event(Laya.Event.COMPLETE)}set dataSource(value){this._dataSource=value,"number"==typeof value||"string"==typeof value?this.index=parseInt(value):super.dataSource=value}get dataSource(){return super.dataSource}get bitmap(){return this._bitmap}_setClipChanged(){this._clipChanged||(this._clipChanged=!0,this.callLater(this.changeClip))}}Laya.ILaya.regClass(Clip),Laya.ClassUtils.regClass("laya.ui.Clip",Clip),Laya.ClassUtils.regClass("Laya.Clip",Clip);class ColorPicker extends UIComponent{constructor(){super(...arguments),this._gridSize=11,this._bgColor="#ffffff",this._borderColor="#000000",this._inputColor="#000000",this._inputBgColor="#efefef",this._colors=[],this._selectedColor="#000000"}destroy(destroyChild=!0){super.destroy(destroyChild),this._colorPanel&&this._colorPanel.destroy(destroyChild),this._colorButton&&this._colorButton.destroy(destroyChild),this._colorPanel=null,this._colorTiles=null,this._colorBlock=null,this._colorInput=null,this._colorButton=null,this._colors=null,this.changeHandler=null}createChildren(){this.addChild(this._colorButton=new Button),this._colorPanel=new Box,this._colorPanel.size(230,166),this._colorPanel.addChild(this._colorTiles=new Laya.Sprite),this._colorPanel.addChild(this._colorBlock=new Laya.Sprite),this._colorPanel.addChild(this._colorInput=new Laya.Input)}initialize(){this._colorButton.on(Laya.Event.CLICK,this,this.onColorButtonClick),this._colorBlock.pos(5,5),this._colorInput.pos(60,5),this._colorInput.size(60,20),this._colorInput.on(Laya.Event.CHANGE,this,this.onColorInputChange),this._colorInput.on(Laya.Event.KEY_DOWN,this,this.onColorFieldKeyDown),this._colorTiles.pos(5,30),this._colorTiles.on(Laya.Event.MOUSE_MOVE,this,this.onColorTilesMouseMove),this._colorTiles.on(Laya.Event.CLICK,this,this.onColorTilesClick),this._colorTiles.size(20*this._gridSize,12*this._gridSize),this._colorPanel.on(Laya.Event.MOUSE_DOWN,this,this.onPanelMouseDown),this.bgColor=this._bgColor}onPanelMouseDown(e){e.stopPropagation()}changePanel(){this._panelChanged=!1;var g=this._colorPanel.graphics;g.clear(!0),g.drawRect(0,0,230,166,this._bgColor,this._borderColor),this.drawBlock(this._selectedColor),this._colorInput.borderColor=this._borderColor,this._colorInput.bgColor=this._inputBgColor,this._colorInput.color=this._inputColor,(g=this._colorTiles.graphics).clear(!0);for(var mainColors=[0,3355443,6710886,10066329,13421772,16777215,16711680,65280,255,16776960,65535,16711935],i=0;i<12;i++)for(var j=0;j<20;j++){var color;color=0===j?mainColors[i]:1===j?0:51*(((3*i+j/6)%3<<0)+3*(i/6<<0))<<16|j%6*51<<8|(i<<0)%6*51;var strColor=UIUtils.toColor(color);this._colors.push(strColor);var x=j*this._gridSize,y=i*this._gridSize;g.drawRect(x,y,this._gridSize,this._gridSize,strColor,"#000000")}}onColorButtonClick(e){this._colorPanel.parent?this.close():this.open()}open(){let stage=Laya.ILaya.stage;var p=this.localToGlobal(new Laya.Point),px=p.x+this._colorPanel.width<=stage.width?p.x:stage.width-this._colorPanel.width,py=p.y+this._colorButton.height;py=py+this._colorPanel.height<=stage.height?py:p.y-this._colorPanel.height,this._colorPanel.pos(px,py),this._colorPanel.zOrder=1001,stage.addChild(this._colorPanel),stage.on(Laya.Event.MOUSE_DOWN,this,this.removeColorBox)}close(){Laya.ILaya.stage.off(Laya.Event.MOUSE_DOWN,this,this.removeColorBox),this._colorPanel.removeSelf()}removeColorBox(e=null){this.close()}onColorFieldKeyDown(e){13==e.keyCode&&(this._colorInput.text?this.selectedColor=this._colorInput.text:this.selectedColor=null,this.close(),e.stopPropagation())}onColorInputChange(e=null){this._colorInput.text?this.drawBlock(this._colorInput.text):this.drawBlock("#FFFFFF")}onColorTilesClick(e){this.selectedColor=this.getColorByMouse(),this.close()}onColorTilesMouseMove(e){this._colorInput.focus=!1;var color=this.getColorByMouse();this._colorInput.text=color,this.drawBlock(color)}getColorByMouse(){var point=this._colorTiles.getMousePoint(),x=Math.floor(point.x/this._gridSize),y=Math.floor(point.y/this._gridSize);return this._colors[20*y+x]}drawBlock(color){var g=this._colorBlock.graphics;g.clear(!0);var showColor=color||"#ffffff";g.drawRect(0,0,50,20,showColor,this._borderColor),color||g.drawLine(0,0,50,20,"#ff0000")}get selectedColor(){return this._selectedColor}set selectedColor(value){this._selectedColor!=value&&(this._selectedColor=this._colorInput.text=value,this.drawBlock(value),this.changeColor(),this.changeHandler&&this.changeHandler.runWith(this._selectedColor),this.event(Laya.Event.CHANGE,Laya.Event.EMPTY.setTo(Laya.Event.CHANGE,this,this)))}get skin(){return this._colorButton.skin}set skin(value){this._colorButton.once(Laya.Event.LOADED,this,this.changeColor),this._colorButton.skin=value}changeColor(){var g=this.graphics;g.clear(!0);var showColor=this._selectedColor||"#000000";g.drawRect(0,0,this._colorButton.width,this._colorButton.height,showColor)}get bgColor(){return this._bgColor}set bgColor(value){this._bgColor=value,this._setPanelChanged()}get borderColor(){return this._borderColor}set borderColor(value){this._borderColor=value,this._setPanelChanged()}get inputColor(){return this._inputColor}set inputColor(value){this._inputColor=value,this._setPanelChanged()}get inputBgColor(){return this._inputBgColor}set inputBgColor(value){this._inputBgColor=value,this._setPanelChanged()}_setPanelChanged(){this._panelChanged||(this._panelChanged=!0,this.callLater(this.changePanel))}}Laya.ILaya.regClass(ColorPicker),Laya.ClassUtils.regClass("laya.ui.ColorPicker",ColorPicker),Laya.ClassUtils.regClass("Laya.ColorPicker",ColorPicker);class Label extends UIComponent{constructor(text=""){super(),this.text=text}destroy(destroyChild=!0){super.destroy(destroyChild),this._tf=null}createChildren(){this.addChild(this._tf=new Laya.Text)}get text(){return this._tf.text}set text(value){this._tf.text!=value&&(value&&(value=UIUtils.adptString(value+"")),this._tf.text=value,this.event(Laya.Event.CHANGE),this._width&&this._height||this.onCompResize())}changeText(text){this._tf.changeText(text)}get wordWrap(){return this._tf.wordWrap}set wordWrap(value){this._tf.wordWrap=value}get color(){return this._tf.color}set color(value){this._tf.color=value}get font(){return this._tf.font}set font(value){this._tf.font=value}get align(){return this._tf.align}set align(value){this._tf.align=value}get valign(){return this._tf.valign}set valign(value){this._tf.valign=value}get bold(){return this._tf.bold}set bold(value){this._tf.bold=value}get italic(){return this._tf.italic}set italic(value){this._tf.italic=value}get leading(){return this._tf.leading}set leading(value){this._tf.leading=value}get fontSize(){return this._tf.fontSize}set fontSize(value){this._tf.fontSize=value}get padding(){return this._tf.padding.join(",")}set padding(value){this._tf.padding=UIUtils.fillArray(Styles.labelPadding,value,Number)}get bgColor(){return this._tf.bgColor}set bgColor(value){this._tf.bgColor=value}get borderColor(){return this._tf.borderColor}set borderColor(value){this._tf.borderColor=value}get stroke(){return this._tf.stroke}set stroke(value){this._tf.stroke=value}get strokeColor(){return this._tf.strokeColor}set strokeColor(value){this._tf.strokeColor=value}get textField(){return this._tf}measureWidth(){return this._tf.width}measureHeight(){return this._tf.height}get width(){return this._width||this._tf.text?super.width:0}set width(value){super.width=value,this._tf.width=value}get height(){return this._height||this._tf.text?super.height:0}set height(value){super.height=value,this._tf.height=value}set dataSource(value){this._dataSource=value,"number"==typeof value||"string"==typeof value?this.text=value+"":super.dataSource=value}get dataSource(){return super.dataSource}get overflow(){return this._tf.overflow}set overflow(value){this._tf.overflow=value}get underline(){return this._tf.underline}set underline(value){this._tf.underline=value}get underlineColor(){return this._tf.underlineColor}set underlineColor(value){this._tf.underlineColor=value}}Laya.ILaya.regClass(Label),Laya.ClassUtils.regClass("laya.ui.Label",Label),Laya.ClassUtils.regClass("Laya.Label",Label);class Slider extends UIComponent{constructor(skin=null){super(),this.isVertical=!0,this.showLabel=!0,this._max=100,this._min=0,this._tick=1,this._value=0,Slider.label||(Slider.label=new Label),this.skin=skin}destroy(destroyChild=!0){super.destroy(destroyChild),this._bg&&this._bg.destroy(destroyChild),this._bar&&this._bar.destroy(destroyChild),this._progress&&this._progress.destroy(destroyChild),this._bg=null,this._bar=null,this._progress=null,this.changeHandler=null}createChildren(){this.addChild(this._bg=new Image),this.addChild(this._bar=new Button)}initialize(){this._bar.on(Laya.Event.MOUSE_DOWN,this,this.onBarMouseDown),this._bg.sizeGrid=this._bar.sizeGrid="4,4,4,4,0",this._progress&&(this._progress.sizeGrid=this._bar.sizeGrid),this.allowClickBack=!0}onBarMouseDown(e){var Laya$1=Laya.ILaya;this._globalSacle||(this._globalSacle=new Laya.Point),this._globalSacle.setTo(this.globalScaleX||.01,this.globalScaleY||.01),this._maxMove=this.isVertical?this.height-this._bar.height:this.width-this._bar.width,this._tx=Laya$1.stage.mouseX,this._ty=Laya$1.stage.mouseY,Laya$1.stage.on(Laya.Event.MOUSE_MOVE,this,this.mouseMove),Laya$1.stage.once(Laya.Event.MOUSE_UP,this,this.mouseUp),Laya$1.stage.once(Laya.Event.MOUSE_OUT,this,this.mouseUp),this.showValueText()}showValueText(){if(this.showLabel){var label=Slider.label;this.addChild(label),label.textField.changeText(this._value+""),this.isVertical?(label.x=this._bar._x+20,label.y=.5*(this._bar.height-label.height)+this._bar._y):(label.y=this._bar._y-20,label.x=.5*(this._bar.width-label.width)+this._bar._x)}}hideValueText(){Slider.label&&Slider.label.removeSelf()}mouseUp(e){let stage=Laya.ILaya.stage;stage.off(Laya.Event.MOUSE_MOVE,this,this.mouseMove),stage.off(Laya.Event.MOUSE_UP,this,this.mouseUp),stage.off(Laya.Event.MOUSE_OUT,this,this.mouseUp),this.sendChangeEvent(Laya.Event.CHANGED),this.hideValueText()}mouseMove(e){let stage=Laya.ILaya.stage;var oldValue=this._value;if(this.isVertical?(this._bar.y+=(stage.mouseY-this._ty)/this._globalSacle.y,this._bar._y>this._maxMove?this._bar.y=this._maxMove:this._bar._y<0&&(this._bar.y=0),this._value=this._bar._y/this._maxMove*(this._max-this._min)+this._min,this._progress&&(this._progress.height=this._bar._y+.5*this._bar.height)):(this._bar.x+=(stage.mouseX-this._tx)/this._globalSacle.x,this._bar._x>this._maxMove?this._bar.x=this._maxMove:this._bar._x<0&&(this._bar.x=0),this._value=this._bar._x/this._maxMove*(this._max-this._min)+this._min,this._progress&&(this._progress.width=this._bar._x+.5*this._bar.width)),this._tx=stage.mouseX,this._ty=stage.mouseY,0!=this._tick){var pow=Math.pow(10,(this._tick+"").length-1);this._value=Math.round(Math.round(this._value/this._tick)*this._tick*pow)/pow}this._value!=oldValue&&this.sendChangeEvent(),this.showValueText()}sendChangeEvent(type=Laya.Event.CHANGE){this.event(type),this.changeHandler&&this.changeHandler.runWith(this._value)}get skin(){return this._skin}set skin(value){this._skin!=value&&(this._skin=value,this._skin&&!Laya.Loader.getRes(this._skin)?Laya.ILaya.loader.load([this._skin,this._skin.replace(".png","$bar.png")],Laya.Handler.create(this,this._skinLoaded)):this._skinLoaded())}_skinLoaded(){this._bg.skin=this._skin,this._bar.skin=this._skin.replace(".png","$bar.png");var progressSkin=this._skin.replace(".png","$progress.png");Laya.Loader.getRes(progressSkin)&&(this._progress||(this.addChild(this._progress=new Image),this._progress.sizeGrid=this._bar.sizeGrid,this.setChildIndex(this._progress,1)),this._progress.skin=progressSkin),this.setBarPoint(),this.callLater(this.changeValue),this._sizeChanged(),this.event(Laya.Event.LOADED)}setBarPoint(){this.isVertical?this._bar.x=Math.round(.5*(this._bg.width-this._bar.width)):this._bar.y=Math.round(.5*(this._bg.height-this._bar.height))}measureWidth(){return Math.max(this._bg.width,this._bar.width)}measureHeight(){return Math.max(this._bg.height,this._bar.height)}_sizeChanged(){super._sizeChanged(),this.isVertical?this._bg.height=this.height:this._bg.width=this.width,this.setBarPoint(),this.changeValue()}get sizeGrid(){return this._bg.sizeGrid}set sizeGrid(value){this._bg.sizeGrid=value,this._bar.sizeGrid=value,this._progress&&(this._progress.sizeGrid=this._bar.sizeGrid)}setSlider(min,max,value){this._value=-1,this._min=min,this._max=max>min?max:min,this.value=value<min?min:value>max?max:value}get tick(){return this._tick}set tick(value){this._tick!=value&&(this._tick=value,this.callLater(this.changeValue))}changeValue(){if(0!=this.tick){var pow=Math.pow(10,(this._tick+"").length-1);this._value=Math.round(Math.round(this._value/this._tick)*this._tick*pow)/pow}this._value=this._value>this._max?this._max:this._value<this._min?this._min:this._value;var num=this._max-this._min;0===num&&(num=1),this.isVertical?(this._bar.y=(this._value-this._min)/num*(this.height-this._bar.height),this._progress&&(this._progress.height=this._bar._y+.5*this._bar.height)):(this._bar.x=(this._value-this._min)/num*(this.width-this._bar.width),this._progress&&(this._progress.width=this._bar._x+.5*this._bar.width))}get max(){return this._max}set max(value){this._max!=value&&(this._max=value,this.callLater(this.changeValue))}get min(){return this._min}set min(value){this._min!=value&&(this._min=value,this.callLater(this.changeValue))}get value(){return this._value}set value(num){if(this._value!=num){var oldValue=this._value;this._value=num,this.changeValue(),this._value!=oldValue&&this.sendChangeEvent()}}get allowClickBack(){return this._allowClickBack}set allowClickBack(value){this._allowClickBack!=value&&(this._allowClickBack=value,value?this._bg.on(Laya.Event.MOUSE_DOWN,this,this.onBgMouseDown):this._bg.off(Laya.Event.MOUSE_DOWN,this,this.onBgMouseDown))}onBgMouseDown(e){var point=this._bg.getMousePoint();this.isVertical?this.value=point.y/(this.height-this._bar.height)*(this._max-this._min)+this._min:this.value=point.x/(this.width-this._bar.width)*(this._max-this._min)+this._min}set dataSource(value){this._dataSource=value,"number"==typeof value||"string"==typeof value?this.value=Number(value):super.dataSource=value}get dataSource(){return super.dataSource}get bar(){return this._bar}}Slider.label=null,Laya.ILaya.regClass(Slider),Laya.ClassUtils.regClass("laya.ui.Slider",Slider),Laya.ClassUtils.regClass("Laya.Slider",Slider);class ScrollBar extends UIComponent{constructor(skin=null){super(),this.rollRatio=.97,this.scaleBar=!0,this.autoHide=!1,this.elasticDistance=0,this.elasticBackTime=500,this._showButtons=UIConfig.showButtons,this._scrollSize=1,this._thumbPercent=1,this._lastOffset=0,this._checkElastic=!1,this._isElastic=!1,this._hide=!1,this._clickOnly=!0,this._touchScrollEnable=UIConfig.touchScrollEnable,this._mouseWheelEnable=UIConfig.mouseWheelEnable,this.skin=skin,this.max=1}destroy(destroyChild=!0){this.stopScroll(),this.target=null,super.destroy(destroyChild),this.upButton&&this.upButton.destroy(destroyChild),this.downButton&&this.downButton.destroy(destroyChild),this.slider&&this.slider.destroy(destroyChild),this.upButton=this.downButton=null,this.slider=null,this.changeHandler=null,this._offsets=null}createChildren(){this.addChild(this.slider=new Slider),this.addChild(this.upButton=new Button),this.addChild(this.downButton=new Button)}initialize(){this.slider.showLabel=!1,this.slider.tick=0,this.slider.on(Laya.Event.CHANGE,this,this.onSliderChange),this.slider.setSlider(0,0,0),this.upButton.on(Laya.Event.MOUSE_DOWN,this,this.onButtonMouseDown),this.downButton.on(Laya.Event.MOUSE_DOWN,this,this.onButtonMouseDown)}onSliderChange(){this._value!=this.slider.value&&(this.value=this.slider.value)}onButtonMouseDown(e){var isUp=e.currentTarget===this.upButton;this.slide(isUp),Laya.ILaya.timer.once(Styles.scrollBarDelayTime,this,this.startLoop,[isUp]),Laya.ILaya.stage.once(Laya.Event.MOUSE_UP,this,this.onStageMouseUp)}startLoop(isUp){Laya.ILaya.timer.frameLoop(1,this,this.slide,[isUp])}slide(isUp){isUp?this.value-=this._scrollSize:this.value+=this._scrollSize}onStageMouseUp(e){Laya.ILaya.timer.clear(this,this.startLoop),Laya.ILaya.timer.clear(this,this.slide)}get skin(){return this._skin}set skin(value){" "!=value&&this._skin!=value&&(this._skin=value,this._skin&&!Laya.Loader.getRes(this._skin)?Laya.ILaya.loader.load([this._skin,this._skin.replace(".png","$up.png"),this._skin.replace(".png","$down.png"),this._skin.replace(".png","$bar.png")],Laya.Handler.create(this,this._skinLoaded)):this._skinLoaded())}_skinLoaded(){this.slider.skin=this._skin,this.callLater(this.changeScrollBar),this._sizeChanged(),this.event(Laya.Event.LOADED)}changeScrollBar(){this.upButton.visible=this._showButtons,this.downButton.visible=this._showButtons,this._showButtons&&(this.upButton.skin=this._skin.replace(".png","$up.png"),this.downButton.skin=this._skin.replace(".png","$down.png")),this.slider.isVertical?this.slider.y=this._showButtons?this.upButton.height:0:this.slider.x=this._showButtons?this.upButton.width:0,this.resetPositions(),this.repaint()}_sizeChanged(){super._sizeChanged(),this.repaint(),this.resetPositions(),this.event(Laya.Event.CHANGE),this.changeHandler&&this.changeHandler.runWith(this.value)}resetPositions(){this.slider.isVertical?this.slider.height=this.height-(this._showButtons?this.upButton.height+this.downButton.height:0):this.slider.width=this.width-(this._showButtons?this.upButton.width+this.downButton.width:0),this.resetButtonPosition()}resetButtonPosition(){this.slider.isVertical?this.downButton.y=this.slider._y+this.slider.height:this.downButton.x=this.slider._x+this.slider.width}measureWidth(){return this.slider.isVertical?this.slider.width:100}measureHeight(){return this.slider.isVertical?100:this.slider.height}setScroll(min,max,value){this.runCallLater(this._sizeChanged),this.slider.setSlider(min,max,value),this.slider.bar.visible=max>0,!this._hide&&this.autoHide&&(this.visible=!1)}get max(){return this.slider.max}set max(value){this.slider.max=value}get min(){return this.slider.min}set min(value){this.slider.min=value}get value(){return this._value}set value(v){v!==this._value&&(this._value=v,this._isElastic||(this.slider._value!=v&&(this.slider._value=v,this.slider.changeValue()),this._value=this.slider._value),this.event(Laya.Event.CHANGE),this.changeHandler&&this.changeHandler.runWith(this._value))}get isVertical(){return this.slider.isVertical}set isVertical(value){this.slider.isVertical=value}get sizeGrid(){return this.slider.sizeGrid}set sizeGrid(value){this.slider.sizeGrid=value}get scrollSize(){return this._scrollSize}set scrollSize(value){this._scrollSize=value}set dataSource(value){this._dataSource=value,"number"==typeof value||"string"==typeof value?this.value=Number(value):super.dataSource=value}get dataSource(){return super.dataSource}get thumbPercent(){return this._thumbPercent}set thumbPercent(value){this.runCallLater(this.changeScrollBar),this.runCallLater(this._sizeChanged),value=value>=1?.99:value,this._thumbPercent=value,this.scaleBar&&(this.slider.isVertical?this.slider.bar.height=Math.max(this.slider.height*value,Styles.scrollBarMinNum):this.slider.bar.width=Math.max(this.slider.width*value,Styles.scrollBarMinNum))}get target(){return this._target}set target(value){this._target&&(this._target.off(Laya.Event.MOUSE_WHEEL,this,this.onTargetMouseWheel),this._target.off(Laya.Event.MOUSE_DOWN,this,this.onTargetMouseDown)),this._target=value,value&&(this._mouseWheelEnable&&this._target.on(Laya.Event.MOUSE_WHEEL,this,this.onTargetMouseWheel),this._touchScrollEnable&&this._target.on(Laya.Event.MOUSE_DOWN,this,this.onTargetMouseDown))}get hide(){return this._hide}set hide(value){this._hide=value,this.visible=!value}get showButtons(){return this._showButtons}set showButtons(value){this._showButtons=value,this.callLater(this.changeScrollBar)}get touchScrollEnable(){return this._touchScrollEnable}set touchScrollEnable(value){this._touchScrollEnable=value,this.target=this._target}get mouseWheelEnable(){return this._mouseWheelEnable}set mouseWheelEnable(value){this._mouseWheelEnable=value,this.target=this._target}onTargetMouseWheel(e){this.value-=e.delta*this._scrollSize,this.target=this._target}onTargetMouseDown(e){this.isLockedFun&&!this.isLockedFun(e)||(this.event(Laya.Event.END),this._clickOnly=!0,this._lastOffset=0,this._checkElastic=!1,this._lastPoint||(this._lastPoint=new Laya.Point),this._lastPoint.setTo(Laya.ILaya.stage.mouseX,Laya.ILaya.stage.mouseY),Laya.ILaya.timer.clear(this,this.tweenMove),Laya.Tween.clearTween(this),Laya.ILaya.stage.once(Laya.Event.MOUSE_UP,this,this.onStageMouseUp2),Laya.ILaya.stage.once(Laya.Event.MOUSE_OUT,this,this.onStageMouseUp2),Laya.ILaya.timer.frameLoop(1,this,this.loop))}startDragForce(){this._clickOnly=!0,this._lastOffset=0,this._checkElastic=!1,this._lastPoint||(this._lastPoint=new Laya.Point),this._lastPoint.setTo(Laya.ILaya.stage.mouseX,Laya.ILaya.stage.mouseY),Laya.ILaya.timer.clear(this,this.tweenMove),Laya.Tween.clearTween(this),Laya.ILaya.stage.once(Laya.Event.MOUSE_UP,this,this.onStageMouseUp2),Laya.ILaya.stage.once(Laya.Event.MOUSE_OUT,this,this.onStageMouseUp2),Laya.ILaya.timer.frameLoop(1,this,this.loop)}cancelDragOp(){Laya.ILaya.stage.off(Laya.Event.MOUSE_UP,this,this.onStageMouseUp2),Laya.ILaya.stage.off(Laya.Event.MOUSE_OUT,this,this.onStageMouseUp2),Laya.ILaya.timer.clear(this,this.tweenMove),Laya.ILaya.timer.clear(this,this.loop),this._target.mouseEnabled=!0}checkTriggers(isTweenMove=!1){return this.value>=0&&this.value-this._lastOffset<=0&&this.triggerDownDragLimit&&this.triggerDownDragLimit(isTweenMove)?(this.cancelDragOp(),this.value=0,!0):!!(this.value<=this.max&&this.value-this._lastOffset>=this.max&&this.triggerUpDragLimit&&this.triggerUpDragLimit(isTweenMove))&&(this.cancelDragOp(),this.value=this.max,!0)}get lastOffset(){return this._lastOffset}startTweenMoveForce(lastOffset){this._lastOffset=lastOffset,Laya.ILaya.timer.frameLoop(1,this,this.tweenMove,[200])}loop(){var mouseY=Laya.ILaya.stage.mouseY,mouseX=Laya.ILaya.stage.mouseX;if(this._lastOffset=this.isVertical?mouseY-this._lastPoint.y:mouseX-this._lastPoint.x,this._clickOnly){if(!(Math.abs(this._lastOffset*(this.isVertical?Laya.ILaya.stage._canvasTransform.getScaleY():Laya.ILaya.stage._canvasTransform.getScaleX()))>1))return;if(this._clickOnly=!1,this.checkTriggers())return;this._offsets||(this._offsets=[]),this._offsets.length=0,this._target.mouseEnabled=!1,!this.hide&&this.autoHide&&(this.alpha=1,this.visible=!0),this.event(Laya.Event.START)}else if(this.checkTriggers())return;this._offsets.push(this._lastOffset),this._lastPoint.x=mouseX,this._lastPoint.y=mouseY,0!==this._lastOffset&&(this._checkElastic||(this.elasticDistance>0?this._checkElastic||0==this._lastOffset||(this._lastOffset>0&&this._value<=this.min||this._lastOffset<0&&this._value>=this.max?(this._isElastic=!0,this._checkElastic=!0):this._isElastic=!1):this._checkElastic=!0),this._isElastic?this._value<=this.min?this._lastOffset>0?this.value-=this._lastOffset*Math.max(0,1-(this.min-this._value)/this.elasticDistance):(this.value-=.5*this._lastOffset,this._value>=this.min&&(this._checkElastic=!1)):this._value>=this.max&&(this._lastOffset<0?this.value-=this._lastOffset*Math.max(0,1-(this._value-this.max)/this.elasticDistance):(this.value-=.5*this._lastOffset,this._value<=this.max&&(this._checkElastic=!1))):this.value-=this._lastOffset)}onStageMouseUp2(e){if(Laya.ILaya.stage.off(Laya.Event.MOUSE_UP,this,this.onStageMouseUp2),Laya.ILaya.stage.off(Laya.Event.MOUSE_OUT,this,this.onStageMouseUp2),Laya.ILaya.timer.clear(this,this.loop),!(this._clickOnly&&this._value>=this.min&&this._value<=this.max))if(this._target.mouseEnabled=!0,this._isElastic)this._value<this.min?Laya.Tween.to(this,{value:this.min},this.elasticBackTime,Laya.Ease.sineOut,Laya.Handler.create(this,this.elasticOver)):this._value>this.max&&Laya.Tween.to(this,{value:this.max},this.elasticBackTime,Laya.Ease.sineOut,Laya.Handler.create(this,this.elasticOver));else{if(!this._offsets)return;this._offsets.length<1&&(this._offsets[0]=this.isVertical?Laya.ILaya.stage.mouseY-this._lastPoint.y:Laya.ILaya.stage.mouseX-this._lastPoint.x);for(var offset=0,n=Math.min(this._offsets.length,3),i=0;i<n;i++)offset+=this._offsets[this._offsets.length-1-i];if(this._lastOffset=offset/n,(offset=Math.abs(this._lastOffset))<2)return void this.event(Laya.Event.END);offset>250&&(this._lastOffset=this._lastOffset>0?250:-250);var dis=Math.round(Math.abs(this.elasticDistance*(this._lastOffset/150)));Laya.ILaya.timer.frameLoop(1,this,this.tweenMove,[dis])}}elasticOver(){this._isElastic=!1,!this.hide&&this.autoHide&&Laya.Tween.to(this,{alpha:0},500),this.event(Laya.Event.END)}tweenMove(maxDistance){var tarSpeed;if((this._lastOffset*=this.rollRatio,!this.checkTriggers(!0))&&(maxDistance>0&&(this._lastOffset>0&&this.value<=this.min?(this._isElastic=!0,tarSpeed=.5*-(this.min-maxDistance-this.value),this._lastOffset>tarSpeed&&(this._lastOffset=tarSpeed)):this._lastOffset<0&&this.value>=this.max&&(this._isElastic=!0,tarSpeed=.5*-(this.max+maxDistance-this.value),this._lastOffset<tarSpeed&&(this._lastOffset=tarSpeed))),this.value-=this._lastOffset,Math.abs(this._lastOffset)<.1)){if(Laya.ILaya.timer.clear(this,this.tweenMove),this._isElastic)return void(this._value<this.min?Laya.Tween.to(this,{value:this.min},this.elasticBackTime,Laya.Ease.sineOut,Laya.Handler.create(this,this.elasticOver)):this._value>this.max?Laya.Tween.to(this,{value:this.max},this.elasticBackTime,Laya.Ease.sineOut,Laya.Handler.create(this,this.elasticOver)):this.elasticOver());this.event(Laya.Event.END),!this.hide&&this.autoHide&&Laya.Tween.to(this,{alpha:0},500)}}stopScroll(){this.onStageMouseUp2(null),Laya.ILaya.timer.clear(this,this.tweenMove),Laya.Tween.clearTween(this)}get tick(){return this.slider.tick}set tick(value){this.slider.tick=value}}Laya.ILaya.regClass(ScrollBar),Laya.ClassUtils.regClass("laya.ui.ScrollBar",ScrollBar),Laya.ClassUtils.regClass("Laya.ScrollBar",ScrollBar);class VScrollBar extends ScrollBar{}Laya.ILaya.regClass(VScrollBar),Laya.ClassUtils.regClass("laya.ui.VScrollBar",VScrollBar),Laya.ClassUtils.regClass("Laya.VScrollBar",VScrollBar);class HScrollBar extends ScrollBar{initialize(){super.initialize(),this.slider.isVertical=!1}}Laya.ILaya.regClass(HScrollBar),Laya.ClassUtils.regClass("laya.ui.HScrollBar",HScrollBar),Laya.ClassUtils.regClass("Laya.HScrollBar",HScrollBar);class List extends Box{constructor(){super(...arguments),this.selectEnable=!1,this.totalPage=0,this._$componentType="List",this._repeatX=0,this._repeatY=0,this._repeatX2=0,this._repeatY2=0,this._spaceX=0,this._spaceY=0,this._cells=[],this._startIndex=0,this._selectedIndex=-1,this._page=0,this._isVertical=!0,this._cellSize=20,this._cellOffset=0,this._createdLine=0,this._offset=new Laya.Point,this._usedCache=null,this._elasticEnabled=!1,this._preLen=0}destroy(destroyChild=!0){this._content&&this._content.destroy(destroyChild),this._scrollBar&&this._scrollBar.destroy(destroyChild),super.destroy(destroyChild),this._content=null,this._scrollBar=null,this._itemRender=null,this._cells=null,this._array=null,this.selectHandler=this.renderHandler=this.mouseHandler=null}createChildren(){this.addChild(this._content=new Box)}set cacheAs(value){super.cacheAs=value,this._scrollBar&&(this._usedCache=null,"none"!==value?this._scrollBar.on(Laya.Event.START,this,this.onScrollStart):this._scrollBar.off(Laya.Event.START,this,this.onScrollStart))}get cacheAs(){return super.cacheAs}onScrollStart(){this._usedCache||(this._usedCache=super.cacheAs),super.cacheAs="none",this._scrollBar.once(Laya.Event.END,this,this.onScrollEnd)}onScrollEnd(){super.cacheAs=this._usedCache}get content(){return this._content}get vScrollBarSkin(){return this._scrollBar?this._scrollBar.skin:null}set vScrollBarSkin(value){this._removePreScrollBar();var scrollBar=new VScrollBar;scrollBar.name="scrollBar",scrollBar.right=0,scrollBar.skin=value,scrollBar.elasticDistance=this._elasticEnabled?200:0,this.scrollBar=scrollBar,this.addChild(scrollBar),this._setCellChanged()}_removePreScrollBar(){var preNode=this.removeChildByName("scrollBar");preNode&&preNode.destroy(!0)}get hScrollBarSkin(){return this._scrollBar?this._scrollBar.skin:null}set hScrollBarSkin(value){this._removePreScrollBar();var scrollBar=new HScrollBar;scrollBar.name="scrollBar",scrollBar.bottom=0,scrollBar.skin=value,scrollBar.elasticDistance=this._elasticEnabled?200:0,this.scrollBar=scrollBar,this.addChild(scrollBar),this._setCellChanged()}get scrollBar(){return this._scrollBar}set scrollBar(value){this._scrollBar!=value&&(this._scrollBar=value,value&&(this._isVertical=this._scrollBar.isVertical,this.addChild(this._scrollBar),this._scrollBar.on(Laya.Event.CHANGE,this,this.onScrollBarChange)))}get itemRender(){return this._itemRender}set itemRender(value){if(this._itemRender!=value){this._itemRender=value;for(var i=this._cells.length-1;i>-1;i--)this._cells[i].destroy();this._cells.length=0,this._setCellChanged()}}set width(value){value!=this._width&&(super.width=value,this._setCellChanged())}get width(){return super.width}set height(value){value!=this._height&&(super.height=value,this._setCellChanged())}get height(){return super.height}get repeatX(){return this._repeatX>0?this._repeatX:this._repeatX2>0?this._repeatX2:1}set repeatX(value){this._repeatX=value,this._setCellChanged()}get repeatY(){return this._repeatY>0?this._repeatY:this._repeatY2>0?this._repeatY2:1}set repeatY(value){this._repeatY=value,this._setCellChanged()}get spaceX(){return this._spaceX}set spaceX(value){this._spaceX=value,this._setCellChanged()}get spaceY(){return this._spaceY}set spaceY(value){this._spaceY=value,this._setCellChanged()}changeCells(){if(this._cellChanged=!1,this._itemRender){this.scrollBar=this.getChildByName("scrollBar");var cell=this._getOneCell(),cellWidth=cell.width+this._spaceX||1,cellHeight=cell.height+this._spaceY||1;this._width>0&&(this._repeatX2=this._isVertical?Math.round(this._width/cellWidth):Math.ceil(this._width/cellWidth)),this._height>0&&(this._repeatY2=this._isVertical?Math.ceil(this._height/cellHeight):Math.round(this._height/cellHeight));var listWidth=this._width?this._width:cellWidth*this.repeatX-this._spaceX,listHeight=this._height?this._height:cellHeight*this.repeatY-this._spaceY;this._cellSize=this._isVertical?cellHeight:cellWidth,this._cellOffset=this._isVertical?cellHeight*Math.max(this._repeatY2,this._repeatY)-listHeight-this._spaceY:cellWidth*Math.max(this._repeatX2,this._repeatX)-listWidth-this._spaceX,this._isVertical&&this.vScrollBarSkin?this._scrollBar.height=listHeight:!this._isVertical&&this.hScrollBarSkin&&(this._scrollBar.width=listWidth),this.setContentSize(listWidth,listHeight);var numX=this._isVertical?this.repeatX:this.repeatY,numY=(this._isVertical?this.repeatY:this.repeatX)+(this._scrollBar?1:0);this._createItems(0,numX,numY),this._createdLine=numY,this._array&&(this.array=this._array,this.runCallLater(this.renderItems))}}_getOneCell(){if(0===this._cells.length){var item=this.createItem();if(this._offset.setTo(item._x,item._y),this.cacheContent)return item;this._cells.push(item)}return this._cells[0]}_createItems(startY,numX,numY){var box=this._content,cell=this._getOneCell(),cellWidth=cell.width+this._spaceX,cellHeight=cell.height+this._spaceY;if(this.cacheContent){var cacheBox=new Box;cacheBox.cacheAs="normal",cacheBox.pos((this._isVertical?0:startY)*cellWidth,(this._isVertical?startY:0)*cellHeight),this._content.addChild(cacheBox),box=cacheBox}else{for(var arr=[],i=this._cells.length-1;i>-1;i--){var item=this._cells[i];item.removeSelf(),arr.push(item)}this._cells.length=0}for(var k=startY;k<numY;k++)for(var l=0;l<numX;l++)(cell=arr&&arr.length?arr.pop():this.createItem()).x=(this._isVertical?l:k)*cellWidth-box._x,cell.y=(this._isVertical?k:l)*cellHeight-box._y,cell.name="item"+(k*numX+l),box.addChild(cell),this.addCell(cell)}createItem(){var arr=[];if("function"==typeof this._itemRender)var box=new this._itemRender;else box=Laya.SceneUtils.createComp(this._itemRender,null,null,arr);if(0==arr.length&&box._watchMap){var watchMap=box._watchMap;for(var name in watchMap)for(var a=watchMap[name],i=0;i<a.length;i++){var watcher=a[i];arr.push(watcher.comp,watcher.prop,watcher.value)}}return arr.length&&(box._$bindData=arr),box}addCell(cell){cell.on(Laya.Event.CLICK,this,this.onCellMouse),cell.on(Laya.Event.RIGHT_CLICK,this,this.onCellMouse),cell.on(Laya.Event.MOUSE_OVER,this,this.onCellMouse),cell.on(Laya.Event.MOUSE_OUT,this,this.onCellMouse),cell.on(Laya.Event.MOUSE_DOWN,this,this.onCellMouse),cell.on(Laya.Event.MOUSE_UP,this,this.onCellMouse),this._cells.push(cell)}_afterInited(){this.initItems()}initItems(){if(!this._itemRender&&null!=this.getChildByName("item0")){var count;this.repeatX=1,count=0;for(var i=0;i<1e4;i++){var cell=this.getChildByName("item"+i);if(!cell)break;this.addCell(cell),count++}this.repeatY=count}}setContentSize(width,height){this._content.width=width,this._content.height=height,(this._scrollBar||0!=this._offset.x||0!=this._offset.y)&&(this._content._style.scrollRect||(this._content.scrollRect=Laya.Rectangle.create()),this._content._style.scrollRect.setTo(-this._offset.x,-this._offset.y,width,height),this._content.scrollRect=this._content.scrollRect),this.event(Laya.Event.RESIZE)}onCellMouse(e){e.type===Laya.Event.MOUSE_DOWN&&(this._isMoved=!1);var cell=e.currentTarget,index=this._startIndex+this._cells.indexOf(cell);index<0||(e.type===Laya.Event.CLICK||e.type===Laya.Event.RIGHT_CLICK?this.selectEnable&&!this._isMoved?this.selectedIndex=index:this.changeCellState(cell,!0,0):e.type!==Laya.Event.MOUSE_OVER&&e.type!==Laya.Event.MOUSE_OUT||this._selectedIndex===index||this.changeCellState(cell,e.type===Laya.Event.MOUSE_OVER,0),this.mouseHandler&&this.mouseHandler.runWith([e,index]))}changeCellState(cell,visible,index){var selectBox=cell.getChildByName("selectBox");selectBox&&(this.selectEnable=!0,selectBox.visible=visible,selectBox.index=index)}_sizeChanged(){super._sizeChanged(),this.setContentSize(this.width,this.height),this._scrollBar&&this.callLater(this.onScrollBarChange)}onScrollBarChange(e=null){this.runCallLater(this.changeCells);var scrollValue=this._scrollBar.value,lineX=this._isVertical?this.repeatX:this.repeatY,lineY=this._isVertical?this.repeatY:this.repeatX,scrollLine=Math.floor(scrollValue/this._cellSize);if(this.cacheContent)num=lineY+1,this._createdLine-scrollLine<num&&(this._createItems(this._createdLine,lineX,this._createdLine+num),this.renderItems(this._createdLine*lineX,0),this._createdLine+=num);else{var index=scrollLine*lineX,num=0;if(index>this._startIndex){num=index-this._startIndex;var down=!0,toIndex=this._startIndex+lineX*(lineY+1);this._isMoved=!0}else index<this._startIndex&&(num=this._startIndex-index,down=!1,toIndex=this._startIndex-1,this._isMoved=!0);for(var i=0;i<num;i++){if(down){var cell=this._cells.shift();this._cells[this._cells.length]=cell;var cellIndex=toIndex+i}else cell=this._cells.pop(),this._cells.unshift(cell),cellIndex=toIndex-i;var pos=Math.floor(cellIndex/lineX)*this._cellSize;this._isVertical?cell.y=pos:cell.x=pos,this.renderItem(cell,cellIndex)}this._startIndex=index,this.changeSelectStatus()}var r=this._content._style.scrollRect;this._isVertical?(r.y=scrollValue-this._offset.y,r.x=-this._offset.x):(r.y=-this._offset.y,r.x=scrollValue-this._offset.x),this._content.scrollRect=r}posCell(cell,cellIndex){if(this._scrollBar){var lineX=this._isVertical?this.repeatX:this.repeatY,pos=(this._isVertical?this.repeatY:this.repeatX,Math.floor(cellIndex/lineX)*this._cellSize);this._isVertical?cell._y=pos:cell.x=pos}}get selectedIndex(){return this._selectedIndex}set selectedIndex(value){this._selectedIndex!=value&&(this._selectedIndex=value,this.changeSelectStatus(),this.event(Laya.Event.CHANGE),this.selectHandler&&this.selectHandler.runWith(value),this.startIndex=this._startIndex)}changeSelectStatus(){for(var i=0,n=this._cells.length;i<n;i++)this.changeCellState(this._cells[i],this._selectedIndex===this._startIndex+i,1)}get selectedItem(){return-1!=this._selectedIndex?this._array[this._selectedIndex]:null}set selectedItem(value){this.selectedIndex=this._array.indexOf(value)}get selection(){return this.getCell(this._selectedIndex)}set selection(value){this.selectedIndex=this._startIndex+this._cells.indexOf(value)}get startIndex(){return this._startIndex}set startIndex(value){this._startIndex=value>0?value:0,this.callLater(this.renderItems)}renderItems(from=0,to=0){for(var i=from,n=to||this._cells.length;i<n;i++)this.renderItem(this._cells[i],this._startIndex+i);this.changeSelectStatus()}renderItem(cell,index){this._array&&index>=0&&index<this._array.length?(cell.visible=!0,cell._$bindData?(cell._dataSource=this._array[index],this._bindData(cell,this._array[index])):cell.dataSource=this._array[index],this.cacheContent||this.posCell(cell,index),this.hasListener(Laya.Event.RENDER)&&this.event(Laya.Event.RENDER,[cell,index]),this.renderHandler&&this.renderHandler.runWith([cell,index])):(cell.visible=!1,cell.dataSource=null)}_bindData(cell,data){for(var arr=cell._$bindData,i=0,n=arr.length;i<n;i++){var ele=arr[i++],prop=arr[i++],value=arr[i],fun=UIUtils.getBindFun(value);ele[prop]=fun.call(this,data)}}get array(){return this._array}set array(value){this.runCallLater(this.changeCells),this._array=value||[],this._preLen=this._array.length;var length=this._array.length;if(this.totalPage=Math.ceil(length/(this.repeatX*this.repeatY)),this._selectedIndex=this._selectedIndex<length?this._selectedIndex:length-1,this.startIndex=this._startIndex,this._scrollBar){this._scrollBar.stopScroll();var numX=this._isVertical?this.repeatX:this.repeatY,numY=this._isVertical?this.repeatY:this.repeatX,lineCount=Math.ceil(length/numX);(this._cellOffset>0?this.totalPage+1:this.totalPage)>1&&lineCount>=numY?(this._scrollBar.scrollSize=this._cellSize,this._scrollBar.thumbPercent=numY/lineCount,this._scrollBar.setScroll(0,(lineCount-numY)*this._cellSize+this._cellOffset,this._scrollBar.value),this._scrollBar.target=this._content):(this._scrollBar.setScroll(0,0,0),this._scrollBar.target=this._content)}}updateArray(array){var freshStart;if(this._array=array,this._array&&((freshStart=this._preLen-this._startIndex)>=0&&this.renderItems(freshStart),this._preLen=this._array.length),this._scrollBar){var length=array.length,numX=this._isVertical?this.repeatX:this.repeatY,numY=this._isVertical?this.repeatY:this.repeatX,lineCount=Math.ceil(length/numX);lineCount>=numY&&(this._scrollBar.thumbPercent=numY/lineCount,this._scrollBar.slider._max=(lineCount-numY)*this._cellSize+this._cellOffset)}}get page(){return this._page}set page(value){this._page=value,this._array&&(this._page=value>0?value:0,this._page=this._page<this.totalPage?this._page:this.totalPage-1,this.startIndex=this._page*this.repeatX*this.repeatY)}get length(){return this._array?this._array.length:0}set dataSource(value){this._dataSource=value,"number"==typeof value||"string"==typeof value?this.selectedIndex=parseInt(value):value instanceof Array?this.array=value:super.dataSource=value}get dataSource(){return super.dataSource}get cells(){return this.runCallLater(this.changeCells),this._cells}get elasticEnabled(){return this._elasticEnabled}set elasticEnabled(value){this._elasticEnabled=value,this._scrollBar&&(this._scrollBar.elasticDistance=value?200:0)}refresh(){this.array=this._array}getItem(index){return index>-1&&index<this._array.length?this._array[index]:null}changeItem(index,source){index>-1&&index<this._array.length&&(this._array[index]=source,index>=this._startIndex&&index<this._startIndex+this._cells.length&&this.renderItem(this.getCell(index),index))}setItem(index,source){this.changeItem(index,source)}addItem(souce){this._array.push(souce),this.array=this._array}addItemAt(souce,index){this._array.splice(index,0,souce),this.array=this._array}deleteItem(index){this._array.splice(index,1),this.array=this._array}getCell(index){return this.runCallLater(this.changeCells),index>-1&&this._cells?this._cells[(index-this._startIndex)%this._cells.length]:null}scrollTo(index){if(this._scrollBar){var numX=this._isVertical?this.repeatX:this.repeatY;this._scrollBar.value=Math.floor(index/numX)*this._cellSize}else this.startIndex=index}tweenTo(index,time=200,complete=null){if(this._scrollBar){this._scrollBar.stopScroll();var numX=this._isVertical?this.repeatX:this.repeatY;Laya.Tween.to(this._scrollBar,{value:Math.floor(index/numX)*this._cellSize},time,null,complete,0,!0)}else this.startIndex=index,complete&&complete.run()}_setCellChanged(){this._cellChanged||(this._cellChanged=!0,this.callLater(this.changeCells))}commitMeasure(){this.runCallLater(this.changeCells)}}Laya.ILaya.regClass(List),Laya.ClassUtils.regClass("laya.ui.List",List),Laya.ClassUtils.regClass("Laya.List",List);class ComboBox extends UIComponent{constructor(skin=null,labels=null){super(),this._visibleNum=6,this._itemColors=Styles.comboBoxItemColors,this._itemSize=12,this._labels=[],this._selectedIndex=-1,this.itemRender=null,this.skin=skin,this.labels=labels}destroy(destroyChild=!0){super.destroy(destroyChild),this._button&&this._button.destroy(destroyChild),this._list&&this._list.destroy(destroyChild),this._button=null,this._list=null,this._itemColors=null,this._labels=null,this._selectHandler=null}createChildren(){this.addChild(this._button=new Button),this._button.text.align="left",this._button.labelPadding="0,0,0,5",this._button.on(Laya.Event.MOUSE_DOWN,this,this.onButtonMouseDown)}_createList(){this._list=new List,this._scrollBarSkin&&(this._list.vScrollBarSkin=this._scrollBarSkin),this._setListEvent(this._list)}_setListEvent(list){this._list.selectEnable=!0,this._list.on(Laya.Event.MOUSE_DOWN,this,this.onListDown),this._list.mouseHandler=Laya.Handler.create(this,this.onlistItemMouse,null,!1),this._list.scrollBar&&this._list.scrollBar.on(Laya.Event.MOUSE_DOWN,this,this.onScrollBarDown)}onListDown(e){e.stopPropagation()}onScrollBarDown(e){e.stopPropagation()}onButtonMouseDown(e){this.callLater(this.switchTo,[!this._isOpen])}get skin(){return this._button.skin}set skin(value){this._button.skin!=value&&(this._button.skin=value,this._listChanged=!0)}measureWidth(){return this._button.width}measureHeight(){return this._button.height}changeList(){this._listChanged=!1;var labelWidth=this.width-2,labelColor=this._itemColors[2];this._itemHeight=this._itemSize+6,this._list.itemRender=this.itemRender||{type:"Box",child:[{type:"Label",props:{name:"label",x:1,padding:"3,3,3,3",width:labelWidth,height:this._itemHeight,fontSize:this._itemSize,color:labelColor}}]},this._list.repeatY=this._visibleNum,this._list.refresh()}onlistItemMouse(e,index){var type=e.type;if(type===Laya.Event.MOUSE_OVER||type===Laya.Event.MOUSE_OUT){if(this._isCustomList)return;var box=this._list.getCell(index);if(!box)return;var label=box.getChildByName("label");label&&(type===Laya.Event.ROLL_OVER?(label.bgColor=this._itemColors[0],label.color=this._itemColors[1]):(label.bgColor=null,label.color=this._itemColors[2]))}else type===Laya.Event.CLICK&&(this.selectedIndex=index,this.isOpen=!1)}switchTo(value){this.isOpen=value}changeOpen(){this.isOpen=!this._isOpen}set width(value){super.width=value,this._button.width=this._width,this._itemChanged=!0,this._listChanged=!0}get width(){return super.width}set height(value){super.height=value,this._button.height=this._height}get height(){return super.height}get labels(){return this._labels.join(",")}set labels(value){this._labels.length>0&&(this.selectedIndex=-1),value?this._labels=value.split(","):this._labels.length=0,this._itemChanged=!0}changeItem(){if(this._itemChanged=!1,this._listHeight=this._labels.length>0?Math.min(this._visibleNum,this._labels.length)*this._itemHeight:this._itemHeight,!this._isCustomList){var g=this._list.graphics;g.clear(!0),g.drawRect(0,0,this.width-1,this._listHeight,this._itemColors[4],this._itemColors[3])}var a=this._list.array||[];a.length=0;for(var i=0,n=this._labels.length;i<n;i++)a.push({label:this._labels[i]});this._list.height=this._listHeight,this._list.array=a}get selectedIndex(){return this._selectedIndex}set selectedIndex(value){this._selectedIndex!=value&&(this._selectedIndex=value,this._labels.length>0?this.changeSelected():this.callLater(this.changeSelected),this.event(Laya.Event.CHANGE,[Laya.Event.EMPTY.setTo(Laya.Event.CHANGE,this,this)]),this._selectHandler&&this._selectHandler.runWith(this._selectedIndex))}changeSelected(){this._button.label=this.selectedLabel}get selectHandler(){return this._selectHandler}set selectHandler(value){this._selectHandler=value}get selectedLabel(){return this._selectedIndex>-1&&this._selectedIndex<this._labels.length?this._labels[this._selectedIndex]:null}set selectedLabel(value){this.selectedIndex=this._labels.indexOf(value)}get visibleNum(){return this._visibleNum}set visibleNum(value){this._visibleNum=value,this._listChanged=!0}get itemColors(){return String(this._itemColors)}set itemColors(value){this._itemColors=UIUtils.fillArray(this._itemColors,value,String),this._listChanged=!0}get itemSize(){return this._itemSize}set itemSize(value){this._itemSize=value,this._listChanged=!0}get isOpen(){return this._isOpen}set isOpen(value){if(this._isOpen!=value)if(this._isOpen=value,this._button.selected=this._isOpen,this._isOpen){this._list||this._createList(),this._listChanged&&!this._isCustomList&&this.changeList(),this._itemChanged&&this.changeItem();var p=this.localToGlobal(Laya.Point.TEMP.setTo(0,0)),py=p.y+this._button.height;py=py+this._listHeight<=Laya.ILaya.stage.height?py:p.y-this._listHeight,this._list.pos(p.x,py),this._list.zOrder=1001,Laya.ILaya.stage.addChild(this._list),Laya.ILaya.stage.once(Laya.Event.MOUSE_DOWN,this,this.removeList),Laya.ILaya.stage.on(Laya.Event.MOUSE_WHEEL,this,this._onStageMouseWheel),this._list.selectedIndex=this._selectedIndex}else this._list&&this._list.removeSelf()}_onStageMouseWheel(e){this._list&&!this._list.contains(e.target)&&this.removeList(null)}removeList(e){Laya.ILaya.stage.off(Laya.Event.MOUSE_DOWN,this,this.removeList),Laya.ILaya.stage.off(Laya.Event.MOUSE_WHEEL,this,this._onStageMouseWheel),this.isOpen=!1}get scrollBarSkin(){return this._scrollBarSkin}set scrollBarSkin(value){this._scrollBarSkin=value}get sizeGrid(){return this._button.sizeGrid}set sizeGrid(value){this._button.sizeGrid=value}get scrollBar(){return this.list.scrollBar}get button(){return this._button}get list(){return this._list||this._createList(),this._list}set list(value){value&&(value.removeSelf(),this._isCustomList=!0,this._list=value,this._setListEvent(value),this._itemHeight=value.getCell(0).height+value.spaceY)}set dataSource(value){this._dataSource=value,"number"==typeof value||"string"==typeof value?this.selectedIndex=parseInt(value):value instanceof Array?this.labels=value.join(","):super.dataSource=value}get dataSource(){return super.dataSource}get labelColors(){return this._button.labelColors}set labelColors(value){this._button.labelColors!=value&&(this._button.labelColors=value)}get labelPadding(){return this._button.text.padding.join(",")}set labelPadding(value){this._button.text.padding=UIUtils.fillArray(Styles.labelPadding,value,Number)}get labelSize(){return this._button.text.fontSize}set labelSize(value){this._button.text.fontSize=value}get labelBold(){return this._button.text.bold}set labelBold(value){this._button.text.bold=value}get labelFont(){return this._button.text.font}set labelFont(value){this._button.text.font=value}get stateNum(){return this._button.stateNum}set stateNum(value){this._button.stateNum=value}}Laya.ILaya.regClass(ComboBox),Laya.ClassUtils.regClass("laya.ui.ComboBox",ComboBox),Laya.ClassUtils.regClass("Laya.ComboBox",ComboBox);class ProgressBar extends UIComponent{constructor(skin=null){super(),this._value=.5,this.skin=skin}destroy(destroyChild=!0){super.destroy(destroyChild),this._bg&&this._bg.destroy(destroyChild),this._bar&&this._bar.destroy(destroyChild),this._bg=this._bar=null,this.changeHandler=null}createChildren(){this.addChild(this._bg=new Image),this.addChild(this._bar=new Image),this._bar._bitmap.autoCacheCmd=!1}get skin(){return this._skin}set skin(value){this._skin!=value&&(this._skin=value,this._skin&&!Laya.Loader.getRes(this._skin)?Laya.ILaya.loader.load(this._skin,Laya.Handler.create(this,this._skinLoaded),null,Laya.Loader.IMAGE,1):this._skinLoaded())}_skinLoaded(){this._bg.skin=this._skin,this._bar.skin=this._skin.replace(".png","$bar.png"),this.callLater(this.changeValue),this._sizeChanged(),this.event(Laya.Event.LOADED)}measureWidth(){return this._bg.width}measureHeight(){return this._bg.height}get value(){return this._value}set value(num){this._value!=num&&(num=num>1?1:num<0?0:num,this._value=num,this.callLater(this.changeValue),this.event(Laya.Event.CHANGE),this.changeHandler&&this.changeHandler.runWith(num))}changeValue(){if(this.sizeGrid){var grid=this.sizeGrid.split(","),left=Number(grid[3]),right=Number(grid[1]),sw=(this.width-left-right)*this._value;this._bar.width=left+right+sw,this._bar.visible=this._bar.width>left+right}else this._bar.width=this.width*this._value}get bar(){return this._bar}get bg(){return this._bg}get sizeGrid(){return this._bg.sizeGrid}set sizeGrid(value){this._bg.sizeGrid=this._bar.sizeGrid=value}set width(value){super.width=value,this._bg.width=this._width,this.callLater(this.changeValue)}get width(){return super.width}set height(value){super.height=value,this._bg.height=this._height,this._bar.height=this._height}get height(){return super.height}set dataSource(value){this._dataSource=value,"number"==typeof value||"string"==typeof value?this.value=Number(value):super.dataSource=value}get dataSource(){return super.dataSource}}Laya.ILaya.regClass(ProgressBar),Laya.ClassUtils.regClass("laya.ui.ProgressBar",ProgressBar),Laya.ClassUtils.regClass("Laya.ProgressBar",ProgressBar);class Radio extends Button{constructor(skin=null,label=""){super(skin,label),this.toggle=!1,this._autoSize=!1}destroy(destroyChild=!0){super.destroy(destroyChild),this._value=null}preinitialize(){super.preinitialize(),this.toggle=!1,this._autoSize=!1}initialize(){super.initialize(),this.createText(),this._text.align="left",this._text.valign="top",this._text.width=0,this.on(Laya.Event.CLICK,this,this.onClick)}onClick(e){this.selected=!0}get value(){return null!=this._value?this._value:this.label}set value(obj){this._value=obj}}Laya.ILaya.regClass(Radio),Laya.ClassUtils.regClass("laya.ui.Radio",Radio),Laya.ClassUtils.regClass("Laya.Radio",Radio);class UIGroup extends Box{constructor(labels=null,skin=null){super(),this._selectedIndex=-1,this._direction="horizontal",this._space=0,this.skin=skin,this.labels=labels}preinitialize(){this.mouseEnabled=!0}destroy(destroyChild=!0){super.destroy(destroyChild),this._items&&(this._items.length=0),this._items=null,this.selectHandler=null}addItem(item,autoLayOut=!0){var display=item,index=this._items.length;if(display.name="item"+index,this.addChild(display),this.initItems(),autoLayOut&&index>0){var preItem=this._items[index-1];"horizontal"==this._direction?display.x=preItem._x+preItem.width+this._space:display.y=preItem._y+preItem.height+this._space}else autoLayOut&&(display.x=0,display.y=0);return index}delItem(item,autoLayOut=!0){var index=this._items.indexOf(item);if(-1!=index){var newIndex,display=item;this.removeChild(display);for(var i=index+1,n=this._items.length;i<n;i++){var child=this._items[i];child.name="item"+(i-1),autoLayOut&&("horizontal"==this._direction?child.x-=display.width+this._space:child.y-=display.height+this._space)}if(this.initItems(),this._selectedIndex>-1)newIndex=this._selectedIndex<this._items.length?this._selectedIndex:this._selectedIndex-1,this._selectedIndex=-1,this.selectedIndex=newIndex}}_afterInited(){this.initItems()}initItems(){this._items||(this._items=[]),this._items.length=0;for(var i=0;i<1e4;i++){var item=this.getChildByName("item"+i);if(null==item)break;this._items.push(item),item.selected=i===this._selectedIndex,item.clickHandler=Laya.Handler.create(this,this.itemClick,[i],!1)}}itemClick(index){this.selectedIndex=index}get selectedIndex(){return this._selectedIndex}set selectedIndex(value){this._selectedIndex!=value&&(this.setSelect(this._selectedIndex,!1),this._selectedIndex=value,this.setSelect(value,!0),this.event(Laya.Event.CHANGE),this.selectHandler&&this.selectHandler.runWith(this._selectedIndex))}setSelect(index,selected){this._items&&index>-1&&index<this._items.length&&(this._items[index].selected=selected)}get skin(){return this._skin}set skin(value){this._skin!=value&&(this._skin=value,this._skin&&!Laya.Loader.getRes(this._skin)?Laya.ILaya.loader.load(this._skin,Laya.Handler.create(this,this._skinLoaded),null,Laya.Loader.IMAGE,1):this._skinLoaded())}_skinLoaded(){this._setLabelChanged(),this.event(Laya.Event.LOADED)}get labels(){return this._labels}set labels(value){if(this._labels!=value){if(this._labels=value,this.removeChildren(),this._setLabelChanged(),this._labels)for(var a=this._labels.split(","),i=0,n=a.length;i<n;i++){var item=this.createItem(this._skin,a[i]);item.name="item"+i,this.addChild(item)}this.initItems()}}createItem(skin,label){return null}get labelColors(){return this._labelColors}set labelColors(value){this._labelColors!=value&&(this._labelColors=value,this._setLabelChanged())}get labelStroke(){return this._labelStroke}set labelStroke(value){this._labelStroke!=value&&(this._labelStroke=value,this._setLabelChanged())}get labelStrokeColor(){return this._labelStrokeColor}set labelStrokeColor(value){this._labelStrokeColor!=value&&(this._labelStrokeColor=value,this._setLabelChanged())}get strokeColors(){return this._strokeColors}set strokeColors(value){this._strokeColors!=value&&(this._strokeColors=value,this._setLabelChanged())}get labelSize(){return this._labelSize}set labelSize(value){this._labelSize!=value&&(this._labelSize=value,this._setLabelChanged())}get stateNum(){return this._stateNum}set stateNum(value){this._stateNum!=value&&(this._stateNum=value,this._setLabelChanged())}get labelBold(){return this._labelBold}set labelBold(value){this._labelBold!=value&&(this._labelBold=value,this._setLabelChanged())}get labelFont(){return this._labelFont}set labelFont(value){this._labelFont!=value&&(this._labelFont=value,this._setLabelChanged())}get labelPadding(){return this._labelPadding}set labelPadding(value){this._labelPadding!=value&&(this._labelPadding=value,this._setLabelChanged())}get direction(){return this._direction}set direction(value){this._direction=value,this._setLabelChanged()}get space(){return this._space}set space(value){this._space=value,this._setLabelChanged()}changeLabels(){if(this._labelChanged=!1,this._items)for(var left=0,i=0,n=this._items.length;i<n;i++){var btn=this._items[i];this._skin&&(btn.skin=this._skin),this._labelColors&&(btn.labelColors=this._labelColors),this._labelSize&&(btn.labelSize=this._labelSize),this._labelStroke&&(btn.labelStroke=this._labelStroke),this._labelStrokeColor&&(btn.labelStrokeColor=this._labelStrokeColor),this._strokeColors&&(btn.strokeColors=this._strokeColors),this._labelBold&&(btn.labelBold=this._labelBold),this._labelPadding&&(btn.labelPadding=this._labelPadding),this._labelAlign&&(btn.labelAlign=this._labelAlign),this._stateNum&&(btn.stateNum=this._stateNum),this._labelFont&&(btn.labelFont=this._labelFont),"horizontal"===this._direction?(btn.y=0,btn.x=left,left+=btn.width+this._space):(btn.x=0,btn.y=left,left+=btn.height+this._space)}this._sizeChanged()}commitMeasure(){this.runCallLater(this.changeLabels)}get items(){return this._items}get selection(){return this._selectedIndex>-1&&this._selectedIndex<this._items.length?this._items[this._selectedIndex]:null}set selection(value){this.selectedIndex=this._items.indexOf(value)}set dataSource(value){this._dataSource=value,"number"==typeof value||"string"==typeof value?this.selectedIndex=parseInt(value):value instanceof Array?this.labels=value.join(","):super.dataSource=value}get dataSource(){return super.dataSource}_setLabelChanged(){this._labelChanged||(this._labelChanged=!0,this.callLater(this.changeLabels))}}Laya.ILaya.regClass(UIGroup),Laya.ClassUtils.regClass("laya.ui.UIGroup",UIGroup),Laya.ClassUtils.regClass("Laya.UIGroup",UIGroup);class RadioGroup extends UIGroup{createItem(skin,label){return new Radio(skin,label)}}Laya.ILaya.regClass(RadioGroup),Laya.ClassUtils.regClass("laya.ui.RadioGroup",RadioGroup),Laya.ClassUtils.regClass("Laya.RadioGroup",RadioGroup);class Tab extends UIGroup{createItem(skin,label){return new Button(skin,label)}}Laya.ILaya.regClass(Tab),Laya.ClassUtils.regClass("laya.ui.Tab",Tab),Laya.ClassUtils.regClass("Laya.Tab",Tab);class ViewStack extends Box{constructor(){super(...arguments),this._setIndexHandler=Laya.Handler.create(this,this.setIndex,null,!1)}setItems(views){this.removeChildren();for(var index=0,i=0,n=views.length;i<n;i++){var item=views[i];item&&(item.name="item"+index,this.addChild(item),index++)}this.initItems()}addItem(view){view.name="item"+this._items.length,this.addChild(view),this.initItems()}_afterInited(){this.initItems()}initItems(){this._items=[];for(var i=0;i<1e4;i++){var item=this.getChildByName("item"+i);if(null==item)break;this._items.push(item),item.visible=i==this._selectedIndex}}get selectedIndex(){return this._selectedIndex}set selectedIndex(value){this._selectedIndex!=value&&(this.setSelect(this._selectedIndex,!1),this._selectedIndex=value,this.setSelect(this._selectedIndex,!0))}setSelect(index,selected){this._items&&index>-1&&index<this._items.length&&(this._items[index].visible=selected)}get selection(){return this._selectedIndex>-1&&this._selectedIndex<this._items.length?this._items[this._selectedIndex]:null}set selection(value){this.selectedIndex=this._items.indexOf(value)}get setIndexHandler(){return this._setIndexHandler}set setIndexHandler(value){this._setIndexHandler=value}setIndex(index){this.selectedIndex=index}get items(){return this._items}set dataSource(value){if(this._dataSource=value,"number"==typeof value||"string"==typeof value)this.selectedIndex=parseInt(value);else for(var prop in this._dataSource)prop in this&&(this[prop]=this._dataSource[prop])}get dataSource(){return super.dataSource}}Laya.ILaya.regClass(ViewStack),Laya.ClassUtils.regClass("laya.ui.ViewStack",ViewStack),Laya.ClassUtils.regClass("Laya.ViewStack",ViewStack);class TextInput extends Label{constructor(text=""){super(),this.text=text,this.skin=this.skin}preinitialize(){this.mouseEnabled=!0}destroy(destroyChild=!0){super.destroy(destroyChild),this._bg&&this._bg.destroy(),this._bg=null}createChildren(){this.addChild(this._tf=new Laya.Input),this._tf.padding=Styles.inputLabelPadding,this._tf.on(Laya.Event.INPUT,this,this._onInput),this._tf.on(Laya.Event.ENTER,this,this._onEnter),this._tf.on(Laya.Event.BLUR,this,this._onBlur),this._tf.on(Laya.Event.FOCUS,this,this._onFocus)}_onFocus(){this.event(Laya.Event.FOCUS,this)}_onBlur(){this.event(Laya.Event.BLUR,this)}_onInput(){this.event(Laya.Event.INPUT,this)}_onEnter(){this.event(Laya.Event.ENTER,this)}initialize(){this.width=128,this.height=22}get bg(){return this._bg}set bg(value){this.graphics=this._bg=value}get skin(){return this._skin}set skin(value){this._skin!=value&&(this._skin=value,this._skin&&!Laya.Loader.getRes(this._skin)?Laya.ILaya.loader.load(this._skin,Laya.Handler.create(this,this._skinLoaded),null,Laya.Loader.IMAGE,1):this._skinLoaded())}_skinLoaded(){this._bg||(this.graphics=this._bg=new AutoBitmap),this._bg.source=Laya.Loader.getRes(this._skin),this._width&&(this._bg.width=this._width),this._height&&(this._bg.height=this._height),this._sizeChanged(),this.event(Laya.Event.LOADED)}get sizeGrid(){return this._bg&&this._bg.sizeGrid?this._bg.sizeGrid.join(","):null}set sizeGrid(value){this._bg||(this.graphics=this._bg=new AutoBitmap),this._bg.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number)}set text(value){this._tf.text!=value&&(value+="",this._tf.text=value,this.event(Laya.Event.CHANGE))}get text(){return super.text}set width(value){super.width=value,this._bg&&(this._bg.width=value)}get width(){return super.width}set height(value){super.height=value,this._bg&&(this._bg.height=value)}get height(){return super.height}get multiline(){return this._tf.multiline}set multiline(value){this._tf.multiline=value}set editable(value){this._tf.editable=value}get editable(){return this._tf.editable}select(){this._tf.select()}get restrict(){return this._tf.restrict}set restrict(pattern){this._tf.restrict=pattern}get prompt(){return this._tf.prompt}set prompt(value){this._tf.prompt=value}get promptColor(){return this._tf.promptColor}set promptColor(value){this._tf.promptColor=value}get maxChars(){return this._tf.maxChars}set maxChars(value){this._tf.maxChars=value}get focus(){return this._tf.focus}set focus(value){this._tf.focus=value}get type(){return this._tf.type}set type(value){this._tf.type=value}setSelection(startIndex,endIndex){this._tf.setSelection(startIndex,endIndex)}}Laya.ILaya.regClass(TextInput),Laya.ClassUtils.regClass("laya.ui.TextInput",TextInput),Laya.ClassUtils.regClass("Laya.TextInput",TextInput);class TextArea extends TextInput{constructor(text=""){super(text),this.on(Laya.Event.CHANGE,this,this._onTextChange)}_onTextChange(){this.callLater(this.changeScroll)}destroy(destroyChild=!0){super.destroy(destroyChild),this._vScrollBar&&this._vScrollBar.destroy(),this._hScrollBar&&this._hScrollBar.destroy(),this._vScrollBar=null,this._hScrollBar=null}initialize(){this.width=180,this.height=150,this._tf.wordWrap=!0,this.multiline=!0}set width(value){super.width=value,this.callLater(this.changeScroll)}get width(){return super.width}set height(value){super.height=value,this.callLater(this.changeScroll)}get height(){return super.height}get vScrollBarSkin(){return this._vScrollBar?this._vScrollBar.skin:null}set vScrollBarSkin(value){null==this._vScrollBar&&(this.addChild(this._vScrollBar=new VScrollBar),this._vScrollBar.on(Laya.Event.CHANGE,this,this.onVBarChanged),this._vScrollBar.target=this._tf,this.callLater(this.changeScroll)),this._vScrollBar.skin=value}get hScrollBarSkin(){return this._hScrollBar?this._hScrollBar.skin:null}set hScrollBarSkin(value){null==this._hScrollBar&&(this.addChild(this._hScrollBar=new HScrollBar),this._hScrollBar.on(Laya.Event.CHANGE,this,this.onHBarChanged),this._hScrollBar.mouseWheelEnable=!1,this._hScrollBar.target=this._tf,this.callLater(this.changeScroll)),this._hScrollBar.skin=value}onVBarChanged(e){this._tf.scrollY!=this._vScrollBar.value&&(this._tf.scrollY=this._vScrollBar.value)}onHBarChanged(e){this._tf.scrollX!=this._hScrollBar.value&&(this._tf.scrollX=this._hScrollBar.value)}get vScrollBar(){return this._vScrollBar}get hScrollBar(){return this._hScrollBar}get maxScrollY(){return this._tf.maxScrollY}get scrollY(){return this._tf.scrollY}get maxScrollX(){return this._tf.maxScrollX}get scrollX(){return this._tf.scrollX}changeScroll(){var vShow=this._vScrollBar&&this._tf.maxScrollY>0,hShow=this._hScrollBar&&this._tf.maxScrollX>0,showWidth=vShow?this._width-this._vScrollBar.width:this._width,showHeight=hShow?this._height-this._hScrollBar.height:this._height,padding=this._tf.padding||Styles.labelPadding;this._tf.width=showWidth,this._tf.height=showHeight,this._vScrollBar&&(this._vScrollBar.x=this._width-this._vScrollBar.width-padding[2],this._vScrollBar.y=padding[1],this._vScrollBar.height=this._height-(hShow?this._hScrollBar.height:0)-padding[1]-padding[3],this._vScrollBar.scrollSize=1,this._vScrollBar.thumbPercent=showHeight/Math.max(this._tf.textHeight,showHeight),this._vScrollBar.setScroll(1,this._tf.maxScrollY,this._tf.scrollY),this._vScrollBar.visible=vShow),this._hScrollBar&&(this._hScrollBar.x=padding[0],this._hScrollBar.y=this._height-this._hScrollBar.height-padding[3],this._hScrollBar.width=this._width-(vShow?this._vScrollBar.width:0)-padding[0]-padding[2],this._hScrollBar.scrollSize=Math.max(.033*showWidth,1),this._hScrollBar.thumbPercent=showWidth/Math.max(this._tf.textWidth,showWidth),this._hScrollBar.setScroll(0,this.maxScrollX,this.scrollX),this._hScrollBar.visible=hShow)}scrollTo(y){this.commitMeasure(),this._tf.scrollY=y}}Laya.ILaya.regClass(TextArea),Laya.ClassUtils.regClass("laya.ui.TextArea",TextArea),Laya.ClassUtils.regClass("Laya.TextArea",TextArea);class ScaleBox extends Box{constructor(){super(...arguments),this._oldW=0,this._oldH=0}onEnable(){Laya.ILaya.stage.on("resize",this,this.onResize),this.onResize()}onDisable(){Laya.ILaya.stage.off("resize",this,this.onResize)}onResize(){let stage=Laya.ILaya.stage;if(this.width>0&&this.height>0){var scale=Math.min(stage.width/this._oldW,stage.height/this._oldH);super.width=stage.width,super.height=stage.height,this.scale(scale,scale)}}set width(value){super.width=value,this._oldW=value}get width(){return super.width}set height(value){super.height=value,this._oldH=value}get height(){return super.height}}Laya.ILaya.regClass(ScaleBox),Laya.ClassUtils.regClass("laya.ui.ScaleBox",ScaleBox),Laya.ClassUtils.regClass("Laya.ScaleBox",ScaleBox);class HSlider extends Slider{constructor(skin=null){super(skin),this.isVertical=!1}}Laya.ILaya.regClass(HSlider),Laya.ClassUtils.regClass("laya.ui.HSlider",HSlider),Laya.ClassUtils.regClass("Laya.HSlider",HSlider);class Panel extends Box{constructor(){super(),this._usedCache=null,this._elasticEnabled=!1,this.width=this.height=100}destroy(destroyChild=!0){super.destroy(destroyChild),this._content&&this._content.destroy(destroyChild),this._vScrollBar&&this._vScrollBar.destroy(destroyChild),this._hScrollBar&&this._hScrollBar.destroy(destroyChild),this._vScrollBar=null,this._hScrollBar=null,this._content=null}destroyChildren(){this._content.destroyChildren()}createChildren(){super.addChild(this._content=new Box)}addChild(child){return child.on(Laya.Event.RESIZE,this,this.onResize),this._setScrollChanged(),this._content.addChild(child)}onResize(){this._setScrollChanged()}addChildAt(child,index){return child.on(Laya.Event.RESIZE,this,this.onResize),this._setScrollChanged(),this._content.addChildAt(child,index)}removeChild(child){return child.off(Laya.Event.RESIZE,this,this.onResize),this._setScrollChanged(),this._content.removeChild(child)}removeChildAt(index){return this.getChildAt(index).off(Laya.Event.RESIZE,this,this.onResize),this._setScrollChanged(),this._content.removeChildAt(index)}removeChildren(beginIndex=0,endIndex=2147483647){return this._content.removeChildren(beginIndex,endIndex),this._setScrollChanged(),this}getChildAt(index){return this._content.getChildAt(index)}getChildByName(name){return this._content.getChildByName(name)}getChildIndex(child){return this._content.getChildIndex(child)}get numChildren(){return this._content.numChildren}changeScroll(){this._scrollChanged=!1;var contentW=this.contentWidth||1,contentH=this.contentHeight||1,vscroll=this._vScrollBar,hscroll=this._hScrollBar,vShow=vscroll&&contentH>this._height,hShow=hscroll&&contentW>this._width,showWidth=vShow?this._width-vscroll.width:this._width,showHeight=hShow?this._height-hscroll.height:this._height;vscroll&&(vscroll.x=this._width-vscroll.width,vscroll.y=0,vscroll.height=this._height-(hShow?hscroll.height:0),vscroll.scrollSize=Math.max(.033*this._height,1),vscroll.thumbPercent=showHeight/contentH,vscroll.setScroll(0,contentH-showHeight,vscroll.value)),hscroll&&(hscroll.x=0,hscroll.y=this._height-hscroll.height,hscroll.width=this._width-(vShow?vscroll.width:0),hscroll.scrollSize=Math.max(.033*this._width,1),hscroll.thumbPercent=showWidth/contentW,hscroll.setScroll(0,contentW-showWidth,hscroll.value))}_sizeChanged(){super._sizeChanged(),this.setContentSize(this._width,this._height)}get contentWidth(){for(var max=0,i=this._content.numChildren-1;i>-1;i--){var comp=this._content.getChildAt(i);max=Math.max(comp._x+comp.width*comp.scaleX-comp.pivotX,max)}return max}get contentHeight(){for(var max=0,i=this._content.numChildren-1;i>-1;i--){var comp=this._content.getChildAt(i);max=Math.max(comp._y+comp.height*comp.scaleY-comp.pivotY,max)}return max}setContentSize(width,height){var content=this._content;content.width=width,content.height=height,content._style.scrollRect||(content.scrollRect=Laya.Rectangle.create()),content._style.scrollRect.setTo(0,0,width,height),content.scrollRect=content.scrollRect}set width(value){super.width=value,this._setScrollChanged()}get width(){return super.width}set height(value){super.height=value,this._setScrollChanged()}get height(){return super.height}get vScrollBarSkin(){return this._vScrollBar?this._vScrollBar.skin:null}set vScrollBarSkin(value){null==this._vScrollBar&&(super.addChild(this._vScrollBar=new VScrollBar),this._vScrollBar.on(Laya.Event.CHANGE,this,this.onScrollBarChange,[this._vScrollBar]),this._vScrollBar.target=this._content,this._vScrollBar.elasticDistance=this._elasticEnabled?200:0,this._setScrollChanged()),this._vScrollBar.skin=value}get hScrollBarSkin(){return this._hScrollBar?this._hScrollBar.skin:null}set hScrollBarSkin(value){null==this._hScrollBar&&(super.addChild(this._hScrollBar=new HScrollBar),this._hScrollBar.on(Laya.Event.CHANGE,this,this.onScrollBarChange,[this._hScrollBar]),this._hScrollBar.target=this._content,this._hScrollBar.elasticDistance=this._elasticEnabled?200:0,this._setScrollChanged()),this._hScrollBar.skin=value}get vScrollBar(){return this._vScrollBar}get hScrollBar(){return this._hScrollBar}get content(){return this._content}onScrollBarChange(scrollBar){var rect=this._content._style.scrollRect;if(rect){var start=Math.round(scrollBar.value);scrollBar.isVertical?rect.y=start:rect.x=start,this._content.scrollRect=rect}}scrollTo(x=0,y=0){this.vScrollBar&&(this.vScrollBar.value=y),this.hScrollBar&&(this.hScrollBar.value=x)}refresh(){this.changeScroll()}set cacheAs(value){super.cacheAs=value,this._usedCache=null,"none"!==value?(this._hScrollBar&&this._hScrollBar.on(Laya.Event.START,this,this.onScrollStart),this._vScrollBar&&this._vScrollBar.on(Laya.Event.START,this,this.onScrollStart)):(this._hScrollBar&&this._hScrollBar.off(Laya.Event.START,this,this.onScrollStart),this._vScrollBar&&this._vScrollBar.off(Laya.Event.START,this,this.onScrollStart))}get cacheAs(){return super.cacheAs}get elasticEnabled(){return this._elasticEnabled}set elasticEnabled(value){this._elasticEnabled=value,this._vScrollBar&&(this._vScrollBar.elasticDistance=value?200:0),this._hScrollBar&&(this._hScrollBar.elasticDistance=value?200:0)}onScrollStart(){this._usedCache||(this._usedCache=super.cacheAs),super.cacheAs="none",this._hScrollBar&&this._hScrollBar.once(Laya.Event.END,this,this.onScrollEnd),this._vScrollBar&&this._vScrollBar.once(Laya.Event.END,this,this.onScrollEnd)}onScrollEnd(){super.cacheAs=this._usedCache}_setScrollChanged(){this._scrollChanged||(this._scrollChanged=!0,this.callLater(this.changeScroll))}}Laya.ILaya.regClass(Panel),Laya.ClassUtils.regClass("laya.ui.Panel",Panel),Laya.ClassUtils.regClass("Laya.Panel",Panel);class VSlider extends Slider{}Laya.ILaya.regClass(VSlider),Laya.ClassUtils.regClass("laya.ui.VSlider",VSlider),Laya.ClassUtils.regClass("Laya.VSlider",VSlider);class Tree extends Box{constructor(){super(),this._spaceLeft=10,this._spaceBottom=0,this._keepStatus=!0,this.width=this.height=200}destroy(destroyChild=!0){super.destroy(destroyChild),this._list&&this._list.destroy(destroyChild),this._list=null,this._source=null,this._renderHandler=null}createChildren(){this.addChild(this._list=new List),this._list.renderHandler=Laya.Handler.create(this,this.renderItem,null,!1),this._list.repeatX=1,this._list.on(Laya.Event.CHANGE,this,this.onListChange)}onListChange(e=null){this.event(Laya.Event.CHANGE)}get keepStatus(){return this._keepStatus}set keepStatus(value){this._keepStatus=value}get array(){return this._list.array}set array(value){this._keepStatus&&this._list.array&&value&&this.parseOpenStatus(this._list.array,value),this._source=value,this._list.array=this.getArray()}get source(){return this._source}get list(){return this._list}get itemRender(){return this._list.itemRender}set itemRender(value){this._list.itemRender=value}get scrollBarSkin(){return this._list.vScrollBarSkin}set scrollBarSkin(value){this._list.vScrollBarSkin=value}get scrollBar(){return this._list.scrollBar}get mouseHandler(){return this._list.mouseHandler}set mouseHandler(value){this._list.mouseHandler=value}get renderHandler(){return this._renderHandler}set renderHandler(value){this._renderHandler=value}get spaceLeft(){return this._spaceLeft}set spaceLeft(value){this._spaceLeft=value}get spaceBottom(){return this._list.spaceY}set spaceBottom(value){this._list.spaceY=value}get selectedIndex(){return this._list.selectedIndex}set selectedIndex(value){this._list.selectedIndex=value}get selectedItem(){return this._list.selectedItem}set selectedItem(value){this._list.selectedItem=value}set width(value){super.width=value,this._list.width=value}get width(){return super.width}set height(value){super.height=value,this._list.height=value}get height(){return super.height}getArray(){var arr=[];for(let item of this._source)this.getParentOpenStatus(item)&&(item.x=this._spaceLeft*this.getDepth(item),arr.push(item));return arr}getDepth(item,num=0){return null==item.nodeParent?num:this.getDepth(item.nodeParent,num+1)}getParentOpenStatus(item){var parent=item.nodeParent;return null==parent||!!parent.isOpen&&(null==parent.nodeParent||this.getParentOpenStatus(parent))}renderItem(cell,index){var item=cell.dataSource;if(item){cell.left=item.x;var arrow=cell.getChildByName("arrow");arrow&&(item.hasChild?(arrow.visible=!0,arrow.index=item.isOpen?1:0,arrow.tag=index,arrow.off(Laya.Event.CLICK,this,this.onArrowClick),arrow.on(Laya.Event.CLICK,this,this.onArrowClick)):arrow.visible=!1);var folder=cell.getChildByName("folder");folder&&(2==folder.clipY?folder.index=item.isDirectory?0:1:folder.index=item.isDirectory?item.isOpen?1:0:2),this._renderHandler&&this._renderHandler.runWith([cell,index])}}onArrowClick(e){var index=e.currentTarget.tag;this._list.array[index].isOpen=!this._list.array[index].isOpen,this.event(Laya.Event.OPEN),this._list.array=this.getArray()}setItemState(index,isOpen){this._list.array[index]&&(this._list.array[index].isOpen=isOpen,this._list.array=this.getArray())}fresh(){this._list.array=this.getArray(),this.repaint()}set dataSource(value){this._dataSource=value,super.dataSource=value}get dataSource(){return super.dataSource}set xml(value){var arr=[];this.parseXml(value.childNodes[0],arr,null,!0),this.array=arr}parseXml(xml,source,nodeParent,isRoot){var obj,list=xml.childNodes,childCount=list.length;if(!isRoot){obj={};var list2=xml.attributes;for(let attrs of list2){var prop=attrs.nodeName,value=attrs.nodeValue;obj[prop]="true"==value||"false"!=value&&value}obj.nodeParent=nodeParent,childCount>0&&(obj.isDirectory=!0),obj.hasChild=childCount>0,source.push(obj)}for(var i=0;i<childCount;i++){var node=list[i];this.parseXml(node,source,obj,!1)}}parseOpenStatus(oldSource,newSource){for(var i=0,n=newSource.length;i<n;i++){var newItem=newSource[i];if(newItem.isDirectory)for(var j=0,m=oldSource.length;j<m;j++){var oldItem=oldSource[j];if(oldItem.isDirectory&&this.isSameParent(oldItem,newItem)&&newItem.label==oldItem.label){newItem.isOpen=oldItem.isOpen;break}}}}isSameParent(item1,item2){return null==item1.nodeParent&&null==item2.nodeParent||null!=item1.nodeParent&&null!=item2.nodeParent&&(item1.nodeParent.label==item2.nodeParent.label&&this.isSameParent(item1.nodeParent,item2.nodeParent))}get selectedPath(){return this._list.selectedItem?this._list.selectedItem.path:null}filter(key){if(Boolean(key)){var result=[];this.getFilterSource(this._source,result,key),this._list.array=result}else this._list.array=this.getArray()}getFilterSource(array,result,key){key=key.toLocaleLowerCase();for(let item of array)!item.isDirectory&&String(item.label).toLowerCase().indexOf(key)>-1&&(item.x=0,result.push(item)),item.child&&item.child.length>0&&this.getFilterSource(item.child,result,key)}}Laya.ILaya.regClass(Tree),Laya.ClassUtils.regClass("laya.ui.Tree",Tree),Laya.ClassUtils.regClass("Laya.Tree",Tree);class LayoutBox extends Box{constructor(){super(...arguments),this._space=0,this._align="none",this._itemChanged=!1}addChild(child){return child.on(Laya.Event.RESIZE,this,this.onResize),this._setItemChanged(),super.addChild(child)}onResize(e){this._setItemChanged()}addChildAt(child,index){return child.on(Laya.Event.RESIZE,this,this.onResize),this._setItemChanged(),super.addChildAt(child,index)}removeChildAt(index){return this.getChildAt(index).off(Laya.Event.RESIZE,this,this.onResize),this._setItemChanged(),super.removeChildAt(index)}refresh(){this._setItemChanged()}changeItems(){this._itemChanged=!1}get space(){return this._space}set space(value){this._space=value,this._setItemChanged()}get align(){return this._align}set align(value){this._align=value,this._setItemChanged()}sortItem(items){items&&items.sort(function(a,b){return a.y-b.y})}_setItemChanged(){this._itemChanged||(this._itemChanged=!0,this.callLater(this.changeItems))}}Laya.ILaya.regClass(LayoutBox),Laya.ClassUtils.regClass("laya.ui.LayoutBox",LayoutBox),Laya.ClassUtils.regClass("Laya.LayoutBox",LayoutBox);class HBox extends LayoutBox{sortItem(items){items&&items.sort(function(a,b){return a.x-b.x})}set height(value){this._height!=value&&(super.height=value,this.callLater(this.changeItems))}get height(){return super.height}changeItems(){this._itemChanged=!1;for(var items=[],maxHeight=0,i=0,n=this.numChildren;i<n;i++){var item=this.getChildAt(i);item&&(items.push(item),maxHeight=this._height?this._height:Math.max(maxHeight,item.height*item.scaleY))}this.sortItem(items);var left=0;for(i=0,n=items.length;i<n;i++)(item=items[i]).x=left,left+=item.width*item.scaleX+this._space,this._align==HBox.TOP?item.y=0:this._align==HBox.MIDDLE?item.y=.5*(maxHeight-item.height*item.scaleY):this._align==HBox.BOTTOM&&(item.y=maxHeight-item.height*item.scaleY);this._sizeChanged()}}HBox.NONE="none",HBox.TOP="top",HBox.MIDDLE="middle",HBox.BOTTOM="bottom",Laya.ILaya.regClass(HBox),Laya.ClassUtils.regClass("laya.ui.HBox",HBox),Laya.ClassUtils.regClass("Laya.HBox",HBox);class VBox extends LayoutBox{set width(value){this._width!=value&&(super.width=value,this.callLater(this.changeItems))}get width(){return super.width}changeItems(){this._itemChanged=!1;for(var items=[],maxWidth=0,i=0,n=this.numChildren;i<n;i++){var item=this.getChildAt(i);item&&(items.push(item),maxWidth=this._width?this._width:Math.max(maxWidth,item.width*item.scaleX))}this.sortItem(items);var top=0;for(i=0,n=items.length;i<n;i++)(item=items[i]).y=top,top+=item.height*item.scaleY+this._space,this._align==VBox.LEFT?item.x=0:this._align==VBox.CENTER?item.x=.5*(maxWidth-item.width*item.scaleX):this._align==VBox.RIGHT&&(item.x=maxWidth-item.width*item.scaleX);this._sizeChanged()}}VBox.NONE="none",VBox.LEFT="left",VBox.CENTER="center",VBox.RIGHT="right",Laya.ILaya.regClass(VBox),Laya.ClassUtils.regClass("laya.ui.VBox",VBox),Laya.ClassUtils.regClass("Laya.VBox",VBox);class FontClip extends Clip{constructor(skin=null,sheet=null){super(),this._valueArr="",this._indexMap=null,this._sheet=null,this._direction="horizontal",this._spaceX=0,this._spaceY=0,this._align="left",this._wordsW=0,this._wordsH=0,skin&&(this.skin=skin),sheet&&(this.sheet=sheet)}createChildren(){this._bitmap=new AutoBitmap,this.on(Laya.Event.LOADED,this,this._onClipLoaded)}_onClipLoaded(){this.callLater(this.changeValue)}get sheet(){return this._sheet}set sheet(value){value+="",this._sheet=value;var arr=value.split(" ");this._clipX=String(arr[0]).length,this.clipY=arr.length,this._indexMap={};for(var i=0;i<this._clipY;i++)for(var line=arr[i].split(""),j=0,n=line.length;j<n;j++)this._indexMap[line[j]]=i*this._clipX+j}get value(){return this._valueArr?this._valueArr:""}set value(value){value+="",this._valueArr=value,this.callLater(this.changeValue)}get direction(){return this._direction}set direction(value){this._direction=value,this.callLater(this.changeValue)}get spaceX(){return this._spaceX}set spaceX(value){this._spaceX=value,"horizontal"===this._direction&&this.callLater(this.changeValue)}get spaceY(){return this._spaceY}set spaceY(value){this._spaceY=value,"horizontal"!==this._direction&&this.callLater(this.changeValue)}set align(v){this._align=v,this.callLater(this.changeValue)}get align(){return this._align}changeValue(){var texture;if(this._sources&&(this._valueArr&&(this.graphics.clear(!0),texture=this._sources[0]))){var isHorizontal="horizontal"===this._direction;isHorizontal?(this._wordsW=this._valueArr.length*(texture.sourceWidth+this.spaceX),this._wordsH=texture.sourceHeight):(this._wordsW=texture.sourceWidth,this._wordsH=(texture.sourceHeight+this.spaceY)*this._valueArr.length);var dX=0;if(this._width)switch(this._align){case"center":dX=.5*(this._width-this._wordsW);break;case"right":dX=this._width-this._wordsW;break;default:dX=0}for(var i=0,sz=this._valueArr.length;i<sz;i++){var index=this._indexMap[this._valueArr.charAt(i)];this.sources[index]&&(texture=this.sources[index],isHorizontal?this.graphics.drawImage(texture,dX+i*(texture.sourceWidth+this.spaceX),0,texture.sourceWidth,texture.sourceHeight):this.graphics.drawImage(texture,0+dX,i*(texture.sourceHeight+this.spaceY),texture.sourceWidth,texture.sourceHeight))}this._width||(this._widget.resetLayoutX(),this.callLater(this._sizeChanged)),this._height||(this._widget.resetLayoutY(),this.callLater(this._sizeChanged))}}set width(value){super.width=value,this.callLater(this.changeValue)}get width(){return super.width}set height(value){super.height=value,this.callLater(this.changeValue)}get height(){return super.height}measureWidth(){return this._wordsW}measureHeight(){return this._wordsH}destroy(destroyChild=!0){this._valueArr=null,this._indexMap=null,this.graphics.clear(!0),this.removeSelf(),this.off(Laya.Event.LOADED,this,this._onClipLoaded),super.destroy(destroyChild)}}Laya.ILaya.regClass(FontClip),Laya.ClassUtils.regClass("laya.ui.FontClip",FontClip),Laya.ClassUtils.regClass("Laya.FontClip",FontClip);class View extends Laya.Scene{constructor(){super(!1),this._watchMap={},this._anchorX=NaN,this._anchorY=NaN,this._widget=Widget.EMPTY,this.createChildren()}static __init__(){Laya.ILaya.ClassUtils.regShortClassName([ViewStack,Button,TextArea,ColorPicker,Box,ScaleBox,CheckBox,Clip,ComboBox,UIComponent,HScrollBar,HSlider,Image,Label,List,Panel,ProgressBar,Radio,RadioGroup,ScrollBar,Slider,Tab,TextInput,View,VScrollBar,VSlider,Tree,HBox,VBox,Laya.Animation,Laya.Text,FontClip])}static regComponent(key,compClass){Laya.ILaya.ClassUtils.regClass(key,compClass)}static regViewRuntime(key,compClass){Laya.ILaya.ClassUtils.regClass(key,compClass)}static regUI(url,json){Laya.ILaya.loader.cacheRes(url,json)}destroy(destroyChild=!0){this._watchMap=null,super.destroy(destroyChild)}changeData(key){var arr=this._watchMap[key];if(arr)for(var i=0,n=arr.length;i<n;i++){arr[i].exe(this)}}get top(){return this._widget.top}set top(value){value!=this._widget.top&&(this._getWidget().top=value)}get bottom(){return this._widget.bottom}set bottom(value){value!=this._widget.bottom&&(this._getWidget().bottom=value)}get left(){return this._widget.left}set left(value){value!=this._widget.left&&(this._getWidget().left=value)}get right(){return this._widget.right}set right(value){value!=this._widget.right&&(this._getWidget().right=value)}get centerX(){return this._widget.centerX}set centerX(value){value!=this._widget.centerX&&(this._getWidget().centerX=value)}get centerY(){return this._widget.centerY}set centerY(value){value!=this._widget.centerY&&(this._getWidget().centerY=value)}get anchorX(){return this._anchorX}set anchorX(value){this._anchorX!=value&&(this._anchorX=value,this.callLater(this._sizeChanged))}get anchorY(){return this._anchorY}set anchorY(value){this._anchorY!=value&&(this._anchorY=value,this.callLater(this._sizeChanged))}_sizeChanged(){isNaN(this._anchorX)||(this.pivotX=this.anchorX*this.width),isNaN(this._anchorY)||(this.pivotY=this.anchorY*this.height),this.event(Laya.Event.RESIZE)}_getWidget(){return this._widget===Widget.EMPTY&&(this._widget=this.addComponent(Widget)),this._widget}loadUI(path){var uiView=View.uiMap[path];View.uiMap&&this.createView(uiView)}get dataSource(){return this._dataSource}set dataSource(value){for(var name in this._dataSource=value,value){var comp=this.getChildByName(name);comp instanceof UIComponent?comp.dataSource=value[name]:name in this&&!(this[name]instanceof Function)&&(this[name]=value[name])}}}View.uiMap={},Laya.ILaya.regClass(View),Laya.ClassUtils.regClass("laya.ui.View",View),Laya.ClassUtils.regClass("Laya.View",View);class IUI{}IUI.Dialog=null;class DialogManager extends Laya.Sprite{constructor(){super(),this.maskLayer=new Laya.Sprite,this.popupEffect=function(dialog){dialog.scale(1,1),dialog._effectTween=Laya.Tween.from(dialog,{x:Laya.ILaya.stage.width/2,y:Laya.ILaya.stage.height/2,scaleX:0,scaleY:0},300,Laya.Ease.backOut,Laya.Handler.create(this,this.doOpen,[dialog]),0,!1,!1)},this.closeEffect=function(dialog){dialog._effectTween=Laya.Tween.to(dialog,{x:Laya.ILaya.stage.width/2,y:Laya.ILaya.stage.height/2,scaleX:0,scaleY:0},300,Laya.Ease.strongOut,Laya.Handler.create(this,this.doClose,[dialog]),0,!1,!1)},this.popupEffectHandler=new Laya.Handler(this,this.popupEffect),this.closeEffectHandler=new Laya.Handler(this,this.closeEffect),this.mouseEnabled=this.maskLayer.mouseEnabled=!0,this.zOrder=1e3,Laya.ILaya.stage.addChild(this),Laya.ILaya.stage.on(Laya.Event.RESIZE,this,this._onResize),UIConfig.closeDialogOnSide&&this.maskLayer.on("click",this,this._closeOnSide),this._onResize(null)}_closeOnSide(){var dialog=this.getChildAt(this.numChildren-1);dialog instanceof IUI.Dialog&&dialog.close()}setLockView(value){this.lockLayer||(this.lockLayer=new Box,this.lockLayer.mouseEnabled=!0,this.lockLayer.size(Laya.ILaya.stage.width,Laya.ILaya.stage.height)),this.lockLayer.removeChildren(),value&&(value.centerX=value.centerY=0,this.lockLayer.addChild(value))}_onResize(e=null){var width=this.maskLayer.width=Laya.ILaya.stage.width,height=this.maskLayer.height=Laya.ILaya.stage.height;this.lockLayer&&this.lockLayer.size(width,height),this.maskLayer.graphics.clear(!0),this.maskLayer.graphics.drawRect(0,0,width,height,UIConfig.popupBgColor),this.maskLayer.alpha=UIConfig.popupBgAlpha;for(var i=this.numChildren-1;i>-1;i--){var item=this.getChildAt(i);item.isPopupCenter&&this._centerDialog(item)}}_centerDialog(dialog){dialog.x=Math.round((Laya.ILaya.stage.width-dialog.width>>1)+dialog.pivotX),dialog.y=Math.round((Laya.ILaya.stage.height-dialog.height>>1)+dialog.pivotY)}open(dialog,closeOther=!1,showEffect=!1){closeOther&&this._closeAll(),this._clearDialogEffect(dialog),dialog.isPopupCenter&&this._centerDialog(dialog),this.addChild(dialog),(dialog.isModal||this._getBit(Laya.Const.HAS_ZORDER))&&Laya.ILaya.timer.callLater(this,this._checkMask),showEffect&&null!=dialog.popupEffect?dialog.popupEffect.runWith(dialog):this.doOpen(dialog),this.event(Laya.Event.OPEN)}_clearDialogEffect(dialog){dialog._effectTween&&(Laya.Tween.clear(dialog._effectTween),dialog._effectTween=null)}doOpen(dialog){dialog.onOpened(dialog._param)}lock(value){this.lockLayer&&(value?this.addChild(this.lockLayer):this.lockLayer.removeSelf())}close(dialog){this._clearDialogEffect(dialog),dialog.isShowEffect&&null!=dialog.closeEffect?dialog.closeEffect.runWith([dialog]):this.doClose(dialog),this.event(Laya.Event.CLOSE)}doClose(dialog){dialog.removeSelf(),dialog.isModal&&this._checkMask(),dialog.closeHandler&&dialog.closeHandler.runWith(dialog.closeType),dialog.onClosed(dialog.closeType),dialog.autoDestroyAtClosed&&dialog.destroy()}closeAll(){this._closeAll(),this.event(Laya.Event.CLOSE)}_closeAll(){for(var i=this.numChildren-1;i>-1;i--){var item=this.getChildAt(i);item&&null!=item.close&&this.doClose(item)}}getDialogsByGroup(group){for(var arr=[],i=this.numChildren-1;i>-1;i--){var item=this.getChildAt(i);item&&item.group===group&&arr.push(item)}return arr}closeByGroup(group){for(var arr=[],i=this.numChildren-1;i>-1;i--){var item=this.getChildAt(i);item&&item.group===group&&(item.close(),arr.push(item))}return arr}_checkMask(){this.maskLayer.removeSelf();for(var i=this.numChildren-1;i>-1;i--){var dialog=this.getChildAt(i);if(dialog&&dialog.isModal)return void this.addChildAt(this.maskLayer,i)}}}Laya.ClassUtils.regClass("laya.ui.DialogManager",DialogManager),Laya.ClassUtils.regClass("Laya.DialogManager",DialogManager);class Dialog extends View{constructor(){super(),this.isShowEffect=!0,this.isPopupCenter=!0,this.popupEffect=Dialog.manager.popupEffectHandler,this.closeEffect=Dialog.manager.closeEffectHandler,this._dealDragArea(),this.on(Laya.Event.CLICK,this,this._onClick)}static get manager(){return Dialog._manager=Dialog._manager||new DialogManager}static set manager(value){Dialog._manager=value}_dealDragArea(){var dragTarget=this.getChildByName("drag");dragTarget&&(this.dragArea=dragTarget._x+","+dragTarget._y+","+dragTarget.width+","+dragTarget.height,dragTarget.removeSelf())}get dragArea(){return this._dragArea?this._dragArea.toString():null}set dragArea(value){if(value){var a=UIUtils.fillArray([0,0,0,0],value,Number);this._dragArea=new Laya.Rectangle(a[0],a[1],a[2],a[3]),this.on(Laya.Event.MOUSE_DOWN,this,this._onMouseDown)}else this._dragArea=null,this.off(Laya.Event.MOUSE_DOWN,this,this._onMouseDown)}_onMouseDown(e){var point=this.getMousePoint();this._dragArea.contains(point.x,point.y)?this.startDrag():this.stopDrag()}_onClick(e){var btn=e.target;if(btn)switch(btn.name){case Dialog.CLOSE:case Dialog.CANCEL:case Dialog.SURE:case Dialog.NO:case Dialog.OK:case Dialog.YES:return void this.close(btn.name)}}open(closeOther=!0,param=null){this._dealDragArea(),this._param=param,Dialog.manager.open(this,closeOther,this.isShowEffect),Dialog.manager.lock(!1)}close(type=null){this.closeType=type,Dialog.manager.close(this)}destroy(destroyChild=!0){this.closeHandler=null,this.popupEffect=null,this.closeEffect=null,this._dragArea=null,super.destroy(destroyChild)}show(closeOther=!1,showEffect=!0){this._open(!1,closeOther,showEffect)}popup(closeOther=!1,showEffect=!0){this._open(!0,closeOther,showEffect)}_open(modal,closeOther,showEffect){this.isModal=modal,this.isShowEffect=showEffect,Dialog.manager.lock(!0),this.open(closeOther)}get isPopup(){return null!=this.parent}set zOrder(value){super.zOrder=value,Dialog.manager._checkMask()}get zOrder(){return super.zOrder}static setLockView(view){Dialog.manager.setLockView(view)}static lock(value){Dialog.manager.lock(value)}static closeAll(){Dialog.manager.closeAll()}static getDialogsByGroup(group){return Dialog.manager.getDialogsByGroup(group)}static closeByGroup(group){return Dialog.manager.closeByGroup(group)}}Dialog.CLOSE="close",Dialog.CANCEL="cancel",Dialog.SURE="sure",Dialog.NO="no",Dialog.YES="yes",Dialog.OK="ok",IUI.Dialog=Dialog,Laya.ILaya.regClass(Dialog),Laya.ClassUtils.regClass("laya.ui.Dialog",Dialog),Laya.ClassUtils.regClass("Laya.Dialog",Dialog);class TipManager extends UIComponent{constructor(){super(),this._tipBox=new UIComponent,this._tipBox.addChild(this._tipText=new Laya.Text),this._tipText.x=this._tipText.y=5,this._tipText.color=TipManager.tipTextColor,this._defaultTipHandler=this._showDefaultTip,Laya.ILaya.stage.on(UIEvent.SHOW_TIP,this,this._onStageShowTip),Laya.ILaya.stage.on(UIEvent.HIDE_TIP,this,this._onStageHideTip),this.zOrder=1100}_onStageHideTip(e){Laya.ILaya.timer.clear(this,this._showTip),this.closeAll(),this.removeSelf()}_onStageShowTip(data){Laya.ILaya.timer.once(TipManager.tipDelay,this,this._showTip,[data],!0)}_showTip(tip){if("string"==typeof tip){var text=String(tip);Boolean(text)&&this._defaultTipHandler(text)}else tip instanceof Laya.Handler?tip.run():tip instanceof Function&&tip.apply();Laya.ILaya.stage.on(Laya.Event.MOUSE_MOVE,this,this._onStageMouseMove),Laya.ILaya.stage.on(Laya.Event.MOUSE_DOWN,this,this._onStageMouseDown),this._onStageMouseMove(null)}_onStageMouseDown(e){this.closeAll()}_onStageMouseMove(e){this._showToStage(this,TipManager.offsetX,TipManager.offsetY)}_showToStage(dis,offX=0,offY=0){var rec=dis.getBounds();dis.x=Laya.ILaya.stage.mouseX+offX,dis.y=Laya.ILaya.stage.mouseY+offY,dis._x+rec.width>Laya.ILaya.stage.width&&(dis.x-=rec.width+offX),dis._y+rec.height>Laya.ILaya.stage.height&&(dis.y-=rec.height+offY)}closeAll(){Laya.ILaya.timer.clear(this,this._showTip),Laya.ILaya.stage.off(Laya.Event.MOUSE_MOVE,this,this._onStageMouseMove),Laya.ILaya.stage.off(Laya.Event.MOUSE_DOWN,this,this._onStageMouseDown),this.removeChildren()}showDislayTip(tip){this.addChild(tip),this._showToStage(this),Laya.ILaya.stage.addChild(this)}_showDefaultTip(text){this._tipText.text=text;var g=this._tipBox.graphics;g.clear(!0),g.drawRect(0,0,this._tipText.width+10,this._tipText.height+10,TipManager.tipBackColor),this.addChild(this._tipBox),this._showToStage(this),Laya.ILaya.stage.addChild(this)}get defaultTipHandler(){return this._defaultTipHandler}set defaultTipHandler(value){this._defaultTipHandler=value}}TipManager.offsetX=10,TipManager.offsetY=15,TipManager.tipTextColor="#ffffff",TipManager.tipBackColor="#111111",TipManager.tipDelay=200,Laya.ILaya.regClass(TipManager),Laya.ClassUtils.regClass("laya.ui.TipManager",TipManager),Laya.ClassUtils.regClass("Laya.TipManager",TipManager);class WXOpenDataViewer extends UIComponent{constructor(){super(),this._width=this._height=200;var tex=new Laya.Texture;tex.bitmap=new Laya.Texture2D,this.texture=tex}onEnable(){this.postMsg({type:"display",rate:Laya.Laya.stage.frameRate}),window.wx&&window.sharedCanvas&&Laya.Laya.timer.frameLoop(1,this,this._onLoop)}onDisable(){this.postMsg({type:"undisplay"}),Laya.Laya.timer.clear(this,this._onLoop)}_onLoop(){this.texture.bitmap.loadImageSource(window.sharedCanvas)}set width(value){super.width=value,window.sharedCanvas&&(window.sharedCanvas.width=value),this.callLater(this._postMsg)}get width(){return super.width}set height(value){super.height=value,window.sharedCanvas&&(window.sharedCanvas.height=value),this.callLater(this._postMsg)}get height(){return super.width}set x(value){super.x=value,this.callLater(this._postMsg)}get x(){return super.x}set y(value){super.y=value,this.callLater(this._postMsg)}get y(){return super.y}_postMsg(){var mat=new Laya.Matrix;mat.translate(this.x,this.y);var stage=Laya.Laya.stage;mat.scale(stage._canvasTransform.getScaleX()*this.globalScaleX*stage.transform.getScaleX(),stage._canvasTransform.getScaleY()*this.globalScaleY*stage.transform.getScaleY()),this.postMsg({type:"changeMatrix",a:mat.a,b:mat.b,c:mat.c,d:mat.d,tx:mat.tx,ty:mat.ty,w:this.width,h:this.height})}postMsg(msg){window.wx&&window.wx.getOpenDataContext&&window.wx.getOpenDataContext().postMessage(msg)}}Laya.ILaya.regClass(WXOpenDataViewer),Laya.ClassUtils.regClass("laya.ui.WXOpenDataViewer",WXOpenDataViewer),Laya.ClassUtils.regClass("Laya.WXOpenDataViewer",WXOpenDataViewer),exports.AdvImage=AdvImage,exports.AutoBitmap=AutoBitmap,exports.Box=Box,exports.Button=Button,exports.CheckBox=CheckBox,exports.Clip=Clip,exports.ColorPicker=ColorPicker,exports.ComboBox=ComboBox,exports.Dialog=Dialog,exports.DialogManager=DialogManager,exports.FontClip=FontClip,exports.HBox=HBox,exports.HScrollBar=HScrollBar,exports.HSlider=HSlider,exports.IUI=IUI,exports.Image=Image,exports.Label=Label,exports.LayoutBox=LayoutBox,exports.List=List,exports.Panel=Panel,exports.ProgressBar=ProgressBar,exports.Radio=Radio,exports.RadioGroup=RadioGroup,exports.ScaleBox=ScaleBox,exports.ScrollBar=ScrollBar,exports.Slider=Slider,exports.Styles=Styles,exports.Tab=Tab,exports.TextArea=TextArea,exports.TextInput=TextInput,exports.TipManager=TipManager,exports.Tree=Tree,exports.UIComponent=UIComponent,exports.UIConfig=UIConfig,exports.UIEvent=UIEvent,exports.UIGroup=UIGroup,exports.UILib=class{static __init__(){}},exports.UIUtils=UIUtils,exports.VBox=VBox,exports.VScrollBar=VScrollBar,exports.VSlider=VSlider,exports.View=View,exports.ViewStack=ViewStack,exports.WXOpenDataViewer=WXOpenDataViewer,exports.Widget=Widget}(window.Laya=window.Laya||{},Laya);