laya.ui.js 332 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148
  1. (function(window,document,Laya){
  2. var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec;
  3. var Animation=laya.display.Animation,Browser=laya.utils.Browser,ClassUtils=laya.utils.ClassUtils,ColorFilter=laya.filters.ColorFilter;
  4. var Component=laya.components.Component,Const=laya.Const,Ease=laya.utils.Ease,Event=laya.events.Event,Graphics=laya.display.Graphics;
  5. var Handler=laya.utils.Handler,HttpRequest=laya.net.HttpRequest,Input=laya.display.Input,Loader=laya.net.Loader;
  6. var LocalStorage=laya.net.LocalStorage,Matrix=laya.maths.Matrix,Node=laya.display.Node,Point=laya.maths.Point;
  7. var Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,Scene=laya.display.Scene,SceneUtils=laya.utils.SceneUtils;
  8. var Sprite=laya.display.Sprite,Stage=laya.display.Stage,Text=laya.display.Text,Texture=laya.resource.Texture;
  9. var TimeLine=laya.utils.TimeLine,Tween=laya.utils.Tween,Utils=laya.utils.Utils,WeakObject=laya.utils.WeakObject;
  10. Laya.interface('laya.ui.IBox');
  11. Laya.interface('laya.ui.IItem');
  12. Laya.interface('laya.ui.ISelect');
  13. Laya.interface('laya.ui.IRender');
  14. /**全局配置*/
  15. //class UIConfig
  16. var UIConfig=(function(){
  17. function UIConfig(){}
  18. __class(UIConfig,'UIConfig');
  19. UIConfig.touchScrollEnable=true;
  20. UIConfig.mouseWheelEnable=true;
  21. UIConfig.showButtons=true;
  22. UIConfig.popupBgColor="#000000";
  23. UIConfig.popupBgAlpha=0.5;
  24. UIConfig.closeDialogOnSide=true;
  25. return UIConfig;
  26. })()
  27. /**
  28. *<code>Styles</code> 定义了组件常用的样式属性。
  29. */
  30. //class laya.ui.Styles
  31. var Styles=(function(){
  32. function Styles(){}
  33. __class(Styles,'laya.ui.Styles');
  34. Styles.labelColor="#000000";
  35. Styles.buttonStateNum=3;
  36. Styles.scrollBarMinNum=15;
  37. Styles.scrollBarDelayTime=500;
  38. __static(Styles,
  39. ['defaultSizeGrid',function(){return this.defaultSizeGrid=[4,4,4,4,0];},'labelPadding',function(){return this.labelPadding=[2,2,2,2];},'inputLabelPadding',function(){return this.inputLabelPadding=[1,1,1,3];},'buttonLabelColors',function(){return this.buttonLabelColors=["#32556b","#32cc6b","#ff0000","#C0C0C0"];},'comboBoxItemColors',function(){return this.comboBoxItemColors=["#5e95b6","#ffffff","#000000","#8fa4b1","#ffffff"];}
  40. ]);
  41. return Styles;
  42. })()
  43. /**
  44. *<code>UIUtils</code> 是文本工具集。
  45. */
  46. //class laya.ui.UIUtils
  47. var UIUtils=(function(){
  48. function UIUtils(){}
  49. __class(UIUtils,'laya.ui.UIUtils');
  50. UIUtils.fillArray=function(arr,str,type){
  51. var temp=arr.concat();
  52. if (str){
  53. var a=str.split(",");
  54. for (var i=0,n=Math.min(temp.length,a.length);i < n;i++){
  55. var value=a[i];
  56. temp[i]=(value=="true" ? true :(value=="false" ? false :value));
  57. if (type !=null)temp[i]=type(value);
  58. }
  59. }
  60. return temp;
  61. }
  62. UIUtils.toColor=function(color){
  63. return Utils.toHexColor(color);
  64. }
  65. UIUtils.gray=function(traget,isGray){
  66. (isGray===void 0)&& (isGray=true);
  67. if (isGray){
  68. UIUtils.addFilter(traget,UIUtils.grayFilter);
  69. }else {
  70. UIUtils.clearFilter(traget,ColorFilter);
  71. }
  72. }
  73. UIUtils.addFilter=function(target,filter){
  74. var filters=target.filters || [];
  75. filters.push(filter);
  76. target.filters=filters;
  77. }
  78. UIUtils.clearFilter=function(target,filterType){
  79. var filters=target.filters;
  80. if (filters !=null && filters.length > 0){
  81. for (var i=filters.length-1;i >-1;i--){
  82. var filter=filters[i];
  83. if (Laya.__typeof(filter,filterType))filters.splice(i,1);
  84. }
  85. target.filters=filters;
  86. }
  87. }
  88. UIUtils._getReplaceStr=function(word){
  89. return UIUtils.escapeSequence[word];
  90. }
  91. UIUtils.adptString=function(str){
  92. return str.replace(/\\(\w)/g,UIUtils._getReplaceStr);
  93. }
  94. UIUtils.getBindFun=function(value){
  95. var fun=UIUtils._funMap.get(value);
  96. if (fun==null){
  97. var temp="\""+value+"\"";
  98. temp=temp.replace(/^"\${|}"$/g,"").replace(/\${/g,"\"+").replace(/}/g,"+\"");
  99. var str="(function(data){if(data==null)return;with(data){try{\nreturn "+temp+"\n}catch(e){}}})";
  100. fun=Laya._runScript(str);
  101. UIUtils._funMap.set(value,fun);
  102. }
  103. return fun;
  104. }
  105. __static(UIUtils,
  106. ['grayFilter',function(){return this.grayFilter=new ColorFilter([0.3086,0.6094,0.082,0,0,0.3086,0.6094,0.082,0,0,0.3086,0.6094,0.082,0,0,0,0,0,1,0]);},'escapeSequence',function(){return this.escapeSequence={"\\n":"\n","\\t":"\t"};},'_funMap',function(){return this._funMap=new WeakObject();}
  107. ]);
  108. return UIUtils;
  109. })()
  110. /**
  111. *相对布局插件
  112. */
  113. //class laya.ui.Widget extends laya.components.Component
  114. var Widget=(function(_super){
  115. function Widget(){
  116. Widget.__super.call(this);
  117. this._top=NaN;
  118. this._bottom=NaN;
  119. this._left=NaN;
  120. this._right=NaN;
  121. this._centerX=NaN;
  122. this._centerY=NaN;
  123. }
  124. __class(Widget,'laya.ui.Widget',_super);
  125. var __proto=Widget.prototype;
  126. __proto.onReset=function(){
  127. this._top=this._bottom=this._left=this._right=this._centerX=this._centerY=NaN;
  128. }
  129. __proto._onEnable=function(){
  130. if (this.owner.parent)this._onAdded();
  131. else this.owner.once(/*laya.events.Event.ADDED*/"added",this,this._onAdded);
  132. }
  133. __proto._onDisable=function(){
  134. this.owner.off(/*laya.events.Event.ADDED*/"added",this,this._onAdded);
  135. if (this.owner.parent)this.owner.parent.off(/*laya.events.Event.RESIZE*/"resize",this,this._onParentResize);
  136. }
  137. /**
  138. *对象被添加到显示列表的事件侦听处理函数。
  139. */
  140. __proto._onAdded=function(){
  141. if (this.owner.parent)
  142. this.owner.parent.on(/*laya.events.Event.RESIZE*/"resize",this,this._onParentResize);
  143. this.resetLayoutX();
  144. this.resetLayoutY();
  145. }
  146. /**
  147. *父容器的 <code>Event.RESIZE</code> 事件侦听处理函数。
  148. */
  149. __proto._onParentResize=function(){
  150. if (this.resetLayoutX()|| this.resetLayoutY())this.owner.event(/*laya.events.Event.RESIZE*/"resize");
  151. }
  152. /**
  153. *<p>重置对象的 <code>X</code> 轴(水平方向)布局。</p>
  154. *@private
  155. */
  156. __proto.resetLayoutX=function(){
  157. var owner=this.owner;
  158. if (!owner)return false;
  159. var parent=owner.parent;
  160. if (parent){
  161. if (!isNaN(this.centerX)){
  162. owner.x=Math.round((parent.width-owner.displayWidth)*0.5+this.centerX+owner.pivotX *owner.scaleX);
  163. }else if (!isNaN(this.left)){
  164. owner.x=Math.round(this.left+owner.pivotX *owner.scaleX);
  165. if (!isNaN(this.right)){
  166. var temp=(parent._width-this.left-this.right)/ (owner.scaleX || 0.01);
  167. if (temp !=owner.width){
  168. owner.width=temp;
  169. return true;
  170. }
  171. }
  172. }else if (!isNaN(this.right)){
  173. owner.x=Math.round(parent.width-owner.displayWidth-this.right+owner.pivotX *owner.scaleX);
  174. }
  175. }
  176. return false;
  177. }
  178. /**
  179. *<p>重置对象的 <code>Y</code> 轴(垂直方向)布局。</p>
  180. *@private
  181. */
  182. __proto.resetLayoutY=function(){
  183. var owner=this.owner;
  184. if (!owner)return false;
  185. var parent=owner.parent;
  186. if (parent){
  187. if (!isNaN(this.centerY)){
  188. owner.y=Math.round((parent.height-owner.displayHeight)*0.5+this.centerY+owner.pivotY *owner.scaleY);
  189. }else if (!isNaN(this.top)){
  190. owner.y=Math.round(this.top+owner.pivotY *owner.scaleY);
  191. if (!isNaN(this.bottom)){
  192. var temp=(parent._height-this.top-this.bottom)/ (owner.scaleY || 0.01);
  193. if (temp !=owner.height){
  194. owner.height=temp;
  195. return true;
  196. }
  197. }
  198. }else if (!isNaN(this.bottom)){
  199. owner.y=Math.round(parent.height-owner.displayHeight-this.bottom+owner.pivotY *owner.scaleY);
  200. }
  201. }
  202. return false;
  203. }
  204. /**
  205. *重新计算布局
  206. */
  207. __proto.resetLayout=function(){
  208. if (this.owner){
  209. this.resetLayoutX();
  210. this.resetLayoutY();
  211. }
  212. }
  213. /**表示距水平方向中心轴的距离(以像素为单位)。*/
  214. __getset(0,__proto,'centerX',function(){
  215. return this._centerX;
  216. },function(value){
  217. if (this._centerX !=value){
  218. this._centerX=value;
  219. this.resetLayoutX();
  220. }
  221. });
  222. /**表示距顶边的距离(以像素为单位)。*/
  223. __getset(0,__proto,'top',function(){
  224. return this._top;
  225. },function(value){
  226. if (this._top !=value){
  227. this._top=value;
  228. this.resetLayoutY();
  229. }
  230. });
  231. /**表示距底边的距离(以像素为单位)。*/
  232. __getset(0,__proto,'bottom',function(){
  233. return this._bottom;
  234. },function(value){
  235. if (this._bottom !=value){
  236. this._bottom=value;
  237. this.resetLayoutY();
  238. }
  239. });
  240. /**表示距左边的距离(以像素为单位)。*/
  241. __getset(0,__proto,'left',function(){
  242. return this._left;
  243. },function(value){
  244. if (this._left !=value){
  245. this._left=value;
  246. this.resetLayoutX();
  247. }
  248. });
  249. /**表示距右边的距离(以像素为单位)。*/
  250. __getset(0,__proto,'right',function(){
  251. return this._right;
  252. },function(value){
  253. if (this._right !=value){
  254. this._right=value;
  255. this.resetLayoutX();
  256. }
  257. });
  258. /**表示距垂直方向中心轴的距离(以像素为单位)。*/
  259. __getset(0,__proto,'centerY',function(){
  260. return this._centerY;
  261. },function(value){
  262. if (this._centerY !=value){
  263. this._centerY=value;
  264. this.resetLayoutY();
  265. }
  266. });
  267. __static(Widget,
  268. ['EMPTY',function(){return this.EMPTY=new Widget();}
  269. ]);
  270. return Widget;
  271. })(Component)
  272. /**
  273. *<code>UIEvent</code> 类用来定义UI组件类的事件类型。
  274. */
  275. //class laya.ui.UIEvent extends laya.events.Event
  276. var UIEvent=(function(_super){
  277. function UIEvent(){
  278. UIEvent.__super.call(this);;
  279. }
  280. __class(UIEvent,'laya.ui.UIEvent',_super);
  281. UIEvent.SHOW_TIP="showtip";
  282. UIEvent.HIDE_TIP="hidetip";
  283. return UIEvent;
  284. })(Event)
  285. /**
  286. *<code>AutoBitmap</code> 类是用于表示位图图像或绘制图形的显示对象。
  287. *<p>封装了位置,宽高及九宫格的处理,供UI组件使用。</p>
  288. */
  289. //class laya.ui.AutoBitmap extends laya.display.Graphics
  290. var AutoBitmap=(function(_super){
  291. function AutoBitmap(){
  292. /**@private 是否自动缓存命令*/
  293. this.autoCacheCmd=true;
  294. /**@private 宽度*/
  295. this._width=0;
  296. /**@private 高度*/
  297. this._height=0;
  298. /**@private 源数据*/
  299. this._source=null;
  300. /**@private 网格数据*/
  301. this._sizeGrid=null;
  302. /**@private */
  303. this._isChanged=false;
  304. /**@private */
  305. this._offset=null;
  306. AutoBitmap.__super.call(this);
  307. }
  308. __class(AutoBitmap,'laya.ui.AutoBitmap',_super);
  309. var __proto=AutoBitmap.prototype;
  310. /**@inheritDoc */
  311. __proto.destroy=function(){
  312. _super.prototype.destroy.call(this);
  313. this._source=null;
  314. this._sizeGrid=null;
  315. this._offset=null;
  316. }
  317. /**@private */
  318. __proto._setChanged=function(){
  319. if (!this._isChanged){
  320. this._isChanged=true;
  321. Laya.timer.callLater(this,this.changeSource);
  322. }
  323. }
  324. /**
  325. *@private
  326. *修改纹理资源。
  327. */
  328. __proto.changeSource=function(){
  329. this._isChanged=false;
  330. var source=this._source;
  331. if (!source || !source.bitmap)return;
  332. var width=this.width;
  333. var height=this.height;
  334. var sizeGrid=this._sizeGrid;
  335. var sw=source.sourceWidth;
  336. var sh=source.sourceHeight;
  337. if (!sizeGrid || (sw===width && sh===height)){
  338. this.clear();
  339. this.drawTexture(source,this._offset ? this._offset[0] :0,this._offset ? this._offset[1] :0,width,height);
  340. }else {
  341. this.clear();
  342. var top=sizeGrid[0];
  343. var right=sizeGrid[1];
  344. var bottom=sizeGrid[2];
  345. var left=sizeGrid[3];
  346. var repeat=sizeGrid[4];
  347. var needClip=false;
  348. if (width==sw){
  349. left=right=0;
  350. }
  351. if (height==sh){
  352. top=bottom=0;
  353. }
  354. if (left+right > width){
  355. var clipWidth=width;
  356. needClip=true;
  357. width=left+right;
  358. this.save();
  359. this.clipRect(0,0,clipWidth,height);
  360. }
  361. left && top && this.drawImage(AutoBitmap.getTexture(source,0,0,left,top),0,0,left,top);
  362. right && top && this.drawImage(AutoBitmap.getTexture(source,sw-right,0,right,top),width-right,0,right,top);
  363. left && bottom && this.drawImage(AutoBitmap.getTexture(source,0,sh-bottom,left,bottom),0,height-bottom,left,bottom);
  364. right && bottom && this.drawImage(AutoBitmap.getTexture(source,sw-right,sh-bottom,right,bottom),width-right,height-bottom,right,bottom);
  365. top && this.drawBitmap(repeat,AutoBitmap.getTexture(source,left,0,sw-left-right,top),left,0,width-left-right,top);
  366. bottom && this.drawBitmap(repeat,AutoBitmap.getTexture(source,left,sh-bottom,sw-left-right,bottom),left,height-bottom,width-left-right,bottom);
  367. left && this.drawBitmap(repeat,AutoBitmap.getTexture(source,0,top,left,sh-top-bottom),0,top,left,height-top-bottom);
  368. right && this.drawBitmap(repeat,AutoBitmap.getTexture(source,sw-right,top,right,sh-top-bottom),width-right,top,right,height-top-bottom);
  369. this.drawBitmap(repeat,AutoBitmap.getTexture(source,left,top,sw-left-right,sh-top-bottom),left,top,width-left-right,height-top-bottom);
  370. if (needClip)this.restore();
  371. }
  372. this._repaint();
  373. }
  374. __proto.drawBitmap=function(repeat,tex,x,y,width,height){
  375. (width===void 0)&& (width=0);
  376. (height===void 0)&& (height=0);
  377. if (width < 0.1 || height < 0.1)return;
  378. if (repeat && (tex.width !=width || tex.height !=height))this.fillTexture(tex,x,y,width,height);
  379. else this.drawImage(tex,x,y,width,height);
  380. }
  381. /**
  382. *当前实例的有效缩放网格数据。
  383. *<p>如果设置为null,则在应用任何缩放转换时,将正常缩放整个显示对象。</p>
  384. *<p>数据格式:[上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)]。
  385. *<ul><li>例如:[4,4,4,4,1]</li></ul></p>
  386. *<p> <code>sizeGrid</code> 的值如下所示:
  387. *<ol>
  388. *<li>上边距</li>
  389. *<li>右边距</li>
  390. *<li>下边距</li>
  391. *<li>左边距</li>
  392. *<li>是否重复填充(值为0:不重复填充,1:重复填充)</li>
  393. *</ol></p>
  394. *<p>当定义 <code>sizeGrid</code> 属性时,该显示对象被分割到以 <code>sizeGrid</code> 数据中的"上边距,右边距,下边距,左边距" 组成的矩形为基础的具有九个区域的网格中,该矩形定义网格的中心区域。网格的其它八个区域如下所示:
  395. *<ul>
  396. *<li>矩形上方的区域</li>
  397. *<li>矩形外的右上角</li>
  398. *<li>矩形左侧的区域</li>
  399. *<li>矩形右侧的区域</li>
  400. *<li>矩形外的左下角</li>
  401. *<li>矩形下方的区域</li>
  402. *<li>矩形外的右下角</li>
  403. *<li>矩形外的左上角</li>
  404. *</ul>
  405. *同时也支持3宫格,比如0,4,0,4,1为水平3宫格,4,0,4,0,1为垂直3宫格,3宫格性能比9宫格高。
  406. *</p>
  407. */
  408. __getset(0,__proto,'sizeGrid',function(){
  409. return this._sizeGrid;
  410. },function(value){
  411. this._sizeGrid=value;
  412. this._setChanged();
  413. });
  414. /**
  415. *表示显示对象的宽度,以像素为单位。
  416. */
  417. __getset(0,__proto,'width',function(){
  418. if (this._width)return this._width;
  419. if (this._source)return this._source.sourceWidth;
  420. return 0;
  421. },function(value){
  422. if (this._width !=value){
  423. this._width=value;
  424. this._setChanged();
  425. }
  426. });
  427. /**
  428. *表示显示对象的高度,以像素为单位。
  429. */
  430. __getset(0,__proto,'height',function(){
  431. if (this._height)return this._height;
  432. if (this._source)return this._source.sourceHeight;
  433. return 0;
  434. },function(value){
  435. if (this._height !=value){
  436. this._height=value;
  437. this._setChanged();
  438. }
  439. });
  440. /**
  441. *对象的纹理资源。
  442. *@see laya.resource.Texture
  443. */
  444. __getset(0,__proto,'source',function(){
  445. return this._source;
  446. },function(value){
  447. if (value){
  448. this._source=value
  449. this._setChanged();
  450. }else {
  451. this._source=null;
  452. this.clear();
  453. }
  454. });
  455. AutoBitmap.getTexture=function(tex,x,y,width,height){
  456. if (width <=0)width=1;
  457. if (height <=0)height=1;
  458. tex.$_GID || (tex.$_GID=Utils.getGID())
  459. var texture;
  460. if (!texture || !texture._getSource()){
  461. texture=Texture.createFromTexture(tex,x,y,width,height);
  462. }
  463. return texture;
  464. }
  465. return AutoBitmap;
  466. })(Graphics)
  467. /**
  468. *<code>Component</code> 是ui控件类的基类。
  469. *<p>生命周期:preinitialize > createChildren > initialize > 组件构造函数</p>
  470. */
  471. //class laya.ui.UIComponent extends laya.display.Sprite
  472. var UIComponent=(function(_super){
  473. function UIComponent(){
  474. /**@private 控件的数据源。 */
  475. this._dataSource=null;
  476. /**@private 鼠标悬停提示 */
  477. this._toolTip=null;
  478. /**@private 标签 */
  479. this._tag=null;
  480. /**@private 禁用 */
  481. this._disabled=false;
  482. /**@private 变灰*/
  483. this._gray=false;
  484. UIComponent.__super.call(this);
  485. this._anchorX=NaN;
  486. this._anchorY=NaN;
  487. this._widget=Widget.EMPTY;
  488. this.preinitialize();
  489. this.createChildren();
  490. this.initialize();
  491. }
  492. __class(UIComponent,'laya.ui.UIComponent',_super);
  493. var __proto=UIComponent.prototype;
  494. /**@inheritDoc */
  495. __proto.destroy=function(destroyChild){
  496. (destroyChild===void 0)&& (destroyChild=true);
  497. _super.prototype.destroy.call(this,destroyChild);
  498. this._dataSource=null;
  499. this._tag=null;
  500. this._toolTip=null;
  501. }
  502. /**
  503. *<p>预初始化。</p>
  504. *@internal 子类可在此函数内设置、修改属性默认值
  505. */
  506. __proto.preinitialize=function(){}
  507. /**
  508. *<p>创建并添加控件子节点。</p>
  509. *@internal 子类可在此函数内创建并添加子节点。
  510. */
  511. __proto.createChildren=function(){}
  512. /**
  513. *<p>控件初始化。</p>
  514. *@internal 在此子对象已被创建,可以对子对象进行修改。
  515. */
  516. __proto.initialize=function(){}
  517. /**
  518. *<p>显示对象的实际显示区域宽度(以像素为单位)。</p>
  519. */
  520. __proto.measureWidth=function(){
  521. var max=0;
  522. this.commitMeasure();
  523. for (var i=this.numChildren-1;i >-1;i--){
  524. var comp=this.getChildAt(i);
  525. if (comp._visible){
  526. max=Math.max(comp._x+comp.width *comp.scaleX,max);
  527. }
  528. }
  529. return max;
  530. }
  531. /**
  532. *<p>立即执行影响宽高度量的延迟调用函数。</p>
  533. *@internal <p>使用 <code>runCallLater</code> 函数,立即执行影响宽高度量的延迟运行函数(使用 <code>callLater</code> 设置延迟执行函数)。</p>
  534. *@see #callLater()
  535. *@see #runCallLater()
  536. */
  537. __proto.commitMeasure=function(){}
  538. /**
  539. *<p>显示对象的实际显示区域高度(以像素为单位)。</p>
  540. */
  541. __proto.measureHeight=function(){
  542. var max=0;
  543. this.commitMeasure();
  544. for (var i=this.numChildren-1;i >-1;i--){
  545. var comp=this.getChildAt(i);
  546. if (comp._visible){
  547. max=Math.max(comp._y+comp.height *comp.scaleY,max);
  548. }
  549. }
  550. return max;
  551. }
  552. __proto._sizeChanged=function(){
  553. if (!isNaN(this._anchorX))this.pivotX=this.anchorX *this.width;
  554. if (!isNaN(this._anchorY))this.pivotY=this.anchorY *this.height;
  555. this.event(/*laya.events.Event.RESIZE*/"resize");
  556. if (this._widget!==Widget.EMPTY)this._widget.resetLayout();
  557. }
  558. /**
  559. *对象的 <code>Event.MOUSE_OVER</code> 事件侦听处理函数。
  560. */
  561. __proto.onMouseOver=function(e){
  562. Laya.stage.event(/*laya.ui.UIEvent.SHOW_TIP*/"showtip",this._toolTip);
  563. }
  564. /**
  565. *对象的 <code>Event.MOUSE_OUT</code> 事件侦听处理函数。
  566. */
  567. __proto.onMouseOut=function(e){
  568. Laya.stage.event(/*laya.ui.UIEvent.HIDE_TIP*/"hidetip",this._toolTip);
  569. }
  570. /**
  571. *@private
  572. *<p>获取对象的布局样式。请不要直接修改此对象</p>
  573. */
  574. __proto._getWidget=function(){
  575. this._widget===Widget.EMPTY && (this._widget=this.addComponent(Widget));
  576. return this._widget;
  577. }
  578. /**@private */
  579. __proto.onCompResize=function(){
  580. this._sizeChanged();
  581. }
  582. __proto._childChanged=function(child){
  583. this.callLater(this._sizeChanged);
  584. _super.prototype._childChanged.call(this,child);
  585. }
  586. /**
  587. *<p>在父容器中,此对象的垂直方向中轴线与父容器的垂直方向中心线的距离(以像素为单位)。</p>
  588. */
  589. __getset(0,__proto,'centerY',function(){
  590. return this._widget.centerY;
  591. },function(value){
  592. if (value !=this._widget.centerY){
  593. this._getWidget().centerY=value;
  594. }
  595. });
  596. /**@inheritDoc */
  597. /**
  598. *<p>表示显示对象的宽度,以像素为单位。</p>
  599. *<p><b>注:</b>当值为0时,宽度为自适应大小。</p>
  600. */
  601. __getset(0,__proto,'width',function(){
  602. if (this._width)return this._width;
  603. return this.measureWidth();
  604. },function(value){
  605. if (Laya.superGet(Sprite,this,'width')==value)return;
  606. Laya.superSet(Sprite,this,'width',value);
  607. this.callLater(this._sizeChanged);
  608. });
  609. /**
  610. *<p>从组件底边到其内容区域底边之间的垂直距离(以像素为单位)。</p>
  611. */
  612. __getset(0,__proto,'bottom',function(){
  613. return this._widget.bottom;
  614. },function(value){
  615. if (value !=this._widget.bottom){
  616. this._getWidget().bottom=value;
  617. }
  618. });
  619. /**@inheritDoc */
  620. /**
  621. *<p>表示显示对象的高度,以像素为单位。</p>
  622. *<p><b>注:</b>当值为0时,高度为自适应大小。</p>
  623. */
  624. __getset(0,__proto,'height',function(){
  625. if (this._height)return this._height;
  626. return this.measureHeight();
  627. },function(value){
  628. if (Laya.superGet(Sprite,this,'height')==value)return;
  629. Laya.superSet(Sprite,this,'height',value);
  630. this.callLater(this._sizeChanged);
  631. });
  632. /**
  633. *<p>从组件左边到其内容区域左边之间的水平距离(以像素为单位)。</p>
  634. */
  635. __getset(0,__proto,'left',function(){
  636. return this._widget.left;
  637. },function(value){
  638. if (value !=this._widget.left){
  639. this._getWidget().left=value;
  640. }
  641. });
  642. /**
  643. *<p>数据赋值,通过对UI赋值来控制UI显示逻辑。</p>
  644. *<p>简单赋值会更改组件的默认属性,使用大括号可以指定组件的任意属性进行赋值。</p>
  645. *@example
  646. //默认属性赋值
  647. dataSource={label1:"改变了label",checkbox1:true};//(更改了label1的text属性值,更改checkbox1的selected属性)。
  648. //任意属性赋值
  649. dataSource={label2:{text:"改变了label",size:14},checkbox2:{selected:true,x:10}};
  650. */
  651. __getset(0,__proto,'dataSource',function(){
  652. return this._dataSource;
  653. },function(value){
  654. this._dataSource=value;
  655. for (var prop in this._dataSource){
  656. if (this.hasOwnProperty(prop)&& !((typeof (this[prop])=='function'))){
  657. this[prop]=this._dataSource[prop];
  658. }
  659. }
  660. });
  661. /**
  662. *<p>在父容器中,此对象的水平方向中轴线与父容器的水平方向中心线的距离(以像素为单位)。</p>
  663. */
  664. __getset(0,__proto,'centerX',function(){
  665. return this._widget.centerX;
  666. },function(value){
  667. if (value !=this._widget.centerX){
  668. this._getWidget().centerX=value;
  669. }
  670. });
  671. /**
  672. *<p>从组件顶边到其内容区域顶边之间的垂直距离(以像素为单位)。</p>
  673. */
  674. __getset(0,__proto,'top',function(){
  675. return this._widget.top;
  676. },function(value){
  677. if (value !=this._widget.top){
  678. this._getWidget().top=value;
  679. }
  680. });
  681. /**
  682. *<p>从组件右边到其内容区域右边之间的水平距离(以像素为单位)。</p>
  683. */
  684. __getset(0,__proto,'right',function(){
  685. return this._widget.right;
  686. },function(value){
  687. if (value !=this._widget.right){
  688. this._getWidget().right=value;
  689. }
  690. });
  691. /**
  692. *<p>对象的标签。</p>
  693. *@internal 冗余字段,可以用来储存数据。
  694. */
  695. __getset(0,__proto,'tag',function(){
  696. return this._tag;
  697. },function(value){
  698. this._tag=value;
  699. });
  700. /**
  701. *<p>鼠标悬停提示。</p>
  702. *<p>可以赋值为文本 <code>String</code> 或函数 <code>Handler</code> ,用来实现自定义样式的鼠标提示和参数携带等。</p>
  703. *@example
  704. *private var _testTips:TestTipsUI=new TestTipsUI();
  705. *private function testTips():void {
  706. //简单鼠标提示
  707. *btn2.toolTip="这里是鼠标提示&lt;b&gt;粗体&lt;/b&gt;&lt;br&gt;换行";
  708. //自定义的鼠标提示
  709. *btn1.toolTip=showTips1;
  710. //带参数的自定义鼠标提示
  711. *clip.toolTip=new Handler(this,showTips2,["clip"]);
  712. *}
  713. *private function showTips1():void {
  714. *_testTips.label.text="这里是按钮["+btn1.label+"]";
  715. *tip.addChild(_testTips);
  716. *}
  717. *private function showTips2(name:String):void {
  718. *_testTips.label.text="这里是"+name;
  719. *tip.addChild(_testTips);
  720. *}
  721. */
  722. __getset(0,__proto,'toolTip',function(){
  723. return this._toolTip;
  724. },function(value){
  725. if (this._toolTip !=value){
  726. this._toolTip=value;
  727. if (value !=null){
  728. this.on(/*laya.events.Event.MOUSE_OVER*/"mouseover",this,this.onMouseOver);
  729. this.on(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onMouseOut);
  730. }else {
  731. this.off(/*laya.events.Event.MOUSE_OVER*/"mouseover",this,this.onMouseOver);
  732. this.off(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onMouseOut);
  733. }
  734. }
  735. });
  736. /**是否变灰。*/
  737. __getset(0,__proto,'gray',function(){
  738. return this._gray;
  739. },function(value){
  740. if (value!==this._gray){
  741. this._gray=value;
  742. UIUtils.gray(this,value);
  743. }
  744. });
  745. /**是否禁用页面,设置为true后,会变灰并且禁用鼠标。*/
  746. __getset(0,__proto,'disabled',function(){
  747. return this._disabled;
  748. },function(value){
  749. if (value!==this._disabled){
  750. this.gray=this._disabled=value;
  751. this.mouseEnabled=!value;
  752. }
  753. });
  754. /**@inheritDoc */
  755. __getset(0,__proto,'scaleX',_super.prototype._$get_scaleX,function(value){
  756. if (Laya.superGet(Sprite,this,'scaleX')==value)return;
  757. Laya.superSet(Sprite,this,'scaleX',value);
  758. this.event(/*laya.events.Event.RESIZE*/"resize");
  759. });
  760. /**@inheritDoc */
  761. __getset(0,__proto,'scaleY',_super.prototype._$get_scaleY,function(value){
  762. if (Laya.superGet(Sprite,this,'scaleY')==value)return;
  763. Laya.superSet(Sprite,this,'scaleY',value);
  764. this.event(/*laya.events.Event.RESIZE*/"resize");
  765. });
  766. /**X锚点,值为0-1,设置anchorX值最终通过pivotX值来改变节点轴心点。*/
  767. __getset(0,__proto,'anchorX',function(){
  768. return this._anchorX;
  769. },function(value){
  770. if (this._anchorX !=value){
  771. this._anchorX=value;
  772. this.callLater(this._sizeChanged);
  773. }
  774. });
  775. /**Y锚点,值为0-1,设置anchorY值最终通过pivotY值来改变节点轴心点。*/
  776. __getset(0,__proto,'anchorY',function(){
  777. return this._anchorY;
  778. },function(value){
  779. if (this._anchorY !=value){
  780. this._anchorY=value
  781. this.callLater(this._sizeChanged);
  782. }
  783. });
  784. return UIComponent;
  785. })(Sprite)
  786. /**
  787. *<code>DialogManager</code> 对话框管理容器,所有的对话框都在该容器内,并且受管理器管理。
  788. *任意对话框打开和关闭,都会出发管理类的open和close事件
  789. *可以通过UIConfig设置弹出框背景透明度,模式窗口点击边缘是否关闭,点击窗口是否切换层次等
  790. *通过设置对话框的zOrder属性,可以更改弹出的层次
  791. */
  792. //class laya.ui.DialogManager extends laya.display.Sprite
  793. var DialogManager=(function(_super){
  794. function DialogManager(){
  795. /**锁屏层*/
  796. this.lockLayer=null;
  797. /**@private 全局默认弹出对话框效果,可以设置一个效果代替默认的弹出效果,如果不想有任何效果,可以赋值为null*/
  798. this.popupEffect=function(dialog){
  799. dialog.scale(1,1);
  800. dialog._effectTween=Tween.from(dialog,{x:Laya.stage.width / 2,y:Laya.stage.height / 2,scaleX:0,scaleY:0},300,Ease.backOut,Handler.create(this,this.doOpen,[dialog]),0,false,false);
  801. }
  802. /**@private 全局默认关闭对话框效果,可以设置一个效果代替默认的关闭效果,如果不想有任何效果,可以赋值为null*/
  803. this.closeEffect=function(dialog){
  804. dialog._effectTween=Tween.to(dialog,{x:Laya.stage.width / 2,y:Laya.stage.height / 2,scaleX:0,scaleY:0},300,Ease.strongOut,Handler.create(this,this.doClose,[dialog]),0,false,false);
  805. }
  806. DialogManager.__super.call(this);
  807. this.maskLayer=new Sprite();
  808. this.popupEffectHandler=new Handler(this,this.popupEffect);
  809. this.closeEffectHandler=new Handler(this,this.closeEffect);
  810. this.mouseEnabled=this.maskLayer.mouseEnabled=true;
  811. this.zOrder=1000;
  812. Laya.stage.addChild(this);
  813. Laya.stage.on(/*laya.events.Event.RESIZE*/"resize",this,this._onResize);
  814. if (UIConfig.closeDialogOnSide)this.maskLayer.on("click",this,this._closeOnSide);
  815. this._onResize(null);
  816. }
  817. __class(DialogManager,'laya.ui.DialogManager',_super);
  818. var __proto=DialogManager.prototype;
  819. __proto._closeOnSide=function(){
  820. var dialog=this.getChildAt(this.numChildren-1);
  821. if ((dialog instanceof laya.ui.Dialog ))dialog.close();
  822. }
  823. /**设置锁定界面,如果为空则什么都不显示*/
  824. __proto.setLockView=function(value){
  825. if (!this.lockLayer){
  826. this.lockLayer=new Box();
  827. this.lockLayer.mouseEnabled=true;
  828. this.lockLayer.size(Laya.stage.width,Laya.stage.height);
  829. }
  830. this.lockLayer.removeChildren();
  831. if (value){
  832. value.centerX=value.centerY=0;
  833. this.lockLayer.addChild(value);
  834. }
  835. }
  836. /**@private */
  837. __proto._onResize=function(e){
  838. var width=this.maskLayer.width=Laya.stage.width;
  839. var height=this.maskLayer.height=Laya.stage.height;
  840. if (this.lockLayer)this.lockLayer.size(width,height);
  841. this.maskLayer.graphics.clear(true);
  842. this.maskLayer.graphics.drawRect(0,0,width,height,UIConfig.popupBgColor);
  843. this.maskLayer.alpha=UIConfig.popupBgAlpha;
  844. for (var i=this.numChildren-1;i >-1;i--){
  845. var item=this.getChildAt(i);
  846. if (item.isPopupCenter)this._centerDialog(item);
  847. }
  848. }
  849. __proto._centerDialog=function(dialog){
  850. dialog.x=Math.round(((Laya.stage.width-dialog.width)>> 1)+dialog.pivotX);
  851. dialog.y=Math.round(((Laya.stage.height-dialog.height)>> 1)+dialog.pivotY);
  852. }
  853. /**
  854. *显示对话框
  855. *@param dialog 需要显示的对象框 <code>Dialog</code> 实例。
  856. *@param closeOther 是否关闭其它对话框,若值为ture,则关闭其它的对话框。
  857. *@param showEffect 是否显示弹出效果
  858. */
  859. __proto.open=function(dialog,closeOther,showEffect){
  860. (closeOther===void 0)&& (closeOther=false);
  861. (showEffect===void 0)&& (showEffect=false);
  862. if (closeOther)this._closeAll();
  863. this._clearDialogEffect(dialog);
  864. if (dialog.isPopupCenter)this._centerDialog(dialog);
  865. this.addChild(dialog);
  866. if (dialog.isModal || this._getBit(/*laya.Const.HAS_ZORDER*/0x20))Laya.timer.callLater(this,this._checkMask);
  867. if (showEffect && dialog.popupEffect !=null)dialog.popupEffect.runWith(dialog);
  868. else this.doOpen(dialog);
  869. this.event(/*laya.events.Event.OPEN*/"open");
  870. }
  871. /**@private */
  872. __proto._clearDialogEffect=function(dialog){
  873. if (dialog._effectTween){
  874. Tween.clear(dialog._effectTween);
  875. dialog._effectTween=null;
  876. }
  877. }
  878. /**
  879. *执行打开对话框。
  880. *@param dialog 需要关闭的对象框 <code>Dialog</code> 实例。
  881. */
  882. __proto.doOpen=function(dialog){
  883. dialog.onOpened(dialog._param);
  884. }
  885. /**
  886. *锁定所有层,显示加载条信息,防止双击
  887. */
  888. __proto.lock=function(value){
  889. if (this.lockLayer){
  890. if (value)this.addChild(this.lockLayer);
  891. else this.lockLayer.removeSelf();
  892. }
  893. }
  894. /**
  895. *关闭对话框。
  896. *@param dialog 需要关闭的对象框 <code>Dialog</code> 实例。
  897. */
  898. __proto.close=function(dialog){
  899. this._clearDialogEffect(dialog);
  900. if (dialog.isShowEffect && dialog.closeEffect !=null)dialog.closeEffect.runWith([dialog]);
  901. else this.doClose(dialog);
  902. this.event(/*laya.events.Event.CLOSE*/"close");
  903. }
  904. /**
  905. *执行关闭对话框。
  906. *@param dialog 需要关闭的对象框 <code>Dialog</code> 实例。
  907. */
  908. __proto.doClose=function(dialog){
  909. dialog.removeSelf();
  910. dialog.isModal && this._checkMask();
  911. dialog.closeHandler && dialog.closeHandler.runWith(dialog.closeType);
  912. dialog.onClosed(dialog.closeType);
  913. if (dialog.autoDestroyAtClosed)dialog.destroy();
  914. }
  915. /**
  916. *关闭所有的对话框。
  917. */
  918. __proto.closeAll=function(){
  919. this._closeAll();
  920. this.event(/*laya.events.Event.CLOSE*/"close");
  921. }
  922. /**@private */
  923. __proto._closeAll=function(){
  924. for (var i=this.numChildren-1;i >-1;i--){
  925. var item=this.getChildAt(i);
  926. if (item && item.close !=null){
  927. this.doClose(item);
  928. }
  929. }
  930. }
  931. /**
  932. *根据组获取所有对话框
  933. *@param group 组名称
  934. *@return 对话框数组
  935. */
  936. __proto.getDialogsByGroup=function(group){
  937. var arr=[];
  938. for (var i=this.numChildren-1;i >-1;i--){
  939. var item=this.getChildAt(i);
  940. if (item && item.group===group){
  941. arr.push(item);
  942. }
  943. }
  944. return arr;
  945. }
  946. /**
  947. *根据组关闭所有弹出框
  948. *@param group 需要关闭的组名称
  949. *@return 需要关闭的对话框数组
  950. */
  951. __proto.closeByGroup=function(group){
  952. var arr=[];
  953. for (var i=this.numChildren-1;i >-1;i--){
  954. var item=this.getChildAt(i);
  955. if (item && item.group===group){
  956. item.close();
  957. arr.push(item);
  958. }
  959. }
  960. return arr;
  961. }
  962. /**@private 发生层次改变后,重新检查遮罩层是否正确*/
  963. __proto._checkMask=function(){
  964. this.maskLayer.removeSelf();
  965. for (var i=this.numChildren-1;i >-1;i--){
  966. var dialog=this.getChildAt(i);
  967. if (dialog && dialog.isModal){
  968. this.addChildAt(this.maskLayer,i);
  969. return;
  970. }
  971. }
  972. }
  973. return DialogManager;
  974. })(Sprite)
  975. /**
  976. *<code>View</code> 是一个视图类,2.0开始,更改继承至Scene类,相对于Scene,增加相对布局功能。
  977. */
  978. //class laya.ui.View extends laya.display.Scene
  979. var View=(function(_super){
  980. function View(){
  981. /**@private */
  982. this._watchMap={};
  983. /**@private 相对布局组件*/
  984. this._widget=null;
  985. /**@private 控件的数据源。 */
  986. this._dataSource=null;
  987. this._anchorX=NaN;
  988. this._anchorY=NaN;
  989. this._widget=Widget.EMPTY;
  990. View.__super.call(this);
  991. }
  992. __class(View,'laya.ui.View',_super);
  993. var __proto=View.prototype;
  994. /**@inheritDoc */
  995. __proto.destroy=function(destroyChild){
  996. (destroyChild===void 0)&& (destroyChild=true);
  997. this._watchMap=null;
  998. _super.prototype.destroy.call(this,destroyChild);
  999. }
  1000. /**@private */
  1001. __proto.changeData=function(key){
  1002. var arr=this._watchMap[key];
  1003. if (!arr)return;
  1004. for (var i=0,n=arr.length;i < n;i++){
  1005. var watcher=arr[i];
  1006. watcher.exe(this);
  1007. }
  1008. }
  1009. /**@private */
  1010. __proto._sizeChanged=function(){
  1011. if (!isNaN(this._anchorX))this.pivotX=this.anchorX *this.width;
  1012. if (!isNaN(this._anchorY))this.pivotY=this.anchorY *this.height;
  1013. this.event(/*laya.events.Event.RESIZE*/"resize");
  1014. }
  1015. /**
  1016. *@private
  1017. *<p>获取对象的布局样式。请不要直接修改此对象</p>
  1018. */
  1019. __proto._getWidget=function(){
  1020. this._widget===Widget.EMPTY && (this._widget=this.addComponent(Widget));
  1021. return this._widget;
  1022. }
  1023. /**@private 兼容老版本*/
  1024. __proto.loadUI=function(path){
  1025. var uiView=View.uiMap[path];
  1026. View.uiMap && this.createView(uiView);
  1027. }
  1028. /**X锚点,值为0-1,设置anchorX值最终通过pivotX值来改变节点轴心点。*/
  1029. __getset(0,__proto,'anchorX',function(){
  1030. return this._anchorX;
  1031. },function(value){
  1032. if (this._anchorX !=value){
  1033. this._anchorX=value;
  1034. this.callLater(this._sizeChanged);
  1035. }
  1036. });
  1037. /**
  1038. *<p>在父容器中,此对象的水平方向中轴线与父容器的水平方向中心线的距离(以像素为单位)。</p>
  1039. */
  1040. __getset(0,__proto,'centerX',function(){
  1041. return this._widget.centerX;
  1042. },function(value){
  1043. if (value !=this._widget.centerX){
  1044. this._getWidget().centerX=value;
  1045. }
  1046. });
  1047. /**
  1048. *<p>从组件顶边到其内容区域顶边之间的垂直距离(以像素为单位)。</p>
  1049. */
  1050. __getset(0,__proto,'top',function(){
  1051. return this._widget.top;
  1052. },function(value){
  1053. if (value !=this._widget.top){
  1054. this._getWidget().top=value;
  1055. }
  1056. });
  1057. /**
  1058. *<p>从组件底边到其内容区域底边之间的垂直距离(以像素为单位)。</p>
  1059. */
  1060. __getset(0,__proto,'bottom',function(){
  1061. return this._widget.bottom;
  1062. },function(value){
  1063. if (value !=this._widget.bottom){
  1064. this._getWidget().bottom=value;
  1065. }
  1066. });
  1067. /**@see laya.ui.UIComponent#dataSource*/
  1068. __getset(0,__proto,'dataSource',function(){
  1069. return this._dataSource;
  1070. },function(value){
  1071. this._dataSource=value;
  1072. for (var name in value){
  1073. var comp=this.getChildByName(name);
  1074. if ((comp instanceof laya.ui.UIComponent ))comp.dataSource=value[name];
  1075. else if (this.hasOwnProperty(name)&& !((typeof (this[name])=='function')))this[name]=value[name];
  1076. }
  1077. });
  1078. /**
  1079. *<p>从组件左边到其内容区域左边之间的水平距离(以像素为单位)。</p>
  1080. */
  1081. __getset(0,__proto,'left',function(){
  1082. return this._widget.left;
  1083. },function(value){
  1084. if (value !=this._widget.left){
  1085. this._getWidget().left=value;
  1086. }
  1087. });
  1088. /**
  1089. *<p>从组件右边到其内容区域右边之间的水平距离(以像素为单位)。</p>
  1090. */
  1091. __getset(0,__proto,'right',function(){
  1092. return this._widget.right;
  1093. },function(value){
  1094. if (value !=this._widget.right){
  1095. this._getWidget().right=value;
  1096. }
  1097. });
  1098. /**Y锚点,值为0-1,设置anchorY值最终通过pivotY值来改变节点轴心点。*/
  1099. __getset(0,__proto,'anchorY',function(){
  1100. return this._anchorY;
  1101. },function(value){
  1102. if (this._anchorY !=value){
  1103. this._anchorY=value
  1104. this.callLater(this._sizeChanged);
  1105. }
  1106. });
  1107. /**
  1108. *<p>在父容器中,此对象的垂直方向中轴线与父容器的垂直方向中心线的距离(以像素为单位)。</p>
  1109. */
  1110. __getset(0,__proto,'centerY',function(){
  1111. return this._widget.centerY;
  1112. },function(value){
  1113. if (value !=this._widget.centerY){
  1114. this._getWidget().centerY=value;
  1115. }
  1116. });
  1117. View.regComponent=function(key,compClass){
  1118. ClassUtils.regClass(key,compClass);
  1119. }
  1120. View.regViewRuntime=function(key,compClass){
  1121. ClassUtils.regClass(key,compClass);
  1122. }
  1123. View.regUI=function(url,json){
  1124. Laya.loader.cacheRes(url,json);
  1125. }
  1126. View.uiMap={};
  1127. View.__init$=function(){
  1128. ClassUtils.regShortClassName([ViewStack,Button,TextArea,ColorPicker,Box,ScaleBox,Button,CheckBox,Clip,ComboBox,UIComponent,HScrollBar,HSlider,Image,Label,List,Panel,ProgressBar,Radio,RadioGroup,ScrollBar,Slider,Tab,TextInput,View,Dialog,VScrollBar,VSlider,Tree,HBox,VBox,Sprite,Animation,Text,FontClip]);
  1129. }
  1130. return View;
  1131. })(Scene)
  1132. /**
  1133. *微信开放数据展示组件,直接实例本组件,即可根据组件宽高,位置,以最优的方式显示开放域数据
  1134. */
  1135. //class laya.ui.WXOpenDataViewer extends laya.ui.UIComponent
  1136. var WXOpenDataViewer=(function(_super){
  1137. function WXOpenDataViewer(){
  1138. this._$4__texture=null;
  1139. WXOpenDataViewer.__super.call(this);
  1140. this._width=this._height=200;
  1141. var tex=new Texture();
  1142. if (Laya["Texture2D"]){
  1143. tex.bitmap=new Laya["Texture2D"]();
  1144. this.texture=tex;
  1145. }else {
  1146. throw new Error("WXOpenDataViewer:webgl not found!");
  1147. }
  1148. }
  1149. __class(WXOpenDataViewer,'laya.ui.WXOpenDataViewer',_super);
  1150. var __proto=WXOpenDataViewer.prototype;
  1151. __proto.onEnable=function(){
  1152. this.postMsg({type:"display",rate:Laya.stage.frameRate});
  1153. if (window.wx && window.sharedCanvas)Laya.timer.frameLoop(1,this,this._onLoop);
  1154. }
  1155. __proto.onDisable=function(){
  1156. this.postMsg({type:"undisplay"});
  1157. Laya.timer.clear(this,this._onLoop);
  1158. }
  1159. __proto._onLoop=function(){
  1160. this.texture.bitmap.loadImageSource(window.sharedCanvas);
  1161. }
  1162. __proto._postMsg=function(){
  1163. var mat=new Matrix();
  1164. mat.translate(this.x,this.y);
  1165. var stage=Laya.stage;
  1166. mat.scale(stage._canvasTransform.getScaleX()*this.globalScaleX *stage.transform.getScaleX(),stage._canvasTransform.getScaleY()*this.globalScaleY *stage.transform.getScaleY());
  1167. 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});
  1168. }
  1169. /**向开放数据域发送消息*/
  1170. __proto.postMsg=function(msg){
  1171. if (window.wx && window.wx.getOpenDataContext){
  1172. var openDataContext=window.wx.getOpenDataContext();
  1173. openDataContext.postMessage(msg);
  1174. }
  1175. }
  1176. __getset(0,__proto,'x',_super.prototype._$get_x,function(value){
  1177. Laya.superSet(UIComponent,this,'x',value);
  1178. this.callLater(this._postMsg);
  1179. });
  1180. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  1181. Laya.superSet(UIComponent,this,'width',value);
  1182. if (window.sharedCanvas)window.sharedCanvas.width=value;
  1183. this.callLater(this._postMsg);
  1184. });
  1185. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  1186. Laya.superSet(UIComponent,this,'height',value);
  1187. if (window.sharedCanvas)window.sharedCanvas.height=value;
  1188. this.callLater(this._postMsg);
  1189. });
  1190. __getset(0,__proto,'y',_super.prototype._$get_y,function(value){
  1191. Laya.superSet(UIComponent,this,'y',value);
  1192. this.callLater(this._postMsg);
  1193. });
  1194. return WXOpenDataViewer;
  1195. })(UIComponent)
  1196. /**
  1197. *<code>Box</code> 类是一个控件容器类。
  1198. */
  1199. //class laya.ui.Box extends laya.ui.UIComponent
  1200. var Box=(function(_super){
  1201. function Box(){
  1202. this._bgColor=null;
  1203. Box.__super.call(this);
  1204. }
  1205. __class(Box,'laya.ui.Box',_super);
  1206. var __proto=Box.prototype;
  1207. Laya.imps(__proto,{"laya.ui.IBox":true})
  1208. __proto._onResize=function(e){
  1209. this.graphics.clear();
  1210. this.graphics.drawRect(0,0,this.width,this.height,this._bgColor);
  1211. }
  1212. /**@inheritDoc */
  1213. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  1214. this._dataSource=value;
  1215. for (var name in value){
  1216. var comp=this.getChildByName(name);
  1217. if (comp)comp.dataSource=value[name];
  1218. else if (this.hasOwnProperty(name)&& !((typeof (this[name])=='function')))this[name]=value[name];
  1219. }
  1220. });
  1221. /**背景颜色*/
  1222. __getset(0,__proto,'bgColor',function(){
  1223. return this._bgColor;
  1224. },function(value){
  1225. this._bgColor=value;
  1226. if (value){
  1227. this._onResize(null);
  1228. this.on(/*laya.events.Event.RESIZE*/"resize",this,this._onResize);
  1229. }else {
  1230. this.graphics.clear();
  1231. this.off(/*laya.events.Event.RESIZE*/"resize",this,this._onResize);
  1232. }
  1233. });
  1234. return Box;
  1235. })(UIComponent)
  1236. /**
  1237. *<code>Button</code> 组件用来表示常用的多态按钮。 <code>Button</code> 组件可显示文本标签、图标或同时显示两者。 *
  1238. *<p>可以是单态,两态和三态,默认三态(up,over,down)。</p>
  1239. *
  1240. *@example <caption>以下示例代码,创建了一个 <code>Button</code> 实例。</caption>
  1241. *package
  1242. *{
  1243. *import laya.ui.Button;
  1244. *import laya.utils.Handler;
  1245. *public class Button_Example
  1246. *{
  1247. *public function Button_Example()
  1248. *{
  1249. *Laya.init(640,800);//设置游戏画布宽高。
  1250. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  1251. *Laya.loader.load("resource/ui/button.png",Handler.create(this,onLoadComplete));//加载资源。
  1252. *}
  1253. *private function onLoadComplete():void
  1254. *{
  1255. *trace("资源加载完成!");
  1256. *var button:Button=new Button("resource/ui/button.png","label");//创建一个 Button 类的实例对象 button ,并传入它的皮肤。
  1257. *button.x=100;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。
  1258. *button.y=100;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。
  1259. *button.clickHandler=new Handler(this,onClickButton,[button]);//设置 button 的点击事件处理器。
  1260. *Laya.stage.addChild(button);//将此 button 对象添加到显示列表。
  1261. *}
  1262. *private function onClickButton(button:Button):void
  1263. *{
  1264. *trace("按钮button被点击了!");
  1265. *}
  1266. *}
  1267. *}
  1268. *@example
  1269. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  1270. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  1271. *Laya.loader.load("resource/ui/button.png",laya.utils.Handler.create(this,loadComplete));//加载资源
  1272. *function loadComplete()
  1273. *{
  1274. *console.log("资源加载完成!");
  1275. *var button=new laya.ui.Button("resource/ui/button.png","label");//创建一个 Button 类的实例对象 button ,传入它的皮肤skin和标签label。
  1276. *button.x=100;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。
  1277. *button.y=100;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。
  1278. *button.clickHandler=laya.utils.Handler.create(this,onClickButton,[button],false);//设置 button 的点击事件处理函数。
  1279. *Laya.stage.addChild(button);//将此 button 对象添加到显示列表。
  1280. *}
  1281. *function onClickButton(button)
  1282. *{
  1283. *console.log("按钮被点击了。",button);
  1284. *}
  1285. *@example
  1286. *import Button=laya.ui.Button;
  1287. *import Handler=laya.utils.Handler;
  1288. *class Button_Example{
  1289. *constructor()
  1290. *{
  1291. *Laya.init(640,800);
  1292. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  1293. *Laya.loader.load("resource/ui/button.png",laya.utils.Handler.create(this,this.onLoadComplete));//加载资源。
  1294. *}
  1295. *private onLoadComplete()
  1296. *{
  1297. *var button:Button=new Button("resource/ui/button.png","label");//创建一个 Button 类的实例对象 button ,并传入它的皮肤。
  1298. *button.x=100;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。
  1299. *button.y=100;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。
  1300. *button.clickHandler=new Handler(this,this.onClickButton,[button]);//设置 button 的点击事件处理器。
  1301. *Laya.stage.addChild(button);//将此 button 对象添加到显示列表。
  1302. *}
  1303. *private onClickButton(button:Button):void
  1304. *{
  1305. *console.log("按钮button被点击了!")
  1306. *}
  1307. *}
  1308. */
  1309. //class laya.ui.Button extends laya.ui.UIComponent
  1310. var Button=(function(_super){
  1311. function Button(skin,label){
  1312. /**
  1313. *指定按钮按下时是否是切换按钮的显示状态。
  1314. *
  1315. *@example 以下示例代码,创建了一个 <code>Button</code> 实例,并设置为切换按钮。
  1316. *@example
  1317. *package
  1318. *{
  1319. *import laya.ui.Button;
  1320. *import laya.utils.Handler;
  1321. *public class Button_toggle
  1322. *{
  1323. *public function Button_toggle()
  1324. *{
  1325. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  1326. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  1327. *Laya.loader.load("resource/ui/button.png",Handler.create(this,onLoadComplete));
  1328. *}
  1329. *private function onLoadComplete():void
  1330. *{
  1331. *trace("资源加载完成!");
  1332. *var button:Button=new Button("resource/ui/button.png","label");//创建一个 Button 实例对象 button ,传入它的皮肤skin和标签label。
  1333. *button.x=100;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。
  1334. *button.y=100;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。
  1335. *button.toggle=true;//设置 button 对象为切换按钮。
  1336. *button.clickHandler=new Handler(this,onClickButton,[button]);//设置 button 的点击事件处理器。
  1337. *Laya.stage.addChild(button);//将此 button 对象添加到显示列表。
  1338. *}
  1339. *private function onClickButton(button:Button):void
  1340. *{
  1341. *trace("button.selected = "+button.selected);
  1342. *}
  1343. *}
  1344. *}
  1345. *@example
  1346. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  1347. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  1348. *Laya.loader.load("resource/ui/button.png",laya.utils.Handler.create(this,loadComplete));//加载资源
  1349. *function loadComplete()
  1350. *{
  1351. *console.log("资源加载完成!");
  1352. *var button=new laya.ui.Button("resource/ui/button.png","label");//创建一个 Button 类的实例对象 button ,传入它的皮肤skin和标签label。
  1353. *button.x=100;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。
  1354. *button.y=100;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。
  1355. *button.toggle=true;//设置 button 对象为切换按钮。
  1356. *button.clickHandler=laya.utils.Handler.create(this,onClickButton,[button],false);//设置 button 的点击事件处理器。
  1357. *Laya.stage.addChild(button);//将此 button 对象添加到显示列表。
  1358. *}
  1359. *function onClickButton(button)
  1360. *{
  1361. *console.log("button.selected = ",button.selected);
  1362. *}
  1363. *@example
  1364. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  1365. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  1366. *Laya.loader.load("button.png",null,null,null,null,null);//加载资源
  1367. *function loadComplete(){
  1368. *console.log("资源加载完成!");
  1369. *var button:laya.ui.Button=new laya.ui.Button("button.png","label");//创建一个 Button 类的实例对象 button ,传入它的皮肤skin和标签label。
  1370. *button.x=100;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。
  1371. *button.y=100;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。
  1372. *button.toggle=true;//设置 button 对象为切换按钮。
  1373. *button.clickHandler=laya.utils.Handler.create(this,onClickButton,[button],false);//设置 button 的点击事件处理器。
  1374. *Laya.stage.addChild(button);//将此 button 对象添加到显示列表。
  1375. *}
  1376. *function onClickButton(button){
  1377. *console.log("button.selected = ",button.selected);
  1378. *}
  1379. */
  1380. this.toggle=false;
  1381. /**
  1382. *@private
  1383. */
  1384. this._bitmap=null;
  1385. /**
  1386. *@private
  1387. *按钮上的文本。
  1388. */
  1389. this._text=null;
  1390. /**
  1391. *@private
  1392. *按钮文本标签描边的颜色值。
  1393. */
  1394. this._strokeColors=null;
  1395. /**
  1396. *@private
  1397. *按钮的状态值。
  1398. */
  1399. this._state=0;
  1400. /**
  1401. *@private
  1402. *表示按钮的选中状态。
  1403. */
  1404. this._selected=false;
  1405. /**
  1406. *@private
  1407. *按钮的皮肤资源。
  1408. */
  1409. this._skin=null;
  1410. /**
  1411. *@private
  1412. *指定此显示对象是否自动计算并改变大小等属性。
  1413. */
  1414. this._autoSize=true;
  1415. /**
  1416. *@private
  1417. *源数据。
  1418. */
  1419. this._sources=null;
  1420. /**
  1421. *@private
  1422. *按钮的点击事件函数。
  1423. */
  1424. this._clickHandler=null;
  1425. /**
  1426. *@private
  1427. */
  1428. this._stateChanged=false;
  1429. Button.__super.call(this);
  1430. this._labelColors=Styles.buttonLabelColors;
  1431. this._stateNum=Styles.buttonStateNum;
  1432. (label===void 0)&& (label="");
  1433. this.skin=skin;
  1434. this.label=label;
  1435. }
  1436. __class(Button,'laya.ui.Button',_super);
  1437. var __proto=Button.prototype;
  1438. Laya.imps(__proto,{"laya.ui.ISelect":true})
  1439. /**@inheritDoc */
  1440. __proto.destroy=function(destroyChild){
  1441. (destroyChild===void 0)&& (destroyChild=true);
  1442. _super.prototype.destroy.call(this,destroyChild);
  1443. this._bitmap && this._bitmap.destroy();
  1444. this._text && this._text.destroy(destroyChild);
  1445. this._bitmap=null;
  1446. this._text=null;
  1447. this._clickHandler=null;
  1448. this._labelColors=this._sources=this._strokeColors=null;
  1449. }
  1450. /**@inheritDoc */
  1451. __proto.createChildren=function(){
  1452. this.graphics=this._bitmap=new AutoBitmap();
  1453. }
  1454. /**@private */
  1455. __proto.createText=function(){
  1456. if (!this._text){
  1457. this._text=new Text();
  1458. this._text.overflow=/*laya.display.Text.HIDDEN*/"hidden";
  1459. this._text.align="center";
  1460. this._text.valign="middle";
  1461. this._text.width=this._width;
  1462. this._text.height=this._height;
  1463. }
  1464. }
  1465. /**@inheritDoc */
  1466. __proto.initialize=function(){
  1467. if (this._mouseState!==1){
  1468. this.mouseEnabled=true;
  1469. this._setBit(/*laya.Const.HAS_MOUSE*/0x40,true);
  1470. }
  1471. this._createListener(/*laya.events.Event.MOUSE_OVER*/"mouseover",this,this.onMouse,null,false,false);
  1472. this._createListener(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onMouse,null,false,false);
  1473. this._createListener(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onMouse,null,false,false);
  1474. this._createListener(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onMouse,null,false,false);
  1475. this._createListener(/*laya.events.Event.CLICK*/"click",this,this.onMouse,null,false,false);
  1476. }
  1477. /**
  1478. *对象的 <code>Event.MOUSE_OVER、Event.MOUSE_OUT、Event.MOUSE_DOWN、Event.MOUSE_UP、Event.CLICK</code> 事件侦听处理函数。
  1479. *@param e Event 对象。
  1480. */
  1481. __proto.onMouse=function(e){
  1482. if (this.toggle===false && this._selected)return;
  1483. if (e.type===/*laya.events.Event.CLICK*/"click"){
  1484. this.toggle && (this.selected=!this._selected);
  1485. this._clickHandler && this._clickHandler.run();
  1486. return;
  1487. }
  1488. !this._selected && (this.state=Button.stateMap[e.type]);
  1489. }
  1490. __proto._skinLoaded=function(){
  1491. this.callLater(this.changeClips);
  1492. this._setStateChanged();
  1493. this._sizeChanged();
  1494. this.event(/*laya.events.Event.LOADED*/"loaded");
  1495. }
  1496. /**
  1497. *@private
  1498. *对象的资源切片发生改变。
  1499. */
  1500. __proto.changeClips=function(){
  1501. var img=Loader.getRes(this._skin);
  1502. if (!img){
  1503. console.log("lose skin",this._skin);
  1504. return;
  1505. };
  1506. var width=img.sourceWidth;
  1507. var height=img.sourceHeight / this._stateNum;
  1508. img.$_GID || (img.$_GID=Utils.getGID());
  1509. var key=img.$_GID+"-"+this._stateNum;
  1510. var clips=WeakObject.I.get(key);
  1511. if (!Utils.isOkTextureList(clips)){
  1512. clips=null;
  1513. }
  1514. if (clips)this._sources=clips;
  1515. else {
  1516. this._sources=[];
  1517. if (this._stateNum===1){
  1518. this._sources.push(img);
  1519. }else {
  1520. for (var i=0;i < this._stateNum;i++){
  1521. this._sources.push(Texture.createFromTexture(img,0,height *i,width,height));
  1522. }
  1523. }
  1524. WeakObject.I.set(key,this._sources);
  1525. }
  1526. if (this._autoSize){
  1527. this._bitmap.width=this._width || width;
  1528. this._bitmap.height=this._height || height;
  1529. if (this._text){
  1530. this._text.width=this._bitmap.width;
  1531. this._text.height=this._bitmap.height;
  1532. }
  1533. }else {
  1534. this._text && (this._text.x=width);
  1535. }
  1536. }
  1537. /**
  1538. *@inheritDoc
  1539. */
  1540. __proto.measureWidth=function(){
  1541. this.runCallLater(this.changeClips);
  1542. if (this._autoSize)return this._bitmap.width;
  1543. this.runCallLater(this.changeState);
  1544. return this._bitmap.width+(this._text ? this._text.width :0);
  1545. }
  1546. /**
  1547. *@inheritDoc
  1548. */
  1549. __proto.measureHeight=function(){
  1550. this.runCallLater(this.changeClips);
  1551. return this._text ? Math.max(this._bitmap.height,this._text.height):this._bitmap.height;
  1552. }
  1553. /**
  1554. *@private
  1555. *改变对象的状态。
  1556. */
  1557. __proto.changeState=function(){
  1558. this._stateChanged=false;
  1559. this.runCallLater(this.changeClips);
  1560. var index=this._state < this._stateNum ? this._state :this._stateNum-1;
  1561. this._sources && (this._bitmap.source=this._sources[index]);
  1562. if (this.label){
  1563. this._text.color=this._labelColors[index];
  1564. if (this._strokeColors)this._text.strokeColor=this._strokeColors[index];
  1565. }
  1566. }
  1567. /**@private */
  1568. __proto._setStateChanged=function(){
  1569. if (!this._stateChanged){
  1570. this._stateChanged=true;
  1571. this.callLater(this.changeState);
  1572. }
  1573. }
  1574. /**
  1575. *<p>对象的皮肤资源地址。</p>
  1576. *支持单态,两态和三态,用 <code>stateNum</code> 属性设置
  1577. *<p>对象的皮肤地址,以字符串表示。</p>
  1578. *@see #stateNum
  1579. */
  1580. __getset(0,__proto,'skin',function(){
  1581. return this._skin;
  1582. },function(value){
  1583. if (this._skin !=value){
  1584. this._skin=value;
  1585. if (value){
  1586. if (!Loader.getRes(value)){
  1587. Laya.loader.load(this._skin,Handler.create(this,this._skinLoaded),null,/*laya.net.Loader.IMAGE*/"image",1);
  1588. }else{
  1589. this._skinLoaded();
  1590. }
  1591. }else {
  1592. this._skinLoaded();
  1593. }
  1594. }
  1595. });
  1596. /**
  1597. *表示按钮文本标签的边距。
  1598. *<p><b>格式:</b>"上边距,右边距,下边距,左边距"。</p>
  1599. */
  1600. __getset(0,__proto,'labelPadding',function(){
  1601. this.createText();
  1602. return this._text.padding.join(",");
  1603. },function(value){
  1604. this.createText();
  1605. this._text.padding=UIUtils.fillArray(Styles.labelPadding,value,Number);
  1606. });
  1607. /**
  1608. *对象的状态值。
  1609. *@see #stateMap
  1610. */
  1611. __getset(0,__proto,'state',function(){
  1612. return this._state;
  1613. },function(value){
  1614. if (this._state !=value){
  1615. this._state=value;
  1616. this._setStateChanged();
  1617. }
  1618. });
  1619. /**
  1620. *按钮文本标签 <code>Text</code> 控件。
  1621. */
  1622. __getset(0,__proto,'text',function(){
  1623. this.createText();
  1624. return this._text;
  1625. });
  1626. /**
  1627. *<p>指定对象的状态值,以数字表示。</p>
  1628. *<p>默认值为3。此值决定皮肤资源图片的切割方式。</p>
  1629. *<p><b>取值:</b>
  1630. *<li>1:单态。图片不做切割,按钮的皮肤状态只有一种。</li>
  1631. *<li>2:两态。图片将以竖直方向被等比切割为2部分,从上向下,依次为
  1632. *弹起状态皮肤、
  1633. *按下和经过及选中状态皮肤。</li>
  1634. *<li>3:三态。图片将以竖直方向被等比切割为3部分,从上向下,依次为
  1635. *弹起状态皮肤、
  1636. *经过状态皮肤、
  1637. *按下和选中状态皮肤</li>
  1638. *</p>
  1639. */
  1640. __getset(0,__proto,'stateNum',function(){
  1641. return this._stateNum;
  1642. },function(value){
  1643. if ((typeof value=='string')){
  1644. value=parseInt(value);
  1645. }
  1646. if (this._stateNum !=value){
  1647. this._stateNum=value < 1 ? 1 :value > 3 ? 3 :value;
  1648. this.callLater(this.changeClips);
  1649. }
  1650. });
  1651. /**
  1652. *按钮的文本内容。
  1653. */
  1654. __getset(0,__proto,'label',function(){
  1655. return this._text ? this._text.text :null;
  1656. },function(value){
  1657. if (!this._text && !value)return;
  1658. this.createText();
  1659. if (this._text.text !=value){
  1660. value && !this._text.parent && this.addChild(this._text);
  1661. this._text.text=(value+"").replace(/\\n/g,"\n");
  1662. this._setStateChanged();
  1663. }
  1664. });
  1665. /**
  1666. *表示按钮文本标签的字体大小。
  1667. *@see laya.display.Text.fontSize()
  1668. */
  1669. __getset(0,__proto,'labelSize',function(){
  1670. this.createText();
  1671. return this._text.fontSize;
  1672. },function(value){
  1673. this.createText();
  1674. this._text.fontSize=value
  1675. });
  1676. /**
  1677. *表示按钮的选中状态。
  1678. *<p>如果值为true,表示该对象处于选中状态。否则该对象处于未选中状态。</p>
  1679. */
  1680. __getset(0,__proto,'selected',function(){
  1681. return this._selected;
  1682. },function(value){
  1683. if (this._selected !=value){
  1684. this._selected=value;
  1685. this.state=this._selected ? 2 :0;
  1686. this.event(/*laya.events.Event.CHANGE*/"change");
  1687. }
  1688. });
  1689. /**
  1690. *表示按钮各个状态下的描边颜色。
  1691. *<p><b>格式:</b> "upColor,overColor,downColor,disableColor"。</p>
  1692. */
  1693. __getset(0,__proto,'strokeColors',function(){
  1694. return this._strokeColors ? this._strokeColors.join(","):"";
  1695. },function(value){
  1696. this._strokeColors=UIUtils.fillArray(Styles.buttonLabelColors,value,String);
  1697. this._setStateChanged();
  1698. });
  1699. /**
  1700. *表示按钮各个状态下的文本颜色。
  1701. *<p><b>格式:</b> "upColor,overColor,downColor,disableColor"。</p>
  1702. */
  1703. __getset(0,__proto,'labelColors',function(){
  1704. return this._labelColors.join(",");
  1705. },function(value){
  1706. this._labelColors=UIUtils.fillArray(Styles.buttonLabelColors,value,String);
  1707. this._setStateChanged();
  1708. });
  1709. /**
  1710. *<p>描边宽度(以像素为单位)。</p>
  1711. *默认值0,表示不描边。
  1712. *@see laya.display.Text.stroke()
  1713. */
  1714. __getset(0,__proto,'labelStroke',function(){
  1715. this.createText();
  1716. return this._text.stroke;
  1717. },function(value){
  1718. this.createText();
  1719. this._text.stroke=value
  1720. });
  1721. /**
  1722. *<p>描边颜色,以字符串表示。</p>
  1723. *默认值为 "#000000"(黑色);
  1724. *@see laya.display.Text.strokeColor()
  1725. */
  1726. __getset(0,__proto,'labelStrokeColor',function(){
  1727. this.createText();
  1728. return this._text.strokeColor;
  1729. },function(value){
  1730. this.createText();
  1731. this._text.strokeColor=value
  1732. });
  1733. /**
  1734. *表示按钮文本标签是否为粗体字。
  1735. *@see laya.display.Text.bold()
  1736. */
  1737. __getset(0,__proto,'labelBold',function(){
  1738. this.createText();
  1739. return this._text.bold;
  1740. },function(value){
  1741. this.createText();
  1742. this._text.bold=value;
  1743. });
  1744. /**
  1745. *表示按钮文本标签的字体名称,以字符串形式表示。
  1746. *@see laya.display.Text.font()
  1747. */
  1748. __getset(0,__proto,'labelFont',function(){
  1749. this.createText();
  1750. return this._text.font;
  1751. },function(value){
  1752. this.createText();
  1753. this._text.font=value;
  1754. });
  1755. /**标签对齐模式,默认为居中对齐。*/
  1756. __getset(0,__proto,'labelAlign',function(){
  1757. this.createText()
  1758. return this._text.align;
  1759. },function(value){
  1760. this.createText()
  1761. this._text.align=value;
  1762. });
  1763. /**
  1764. *对象的点击事件处理器函数(无默认参数)。
  1765. */
  1766. __getset(0,__proto,'clickHandler',function(){
  1767. return this._clickHandler;
  1768. },function(value){
  1769. this._clickHandler=value;
  1770. });
  1771. /**
  1772. *<p>当前实例的位图 <code>AutoImage</code> 实例的有效缩放网格数据。</p>
  1773. *<p>数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。
  1774. *<ul><li>例如:"4,4,4,4,1"</li></ul></p>
  1775. *@see laya.ui.AutoBitmap.sizeGrid
  1776. */
  1777. __getset(0,__proto,'sizeGrid',function(){
  1778. if (this._bitmap.sizeGrid)return this._bitmap.sizeGrid.join(",");
  1779. return null;
  1780. },function(value){
  1781. this._bitmap.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number);
  1782. });
  1783. /**@inheritDoc */
  1784. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  1785. Laya.superSet(UIComponent,this,'width',value);
  1786. if (this._autoSize){
  1787. this._bitmap.width=value;
  1788. this._text && (this._text.width=value);
  1789. }
  1790. });
  1791. /**@inheritDoc */
  1792. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  1793. Laya.superSet(UIComponent,this,'height',value);
  1794. if (this._autoSize){
  1795. this._bitmap.height=value;
  1796. this._text && (this._text.height=value);
  1797. }
  1798. });
  1799. /**@inheritDoc */
  1800. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  1801. this._dataSource=value;
  1802. if ((typeof value=='number')|| (typeof value=='string'))this.label=value+"";
  1803. else Laya.superSet(UIComponent,this,'dataSource',value);
  1804. });
  1805. /**图标x,y偏移,格式:100,100*/
  1806. __getset(0,__proto,'iconOffset',function(){
  1807. return this._bitmap._offset ? this._bitmap._offset.join(","):null;
  1808. },function(value){
  1809. if (value)this._bitmap._offset=UIUtils.fillArray([1,1],value,Number);
  1810. else this._bitmap._offset=[];
  1811. });
  1812. __static(Button,
  1813. ['stateMap',function(){return this.stateMap={"mouseup":0,"mouseover":1,"mousedown":2,"mouseout":0};}
  1814. ]);
  1815. return Button;
  1816. })(UIComponent)
  1817. /**
  1818. *<code>Image</code> 类是用于表示位图图像或绘制图形的显示对象。
  1819. *Image和Clip组件是唯一支持异步加载的两个组件,比如img.skin="abc/xxx.png",其他UI组件均不支持异步加载。
  1820. *
  1821. *@example <caption>以下示例代码,创建了一个新的 <code>Image</code> 实例,设置了它的皮肤、位置信息,并添加到舞台上。</caption>
  1822. *package
  1823. *{
  1824. *import laya.ui.Image;
  1825. *public class Image_Example
  1826. *{
  1827. *public function Image_Example()
  1828. *{
  1829. *Laya.init(640,800);//设置游戏画布宽高。
  1830. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  1831. *onInit();
  1832. *}
  1833. *private function onInit():void
  1834. *{
  1835. *var bg:Image=new Image("resource/ui/bg.png");//创建一个 Image 类的实例对象 bg ,并传入它的皮肤。
  1836. *bg.x=100;//设置 bg 对象的属性 x 的值,用于控制 bg 对象的显示位置。
  1837. *bg.y=100;//设置 bg 对象的属性 y 的值,用于控制 bg 对象的显示位置。
  1838. *bg.sizeGrid="40,10,5,10";//设置 bg 对象的网格信息。
  1839. *bg.width=150;//设置 bg 对象的宽度。
  1840. *bg.height=250;//设置 bg 对象的高度。
  1841. *Laya.stage.addChild(bg);//将此 bg 对象添加到显示列表。
  1842. *var image:Image=new Image("resource/ui/image.png");//创建一个 Image 类的实例对象 image ,并传入它的皮肤。
  1843. *image.x=100;//设置 image 对象的属性 x 的值,用于控制 image 对象的显示位置。
  1844. *image.y=100;//设置 image 对象的属性 y 的值,用于控制 image 对象的显示位置。
  1845. *Laya.stage.addChild(image);//将此 image 对象添加到显示列表。
  1846. *}
  1847. *}
  1848. *}
  1849. *@example
  1850. *Laya.init(640,800);//设置游戏画布宽高
  1851. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  1852. *onInit();
  1853. *function onInit(){
  1854. *var bg=new laya.ui.Image("resource/ui/bg.png");//创建一个 Image 类的实例对象 bg ,并传入它的皮肤。
  1855. *bg.x=100;//设置 bg 对象的属性 x 的值,用于控制 bg 对象的显示位置。
  1856. *bg.y=100;//设置 bg 对象的属性 y 的值,用于控制 bg 对象的显示位置。
  1857. *bg.sizeGrid="40,10,5,10";//设置 bg 对象的网格信息。
  1858. *bg.width=150;//设置 bg 对象的宽度。
  1859. *bg.height=250;//设置 bg 对象的高度。
  1860. *Laya.stage.addChild(bg);//将此 bg 对象添加到显示列表。
  1861. *var image=new laya.ui.Image("resource/ui/image.png");//创建一个 Image 类的实例对象 image ,并传入它的皮肤。
  1862. *image.x=100;//设置 image 对象的属性 x 的值,用于控制 image 对象的显示位置。
  1863. *image.y=100;//设置 image 对象的属性 y 的值,用于控制 image 对象的显示位置。
  1864. *Laya.stage.addChild(image);//将此 image 对象添加到显示列表。
  1865. *}
  1866. *@example
  1867. *class Image_Example {
  1868. *constructor(){
  1869. *Laya.init(640,800);//设置游戏画布宽高。
  1870. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  1871. *this.onInit();
  1872. *}
  1873. *private onInit():void {
  1874. *var bg:laya.ui.Image=new laya.ui.Image("resource/ui/bg.png");//创建一个 Image 类的实例对象 bg ,并传入它的皮肤。
  1875. *bg.x=100;//设置 bg 对象的属性 x 的值,用于控制 bg 对象的显示位置。
  1876. *bg.y=100;//设置 bg 对象的属性 y 的值,用于控制 bg 对象的显示位置。
  1877. *bg.sizeGrid="40,10,5,10";//设置 bg 对象的网格信息。
  1878. *bg.width=150;//设置 bg 对象的宽度。
  1879. *bg.height=250;//设置 bg 对象的高度。
  1880. *Laya.stage.addChild(bg);//将此 bg 对象添加到显示列表。
  1881. *var image:laya.ui.Image=new laya.ui.Image("resource/ui/image.png");//创建一个 Image 类的实例对象 image ,并传入它的皮肤。
  1882. *image.x=100;//设置 image 对象的属性 x 的值,用于控制 image 对象的显示位置。
  1883. *image.y=100;//设置 image 对象的属性 y 的值,用于控制 image 对象的显示位置。
  1884. *Laya.stage.addChild(image);//将此 image 对象添加到显示列表。
  1885. *}
  1886. *}
  1887. *@see laya.ui.AutoBitmap
  1888. */
  1889. //class laya.ui.Image extends laya.ui.UIComponent
  1890. var Image=(function(_super){
  1891. function Image(skin){
  1892. /**@private */
  1893. this._bitmap=null;
  1894. /**@private */
  1895. this._skin=null;
  1896. /**@private */
  1897. this._group=null;
  1898. Image.__super.call(this);
  1899. this.skin=skin;
  1900. }
  1901. __class(Image,'laya.ui.Image',_super);
  1902. var __proto=Image.prototype;
  1903. /**@inheritDoc */
  1904. __proto.destroy=function(destroyChild){
  1905. (destroyChild===void 0)&& (destroyChild=true);
  1906. _super.prototype.destroy.call(this,true);
  1907. this._bitmap && this._bitmap.destroy();
  1908. this._bitmap=null;
  1909. }
  1910. /**
  1911. *销毁对象并释放加载的皮肤资源。
  1912. */
  1913. __proto.dispose=function(){
  1914. this.destroy(true);
  1915. Laya.loader.clearRes(this._skin);
  1916. }
  1917. /**@inheritDoc */
  1918. __proto.createChildren=function(){
  1919. this.graphics=this._bitmap=new AutoBitmap();
  1920. this._bitmap.autoCacheCmd=false;
  1921. }
  1922. /**
  1923. *@private
  1924. *设置皮肤资源。
  1925. */
  1926. __proto.setSource=function(url,img){
  1927. if (url===this._skin && img){
  1928. this.source=img
  1929. this.onCompResize();
  1930. }
  1931. }
  1932. /**@inheritDoc */
  1933. __proto.measureWidth=function(){
  1934. return this._bitmap.width;
  1935. }
  1936. /**@inheritDoc */
  1937. __proto.measureHeight=function(){
  1938. return this._bitmap.height;
  1939. }
  1940. /**@inheritDoc */
  1941. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  1942. this._dataSource=value;
  1943. if ((typeof value=='string'))this.skin=value;
  1944. else Laya.superSet(UIComponent,this,'dataSource',value);
  1945. });
  1946. /**
  1947. *@copy laya.ui.AutoBitmap#source
  1948. */
  1949. __getset(0,__proto,'source',function(){
  1950. return this._bitmap.source;
  1951. },function(value){
  1952. if (!this._bitmap)return;
  1953. this._bitmap.source=value;
  1954. this.event(/*laya.events.Event.LOADED*/"loaded");
  1955. this.repaint();
  1956. });
  1957. /**
  1958. *<p>对象的皮肤地址,以字符串表示。</p>
  1959. *<p>如果资源未加载,则先加载资源,加载完成后应用于此对象。</p>
  1960. *<b>注意:</b>资源加载完成后,会自动缓存至资源库中。
  1961. */
  1962. __getset(0,__proto,'skin',function(){
  1963. return this._skin;
  1964. },function(value){
  1965. if (this._skin !=value){
  1966. this._skin=value;
  1967. if (value){
  1968. var source=Loader.getRes(value);
  1969. if (source){
  1970. this.source=source;
  1971. this.onCompResize();
  1972. }else Laya.loader.load(this._skin,Handler.create(this,this.setSource,[this._skin]),null,/*laya.net.Loader.IMAGE*/"image",1,true,this._group);
  1973. }else {
  1974. this.source=null;
  1975. }
  1976. }
  1977. });
  1978. /**
  1979. *<p>当前实例的位图 <code>AutoImage</code> 实例的有效缩放网格数据。</p>
  1980. *<p>数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。
  1981. *<ul><li>例如:"4,4,4,4,1"。</li></ul></p>
  1982. *@see laya.ui.AutoBitmap#sizeGrid
  1983. */
  1984. __getset(0,__proto,'sizeGrid',function(){
  1985. if (this._bitmap.sizeGrid)return this._bitmap.sizeGrid.join(",");
  1986. return null;
  1987. },function(value){
  1988. this._bitmap.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number);
  1989. });
  1990. /**
  1991. *资源分组。
  1992. */
  1993. __getset(0,__proto,'group',function(){
  1994. return this._group;
  1995. },function(value){
  1996. if (value && this._skin)Loader.setGroup(this._skin,value);
  1997. this._group=value;
  1998. });
  1999. /**@inheritDoc */
  2000. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  2001. Laya.superSet(UIComponent,this,'width',value);
  2002. this._bitmap.width=value==0 ? 0.0000001 :value;
  2003. });
  2004. /**@inheritDoc */
  2005. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  2006. Laya.superSet(UIComponent,this,'height',value);
  2007. this._bitmap.height=value==0 ? 0.0000001 :value;
  2008. });
  2009. return Image;
  2010. })(UIComponent)
  2011. /**
  2012. *<p> <code>Label</code> 类用于创建显示对象以显示文本。</p>
  2013. *
  2014. *@example <caption>以下示例代码,创建了一个 <code>Label</code> 实例。</caption>
  2015. *package
  2016. *{
  2017. *import laya.ui.Label;
  2018. *public class Label_Example
  2019. *{
  2020. *public function Label_Example()
  2021. *{
  2022. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  2023. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  2024. *onInit();
  2025. *}
  2026. *private function onInit():void
  2027. *{
  2028. *var label:Label=new Label();//创建一个 Label 类的实例对象 label 。
  2029. *label.font="Arial";//设置 label 的字体。
  2030. *label.bold=true;//设置 label 显示为粗体。
  2031. *label.leading=4;//设置 label 的行间距。
  2032. *label.wordWrap=true;//设置 label 自动换行。
  2033. *label.padding="10,10,10,10";//设置 label 的边距。
  2034. *label.color="#ff00ff";//设置 label 的颜色。
  2035. *label.text="Hello everyone,我是一个可爱的文本!";//设置 label 的文本内容。
  2036. *label.x=100;//设置 label 对象的属性 x 的值,用于控制 label 对象的显示位置。
  2037. *label.y=100;//设置 label 对象的属性 y 的值,用于控制 label 对象的显示位置。
  2038. *label.width=300;//设置 label 的宽度。
  2039. *label.height=200;//设置 label 的高度。
  2040. *Laya.stage.addChild(label);//将 label 添加到显示列表。
  2041. *var passwordLabel:Label=new Label("请原谅我,我不想被人看到我心里话。");//创建一个 Label 类的实例对象 passwordLabel 。
  2042. *passwordLabel.asPassword=true;//设置 passwordLabel 的显示反式为密码显示。
  2043. *passwordLabel.x=100;//设置 passwordLabel 对象的属性 x 的值,用于控制 passwordLabel 对象的显示位置。
  2044. *passwordLabel.y=350;//设置 passwordLabel 对象的属性 y 的值,用于控制 passwordLabel 对象的显示位置。
  2045. *passwordLabel.width=300;//设置 passwordLabel 的宽度。
  2046. *passwordLabel.color="#000000";//设置 passwordLabel 的文本颜色。
  2047. *passwordLabel.bgColor="#ccffff";//设置 passwordLabel 的背景颜色。
  2048. *passwordLabel.fontSize=20;//设置 passwordLabel 的文本字体大小。
  2049. *Laya.stage.addChild(passwordLabel);//将 passwordLabel 添加到显示列表。
  2050. *}
  2051. *}
  2052. *}
  2053. *@example
  2054. *Laya.init(640,800);//设置游戏画布宽高
  2055. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  2056. *onInit();
  2057. *function onInit(){
  2058. *var label=new laya.ui.Label();//创建一个 Label 类的实例对象 label 。
  2059. *label.font="Arial";//设置 label 的字体。
  2060. *label.bold=true;//设置 label 显示为粗体。
  2061. *label.leading=4;//设置 label 的行间距。
  2062. *label.wordWrap=true;//设置 label 自动换行。
  2063. *label.padding="10,10,10,10";//设置 label 的边距。
  2064. *label.color="#ff00ff";//设置 label 的颜色。
  2065. *label.text="Hello everyone,我是一个可爱的文本!";//设置 label 的文本内容。
  2066. *label.x=100;//设置 label 对象的属性 x 的值,用于控制 label 对象的显示位置。
  2067. *label.y=100;//设置 label 对象的属性 y 的值,用于控制 label 对象的显示位置。
  2068. *label.width=300;//设置 label 的宽度。
  2069. *label.height=200;//设置 label 的高度。
  2070. *Laya.stage.addChild(label);//将 label 添加到显示列表。
  2071. *var passwordLabel=new laya.ui.Label("请原谅我,我不想被人看到我心里话。");//创建一个 Label 类的实例对象 passwordLabel 。
  2072. *passwordLabel.asPassword=true;//设置 passwordLabel 的显示反式为密码显示。
  2073. *passwordLabel.x=100;//设置 passwordLabel 对象的属性 x 的值,用于控制 passwordLabel 对象的显示位置。
  2074. *passwordLabel.y=350;//设置 passwordLabel 对象的属性 y 的值,用于控制 passwordLabel 对象的显示位置。
  2075. *passwordLabel.width=300;//设置 passwordLabel 的宽度。
  2076. *passwordLabel.color="#000000";//设置 passwordLabel 的文本颜色。
  2077. *passwordLabel.bgColor="#ccffff";//设置 passwordLabel 的背景颜色。
  2078. *passwordLabel.fontSize=20;//设置 passwordLabel 的文本字体大小。
  2079. *Laya.stage.addChild(passwordLabel);//将 passwordLabel 添加到显示列表。
  2080. *}
  2081. *@example
  2082. *import Label=laya.ui.Label;
  2083. *class Label_Example {
  2084. *constructor(){
  2085. *Laya.init(640,800);//设置游戏画布宽高。
  2086. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  2087. *this.onInit();
  2088. *}
  2089. *private onInit():void {
  2090. *var label:Label=new Label();//创建一个 Label 类的实例对象 label 。
  2091. *label.font="Arial";//设置 label 的字体。
  2092. *label.bold=true;//设置 label 显示为粗体。
  2093. *label.leading=4;//设置 label 的行间距。
  2094. *label.wordWrap=true;//设置 label 自动换行。
  2095. *label.padding="10,10,10,10";//设置 label 的边距。
  2096. *label.color="#ff00ff";//设置 label 的颜色。
  2097. *label.text="Hello everyone,我是一个可爱的文本!";//设置 label 的文本内容。
  2098. *label.x=100;//设置 label 对象的属性 x 的值,用于控制 label 对象的显示位置。
  2099. *label.y=100;//设置 label 对象的属性 y 的值,用于控制 label 对象的显示位置。
  2100. *label.width=300;//设置 label 的宽度。
  2101. *label.height=200;//设置 label 的高度。
  2102. *Laya.stage.addChild(label);//将 label 添加到显示列表。
  2103. *var passwordLabel:Label=new Label("请原谅我,我不想被人看到我心里话。");//创建一个 Label 类的实例对象 passwordLabel 。
  2104. *passwordLabel.asPassword=true;//设置 passwordLabel 的显示反式为密码显示。
  2105. *passwordLabel.x=100;//设置 passwordLabel 对象的属性 x 的值,用于控制 passwordLabel 对象的显示位置。
  2106. *passwordLabel.y=350;//设置 passwordLabel 对象的属性 y 的值,用于控制 passwordLabel 对象的显示位置。
  2107. *passwordLabel.width=300;//设置 passwordLabel 的宽度。
  2108. *passwordLabel.color="#000000";//设置 passwordLabel 的文本颜色。
  2109. *passwordLabel.bgColor="#ccffff";//设置 passwordLabel 的背景颜色。
  2110. *passwordLabel.fontSize=20;//设置 passwordLabel 的文本字体大小。
  2111. *Laya.stage.addChild(passwordLabel);//将 passwordLabel 添加到显示列表。
  2112. *}
  2113. *}
  2114. *@see laya.display.Text
  2115. */
  2116. //class laya.ui.Label extends laya.ui.UIComponent
  2117. var Label=(function(_super){
  2118. function Label(text){
  2119. /**
  2120. *@private
  2121. *文本 <code>Text</code> 实例。
  2122. */
  2123. this._tf=null;
  2124. Label.__super.call(this);
  2125. (text===void 0)&& (text="");
  2126. this.text=text;
  2127. }
  2128. __class(Label,'laya.ui.Label',_super);
  2129. var __proto=Label.prototype;
  2130. /**@inheritDoc */
  2131. __proto.destroy=function(destroyChild){
  2132. (destroyChild===void 0)&& (destroyChild=true);
  2133. _super.prototype.destroy.call(this,destroyChild);
  2134. this._tf=null;
  2135. }
  2136. /**@inheritDoc */
  2137. __proto.createChildren=function(){
  2138. this.addChild(this._tf=new Text());
  2139. }
  2140. /**@copy laya.display.Text#changeText()
  2141. **/
  2142. __proto.changeText=function(text){
  2143. this._tf.changeText(text);
  2144. }
  2145. /**
  2146. *@inheritDoc
  2147. */
  2148. __proto.measureWidth=function(){
  2149. return this._tf.width;
  2150. }
  2151. /**
  2152. *@inheritDoc
  2153. */
  2154. __proto.measureHeight=function(){
  2155. return this._tf.height;
  2156. }
  2157. /**
  2158. *<p>边距信息</p>
  2159. *<p>"上边距,右边距,下边距 , 左边距(边距以像素为单位)"</p>
  2160. *@see laya.display.Text.padding
  2161. */
  2162. __getset(0,__proto,'padding',function(){
  2163. return this._tf.padding.join(",");
  2164. },function(value){
  2165. this._tf.padding=UIUtils.fillArray(Styles.labelPadding,value,Number);
  2166. });
  2167. /**
  2168. *@copy laya.display.Text#bold
  2169. */
  2170. __getset(0,__proto,'bold',function(){
  2171. return this._tf.bold;
  2172. },function(value){
  2173. this._tf.bold=value;
  2174. });
  2175. /**
  2176. *@copy laya.display.Text#align
  2177. */
  2178. __getset(0,__proto,'align',function(){
  2179. return this._tf.align;
  2180. },function(value){
  2181. this._tf.align=value;
  2182. });
  2183. /**
  2184. *当前文本内容字符串。
  2185. *@see laya.display.Text.text
  2186. */
  2187. __getset(0,__proto,'text',function(){
  2188. return this._tf.text;
  2189. },function(value){
  2190. if (this._tf.text !=value){
  2191. if(value)
  2192. value=UIUtils.adptString(value+"");
  2193. this._tf.text=value;
  2194. this.event(/*laya.events.Event.CHANGE*/"change");
  2195. if (!this._width || !this._height)this.onCompResize();
  2196. }
  2197. });
  2198. /**
  2199. *@copy laya.display.Text#italic
  2200. */
  2201. __getset(0,__proto,'italic',function(){
  2202. return this._tf.italic;
  2203. },function(value){
  2204. this._tf.italic=value;
  2205. });
  2206. /**
  2207. *@copy laya.display.Text#wordWrap
  2208. */
  2209. /**
  2210. *@copy laya.display.Text#wordWrap
  2211. */
  2212. __getset(0,__proto,'wordWrap',function(){
  2213. return this._tf.wordWrap;
  2214. },function(value){
  2215. this._tf.wordWrap=value;
  2216. });
  2217. /**
  2218. *@copy laya.display.Text#font
  2219. */
  2220. __getset(0,__proto,'font',function(){
  2221. return this._tf.font;
  2222. },function(value){
  2223. this._tf.font=value;
  2224. });
  2225. /**@inheritDoc */
  2226. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  2227. this._dataSource=value;
  2228. if ((typeof value=='number')|| (typeof value=='string'))this.text=value+"";
  2229. else Laya.superSet(UIComponent,this,'dataSource',value);
  2230. });
  2231. /**
  2232. *@copy laya.display.Text#color
  2233. */
  2234. __getset(0,__proto,'color',function(){
  2235. return this._tf.color;
  2236. },function(value){
  2237. this._tf.color=value;
  2238. });
  2239. /**
  2240. *@copy laya.display.Text#valign
  2241. */
  2242. __getset(0,__proto,'valign',function(){
  2243. return this._tf.valign;
  2244. },function(value){
  2245. this._tf.valign=value;
  2246. });
  2247. /**
  2248. *@copy laya.display.Text#leading
  2249. */
  2250. __getset(0,__proto,'leading',function(){
  2251. return this._tf.leading;
  2252. },function(value){
  2253. this._tf.leading=value;
  2254. });
  2255. /**
  2256. *@copy laya.display.Text#fontSize
  2257. */
  2258. __getset(0,__proto,'fontSize',function(){
  2259. return this._tf.fontSize;
  2260. },function(value){
  2261. this._tf.fontSize=value;
  2262. });
  2263. /**
  2264. *@copy laya.display.Text#bgColor
  2265. */
  2266. __getset(0,__proto,'bgColor',function(){
  2267. return this._tf.bgColor
  2268. },function(value){
  2269. this._tf.bgColor=value;
  2270. });
  2271. /**
  2272. *@copy laya.display.Text#borderColor
  2273. */
  2274. __getset(0,__proto,'borderColor',function(){
  2275. return this._tf.borderColor
  2276. },function(value){
  2277. this._tf.borderColor=value;
  2278. });
  2279. /**
  2280. *@copy laya.display.Text#stroke
  2281. */
  2282. __getset(0,__proto,'stroke',function(){
  2283. return this._tf.stroke;
  2284. },function(value){
  2285. this._tf.stroke=value;
  2286. });
  2287. /**
  2288. *@copy laya.display.Text#strokeColor
  2289. */
  2290. __getset(0,__proto,'strokeColor',function(){
  2291. return this._tf.strokeColor;
  2292. },function(value){
  2293. this._tf.strokeColor=value;
  2294. });
  2295. /**
  2296. *文本控件实体 <code>Text</code> 实例。
  2297. */
  2298. __getset(0,__proto,'textField',function(){
  2299. return this._tf;
  2300. });
  2301. /**
  2302. *@inheritDoc
  2303. */
  2304. /**
  2305. *@inheritDoc
  2306. */
  2307. __getset(0,__proto,'width',function(){
  2308. if (this._width || this._tf.text)return Laya.superGet(UIComponent,this,'width');
  2309. return 0;
  2310. },function(value){
  2311. Laya.superSet(UIComponent,this,'width',value);
  2312. this._tf.width=value;
  2313. });
  2314. /**
  2315. *@inheritDoc
  2316. */
  2317. /**
  2318. *@inheritDoc
  2319. */
  2320. __getset(0,__proto,'height',function(){
  2321. if (this._height || this._tf.text)return Laya.superGet(UIComponent,this,'height');
  2322. return 0;
  2323. },function(value){
  2324. Laya.superSet(UIComponent,this,'height',value);
  2325. this._tf.height=value;
  2326. });
  2327. /**
  2328. *@copy laya.display.Text#overflow
  2329. */
  2330. /**
  2331. *@copy laya.display.Text#overflow
  2332. */
  2333. __getset(0,__proto,'overflow',function(){
  2334. return this._tf.overflow;
  2335. },function(value){
  2336. this._tf.overflow=value;
  2337. });
  2338. /**
  2339. *@copy laya.display.Text#underline
  2340. */
  2341. /**
  2342. *@copy laya.display.Text#underline
  2343. */
  2344. __getset(0,__proto,'underline',function(){
  2345. return this._tf.underline;
  2346. },function(value){
  2347. this._tf.underline=value;
  2348. });
  2349. /**
  2350. *@copy laya.display.Text#underlineColor
  2351. */
  2352. /**
  2353. *@copy laya.display.Text#underlineColor
  2354. */
  2355. __getset(0,__proto,'underlineColor',function(){
  2356. return this._tf.underlineColor;
  2357. },function(value){
  2358. this._tf.underlineColor=value;
  2359. });
  2360. return Label;
  2361. })(UIComponent)
  2362. /**
  2363. *<code>ComboBox</code> 组件包含一个下拉列表,用户可以从该列表中选择单个值。
  2364. *
  2365. *@example <caption>以下示例代码,创建了一个 <code>ComboBox</code> 实例。</caption>
  2366. *package
  2367. *{
  2368. *import laya.ui.ComboBox;
  2369. *import laya.utils.Handler;
  2370. *public class ComboBox_Example
  2371. *{
  2372. *public function ComboBox_Example()
  2373. *{
  2374. *Laya.init(640,800);//设置游戏画布宽高。
  2375. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  2376. *Laya.loader.load("resource/ui/button.png",Handler.create(this,onLoadComplete));//加载资源。
  2377. *}
  2378. *private function onLoadComplete():void
  2379. *{
  2380. *trace("资源加载完成!");
  2381. *var comboBox:ComboBox=new ComboBox("resource/ui/button.png","item0,item1,item2,item3,item4,item5");//创建一个 ComboBox 类的实例对象 comboBox ,传入它的皮肤和标签集。
  2382. *comboBox.x=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。
  2383. *comboBox.y=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。
  2384. *comboBox.selectHandler=new Handler(this,onSelect);//设置 comboBox 选择项改变时执行的处理器。
  2385. *Laya.stage.addChild(comboBox);//将此 comboBox 对象添加到显示列表。
  2386. *}
  2387. *private function onSelect(index:int):void
  2388. *{
  2389. *trace("当前选中的项对象索引: ",index);
  2390. *}
  2391. *}
  2392. *}
  2393. *@example
  2394. *Laya.init(640,800);//设置游戏画布宽高。
  2395. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  2396. *Laya.loader.load("resource/ui/button.png",laya.utils.Handler.create(this,loadComplete));//加载资源
  2397. *function loadComplete(){
  2398. *console.log("资源加载完成!");
  2399. *var comboBox=new laya.ui.ComboBox("resource/ui/button.png","item0,item1,item2,item3,item4,item5");//创建一个 ComboBox 类的实例对象 comboBox ,传入它的皮肤和标签集。
  2400. *comboBox.x=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。
  2401. *comboBox.y=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。
  2402. *comboBox.selectHandler=new laya.utils.Handler(this,onSelect);//设置 comboBox 选择项改变时执行的处理器。
  2403. *Laya.stage.addChild(comboBox);//将此 comboBox 对象添加到显示列表。
  2404. *}
  2405. *function onSelect(index)
  2406. *{
  2407. *console.log("当前选中的项对象索引: ",index);
  2408. *}
  2409. *@example
  2410. *import ComboBox=laya.ui.ComboBox;
  2411. *import Handler=laya.utils.Handler;
  2412. *class ComboBox_Example {
  2413. *constructor(){
  2414. *Laya.init(640,800);//设置游戏画布宽高。
  2415. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  2416. *Laya.loader.load("resource/ui/button.png",Handler.create(this,this.onLoadComplete));//加载资源。
  2417. *}
  2418. *private onLoadComplete():void {
  2419. *console.log("资源加载完成!");
  2420. *var comboBox:ComboBox=new ComboBox("resource/ui/button.png","item0,item1,item2,item3,item4,item5");//创建一个 ComboBox 类的实例对象 comboBox ,传入它的皮肤和标签集。
  2421. *comboBox.x=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。
  2422. *comboBox.y=100;//设置 comboBox 对象的属性 x 的值,用于控制 comboBox 对象的显示位置。
  2423. *comboBox.selectHandler=new Handler(this,this.onSelect);//设置 comboBox 选择项改变时执行的处理器。
  2424. *Laya.stage.addChild(comboBox);//将此 comboBox 对象添加到显示列表。
  2425. *}
  2426. *private onSelect(index:number):void {
  2427. *console.log("当前选中的项对象索引: ",index);
  2428. *}
  2429. *}
  2430. *
  2431. */
  2432. //class laya.ui.ComboBox extends laya.ui.UIComponent
  2433. var ComboBox=(function(_super){
  2434. function ComboBox(skin,labels){
  2435. /**@private */
  2436. this._visibleNum=6;
  2437. /**
  2438. *@private
  2439. */
  2440. this._button=null;
  2441. /**
  2442. *@private
  2443. */
  2444. this._list=null;
  2445. /**
  2446. *@private
  2447. */
  2448. this._isOpen=false;
  2449. /**
  2450. *@private
  2451. */
  2452. this._itemSize=12;
  2453. /**
  2454. *@private
  2455. */
  2456. this._labels=[];
  2457. /**
  2458. *@private
  2459. */
  2460. this._selectedIndex=-1;
  2461. /**
  2462. *@private
  2463. */
  2464. this._selectHandler=null;
  2465. /**
  2466. *@private
  2467. */
  2468. this._itemHeight=NaN;
  2469. /**
  2470. *@private
  2471. */
  2472. this._listHeight=NaN;
  2473. /**
  2474. *@private
  2475. */
  2476. this._listChanged=false;
  2477. /**
  2478. *@private
  2479. */
  2480. this._itemChanged=false;
  2481. /**
  2482. *@private
  2483. */
  2484. this._scrollBarSkin=null;
  2485. /**
  2486. *@private
  2487. */
  2488. this._isCustomList=false;
  2489. /**
  2490. *渲染项,用来显示下拉列表展示对象
  2491. */
  2492. this.itemRender=null;
  2493. ComboBox.__super.call(this);
  2494. this._itemColors=Styles.comboBoxItemColors;
  2495. this.skin=skin;
  2496. this.labels=labels;
  2497. }
  2498. __class(ComboBox,'laya.ui.ComboBox',_super);
  2499. var __proto=ComboBox.prototype;
  2500. /**@inheritDoc */
  2501. __proto.destroy=function(destroyChild){
  2502. (destroyChild===void 0)&& (destroyChild=true);
  2503. _super.prototype.destroy.call(this,destroyChild);
  2504. this._button && this._button.destroy(destroyChild);
  2505. this._list && this._list.destroy(destroyChild);
  2506. this._button=null;
  2507. this._list=null;
  2508. this._itemColors=null;
  2509. this._labels=null;
  2510. this._selectHandler=null;
  2511. }
  2512. /**@inheritDoc */
  2513. __proto.createChildren=function(){
  2514. this.addChild(this._button=new Button());
  2515. this._button.text.align="left";
  2516. this._button.labelPadding="0,0,0,5";
  2517. this._button.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onButtonMouseDown);
  2518. }
  2519. __proto._createList=function(){
  2520. this._list=new List();
  2521. if (this._scrollBarSkin)this._list.vScrollBarSkin=this._scrollBarSkin;
  2522. this._setListEvent(this._list);
  2523. }
  2524. __proto._setListEvent=function(list){
  2525. this._list.selectEnable=true;
  2526. this._list.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onListDown);
  2527. this._list.mouseHandler=Handler.create(this,this.onlistItemMouse,null,false);
  2528. if (this._list.scrollBar)this._list.scrollBar.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onScrollBarDown);
  2529. }
  2530. /**
  2531. *@private
  2532. */
  2533. __proto.onListDown=function(e){
  2534. e.stopPropagation();
  2535. }
  2536. __proto.onScrollBarDown=function(e){
  2537. e.stopPropagation();
  2538. }
  2539. __proto.onButtonMouseDown=function(e){
  2540. this.callLater(this.switchTo,[!this._isOpen]);
  2541. }
  2542. /**@inheritDoc */
  2543. __proto.measureWidth=function(){
  2544. return this._button.width;
  2545. }
  2546. /**@inheritDoc */
  2547. __proto.measureHeight=function(){
  2548. return this._button.height;
  2549. }
  2550. /**
  2551. *@private
  2552. */
  2553. __proto.changeList=function(){
  2554. this._listChanged=false;
  2555. var labelWidth=this.width-2;
  2556. var labelColor=this._itemColors[2];
  2557. this._itemHeight=this._itemSize+6;
  2558. 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}}]};
  2559. this._list.repeatY=this._visibleNum;
  2560. this._list.refresh();
  2561. }
  2562. /**
  2563. *@private
  2564. *下拉列表的鼠标事件响应函数。
  2565. */
  2566. __proto.onlistItemMouse=function(e,index){
  2567. var type=e.type;
  2568. if (type===/*laya.events.Event.MOUSE_OVER*/"mouseover" || type===/*laya.events.Event.MOUSE_OUT*/"mouseout"){
  2569. if (this._isCustomList)return;
  2570. var box=this._list.getCell(index);
  2571. if (!box)return;
  2572. var label=box.getChildByName("label");
  2573. if (label){
  2574. if (type===/*laya.events.Event.ROLL_OVER*/"mouseover"){
  2575. label.bgColor=this._itemColors[0];
  2576. label.color=this._itemColors[1];
  2577. }else {
  2578. label.bgColor=null;
  2579. label.color=this._itemColors[2];
  2580. }
  2581. }
  2582. }else if (type===/*laya.events.Event.CLICK*/"click"){
  2583. this.selectedIndex=index;
  2584. this.isOpen=false;
  2585. }
  2586. }
  2587. /**
  2588. *@private
  2589. */
  2590. __proto.switchTo=function(value){
  2591. this.isOpen=value;
  2592. }
  2593. /**
  2594. *更改下拉列表的打开状态。
  2595. */
  2596. __proto.changeOpen=function(){
  2597. this.isOpen=!this._isOpen;
  2598. }
  2599. /**
  2600. *更改下拉列表。
  2601. */
  2602. __proto.changeItem=function(){
  2603. this._itemChanged=false;
  2604. this._listHeight=this._labels.length > 0 ? Math.min(this._visibleNum,this._labels.length)*this._itemHeight :this._itemHeight;
  2605. if (!this._isCustomList){
  2606. var g=this._list.graphics;
  2607. g.clear(true);
  2608. g.drawRect(0,0,this.width-1,this._listHeight,this._itemColors[4],this._itemColors[3]);
  2609. };
  2610. var a=this._list.array || [];
  2611. a.length=0;
  2612. for (var i=0,n=this._labels.length;i < n;i++){
  2613. a.push({label:this._labels[i]});
  2614. }
  2615. this._list.height=this._listHeight;
  2616. this._list.array=a;
  2617. }
  2618. __proto.changeSelected=function(){
  2619. this._button.label=this.selectedLabel;
  2620. }
  2621. __proto._onStageMouseWheel=function(e){
  2622. if(!this._list||this._list.contains(e.target))return;
  2623. this.removeList(null);
  2624. }
  2625. /**
  2626. *关闭下拉列表。
  2627. */
  2628. __proto.removeList=function(e){
  2629. Laya.stage.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.removeList);
  2630. Laya.stage.off(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this,this._onStageMouseWheel);
  2631. this.isOpen=false;
  2632. }
  2633. /**
  2634. *表示选择的下拉列表项的索引。
  2635. */
  2636. __getset(0,__proto,'selectedIndex',function(){
  2637. return this._selectedIndex;
  2638. },function(value){
  2639. if (this._selectedIndex !=value){
  2640. this._selectedIndex=value;
  2641. if (this._labels.length > 0)this.changeSelected();
  2642. else this.callLater(this.changeSelected);
  2643. this.event(/*laya.events.Event.CHANGE*/"change",[Event.EMPTY.setTo(/*laya.events.Event.CHANGE*/"change",this,this)]);
  2644. this._selectHandler && this._selectHandler.runWith(this._selectedIndex);
  2645. }
  2646. });
  2647. /**
  2648. *@copy laya.ui.Button#skin
  2649. */
  2650. __getset(0,__proto,'skin',function(){
  2651. return this._button.skin;
  2652. },function(value){
  2653. if (this._button.skin !=value){
  2654. this._button.skin=value;
  2655. this._listChanged=true;
  2656. }
  2657. });
  2658. /**
  2659. *获取或设置没有滚动条的下拉列表中可显示的最大行数。
  2660. */
  2661. __getset(0,__proto,'visibleNum',function(){
  2662. return this._visibleNum;
  2663. },function(value){
  2664. this._visibleNum=value;
  2665. this._listChanged=true;
  2666. });
  2667. /**@inheritDoc */
  2668. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  2669. Laya.superSet(UIComponent,this,'width',value);
  2670. this._button.width=this._width;
  2671. this._itemChanged=true;
  2672. this._listChanged=true;
  2673. });
  2674. /**
  2675. *表示选择的下拉列表项的的标签。
  2676. */
  2677. __getset(0,__proto,'selectedLabel',function(){
  2678. return this._selectedIndex >-1 && this._selectedIndex < this._labels.length ? this._labels[this._selectedIndex] :null;
  2679. },function(value){
  2680. this.selectedIndex=this._labels.indexOf(value);
  2681. });
  2682. /**
  2683. *标签集合字符串。
  2684. */
  2685. __getset(0,__proto,'labels',function(){
  2686. return this._labels.join(",");
  2687. },function(value){
  2688. if (this._labels.length > 0)this.selectedIndex=-1;
  2689. if (value)this._labels=value.split(",");
  2690. else this._labels.length=0;
  2691. this._itemChanged=true;
  2692. });
  2693. /**@inheritDoc */
  2694. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  2695. Laya.superSet(UIComponent,this,'height',value);
  2696. this._button.height=this._height;
  2697. });
  2698. /**
  2699. *改变下拉列表的选择项时执行的处理器(默认返回参数index:int)。
  2700. */
  2701. __getset(0,__proto,'selectHandler',function(){
  2702. return this._selectHandler;
  2703. },function(value){
  2704. this._selectHandler=value;
  2705. });
  2706. /**
  2707. *表示按钮文本标签是否为粗体字。
  2708. *@see laya.display.Text#bold
  2709. */
  2710. __getset(0,__proto,'labelBold',function(){
  2711. return this._button.text.bold;
  2712. },function(value){
  2713. this._button.text.bold=value
  2714. });
  2715. /**
  2716. *下拉列表项颜色。
  2717. *<p><b>格式:</b>"悬停或被选中时背景颜色,悬停或被选中时标签颜色,标签颜色,边框颜色,背景颜色"</p>
  2718. */
  2719. __getset(0,__proto,'itemColors',function(){
  2720. return String(this._itemColors)
  2721. },function(value){
  2722. this._itemColors=UIUtils.fillArray(this._itemColors,value,String);
  2723. this._listChanged=true;
  2724. });
  2725. /**
  2726. *下拉列表项标签的字体大小。
  2727. */
  2728. __getset(0,__proto,'itemSize',function(){
  2729. return this._itemSize;
  2730. },function(value){
  2731. this._itemSize=value;
  2732. this._listChanged=true;
  2733. });
  2734. /**
  2735. *获取对 <code>ComboBox</code> 组件所包含的 <code>VScrollBar</code> 滚动条组件的引用。
  2736. */
  2737. __getset(0,__proto,'scrollBar',function(){
  2738. return this.list.scrollBar;
  2739. });
  2740. /**
  2741. *表示下拉列表的打开状态。
  2742. */
  2743. __getset(0,__proto,'isOpen',function(){
  2744. return this._isOpen;
  2745. },function(value){
  2746. if (this._isOpen !=value){
  2747. this._isOpen=value;
  2748. this._button.selected=this._isOpen;
  2749. if (this._isOpen){
  2750. this._list || this._createList();
  2751. this._listChanged && !this._isCustomList && this.changeList();
  2752. this._itemChanged && this.changeItem();
  2753. var p=this.localToGlobal(Point.TEMP.setTo(0,0));
  2754. var py=p.y+this._button.height;
  2755. py=py+this._listHeight <=Laya.stage.height ? py :p.y-this._listHeight;
  2756. this._list.pos(p.x,py);
  2757. this._list.zOrder=1001;
  2758. Laya._currentStage.addChild(this._list);
  2759. Laya.stage.once(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.removeList);
  2760. Laya.stage.on(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this,this._onStageMouseWheel);
  2761. this._list.selectedIndex=this._selectedIndex;
  2762. }else {
  2763. this._list && this._list.removeSelf();
  2764. }
  2765. }
  2766. });
  2767. /**
  2768. *滚动条皮肤。
  2769. */
  2770. __getset(0,__proto,'scrollBarSkin',function(){
  2771. return this._scrollBarSkin;
  2772. },function(value){
  2773. this._scrollBarSkin=value;
  2774. });
  2775. /**
  2776. *<p>当前实例的位图 <code>AutoImage</code> 实例的有效缩放网格数据。</p>
  2777. *<p>数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。
  2778. *<ul><li>例如:"4,4,4,4,1"</li></ul></p>
  2779. *@see laya.ui.AutoBitmap.sizeGrid
  2780. */
  2781. __getset(0,__proto,'sizeGrid',function(){
  2782. return this._button.sizeGrid;
  2783. },function(value){
  2784. this._button.sizeGrid=value;
  2785. });
  2786. /**
  2787. *获取对 <code>ComboBox</code> 组件所包含的 <code>Button</code> 组件的引用。
  2788. */
  2789. __getset(0,__proto,'button',function(){
  2790. return this._button;
  2791. });
  2792. /**
  2793. *获取对 <code>ComboBox</code> 组件所包含的 <code>List</code> 列表组件的引用。
  2794. */
  2795. __getset(0,__proto,'list',function(){
  2796. this._list || this._createList();
  2797. return this._list;
  2798. },function(value){
  2799. if (value){
  2800. value.removeSelf();
  2801. this._isCustomList=true;
  2802. this._list=value;
  2803. this._setListEvent(value);
  2804. this._itemHeight=value.getCell(0).height+value.spaceY;
  2805. }
  2806. });
  2807. /**@inheritDoc */
  2808. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  2809. this._dataSource=value;
  2810. if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string'))this.selectedIndex=parseInt(value);
  2811. else if ((value instanceof Array))this.labels=(value).join(",");
  2812. else Laya.superSet(UIComponent,this,'dataSource',value);
  2813. });
  2814. /**
  2815. *获取或设置对 <code>ComboBox</code> 组件所包含的 <code>Button</code> 组件的文本标签颜色。
  2816. *<p><b>格式:</b>upColor,overColor,downColor,disableColor</p>
  2817. */
  2818. __getset(0,__proto,'labelColors',function(){
  2819. return this._button.labelColors;
  2820. },function(value){
  2821. if (this._button.labelColors !=value){
  2822. this._button.labelColors=value;
  2823. }
  2824. });
  2825. /**
  2826. *获取或设置对 <code>ComboBox</code> 组件所包含的 <code>Button</code> 组件的文本边距。
  2827. *<p><b>格式:</b>上边距,右边距,下边距,左边距</p>
  2828. */
  2829. __getset(0,__proto,'labelPadding',function(){
  2830. return this._button.text.padding.join(",");
  2831. },function(value){
  2832. this._button.text.padding=UIUtils.fillArray(Styles.labelPadding,value,Number);
  2833. });
  2834. /**
  2835. *获取或设置对 <code>ComboBox</code> 组件所包含的 <code>Button</code> 组件的标签字体大小。
  2836. */
  2837. __getset(0,__proto,'labelSize',function(){
  2838. return this._button.text.fontSize;
  2839. },function(value){
  2840. this._button.text.fontSize=value
  2841. });
  2842. /**
  2843. *表示按钮文本标签的字体名称,以字符串形式表示。
  2844. *@see laya.display.Text#font
  2845. */
  2846. __getset(0,__proto,'labelFont',function(){
  2847. return this._button.text.font;
  2848. },function(value){
  2849. this._button.text.font=value
  2850. });
  2851. /**
  2852. *表示按钮的状态值。
  2853. *@see laya.ui.Button#stateNum
  2854. */
  2855. __getset(0,__proto,'stateNum',function(){
  2856. return this._button.stateNum;
  2857. },function(value){
  2858. this._button.stateNum=value
  2859. });
  2860. return ComboBox;
  2861. })(UIComponent)
  2862. /**鼠标提示管理类*/
  2863. //class laya.ui.TipManager extends laya.ui.UIComponent
  2864. var TipManager=(function(_super){
  2865. function TipManager(){
  2866. this._tipBox=null;
  2867. this._tipText=null;
  2868. this._defaultTipHandler=null;
  2869. TipManager.__super.call(this);
  2870. this._tipBox=new UIComponent();
  2871. this._tipBox.addChild(this._tipText=new Text());
  2872. this._tipText.x=this._tipText.y=5;
  2873. this._tipText.color=TipManager.tipTextColor;
  2874. this._defaultTipHandler=this._showDefaultTip;
  2875. Laya.stage.on(/*laya.ui.UIEvent.SHOW_TIP*/"showtip",this,this._onStageShowTip);
  2876. Laya.stage.on(/*laya.ui.UIEvent.HIDE_TIP*/"hidetip",this,this._onStageHideTip);
  2877. this.zOrder=1100
  2878. }
  2879. __class(TipManager,'laya.ui.TipManager',_super);
  2880. var __proto=TipManager.prototype;
  2881. /**
  2882. *@private
  2883. */
  2884. __proto._onStageHideTip=function(e){
  2885. Laya.timer.clear(this,this._showTip);
  2886. this.closeAll();
  2887. this.removeSelf();
  2888. }
  2889. /**
  2890. *@private
  2891. */
  2892. __proto._onStageShowTip=function(data){
  2893. Laya.timer.once(TipManager.tipDelay,this,this._showTip,[data],true);
  2894. }
  2895. /**
  2896. *@private
  2897. */
  2898. __proto._showTip=function(tip){
  2899. if ((typeof tip=='string')){
  2900. var text=String(tip);
  2901. if (Boolean(text)){
  2902. this._defaultTipHandler(text);
  2903. }
  2904. }else if ((tip instanceof laya.utils.Handler )){
  2905. (tip).run();
  2906. }else if ((typeof tip=='function')){
  2907. (tip).apply();
  2908. }
  2909. if (true){
  2910. Laya.stage.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this._onStageMouseMove);
  2911. Laya.stage.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onStageMouseDown);
  2912. }
  2913. this._onStageMouseMove(null);
  2914. }
  2915. /**
  2916. *@private
  2917. */
  2918. __proto._onStageMouseDown=function(e){
  2919. this.closeAll();
  2920. }
  2921. /**
  2922. *@private
  2923. */
  2924. __proto._onStageMouseMove=function(e){
  2925. this._showToStage(this,TipManager.offsetX,TipManager.offsetY);
  2926. }
  2927. /**
  2928. *@private
  2929. */
  2930. __proto._showToStage=function(dis,offX,offY){
  2931. (offX===void 0)&& (offX=0);
  2932. (offY===void 0)&& (offY=0);
  2933. var rec=dis.getBounds();
  2934. dis.x=Laya.stage.mouseX+offX;
  2935. dis.y=Laya.stage.mouseY+offY;
  2936. if (dis._x+rec.width > Laya.stage.width){
  2937. dis.x-=rec.width+offX;
  2938. }
  2939. if (dis._y+rec.height > Laya.stage.height){
  2940. dis.y-=rec.height+offY;
  2941. }
  2942. }
  2943. /**关闭所有鼠标提示*/
  2944. __proto.closeAll=function(){
  2945. Laya.timer.clear(this,this._showTip);
  2946. Laya.stage.off(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this._onStageMouseMove);
  2947. Laya.stage.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onStageMouseDown);
  2948. this.removeChildren();
  2949. }
  2950. /**
  2951. *显示显示对象类型的tip
  2952. */
  2953. __proto.showDislayTip=function(tip){
  2954. this.addChild(tip);
  2955. this._showToStage(this);
  2956. Laya._currentStage.addChild(this);
  2957. }
  2958. /**
  2959. *@private
  2960. */
  2961. __proto._showDefaultTip=function(text){
  2962. this._tipText.text=text;
  2963. var g=this._tipBox.graphics;
  2964. g.clear(true);
  2965. g.drawRect(0,0,this._tipText.width+10,this._tipText.height+10,TipManager.tipBackColor);
  2966. this.addChild(this._tipBox);
  2967. this._showToStage(this);
  2968. Laya._currentStage.addChild(this);
  2969. }
  2970. /**默认鼠标提示函数*/
  2971. __getset(0,__proto,'defaultTipHandler',function(){
  2972. return this._defaultTipHandler;
  2973. },function(value){
  2974. this._defaultTipHandler=value;
  2975. });
  2976. TipManager.offsetX=10;
  2977. TipManager.offsetY=15;
  2978. TipManager.tipTextColor="#ffffff";
  2979. TipManager.tipBackColor="#111111";
  2980. TipManager.tipDelay=200;
  2981. return TipManager;
  2982. })(UIComponent)
  2983. /**
  2984. *<p> <code>Clip</code> 类是位图切片动画。</p>
  2985. *<p> <code>Clip</code> 可将一张图片,按横向分割数量 <code>clipX</code> 、竖向分割数量 <code>clipY</code> ,
  2986. *或横向分割每个切片的宽度 <code>clipWidth</code> 、竖向分割每个切片的高度 <code>clipHeight</code> ,
  2987. *从左向右,从上到下,分割组合为一个切片动画。</p>
  2988. *Image和Clip组件是唯一支持异步加载的两个组件,比如clip.skin="abc/xxx.png",其他UI组件均不支持异步加载。
  2989. *
  2990. *@example <caption>以下示例代码,创建了一个 <code>Clip</code> 实例。</caption>
  2991. *package
  2992. *{
  2993. *import laya.ui.Clip;
  2994. *public class Clip_Example
  2995. *{
  2996. *private var clip:Clip;
  2997. *public function Clip_Example()
  2998. *{
  2999. *Laya.init(640,800);//设置游戏画布宽高。
  3000. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  3001. *onInit();
  3002. *}
  3003. *private function onInit():void
  3004. *{
  3005. *clip=new Clip("resource/ui/clip_num.png",10,1);//创建一个 Clip 类的实例对象 clip ,传入它的皮肤skin和横向分割数量、竖向分割数量。
  3006. *clip.autoPlay=true;//设置 clip 动画自动播放。
  3007. *clip.interval=100;//设置 clip 动画的播放时间间隔。
  3008. *clip.x=100;//设置 clip 对象的属性 x 的值,用于控制 clip 对象的显示位置。
  3009. *clip.y=100;//设置 clip 对象的属性 y 的值,用于控制 clip 对象的显示位置。
  3010. *clip.on(Event.CLICK,this,onClick);//给 clip 添加点击事件函数侦听。
  3011. *Laya.stage.addChild(clip);//将此 clip 对象添加到显示列表。
  3012. *}
  3013. *private function onClick():void
  3014. *{
  3015. *trace("clip 的点击事件侦听处理函数。clip.total="+clip.total);
  3016. *if (clip.isPlaying==true)
  3017. *{
  3018. *clip.stop();//停止动画。
  3019. *}else {
  3020. *clip.play();//播放动画。
  3021. *}
  3022. *}
  3023. *}
  3024. *}
  3025. *@example
  3026. *Laya.init(640,800);//设置游戏画布宽高
  3027. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  3028. *var clip;
  3029. *Laya.loader.load("resource/ui/clip_num.png",laya.utils.Handler.create(this,loadComplete));//加载资源
  3030. *function loadComplete(){
  3031. *console.log("资源加载完成!");
  3032. *clip=new laya.ui.Clip("resource/ui/clip_num.png",10,1);//创建一个 Clip 类的实例对象 clip ,传入它的皮肤skin和横向分割数量、竖向分割数量。
  3033. *clip.autoPlay=true;//设置 clip 动画自动播放。
  3034. *clip.interval=100;//设置 clip 动画的播放时间间隔。
  3035. *clip.x=100;//设置 clip 对象的属性 x 的值,用于控制 clip 对象的显示位置。
  3036. *clip.y=100;//设置 clip 对象的属性 y 的值,用于控制 clip 对象的显示位置。
  3037. *clip.on(Event.CLICK,this,onClick);//给 clip 添加点击事件函数侦听。
  3038. *Laya.stage.addChild(clip);//将此 clip 对象添加到显示列表。
  3039. *}
  3040. *function onClick()
  3041. *{
  3042. *console.log("clip 的点击事件侦听处理函数。");
  3043. *if(clip.isPlaying==true)
  3044. *{
  3045. *clip.stop();
  3046. *}else {
  3047. *clip.play();
  3048. *}
  3049. *}
  3050. *@example
  3051. *import Clip=laya.ui.Clip;
  3052. *import Handler=laya.utils.Handler;
  3053. *class Clip_Example {
  3054. *private clip:Clip;
  3055. *constructor(){
  3056. *Laya.init(640,800);//设置游戏画布宽高。
  3057. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  3058. *this.onInit();
  3059. *}
  3060. *private onInit():void {
  3061. *this.clip=new Clip("resource/ui/clip_num.png",10,1);//创建一个 Clip 类的实例对象 clip ,传入它的皮肤skin和横向分割数量、竖向分割数量。
  3062. *this.clip.autoPlay=true;//设置 clip 动画自动播放。
  3063. *this.clip.interval=100;//设置 clip 动画的播放时间间隔。
  3064. *this.clip.x=100;//设置 clip 对象的属性 x 的值,用于控制 clip 对象的显示位置。
  3065. *this.clip.y=100;//设置 clip 对象的属性 y 的值,用于控制 clip 对象的显示位置。
  3066. *this.clip.on(laya.events.Event.CLICK,this,this.onClick);//给 clip 添加点击事件函数侦听。
  3067. *Laya.stage.addChild(this.clip);//将此 clip 对象添加到显示列表。
  3068. *}
  3069. *private onClick():void {
  3070. *console.log("clip 的点击事件侦听处理函数。clip.total="+this.clip.total);
  3071. *if (this.clip.isPlaying==true){
  3072. *this.clip.stop();//停止动画。
  3073. *}else {
  3074. *this.clip.play();//播放动画。
  3075. *}
  3076. *}
  3077. *}
  3078. *
  3079. */
  3080. //class laya.ui.Clip extends laya.ui.UIComponent
  3081. var Clip=(function(_super){
  3082. function Clip(url,clipX,clipY){
  3083. /**@private */
  3084. this._sources=null;
  3085. /**@private */
  3086. this._bitmap=null;
  3087. /**@private */
  3088. this._skin=null;
  3089. /**@private */
  3090. this._clipX=1;
  3091. /**@private */
  3092. this._clipY=1;
  3093. /**@private */
  3094. this._clipWidth=0;
  3095. /**@private */
  3096. this._clipHeight=0;
  3097. /**@private */
  3098. this._autoPlay=false;
  3099. /**@private */
  3100. this._interval=50;
  3101. /**@private */
  3102. this._complete=null;
  3103. /**@private */
  3104. this._isPlaying=false;
  3105. /**@private */
  3106. this._index=0;
  3107. /**@private */
  3108. this._clipChanged=false;
  3109. /**@private */
  3110. this._group=null;
  3111. /**@private */
  3112. this._toIndex=-1;
  3113. Clip.__super.call(this);
  3114. (clipX===void 0)&& (clipX=1);
  3115. (clipY===void 0)&& (clipY=1);
  3116. this._clipX=clipX;
  3117. this._clipY=clipY;
  3118. this.skin=url;
  3119. }
  3120. __class(Clip,'laya.ui.Clip',_super);
  3121. var __proto=Clip.prototype;
  3122. /**@inheritDoc */
  3123. __proto.destroy=function(destroyChild){
  3124. (destroyChild===void 0)&& (destroyChild=true);
  3125. _super.prototype.destroy.call(this,true);
  3126. this._bitmap && this._bitmap.destroy();
  3127. this._bitmap=null;
  3128. this._sources=null;
  3129. }
  3130. /**
  3131. *销毁对象并释放加载的皮肤资源。
  3132. */
  3133. __proto.dispose=function(){
  3134. this.destroy(true);
  3135. Laya.loader.clearRes(this._skin);
  3136. }
  3137. /**@inheritDoc */
  3138. __proto.createChildren=function(){
  3139. this.graphics=this._bitmap=new AutoBitmap();
  3140. }
  3141. /**@private */
  3142. __proto._onDisplay=function(e){
  3143. if (this._isPlaying){
  3144. if (this._getBit(/*laya.Const.DISPLAYED_INSTAGE*/0x80))this.play();
  3145. else this.stop();
  3146. }else if (this._autoPlay){
  3147. this.play();
  3148. }
  3149. }
  3150. __proto._skinLoaded=function(){
  3151. this._setClipChanged();
  3152. this._sizeChanged();
  3153. this.event(/*laya.events.Event.LOADED*/"loaded");
  3154. }
  3155. /**
  3156. *@private
  3157. *改变切片的资源、切片的大小。
  3158. */
  3159. __proto.changeClip=function(){
  3160. this._clipChanged=false;
  3161. if (!this._skin)return;
  3162. var img=Loader.getRes(this._skin);
  3163. if (img){
  3164. this.loadComplete(this._skin,img);
  3165. }else {
  3166. Laya.loader.load(this._skin,Handler.create(this,this.loadComplete,[this._skin]));
  3167. }
  3168. }
  3169. /**
  3170. *@private
  3171. *加载切片图片资源完成函数。
  3172. *@param url 资源地址。
  3173. *@param img 纹理。
  3174. */
  3175. __proto.loadComplete=function(url,img){
  3176. if (url===this._skin && img){
  3177. var w=this._clipWidth || Math.ceil(img.sourceWidth / this._clipX);
  3178. var h=this._clipHeight || Math.ceil(img.sourceHeight / this._clipY);
  3179. var key=this._skin+w+h;
  3180. var clips=WeakObject.I.get(key);
  3181. if (!Utils.isOkTextureList(clips)){
  3182. clips=null;
  3183. }
  3184. if (clips)this._sources=clips;
  3185. else {
  3186. this._sources=[];
  3187. for (var i=0;i < this._clipY;i++){
  3188. for (var j=0;j < this._clipX;j++){
  3189. this._sources.push(Texture.createFromTexture(img,w *j,h *i,w,h));
  3190. }
  3191. }
  3192. WeakObject.I.set(key,this._sources);
  3193. }
  3194. this.index=this._index;
  3195. this.event(/*laya.events.Event.LOADED*/"loaded");
  3196. this.onCompResize();
  3197. }
  3198. }
  3199. /**@inheritDoc */
  3200. __proto.measureWidth=function(){
  3201. this.runCallLater(this.changeClip);
  3202. return this._bitmap.width;
  3203. }
  3204. /**@inheritDoc */
  3205. __proto.measureHeight=function(){
  3206. this.runCallLater(this.changeClip);
  3207. return this._bitmap.height;
  3208. }
  3209. /**
  3210. *播放动画。
  3211. *@param from 开始索引
  3212. *@param to 结束索引,-1为不限制
  3213. */
  3214. __proto.play=function(from,to){
  3215. (from===void 0)&& (from=0);
  3216. (to===void 0)&& (to=-1);
  3217. this._isPlaying=true;
  3218. this.index=from;
  3219. this._toIndex=to;
  3220. this._index++;
  3221. Laya.timer.loop(this.interval,this,this._loop);
  3222. this.on(/*laya.events.Event.DISPLAY*/"display",this,this._onDisplay);
  3223. this.on(/*laya.events.Event.UNDISPLAY*/"undisplay",this,this._onDisplay);
  3224. }
  3225. /**
  3226. *@private
  3227. */
  3228. __proto._loop=function(){
  3229. if (this._visible && this._sources){
  3230. this._index++;
  3231. if (this._toIndex >-1 && this._index >=this._toIndex)this.stop();
  3232. else if (this._index >=this._sources.length)this._index=0;
  3233. this.index=this._index;
  3234. }
  3235. }
  3236. /**
  3237. *停止动画。
  3238. */
  3239. __proto.stop=function(){
  3240. this._isPlaying=false;
  3241. Laya.timer.clear(this,this._loop);
  3242. this.event(/*laya.events.Event.COMPLETE*/"complete");
  3243. }
  3244. /**@private */
  3245. __proto._setClipChanged=function(){
  3246. if (!this._clipChanged){
  3247. this._clipChanged=true;
  3248. this.callLater(this.changeClip);
  3249. }
  3250. }
  3251. /**
  3252. *表示动画播放间隔时间(以毫秒为单位)。
  3253. */
  3254. __getset(0,__proto,'interval',function(){
  3255. return this._interval;
  3256. },function(value){
  3257. if (this._interval !=value){
  3258. this._interval=value;
  3259. if (this._isPlaying)this.play();
  3260. }
  3261. });
  3262. /**
  3263. *@copy laya.ui.Image#skin
  3264. */
  3265. __getset(0,__proto,'skin',function(){
  3266. return this._skin;
  3267. },function(value){
  3268. if (this._skin !=value){
  3269. this._skin=value;
  3270. if (value){
  3271. if(!Loader.getRes(value)){
  3272. Laya.loader.load(this._skin,Handler.create(this,this._skinLoaded),null,/*laya.net.Loader.IMAGE*/"image",1);
  3273. }else{
  3274. this._skinLoaded();
  3275. }
  3276. }else {
  3277. this._bitmap.source=null;
  3278. }
  3279. }
  3280. });
  3281. /**
  3282. *源数据。
  3283. */
  3284. __getset(0,__proto,'sources',function(){
  3285. return this._sources;
  3286. },function(value){
  3287. this._sources=value;
  3288. this.index=this._index;
  3289. this.event(/*laya.events.Event.LOADED*/"loaded");
  3290. });
  3291. /**X轴(横向)切片数量。*/
  3292. __getset(0,__proto,'clipX',function(){
  3293. return this._clipX;
  3294. },function(value){
  3295. this._clipX=value || 1;
  3296. this._setClipChanged()
  3297. });
  3298. /**Y轴(竖向)切片数量。*/
  3299. __getset(0,__proto,'clipY',function(){
  3300. return this._clipY;
  3301. },function(value){
  3302. this._clipY=value || 1;
  3303. this._setClipChanged()
  3304. });
  3305. /**
  3306. *切片动画的总帧数。
  3307. */
  3308. __getset(0,__proto,'total',function(){
  3309. this.runCallLater(this.changeClip);
  3310. return this._sources ? this._sources.length :0;
  3311. });
  3312. /**
  3313. *横向分割时每个切片的宽度,与 <code>clipX</code> 同时设置时优先级高于 <code>clipX</code> 。
  3314. */
  3315. __getset(0,__proto,'clipWidth',function(){
  3316. return this._clipWidth;
  3317. },function(value){
  3318. this._clipWidth=value;
  3319. this._setClipChanged()
  3320. });
  3321. /**
  3322. *<p>当前实例的位图 <code>AutoImage</code> 实例的有效缩放网格数据。</p>
  3323. *<p>数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。
  3324. *<ul><li>例如:"4,4,4,4,1"</li></ul></p>
  3325. *@see laya.ui.AutoBitmap.sizeGrid
  3326. */
  3327. __getset(0,__proto,'sizeGrid',function(){
  3328. if (this._bitmap.sizeGrid)return this._bitmap.sizeGrid.join(",");
  3329. return null;
  3330. },function(value){
  3331. this._bitmap.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number);
  3332. });
  3333. /**
  3334. *资源分组。
  3335. */
  3336. __getset(0,__proto,'group',function(){
  3337. return this._group;
  3338. },function(value){
  3339. if (value && this._skin)Loader.setGroup(this._skin,value);
  3340. this._group=value;
  3341. });
  3342. /**
  3343. *竖向分割时每个切片的高度,与 <code>clipY</code> 同时设置时优先级高于 <code>clipY</code> 。
  3344. */
  3345. __getset(0,__proto,'clipHeight',function(){
  3346. return this._clipHeight;
  3347. },function(value){
  3348. this._clipHeight=value;
  3349. this._setClipChanged()
  3350. });
  3351. /**@inheritDoc */
  3352. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  3353. Laya.superSet(UIComponent,this,'width',value);
  3354. this._bitmap.width=value;
  3355. });
  3356. /**@inheritDoc */
  3357. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  3358. Laya.superSet(UIComponent,this,'height',value);
  3359. this._bitmap.height=value;
  3360. });
  3361. /**
  3362. *当前帧索引。
  3363. */
  3364. __getset(0,__proto,'index',function(){
  3365. return this._index;
  3366. },function(value){
  3367. this._index=value;
  3368. this._bitmap && this._sources && (this._bitmap.source=this._sources[value]);
  3369. this.event(/*laya.events.Event.CHANGE*/"change");
  3370. });
  3371. /**
  3372. *表示是否自动播放动画,若自动播放值为true,否则值为false;
  3373. *<p>可控制切片动画的播放、停止。</p>
  3374. */
  3375. __getset(0,__proto,'autoPlay',function(){
  3376. return this._autoPlay;
  3377. },function(value){
  3378. if (this._autoPlay !=value){
  3379. this._autoPlay=value;
  3380. value ? this.play():this.stop();
  3381. }
  3382. });
  3383. /**
  3384. *表示动画的当前播放状态。
  3385. *如果动画正在播放中,则为true,否则为flash。
  3386. */
  3387. __getset(0,__proto,'isPlaying',function(){
  3388. return this._isPlaying;
  3389. },function(value){
  3390. this._isPlaying=value;
  3391. });
  3392. /**@inheritDoc */
  3393. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  3394. this._dataSource=value;
  3395. if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string'))this.index=parseInt(value);
  3396. else Laya.superSet(UIComponent,this,'dataSource',value);
  3397. });
  3398. /**
  3399. *<code>AutoBitmap</code> 位图实例。
  3400. */
  3401. __getset(0,__proto,'bitmap',function(){
  3402. return this._bitmap;
  3403. });
  3404. return Clip;
  3405. })(UIComponent)
  3406. /**
  3407. *<code>ColorPicker</code> 组件将显示包含多个颜色样本的列表,用户可以从中选择颜色。
  3408. *
  3409. *@example <caption>以下示例代码,创建了一个 <code>ColorPicker</code> 实例。</caption>
  3410. *package
  3411. *{
  3412. *import laya.ui.ColorPicker;
  3413. *import laya.utils.Handler;
  3414. *public class ColorPicker_Example
  3415. *{
  3416. *public function ColorPicker_Example()
  3417. *{
  3418. *Laya.init(640,800);//设置游戏画布宽高。
  3419. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  3420. *Laya.loader.load("resource/ui/color.png",Handler.create(this,onLoadComplete));//加载资源。
  3421. *}
  3422. *private function onLoadComplete():void
  3423. *{
  3424. *trace("资源加载完成!");
  3425. *var colorPicket:ColorPicker=new ColorPicker();//创建一个 ColorPicker 类的实例对象 colorPicket 。
  3426. *colorPicket.skin="resource/ui/color.png";//设置 colorPicket 的皮肤。
  3427. *colorPicket.x=100;//设置 colorPicket 对象的属性 x 的值,用于控制 colorPicket 对象的显示位置。
  3428. *colorPicket.y=100;//设置 colorPicket 对象的属性 y 的值,用于控制 colorPicket 对象的显示位置。
  3429. *colorPicket.changeHandler=new Handler(this,onChangeColor,[colorPicket]);//设置 colorPicket 的颜色改变回调函数。
  3430. *Laya.stage.addChild(colorPicket);//将此 colorPicket 对象添加到显示列表。
  3431. *}
  3432. *private function onChangeColor(colorPicket:ColorPicker):void
  3433. *{
  3434. *trace("当前选择的颜色: "+colorPicket.selectedColor);
  3435. *}
  3436. *}
  3437. *}
  3438. *@example
  3439. *Laya.init(640,800);//设置游戏画布宽高
  3440. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  3441. *Laya.loader.load("resource/ui/color.png",laya.utils.Handler.create(this,loadComplete));//加载资源
  3442. *function loadComplete()
  3443. *{
  3444. *console.log("资源加载完成!");
  3445. *var colorPicket=new laya.ui.ColorPicker();//创建一个 ColorPicker 类的实例对象 colorPicket 。
  3446. *colorPicket.skin="resource/ui/color.png";//设置 colorPicket 的皮肤。
  3447. *colorPicket.x=100;//设置 colorPicket 对象的属性 x 的值,用于控制 colorPicket 对象的显示位置。
  3448. *colorPicket.y=100;//设置 colorPicket 对象的属性 y 的值,用于控制 colorPicket 对象的显示位置。
  3449. *colorPicket.changeHandler=laya.utils.Handler.create(this,onChangeColor,[colorPicket],false);//设置 colorPicket 的颜色改变回调函数。
  3450. *Laya.stage.addChild(colorPicket);//将此 colorPicket 对象添加到显示列表。
  3451. *}
  3452. *function onChangeColor(colorPicket)
  3453. *{
  3454. *console.log("当前选择的颜色: "+colorPicket.selectedColor);
  3455. *}
  3456. *@example
  3457. *import ColorPicker=laya.ui.ColorPicker;
  3458. *import Handler=laya.utils.Handler;
  3459. *class ColorPicker_Example {
  3460. *constructor(){
  3461. *Laya.init(640,800);//设置游戏画布宽高。
  3462. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  3463. *Laya.loader.load("resource/ui/color.png",Handler.create(this,this.onLoadComplete));//加载资源。
  3464. *}
  3465. *private onLoadComplete():void {
  3466. *console.log("资源加载完成!");
  3467. *var colorPicket:ColorPicker=new ColorPicker();//创建一个 ColorPicker 类的实例对象 colorPicket 。
  3468. *colorPicket.skin="resource/ui/color.png";//设置 colorPicket 的皮肤。
  3469. *colorPicket.x=100;//设置 colorPicket 对象的属性 x 的值,用于控制 colorPicket 对象的显示位置。
  3470. *colorPicket.y=100;//设置 colorPicket 对象的属性 y 的值,用于控制 colorPicket 对象的显示位置。
  3471. *colorPicket.changeHandler=new Handler(this,this.onChangeColor,[colorPicket]);//设置 colorPicket 的颜色改变回调函数。
  3472. *Laya.stage.addChild(colorPicket);//将此 colorPicket 对象添加到显示列表。
  3473. *}
  3474. *private onChangeColor(colorPicket:ColorPicker):void {
  3475. *console.log("当前选择的颜色: "+colorPicket.selectedColor);
  3476. *}
  3477. *}
  3478. */
  3479. //class laya.ui.ColorPicker extends laya.ui.UIComponent
  3480. var ColorPicker=(function(_super){
  3481. function ColorPicker(){
  3482. /**
  3483. *当颜色发生改变时执行的函数处理器。
  3484. *默认返回参数color:颜色值字符串。
  3485. */
  3486. this.changeHandler=null;
  3487. /**
  3488. *@private
  3489. *指定每个正方形的颜色小格子的宽高(以像素为单位)。
  3490. */
  3491. this._gridSize=11;
  3492. /**
  3493. *@private
  3494. *表示颜色样本列表面板的背景颜色值。
  3495. */
  3496. this._bgColor="#ffffff";
  3497. /**
  3498. *@private
  3499. *表示颜色样本列表面板的边框颜色值。
  3500. */
  3501. this._borderColor="#000000";
  3502. /**
  3503. *@private
  3504. *表示颜色样本列表面板选择或输入的颜色值。
  3505. */
  3506. this._inputColor="#000000";
  3507. /**
  3508. *@private
  3509. *表示颜色输入框的背景颜色值。
  3510. */
  3511. this._inputBgColor="#efefef";
  3512. /**
  3513. *@private
  3514. *表示颜色样本列表面板。
  3515. */
  3516. this._colorPanel=null;
  3517. /**
  3518. *@private
  3519. *表示颜色网格。
  3520. */
  3521. this._colorTiles=null;
  3522. /**
  3523. *@private
  3524. *表示颜色块显示对象。
  3525. */
  3526. this._colorBlock=null;
  3527. /**
  3528. *@private
  3529. *表示颜色输入框控件 <code>Input</code> 。
  3530. */
  3531. this._colorInput=null;
  3532. /**
  3533. *@private
  3534. *表示点击后显示颜色样本列表面板的按钮控件 <code>Button</code> 。
  3535. */
  3536. this._colorButton=null;
  3537. /**
  3538. *@private
  3539. *表示颜色值列表。
  3540. */
  3541. this._colors=[];
  3542. /**
  3543. *@private
  3544. *表示选择的颜色值。
  3545. */
  3546. this._selectedColor="#000000";
  3547. /**@private */
  3548. this._panelChanged=false;
  3549. ColorPicker.__super.call(this);
  3550. }
  3551. __class(ColorPicker,'laya.ui.ColorPicker',_super);
  3552. var __proto=ColorPicker.prototype;
  3553. /**@inheritDoc */
  3554. __proto.destroy=function(destroyChild){
  3555. (destroyChild===void 0)&& (destroyChild=true);
  3556. _super.prototype.destroy.call(this,destroyChild);
  3557. this._colorPanel && this._colorPanel.destroy(destroyChild);
  3558. this._colorButton && this._colorButton.destroy(destroyChild);
  3559. this._colorPanel=null;
  3560. this._colorTiles=null;
  3561. this._colorBlock=null;
  3562. this._colorInput=null;
  3563. this._colorButton=null;
  3564. this._colors=null;
  3565. this.changeHandler=null;
  3566. }
  3567. /**@inheritDoc */
  3568. __proto.createChildren=function(){
  3569. this.addChild(this._colorButton=new Button());
  3570. this._colorPanel=new Box();
  3571. this._colorPanel.size(230,166);
  3572. this._colorPanel.addChild(this._colorTiles=new Sprite());
  3573. this._colorPanel.addChild(this._colorBlock=new Sprite());
  3574. this._colorPanel.addChild(this._colorInput=new Input());
  3575. }
  3576. /**@inheritDoc */
  3577. __proto.initialize=function(){
  3578. this._colorButton.on(/*laya.events.Event.CLICK*/"click",this,this.onColorButtonClick);
  3579. this._colorBlock.pos(5,5);
  3580. this._colorInput.pos(60,5);
  3581. this._colorInput.size(60,20);
  3582. this._colorInput.on(/*laya.events.Event.CHANGE*/"change",this,this.onColorInputChange);
  3583. this._colorInput.on(/*laya.events.Event.KEY_DOWN*/"keydown",this,this.onColorFieldKeyDown);
  3584. this._colorTiles.pos(5,30);
  3585. this._colorTiles.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.onColorTilesMouseMove);
  3586. this._colorTiles.on(/*laya.events.Event.CLICK*/"click",this,this.onColorTilesClick);
  3587. this._colorTiles.size(20 *this._gridSize,12 *this._gridSize);
  3588. this._colorPanel.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onPanelMouseDown);
  3589. this.bgColor=this._bgColor;
  3590. }
  3591. __proto.onPanelMouseDown=function(e){
  3592. e.stopPropagation();
  3593. }
  3594. /**
  3595. *改变颜色样本列表面板。
  3596. */
  3597. __proto.changePanel=function(){
  3598. this._panelChanged=false;
  3599. var g=this._colorPanel.graphics;
  3600. g.clear(true);
  3601. g.drawRect(0,0,230,166,this._bgColor,this._borderColor);
  3602. this.drawBlock(this._selectedColor);
  3603. this._colorInput.borderColor=this._borderColor;
  3604. this._colorInput.bgColor=this._inputBgColor;
  3605. this._colorInput.color=this._inputColor;
  3606. g=this._colorTiles.graphics;
  3607. g.clear(true);
  3608. var mainColors=[0x000000,0x333333,0x666666,0x999999,0xCCCCCC,0xFFFFFF,0xFF0000,0x00FF00,0x0000FF,0xFFFF00,0x00FFFF,0xFF00FF];
  3609. for (var i=0;i < 12;i++){
  3610. for (var j=0;j < 20;j++){
  3611. var color=0;
  3612. if (j===0)color=mainColors[i];
  3613. else if (j===1)color=0x000000;
  3614. else color=(((i *3+j / 6)% 3 << 0)+((i / 6)<< 0)*3)*0x33 << 16 | j % 6 *0x33 << 8 | (i << 0)% 6 *0x33;
  3615. var strColor=UIUtils.toColor(color);
  3616. this._colors.push(strColor);
  3617. var x=j *this._gridSize;
  3618. var y=i *this._gridSize;
  3619. g.drawRect(x,y,this._gridSize,this._gridSize,strColor,"#000000");
  3620. }
  3621. }
  3622. }
  3623. /**
  3624. *颜色样本列表面板的显示按钮的 <code>Event.MOUSE_DOWN</code> 事件侦听处理函数。
  3625. */
  3626. __proto.onColorButtonClick=function(e){
  3627. if (this._colorPanel.parent)this.close();
  3628. else this.open();
  3629. }
  3630. /**
  3631. *打开颜色样本列表面板。
  3632. */
  3633. __proto.open=function(){
  3634. var p=this.localToGlobal(new Point());
  3635. var px=p.x+this._colorPanel.width <=Laya.stage.width ? p.x :Laya.stage.width-this._colorPanel.width;
  3636. var py=p.y+this._colorButton.height;
  3637. py=py+this._colorPanel.height <=Laya.stage.height ? py :p.y-this._colorPanel.height;
  3638. this._colorPanel.pos(px,py);
  3639. this._colorPanel.zOrder=1001;
  3640. Laya._currentStage.addChild(this._colorPanel);
  3641. Laya.stage.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.removeColorBox);
  3642. }
  3643. /**
  3644. *关闭颜色样本列表面板。
  3645. */
  3646. __proto.close=function(){
  3647. Laya.stage.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.removeColorBox);
  3648. this._colorPanel.removeSelf();
  3649. }
  3650. /**
  3651. *舞台的 <code>Event.MOUSE_DOWN</code> 事件侦听处理函数。
  3652. */
  3653. __proto.removeColorBox=function(e){
  3654. this.close();
  3655. }
  3656. /**
  3657. *小格子色块的 <code>Event.KEY_DOWN</code> 事件侦听处理函数。
  3658. */
  3659. __proto.onColorFieldKeyDown=function(e){
  3660. if (e.keyCode==13){
  3661. if (this._colorInput.text)this.selectedColor=this._colorInput.text;
  3662. else this.selectedColor=null;
  3663. this.close();
  3664. e.stopPropagation();
  3665. }
  3666. }
  3667. /**
  3668. *颜色值输入框 <code>Event.CHANGE</code> 事件侦听处理函数。
  3669. */
  3670. __proto.onColorInputChange=function(e){
  3671. if (this._colorInput.text)this.drawBlock(this._colorInput.text);
  3672. else this.drawBlock("#FFFFFF");
  3673. }
  3674. /**
  3675. *小格子色块的 <code>Event.CLICK</code> 事件侦听处理函数。
  3676. */
  3677. __proto.onColorTilesClick=function(e){
  3678. this.selectedColor=this.getColorByMouse();
  3679. this.close();
  3680. }
  3681. /**
  3682. *@private
  3683. *小格子色块的 <code>Event.MOUSE_MOVE</code> 事件侦听处理函数。
  3684. */
  3685. __proto.onColorTilesMouseMove=function(e){
  3686. this._colorInput.focus=false;
  3687. var color=this.getColorByMouse();
  3688. this._colorInput.text=color;
  3689. this.drawBlock(color);
  3690. }
  3691. /**
  3692. *通过鼠标位置取对应的颜色块的颜色值。
  3693. */
  3694. __proto.getColorByMouse=function(){
  3695. var point=this._colorTiles.getMousePoint();
  3696. var x=Math.floor(point.x / this._gridSize);
  3697. var y=Math.floor(point.y / this._gridSize);
  3698. return this._colors[y *20+x];
  3699. }
  3700. /**
  3701. *绘制颜色块。
  3702. *@param color 需要绘制的颜色块的颜色值。
  3703. */
  3704. __proto.drawBlock=function(color){
  3705. var g=this._colorBlock.graphics;
  3706. g.clear(true);
  3707. var showColor=color ? color :"#ffffff";
  3708. g.drawRect(0,0,50,20,showColor,this._borderColor);
  3709. color || g.drawLine(0,0,50,20,"#ff0000");
  3710. }
  3711. /**
  3712. *改变颜色。
  3713. */
  3714. __proto.changeColor=function(){
  3715. var g=this.graphics;
  3716. g.clear(true);
  3717. var showColor=this._selectedColor || "#000000";
  3718. g.drawRect(0,0,this._colorButton.width,this._colorButton.height,showColor);
  3719. }
  3720. /**@private */
  3721. __proto._setPanelChanged=function(){
  3722. if (!this._panelChanged){
  3723. this._panelChanged=true;
  3724. this.callLater(this.changePanel);
  3725. }
  3726. }
  3727. /**
  3728. *表示颜色输入框的背景颜色值。
  3729. */
  3730. __getset(0,__proto,'inputBgColor',function(){
  3731. return this._inputBgColor;
  3732. },function(value){
  3733. this._inputBgColor=value;
  3734. this._setPanelChanged();
  3735. });
  3736. /**
  3737. *表示选择的颜色值。
  3738. */
  3739. __getset(0,__proto,'selectedColor',function(){
  3740. return this._selectedColor;
  3741. },function(value){
  3742. if (this._selectedColor !=value){
  3743. this._selectedColor=this._colorInput.text=value;
  3744. this.drawBlock(value);
  3745. this.changeColor();
  3746. this.changeHandler && this.changeHandler.runWith(this._selectedColor);
  3747. this.event(/*laya.events.Event.CHANGE*/"change",Event.EMPTY.setTo(/*laya.events.Event.CHANGE*/"change",this,this));
  3748. }
  3749. });
  3750. /**
  3751. *@copy laya.ui.Button#skin
  3752. */
  3753. __getset(0,__proto,'skin',function(){
  3754. return this._colorButton.skin;
  3755. },function(value){
  3756. this._colorButton.once(/*laya.events.Event.LOADED*/"loaded",this,this.changeColor);
  3757. this._colorButton.skin=value;
  3758. });
  3759. /**
  3760. *表示颜色样本列表面板的背景颜色值。
  3761. */
  3762. __getset(0,__proto,'bgColor',function(){
  3763. return this._bgColor;
  3764. },function(value){
  3765. this._bgColor=value;
  3766. this._setPanelChanged();
  3767. });
  3768. /**
  3769. *表示颜色样本列表面板的边框颜色值。
  3770. */
  3771. __getset(0,__proto,'borderColor',function(){
  3772. return this._borderColor;
  3773. },function(value){
  3774. this._borderColor=value;
  3775. this._setPanelChanged();
  3776. });
  3777. /**
  3778. *表示颜色样本列表面板选择或输入的颜色值。
  3779. */
  3780. __getset(0,__proto,'inputColor',function(){
  3781. return this._inputColor;
  3782. },function(value){
  3783. this._inputColor=value;
  3784. this._setPanelChanged();
  3785. });
  3786. return ColorPicker;
  3787. })(UIComponent)
  3788. /**
  3789. *<code>ProgressBar</code> 组件显示内容的加载进度。
  3790. *@example <caption>以下示例代码,创建了一个新的 <code>ProgressBar</code> 实例,设置了它的皮肤、位置、宽高、网格等信息,并添加到舞台上。</caption>
  3791. *package
  3792. *{
  3793. *import laya.ui.ProgressBar;
  3794. *import laya.utils.Handler;
  3795. *public class ProgressBar_Example
  3796. *{
  3797. *private var progressBar:ProgressBar;
  3798. *public function ProgressBar_Example()
  3799. *{
  3800. *Laya.init(640,800);//设置游戏画布宽高。
  3801. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  3802. *Laya.loader.load(["resource/ui/progress.png","resource/ui/progress$bar.png"],Handler.create(this,onLoadComplete));//加载资源。
  3803. *}
  3804. *private function onLoadComplete():void
  3805. *{
  3806. *progressBar=new ProgressBar("resource/ui/progress.png");//创建一个 ProgressBar 类的实例对象 progressBar 。
  3807. *progressBar.x=100;//设置 progressBar 对象的属性 x 的值,用于控制 progressBar 对象的显示位置。
  3808. *progressBar.y=100;//设置 progressBar 对象的属性 y 的值,用于控制 progressBar 对象的显示位置。
  3809. *progressBar.value=0.3;//设置 progressBar 的进度值。
  3810. *progressBar.width=200;//设置 progressBar 的宽度。
  3811. *progressBar.height=50;//设置 progressBar 的高度。
  3812. *progressBar.sizeGrid="5,10,5,10";//设置 progressBar 的网格信息。
  3813. *progressBar.changeHandler=new Handler(this,onChange);//设置 progressBar 的value值改变时执行的处理器。
  3814. *Laya.stage.addChild(progressBar);//将 progressBar 添加到显示列表。
  3815. *Laya.timer.once(3000,this,changeValue);//设定 3000ms(毫秒)后,执行函数changeValue。
  3816. *}
  3817. *private function changeValue():void
  3818. *{
  3819. *trace("改变进度条的进度值。");
  3820. *progressBar.value=0.6;
  3821. *}
  3822. *private function onChange(value:Number):void
  3823. *{
  3824. *trace("进度发生改变: value=" ,value);
  3825. *}
  3826. *}
  3827. *}
  3828. *@example
  3829. *Laya.init(640,800);//设置游戏画布宽高
  3830. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  3831. *var res=["resource/ui/progress.png","resource/ui/progress$bar.png"];
  3832. *Laya.loader.load(res,laya.utils.Handler.create(this,onLoadComplete));//加载资源。
  3833. *function onLoadComplete()
  3834. *{
  3835. *progressBar=new laya.ui.ProgressBar("resource/ui/progress.png");//创建一个 ProgressBar 类的实例对象 progressBar 。
  3836. *progressBar.x=100;//设置 progressBar 对象的属性 x 的值,用于控制 progressBar 对象的显示位置。
  3837. *progressBar.y=100;//设置 progressBar 对象的属性 y 的值,用于控制 progressBar 对象的显示位置。
  3838. *progressBar.value=0.3;//设置 progressBar 的进度值。
  3839. *progressBar.width=200;//设置 progressBar 的宽度。
  3840. *progressBar.height=50;//设置 progressBar 的高度。
  3841. *progressBar.sizeGrid="10,5,10,5";//设置 progressBar 的网格信息。
  3842. *progressBar.changeHandler=new laya.utils.Handler(this,onChange);//设置 progressBar 的value值改变时执行的处理器。
  3843. *Laya.stage.addChild(progressBar);//将 progressBar 添加到显示列表。
  3844. *Laya.timer.once(3000,this,changeValue);//设定 3000ms(毫秒)后,执行函数changeValue。
  3845. *}
  3846. *function changeValue()
  3847. *{
  3848. *console.log("改变进度条的进度值。");
  3849. *progressBar.value=0.6;
  3850. *}
  3851. *function onChange(value)
  3852. *{
  3853. *console.log("进度发生改变: value=" ,value);
  3854. *}
  3855. *@example
  3856. *import ProgressBar=laya.ui.ProgressBar;
  3857. *import Handler=laya.utils.Handler;
  3858. *class ProgressBar_Example {
  3859. *private progressBar:ProgressBar;
  3860. *public ProgressBar_Example(){
  3861. *Laya.init(640,800);//设置游戏画布宽高。
  3862. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  3863. *Laya.loader.load(["resource/ui/progress.png","resource/ui/progress$bar.png"],Handler.create(this,this.onLoadComplete));//加载资源。
  3864. *}
  3865. *private onLoadComplete():void {
  3866. *this.progressBar=new ProgressBar("resource/ui/progress.png");//创建一个 ProgressBar 类的实例对象 progressBar 。
  3867. *this.progressBar.x=100;//设置 progressBar 对象的属性 x 的值,用于控制 progressBar 对象的显示位置。
  3868. *this.progressBar.y=100;//设置 progressBar 对象的属性 y 的值,用于控制 progressBar 对象的显示位置。
  3869. *this.progressBar.value=0.3;//设置 progressBar 的进度值。
  3870. *this.progressBar.width=200;//设置 progressBar 的宽度。
  3871. *this.progressBar.height=50;//设置 progressBar 的高度。
  3872. *this.progressBar.sizeGrid="5,10,5,10";//设置 progressBar 的网格信息。
  3873. *this.progressBar.changeHandler=new Handler(this,this.onChange);//设置 progressBar 的value值改变时执行的处理器。
  3874. *Laya.stage.addChild(this.progressBar);//将 progressBar 添加到显示列表。
  3875. *Laya.timer.once(3000,this,this.changeValue);//设定 3000ms(毫秒)后,执行函数changeValue。
  3876. *}
  3877. *private changeValue():void {
  3878. *console.log("改变进度条的进度值。");
  3879. *this.progressBar.value=0.6;
  3880. *}
  3881. *private onChange(value:number):void {
  3882. *console.log("进度发生改变: value=",value);
  3883. *}
  3884. *}
  3885. */
  3886. //class laya.ui.ProgressBar extends laya.ui.UIComponent
  3887. var ProgressBar=(function(_super){
  3888. function ProgressBar(skin){
  3889. /**
  3890. *当 <code>ProgressBar</code> 实例的 <code>value</code> 属性发生变化时的函数处理器。
  3891. *<p>默认返回参数<code>value</code> 属性(进度值)。</p>
  3892. */
  3893. this.changeHandler=null;
  3894. /**@private */
  3895. this._bg=null;
  3896. /**@private */
  3897. this._bar=null;
  3898. /**@private */
  3899. this._skin=null;
  3900. /**@private */
  3901. this._value=0.5;
  3902. ProgressBar.__super.call(this);
  3903. this.skin=skin;
  3904. }
  3905. __class(ProgressBar,'laya.ui.ProgressBar',_super);
  3906. var __proto=ProgressBar.prototype;
  3907. /**@inheritDoc */
  3908. __proto.destroy=function(destroyChild){
  3909. (destroyChild===void 0)&& (destroyChild=true);
  3910. _super.prototype.destroy.call(this,destroyChild);
  3911. this._bg && this._bg.destroy(destroyChild);
  3912. this._bar && this._bar.destroy(destroyChild);
  3913. this._bg=this._bar=null;
  3914. this.changeHandler=null;
  3915. }
  3916. /**@inheritDoc */
  3917. __proto.createChildren=function(){
  3918. this.addChild(this._bg=new Image());
  3919. this.addChild(this._bar=new Image());
  3920. this._bar._bitmap.autoCacheCmd=false;
  3921. }
  3922. __proto._skinLoaded=function(){
  3923. this._bg.skin=this._skin;
  3924. this._bar.skin=this._skin.replace(".png","$bar.png");
  3925. this.callLater(this.changeValue);
  3926. this._sizeChanged();
  3927. this.event(/*laya.events.Event.LOADED*/"loaded");
  3928. }
  3929. /**@inheritDoc */
  3930. __proto.measureWidth=function(){
  3931. return this._bg.width;
  3932. }
  3933. /**@inheritDoc */
  3934. __proto.measureHeight=function(){
  3935. return this._bg.height;
  3936. }
  3937. /**
  3938. *@private
  3939. *更改进度值的显示。
  3940. */
  3941. __proto.changeValue=function(){
  3942. if (this.sizeGrid){
  3943. var grid=this.sizeGrid.split(",");
  3944. var left=Number(grid[3]);
  3945. var right=Number(grid[1]);
  3946. var max=this.width-left-right;
  3947. var sw=max *this._value;
  3948. this._bar.width=left+right+sw;
  3949. this._bar.visible=this._bar.width > left+right;
  3950. }else {
  3951. this._bar.width=this.width *this._value;
  3952. }
  3953. }
  3954. /**@inheritDoc */
  3955. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  3956. this._dataSource=value;
  3957. if ((typeof value=='number')|| (typeof value=='string'))this.value=Number(value);
  3958. else Laya.superSet(UIComponent,this,'dataSource',value);
  3959. });
  3960. /**
  3961. *@copy laya.ui.Image#skin
  3962. */
  3963. __getset(0,__proto,'skin',function(){
  3964. return this._skin;
  3965. },function(value){
  3966. if (this._skin !=value){
  3967. this._skin=value;
  3968. if (this._skin&&!Loader.getRes(this._skin)){
  3969. Laya.loader.load(this._skin,Handler.create(this,this._skinLoaded),null,/*laya.net.Loader.IMAGE*/"image",1);
  3970. }else{
  3971. this._skinLoaded();
  3972. }
  3973. }
  3974. });
  3975. /**@inheritDoc */
  3976. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  3977. Laya.superSet(UIComponent,this,'height',value);
  3978. this._bg.height=this._height;
  3979. this._bar.height=this._height;
  3980. });
  3981. /**
  3982. *获取进度条对象。
  3983. */
  3984. __getset(0,__proto,'bar',function(){
  3985. return this._bar;
  3986. });
  3987. /**
  3988. *当前的进度量。
  3989. *<p><b>取值:</b>介于0和1之间。</p>
  3990. */
  3991. __getset(0,__proto,'value',function(){
  3992. return this._value;
  3993. },function(num){
  3994. if (this._value !=num){
  3995. num=num > 1 ? 1 :num < 0 ? 0 :num;
  3996. this._value=num;
  3997. this.callLater(this.changeValue);
  3998. this.event(/*laya.events.Event.CHANGE*/"change");
  3999. this.changeHandler && this.changeHandler.runWith(num);
  4000. }
  4001. });
  4002. /**
  4003. *获取背景条对象。
  4004. */
  4005. __getset(0,__proto,'bg',function(){
  4006. return this._bg;
  4007. });
  4008. /**
  4009. *<p>当前 <code>ProgressBar</code> 实例的进度条背景位图( <code>Image</code> 实例)的有效缩放网格数据。</p>
  4010. *<p>数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。
  4011. *<ul><li>例如:"4,4,4,4,1"</li></ul></p>
  4012. *@see laya.ui.AutoBitmap.sizeGrid
  4013. */
  4014. __getset(0,__proto,'sizeGrid',function(){
  4015. return this._bg.sizeGrid;
  4016. },function(value){
  4017. this._bg.sizeGrid=this._bar.sizeGrid=value;
  4018. });
  4019. /**@inheritDoc */
  4020. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  4021. Laya.superSet(UIComponent,this,'width',value);
  4022. this._bg.width=this._width;
  4023. this.callLater(this.changeValue);
  4024. });
  4025. return ProgressBar;
  4026. })(UIComponent)
  4027. /**
  4028. *<code>ScrollBar</code> 组件是一个滚动条组件。
  4029. *<p>当数据太多以至于显示区域无法容纳时,最终用户可以使用 <code>ScrollBar</code> 组件控制所显示的数据部分。</p>
  4030. *<p> 滚动条由四部分组成:两个箭头按钮、一个轨道和一个滑块。 </p> *
  4031. *
  4032. *@see laya.ui.VScrollBar
  4033. *@see laya.ui.HScrollBar
  4034. */
  4035. //class laya.ui.ScrollBar extends laya.ui.UIComponent
  4036. var ScrollBar=(function(_super){
  4037. function ScrollBar(skin){
  4038. /**滚动衰减系数*/
  4039. this.rollRatio=0.97;
  4040. /**滚动变化时回调,回传value参数。*/
  4041. this.changeHandler=null;
  4042. /**是否缩放滑动条,默认值为true。 */
  4043. this.scaleBar=true;
  4044. /**一个布尔值,指定是否自动隐藏滚动条(无需滚动时),默认值为false。*/
  4045. this.autoHide=false;
  4046. /**橡皮筋效果极限距离,0为没有橡皮筋效果。*/
  4047. this.elasticDistance=0;
  4048. /**橡皮筋回弹时间,单位为毫秒。*/
  4049. this.elasticBackTime=500;
  4050. /**上按钮 */
  4051. this.upButton=null;
  4052. /**下按钮 */
  4053. this.downButton=null;
  4054. /**滑条 */
  4055. this.slider=null;
  4056. /**@private */
  4057. this._scrollSize=1;
  4058. /**@private */
  4059. this._skin=null;
  4060. /**@private */
  4061. this._thumbPercent=1;
  4062. /**@private */
  4063. this._target=null;
  4064. /**@private */
  4065. this._lastPoint=null;
  4066. /**@private */
  4067. this._lastOffset=0;
  4068. /**@private */
  4069. this._checkElastic=false;
  4070. /**@private */
  4071. this._isElastic=false;
  4072. /**@private */
  4073. this._value=NaN;
  4074. /**@private */
  4075. this._hide=false;
  4076. /**@private */
  4077. this._clickOnly=true;
  4078. /**@private */
  4079. this._offsets=null;
  4080. this.isLockedFun=null;
  4081. this.triggerDownDragLimit=null;
  4082. this.triggerUpDragLimit=null;
  4083. ScrollBar.__super.call(this);
  4084. this._showButtons=UIConfig.showButtons;
  4085. this._touchScrollEnable=UIConfig.touchScrollEnable;
  4086. this._mouseWheelEnable=UIConfig.mouseWheelEnable;
  4087. this.skin=skin;
  4088. this.max=1;
  4089. }
  4090. __class(ScrollBar,'laya.ui.ScrollBar',_super);
  4091. var __proto=ScrollBar.prototype;
  4092. /**@inheritDoc */
  4093. __proto.destroy=function(destroyChild){
  4094. (destroyChild===void 0)&& (destroyChild=true);
  4095. this.stopScroll();
  4096. this.target=null;
  4097. _super.prototype.destroy.call(this,destroyChild);
  4098. this.upButton && this.upButton.destroy(destroyChild);
  4099. this.downButton && this.downButton.destroy(destroyChild);
  4100. this.slider && this.slider.destroy(destroyChild);
  4101. this.upButton=this.downButton=null;
  4102. this.slider=null;
  4103. this.changeHandler=null;
  4104. this._offsets=null;
  4105. }
  4106. /**@inheritDoc */
  4107. __proto.createChildren=function(){
  4108. this.addChild(this.slider=new Slider());
  4109. this.addChild(this.upButton=new Button());
  4110. this.addChild(this.downButton=new Button());
  4111. }
  4112. /**@inheritDoc */
  4113. __proto.initialize=function(){
  4114. this.slider.showLabel=false;
  4115. this.slider.tick=0;
  4116. this.slider.on(/*laya.events.Event.CHANGE*/"change",this,this.onSliderChange);
  4117. this.slider.setSlider(0,0,0);
  4118. this.upButton.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onButtonMouseDown);
  4119. this.downButton.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onButtonMouseDown);
  4120. }
  4121. /**
  4122. *@private
  4123. *滑块位置发生改变的处理函数。
  4124. */
  4125. __proto.onSliderChange=function(){
  4126. if(this._value !=this.slider.value)this.value=this.slider.value;
  4127. }
  4128. /**
  4129. *@private
  4130. *向上和向下按钮的 <code>Event.MOUSE_DOWN</code> 事件侦听处理函数。
  4131. */
  4132. __proto.onButtonMouseDown=function(e){
  4133. var isUp=e.currentTarget===this.upButton;
  4134. this.slide(isUp);
  4135. Laya.timer.once(Styles.scrollBarDelayTime,this,this.startLoop,[isUp]);
  4136. Laya.stage.once(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp);
  4137. }
  4138. /**@private */
  4139. __proto.startLoop=function(isUp){
  4140. Laya.timer.frameLoop(1,this,this.slide,[isUp]);
  4141. }
  4142. /**@private */
  4143. __proto.slide=function(isUp){
  4144. if (isUp)this.value-=this._scrollSize;
  4145. else this.value+=this._scrollSize;
  4146. }
  4147. /**
  4148. *@private
  4149. *舞台的 <code>Event.MOUSE_DOWN</code> 事件侦听处理函数。
  4150. */
  4151. __proto.onStageMouseUp=function(e){
  4152. Laya.timer.clear(this,this.startLoop);
  4153. Laya.timer.clear(this,this.slide);
  4154. }
  4155. __proto._skinLoaded=function(){
  4156. this.slider.skin=this._skin;
  4157. this.callLater(this.changeScrollBar);
  4158. this._sizeChanged();
  4159. this.event(/*laya.events.Event.LOADED*/"loaded");
  4160. }
  4161. /**
  4162. *@private
  4163. *更改对象的皮肤及位置。
  4164. */
  4165. __proto.changeScrollBar=function(){
  4166. this.upButton.visible=this._showButtons;
  4167. this.downButton.visible=this._showButtons;
  4168. if (this._showButtons){
  4169. this.upButton.skin=this._skin.replace(".png","$up.png");
  4170. this.downButton.skin=this._skin.replace(".png","$down.png");
  4171. }
  4172. if (this.slider.isVertical)this.slider.y=this._showButtons ? this.upButton.height :0;
  4173. else this.slider.x=this._showButtons ? this.upButton.width :0;
  4174. this.resetPositions();
  4175. this.repaint();
  4176. }
  4177. /**@inheritDoc */
  4178. __proto._sizeChanged=function(){
  4179. _super.prototype._sizeChanged.call(this);
  4180. this.repaint();
  4181. this.resetPositions();
  4182. this.event(/*laya.events.Event.CHANGE*/"change");
  4183. this.changeHandler && this.changeHandler.runWith(this.value);
  4184. }
  4185. /**@private */
  4186. __proto.resetPositions=function(){
  4187. if (this.slider.isVertical)this.slider.height=this.height-(this._showButtons ? (this.upButton.height+this.downButton.height):0);
  4188. else this.slider.width=this.width-(this._showButtons ? (this.upButton.width+this.downButton.width):0);
  4189. this.resetButtonPosition();
  4190. }
  4191. /**@private */
  4192. __proto.resetButtonPosition=function(){
  4193. if (this.slider.isVertical)this.downButton.y=this.slider._y+this.slider.height;
  4194. else this.downButton.x=this.slider._x+this.slider.width;
  4195. }
  4196. /**@inheritDoc */
  4197. __proto.measureWidth=function(){
  4198. if (this.slider.isVertical)return this.slider.width;
  4199. return 100;
  4200. }
  4201. /**@inheritDoc */
  4202. __proto.measureHeight=function(){
  4203. if (this.slider.isVertical)return 100;
  4204. return this.slider.height;
  4205. }
  4206. /**
  4207. *设置滚动条信息。
  4208. *@param min 滚动条最小位置值。
  4209. *@param max 滚动条最大位置值。
  4210. *@param value 滚动条当前位置值。
  4211. */
  4212. __proto.setScroll=function(min,max,value){
  4213. this.runCallLater(this._sizeChanged);
  4214. this.slider.setSlider(min,max,value);
  4215. this.slider.bar.visible=max > 0;
  4216. if (!this._hide && this.autoHide)this.visible=false;
  4217. }
  4218. /**@private */
  4219. __proto.onTargetMouseWheel=function(e){
  4220. this.value-=e.delta *this._scrollSize;
  4221. this.target=this._target;
  4222. }
  4223. /**@private */
  4224. __proto.onTargetMouseDown=function(e){
  4225. if ((this.isLockedFun)&& !this.isLockedFun(e))return;
  4226. this.event(/*laya.events.Event.END*/"end");
  4227. this._clickOnly=true;
  4228. this._lastOffset=0;
  4229. this._checkElastic=false;
  4230. this._lastPoint || (this._lastPoint=new Point());
  4231. this._lastPoint.setTo(Laya.stage.mouseX,Laya.stage.mouseY);
  4232. Laya.timer.clear(this,this.tweenMove);
  4233. Tween.clearTween(this);
  4234. Laya.stage.once(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp2);
  4235. Laya.stage.once(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onStageMouseUp2);
  4236. Laya.timer.frameLoop(1,this,this.loop);
  4237. }
  4238. __proto.startDragForce=function(){
  4239. this._clickOnly=true;
  4240. this._lastOffset=0;
  4241. this._checkElastic=false;
  4242. this._lastPoint || (this._lastPoint=new Point());
  4243. this._lastPoint.setTo(Laya.stage.mouseX,Laya.stage.mouseY);
  4244. Laya.timer.clear(this,this.tweenMove);
  4245. Tween.clearTween(this);
  4246. Laya.stage.once(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp2);
  4247. Laya.stage.once(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onStageMouseUp2);
  4248. Laya.timer.frameLoop(1,this,this.loop);
  4249. }
  4250. __proto.cancelDragOp=function(){
  4251. Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp2);
  4252. Laya.stage.off(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onStageMouseUp2);
  4253. Laya.timer.clear(this,this.tweenMove);
  4254. Laya.timer.clear(this,this.loop);
  4255. this._target.mouseEnabled=true;
  4256. }
  4257. __proto.checkTriggers=function(isTweenMove){
  4258. (isTweenMove===void 0)&& (isTweenMove=false);
  4259. if (this.value >=0&&this.value-this._lastOffset<=0){
  4260. if ((this.triggerDownDragLimit)&& this.triggerDownDragLimit(isTweenMove)){
  4261. this.cancelDragOp();
  4262. this.value=0;
  4263. return true;
  4264. }
  4265. }
  4266. if (this.value <=this.max && (this.value-this._lastOffset >=this.max)){
  4267. if ((this.triggerUpDragLimit)&& this.triggerUpDragLimit(isTweenMove)){
  4268. this.cancelDragOp();
  4269. this.value=this.max;
  4270. return true;
  4271. }
  4272. }
  4273. return false;
  4274. }
  4275. __proto.startTweenMoveForce=function(lastOffset){
  4276. this._lastOffset=lastOffset;
  4277. Laya.timer.frameLoop(1,this,this.tweenMove,[200]);
  4278. }
  4279. /**@private */
  4280. __proto.loop=function(){
  4281. var mouseY=Laya.stage.mouseY;
  4282. var mouseX=Laya.stage.mouseX;
  4283. this._lastOffset=this.isVertical ? (mouseY-this._lastPoint.y):(mouseX-this._lastPoint.x);
  4284. if (this._clickOnly){
  4285. if (Math.abs(this._lastOffset *(this.isVertical ? Laya.stage._canvasTransform.getScaleY():Laya.stage._canvasTransform.getScaleX()))> 1){
  4286. this._clickOnly=false;
  4287. if (this.checkTriggers())return;
  4288. this._offsets || (this._offsets=[]);
  4289. this._offsets.length=0;
  4290. this._target.mouseEnabled=false;
  4291. if (!this.hide && this.autoHide){
  4292. this.alpha=1;
  4293. this.visible=true;
  4294. }
  4295. this.event(/*laya.events.Event.START*/"start");
  4296. }else return;
  4297. }else{
  4298. if (this.checkTriggers())return;
  4299. }
  4300. this._offsets.push(this._lastOffset);
  4301. this._lastPoint.x=mouseX;
  4302. this._lastPoint.y=mouseY;
  4303. if (this._lastOffset===0)return;
  4304. if (!this._checkElastic){
  4305. if (this.elasticDistance > 0){
  4306. if (!this._checkElastic && this._lastOffset !=0){
  4307. if ((this._lastOffset > 0 && this._value <=this.min)|| (this._lastOffset < 0 && this._value >=this.max)){
  4308. this._isElastic=true;
  4309. this._checkElastic=true;
  4310. }else {
  4311. this._isElastic=false;
  4312. }
  4313. }
  4314. }else {
  4315. this._checkElastic=true;
  4316. }
  4317. }
  4318. if (this._isElastic){
  4319. if (this._value <=this.min){
  4320. if (this._lastOffset > 0){
  4321. this.value-=this._lastOffset *Math.max(0,(1-((this.min-this._value)/ this.elasticDistance)));
  4322. }else{
  4323. this.value-=this._lastOffset *0.5;
  4324. if(this._value>=this.min)
  4325. this._checkElastic=false;
  4326. }
  4327. }else if (this._value >=this.max){
  4328. if (this._lastOffset < 0){
  4329. this.value-=this._lastOffset *Math.max(0,(1-((this._value-this.max)/ this.elasticDistance)));
  4330. }else{
  4331. this.value-=this._lastOffset *0.5;
  4332. if(this._value<=this.max)
  4333. this._checkElastic=false;
  4334. }
  4335. }
  4336. }else {
  4337. this.value-=this._lastOffset;
  4338. }
  4339. }
  4340. /**@private */
  4341. __proto.onStageMouseUp2=function(e){
  4342. Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onStageMouseUp2);
  4343. Laya.stage.off(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onStageMouseUp2);
  4344. Laya.timer.clear(this,this.loop);
  4345. if (this._clickOnly){
  4346. if(this._value>=this.min&&this._value<=this.max)
  4347. return;
  4348. }
  4349. this._target.mouseEnabled=true;
  4350. if (this._isElastic){
  4351. if (this._value < this.min){
  4352. Tween.to(this,{value:this.min},this.elasticBackTime,Ease.sineOut,Handler.create(this,this.elasticOver));
  4353. }else if (this._value > this.max){
  4354. Tween.to(this,{value:this.max},this.elasticBackTime,Ease.sineOut,Handler.create(this,this.elasticOver));
  4355. }
  4356. }else {
  4357. if (!this._offsets)return;
  4358. if (this._offsets.length < 1){
  4359. this._offsets[0]=this.isVertical ? Laya.stage.mouseY-this._lastPoint.y :Laya.stage.mouseX-this._lastPoint.x;
  4360. };
  4361. var offset=0;
  4362. var n=Math.min(this._offsets.length,3);
  4363. for (var i=0;i < n;i++){
  4364. offset+=this._offsets[this._offsets.length-1-i];
  4365. }
  4366. this._lastOffset=offset / n;
  4367. offset=Math.abs(this._lastOffset);
  4368. if (offset < 2){
  4369. this.event(/*laya.events.Event.END*/"end");
  4370. return;
  4371. }
  4372. if (offset > 250)this._lastOffset=this._lastOffset > 0 ? 250 :-250;
  4373. var dis=Math.round(Math.abs(this.elasticDistance *(this._lastOffset / 150)));
  4374. Laya.timer.frameLoop(1,this,this.tweenMove,[dis]);
  4375. }
  4376. }
  4377. /**@private */
  4378. __proto.elasticOver=function(){
  4379. this._isElastic=false;
  4380. if (!this.hide && this.autoHide){
  4381. Tween.to(this,{alpha:0},500);
  4382. }
  4383. this.event(/*laya.events.Event.END*/"end");
  4384. }
  4385. /**@private */
  4386. __proto.tweenMove=function(maxDistance){
  4387. this._lastOffset *=this.rollRatio;
  4388. if (this.checkTriggers(true)){
  4389. return;
  4390. };
  4391. var tarSpeed=NaN;
  4392. if (maxDistance > 0){
  4393. if (this._lastOffset > 0 && this.value <=this.min){
  4394. this._isElastic=true;
  4395. tarSpeed=-(this.min-maxDistance-this.value)*0.5;
  4396. if (this._lastOffset > tarSpeed)this._lastOffset=tarSpeed;
  4397. }else if (this._lastOffset < 0 && this.value >=this.max){
  4398. this._isElastic=true;
  4399. tarSpeed=-(this.max+maxDistance-this.value)*0.5;
  4400. if (this._lastOffset < tarSpeed)this._lastOffset=tarSpeed;
  4401. }
  4402. }
  4403. this.value-=this._lastOffset;
  4404. if (Math.abs(this._lastOffset)< 0.1){
  4405. Laya.timer.clear(this,this.tweenMove);
  4406. if (this._isElastic){
  4407. if (this._value < this.min){
  4408. Tween.to(this,{value:this.min},this.elasticBackTime,Ease.sineOut,Handler.create(this,this.elasticOver));
  4409. }else if (this._value > this.max){
  4410. Tween.to(this,{value:this.max},this.elasticBackTime,Ease.sineOut,Handler.create(this,this.elasticOver));
  4411. }else {
  4412. this.elasticOver();
  4413. }
  4414. return;
  4415. }
  4416. this.event(/*laya.events.Event.END*/"end");
  4417. if (!this.hide && this.autoHide){
  4418. Tween.to(this,{alpha:0},500);
  4419. }
  4420. }
  4421. }
  4422. /**
  4423. *停止滑动。
  4424. */
  4425. __proto.stopScroll=function(){
  4426. this.onStageMouseUp2(null);
  4427. Laya.timer.clear(this,this.tweenMove);
  4428. Tween.clearTween(this);
  4429. }
  4430. /**获取或设置一个值,该值表示滑条长度比例,值为:(0-1)。 */
  4431. __getset(0,__proto,'thumbPercent',function(){
  4432. return this._thumbPercent;
  4433. },function(value){
  4434. this.runCallLater(this.changeScrollBar);
  4435. this.runCallLater(this._sizeChanged);
  4436. value=value >=1 ? 0.99 :value;
  4437. this._thumbPercent=value;
  4438. if (this.scaleBar){
  4439. if (this.slider.isVertical)this.slider.bar.height=Math.max(this.slider.height *value,Styles.scrollBarMinNum);
  4440. else this.slider.bar.width=Math.max(this.slider.width *value,Styles.scrollBarMinNum);
  4441. }
  4442. });
  4443. /**@inheritDoc */
  4444. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  4445. this._dataSource=value;
  4446. if ((typeof value=='number')|| (typeof value=='string'))this.value=Number(value);
  4447. else Laya.superSet(UIComponent,this,'dataSource',value);
  4448. });
  4449. /**
  4450. *@copy laya.ui.Image#skin
  4451. */
  4452. __getset(0,__proto,'skin',function(){
  4453. return this._skin;
  4454. },function(value){
  4455. if (value==" ")return;
  4456. if (this._skin !=value){
  4457. this._skin=value;
  4458. if (this._skin&&!Loader.getRes(this._skin)){
  4459. Laya.loader.load([this._skin,this._skin.replace(".png","$up.png"),this._skin.replace(".png","$down.png"),this._skin.replace(".png","$bar.png")],Handler.create(this,this._skinLoaded));
  4460. }else{
  4461. this._skinLoaded();
  4462. }
  4463. }
  4464. });
  4465. /**
  4466. *获取或设置表示最高滚动位置的数字。
  4467. */
  4468. __getset(0,__proto,'max',function(){
  4469. return this.slider.max;
  4470. },function(value){
  4471. this.slider.max=value;
  4472. });
  4473. /**
  4474. *获取或设置表示最低滚动位置的数字。
  4475. */
  4476. __getset(0,__proto,'min',function(){
  4477. return this.slider.min;
  4478. },function(value){
  4479. this.slider.min=value;
  4480. });
  4481. /**
  4482. *获取或设置表示当前滚动位置的数字。
  4483. */
  4484. __getset(0,__proto,'value',function(){
  4485. return this._value;
  4486. },function(v){
  4487. if (v!==this._value){
  4488. this._value=v;
  4489. if (!this._isElastic){
  4490. if (this.slider["_value"] !=v){
  4491. this.slider["_value"]=v;
  4492. this.slider.changeValue();
  4493. }
  4494. this._value=this.slider["_value"];
  4495. }
  4496. this.event(/*laya.events.Event.CHANGE*/"change");
  4497. this.changeHandler && this.changeHandler.runWith(this._value);
  4498. }
  4499. });
  4500. /**
  4501. *一个布尔值,指示滚动条是否为垂直滚动。如果值为true,则为垂直滚动,否则为水平滚动。
  4502. *<p>默认值为:true。</p>
  4503. */
  4504. __getset(0,__proto,'isVertical',function(){
  4505. return this.slider.isVertical;
  4506. },function(value){
  4507. this.slider.isVertical=value;
  4508. });
  4509. /**
  4510. *<p>当前实例的 <code>Slider</code> 实例的有效缩放网格数据。</p>
  4511. *<p>数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。
  4512. *<ul><li>例如:"4,4,4,4,1"</li></ul></p>
  4513. *@see laya.ui.AutoBitmap.sizeGrid
  4514. */
  4515. __getset(0,__proto,'sizeGrid',function(){
  4516. return this.slider.sizeGrid;
  4517. },function(value){
  4518. this.slider.sizeGrid=value;
  4519. });
  4520. /**获取或设置一个值,该值表示按下滚动条轨道时页面滚动的增量。 */
  4521. __getset(0,__proto,'scrollSize',function(){
  4522. return this._scrollSize;
  4523. },function(value){
  4524. this._scrollSize=value;
  4525. });
  4526. /**
  4527. *设置滚动对象。
  4528. *@see laya.ui.TouchScroll#target
  4529. */
  4530. __getset(0,__proto,'target',function(){
  4531. return this._target;
  4532. },function(value){
  4533. if (this._target){
  4534. this._target.off(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this,this.onTargetMouseWheel);
  4535. this._target.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onTargetMouseDown);
  4536. }
  4537. this._target=value;
  4538. if (value){
  4539. this._mouseWheelEnable && this._target.on(/*laya.events.Event.MOUSE_WHEEL*/"mousewheel",this,this.onTargetMouseWheel);
  4540. this._touchScrollEnable && this._target.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onTargetMouseDown);
  4541. }
  4542. });
  4543. /**是否隐藏滚动条,不显示滚动条,但是可以正常滚动,默认为false。*/
  4544. __getset(0,__proto,'hide',function(){
  4545. return this._hide;
  4546. },function(value){
  4547. this._hide=value;
  4548. this.visible=!value;
  4549. });
  4550. /**一个布尔值,指定是否显示向上、向下按钮,默认值为true。*/
  4551. __getset(0,__proto,'showButtons',function(){
  4552. return this._showButtons;
  4553. },function(value){
  4554. this._showButtons=value;
  4555. this.callLater(this.changeScrollBar);
  4556. });
  4557. /**一个布尔值,指定是否开启触摸,默认值为true。*/
  4558. __getset(0,__proto,'touchScrollEnable',function(){
  4559. return this._touchScrollEnable;
  4560. },function(value){
  4561. this._touchScrollEnable=value;
  4562. this.target=this._target;
  4563. });
  4564. /**一个布尔值,指定是否滑轮滚动,默认值为true。*/
  4565. __getset(0,__proto,'mouseWheelEnable',function(){
  4566. return this._mouseWheelEnable;
  4567. },function(value){
  4568. this._mouseWheelEnable=value;
  4569. this.target=this._target;
  4570. });
  4571. __getset(0,__proto,'lastOffset',function(){
  4572. return this._lastOffset;
  4573. });
  4574. /**
  4575. *滚动的刻度值,滑动数值为tick的整数倍。默认值为1。
  4576. */
  4577. __getset(0,__proto,'tick',function(){
  4578. return this.slider.tick;
  4579. },function(value){
  4580. this.slider.tick=value;
  4581. });
  4582. return ScrollBar;
  4583. })(UIComponent)
  4584. /**
  4585. *使用 <code>Slider</code> 控件,用户可以通过在滑块轨道的终点之间移动滑块来选择值。
  4586. *<p>滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。</p>
  4587. *<p>滑块允许最小值和最大值之间特定间隔内的值。滑块还可以使用数据提示显示其当前值。</p>
  4588. *
  4589. *@see laya.ui.HSlider
  4590. *@see laya.ui.VSlider
  4591. */
  4592. //class laya.ui.Slider extends laya.ui.UIComponent
  4593. var Slider=(function(_super){
  4594. function Slider(skin){
  4595. /**
  4596. *数据变化处理器。
  4597. *<p>默认回调参数为滑块位置属性 <code>value</code>属性值:Number 。</p>
  4598. */
  4599. this.changeHandler=null;
  4600. /**
  4601. *一个布尔值,指示是否为垂直滚动。如果值为true,则为垂直方向,否则为水平方向。
  4602. *<p>默认值为:true。</p>
  4603. *@default true
  4604. */
  4605. this.isVertical=true;
  4606. /**
  4607. *一个布尔值,指示是否显示标签。
  4608. *@default true
  4609. */
  4610. this.showLabel=true;
  4611. /**@private */
  4612. this._allowClickBack=false;
  4613. /**@private */
  4614. this._max=100;
  4615. /**@private */
  4616. this._min=0;
  4617. /**@private */
  4618. this._tick=1;
  4619. /**@private */
  4620. this._value=0;
  4621. /**@private */
  4622. this._skin=null;
  4623. /**@private */
  4624. this._bg=null;
  4625. /**@private */
  4626. this._progress=null;
  4627. /**@private */
  4628. this._bar=null;
  4629. /**@private */
  4630. this._tx=NaN;
  4631. /**@private */
  4632. this._ty=NaN;
  4633. /**@private */
  4634. this._maxMove=NaN;
  4635. /**@private */
  4636. this._globalSacle=null;
  4637. Slider.__super.call(this);
  4638. this.skin=skin;
  4639. }
  4640. __class(Slider,'laya.ui.Slider',_super);
  4641. var __proto=Slider.prototype;
  4642. /**
  4643. *@inheritDoc
  4644. */
  4645. __proto.destroy=function(destroyChild){
  4646. (destroyChild===void 0)&& (destroyChild=true);
  4647. _super.prototype.destroy.call(this,destroyChild);
  4648. this._bg && this._bg.destroy(destroyChild);
  4649. this._bar && this._bar.destroy(destroyChild);
  4650. this._progress && this._progress.destroy(destroyChild);
  4651. this._bg=null;
  4652. this._bar=null;
  4653. this._progress=null;
  4654. this.changeHandler=null;
  4655. }
  4656. /**@inheritDoc */
  4657. __proto.createChildren=function(){
  4658. this.addChild(this._bg=new Image());
  4659. this.addChild(this._bar=new Button());
  4660. }
  4661. /**@inheritDoc */
  4662. __proto.initialize=function(){
  4663. this._bar.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onBarMouseDown);
  4664. this._bg.sizeGrid=this._bar.sizeGrid="4,4,4,4,0";
  4665. if (this._progress)this._progress.sizeGrid=this._bar.sizeGrid;
  4666. this.allowClickBack=true;
  4667. }
  4668. /**
  4669. *@private
  4670. *滑块的的 <code>Event.MOUSE_DOWN</code> 事件侦听处理函数。
  4671. */
  4672. __proto.onBarMouseDown=function(e){
  4673. this._globalSacle || (this._globalSacle=new Point());
  4674. this._globalSacle.setTo(this.globalScaleX || 0.01,this.globalScaleY || 0.01);
  4675. this._maxMove=this.isVertical ? (this.height-this._bar.height):(this.width-this._bar.width);
  4676. this._tx=Laya.stage.mouseX;
  4677. this._ty=Laya.stage.mouseY;
  4678. Laya.stage.on(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.mouseMove);
  4679. Laya.stage.once(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.mouseUp);
  4680. Laya.stage.once(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.mouseUp);
  4681. this.showValueText();
  4682. }
  4683. /**
  4684. *@private
  4685. *显示标签。
  4686. */
  4687. __proto.showValueText=function(){
  4688. if (this.showLabel){
  4689. var label=laya.ui.Slider.label;
  4690. this.addChild(label);
  4691. label.textField.changeText(this._value+"");
  4692. if (this.isVertical){
  4693. label.x=this._bar._x+20;
  4694. label.y=(this._bar.height-label.height)*0.5+this._bar._y;
  4695. }else {
  4696. label.y=this._bar._y-20;
  4697. label.x=(this._bar.width-label.width)*0.5+this._bar._x;
  4698. }
  4699. }
  4700. }
  4701. /**
  4702. *@private
  4703. *隐藏标签。
  4704. */
  4705. __proto.hideValueText=function(){
  4706. laya.ui.Slider.label && laya.ui.Slider.label.removeSelf();
  4707. }
  4708. /**
  4709. *@private
  4710. */
  4711. __proto.mouseUp=function(e){
  4712. Laya.stage.off(/*laya.events.Event.MOUSE_MOVE*/"mousemove",this,this.mouseMove);
  4713. Laya.stage.off(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.mouseUp);
  4714. Laya.stage.off(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.mouseUp);
  4715. this.sendChangeEvent(/*laya.events.Event.CHANGED*/"changed");
  4716. this.hideValueText();
  4717. }
  4718. /**
  4719. *@private
  4720. */
  4721. __proto.mouseMove=function(e){
  4722. var oldValue=this._value;
  4723. if (this.isVertical){
  4724. this._bar.y+=(Laya.stage.mouseY-this._ty)/ this._globalSacle.y;
  4725. if (this._bar._y > this._maxMove)this._bar.y=this._maxMove;
  4726. else if (this._bar._y < 0)this._bar.y=0;
  4727. this._value=this._bar._y / this._maxMove *(this._max-this._min)+this._min;
  4728. if(this._progress)this._progress.height=this._bar._y+0.5*this._bar.height;
  4729. }else {
  4730. this._bar.x+=(Laya.stage.mouseX-this._tx)/ this._globalSacle.x;
  4731. if (this._bar._x > this._maxMove)this._bar.x=this._maxMove;
  4732. else if (this._bar._x < 0)this._bar.x=0;
  4733. this._value=this._bar._x / this._maxMove *(this._max-this._min)+this._min;
  4734. if(this._progress)this._progress.width=this._bar._x+0.5*this._bar.width;
  4735. }
  4736. this._tx=Laya.stage.mouseX;
  4737. this._ty=Laya.stage.mouseY;
  4738. if (this._tick !=0){
  4739. var pow=Math.pow(10,(this._tick+"").length-1);
  4740. this._value=Math.round(Math.round(this._value / this._tick)*this._tick *pow)/ pow;
  4741. }
  4742. if (this._value !=oldValue){
  4743. this.sendChangeEvent();
  4744. }
  4745. this.showValueText();
  4746. }
  4747. /**
  4748. *@private
  4749. */
  4750. __proto.sendChangeEvent=function(type){
  4751. (type===void 0)&& (type=/*laya.events.Event.CHANGE*/"change");
  4752. this.event(type);
  4753. this.changeHandler && this.changeHandler.runWith(this._value);
  4754. }
  4755. __proto._skinLoaded=function(){
  4756. this._bg.skin=this._skin;
  4757. this._bar.skin=this._skin.replace(".png","$bar.png");
  4758. var progressSkin=this._skin.replace(".png","$progress.png");
  4759. if (Loader.getRes(progressSkin)){
  4760. if (!this._progress){
  4761. this.addChild(this._progress=new Image());
  4762. this._progress.sizeGrid=this._bar.sizeGrid;
  4763. this.setChildIndex(this._progress,1);
  4764. }
  4765. this._progress.skin=progressSkin;
  4766. }
  4767. this.setBarPoint();
  4768. this.callLater(this.changeValue);
  4769. this._sizeChanged();
  4770. this.event(/*laya.events.Event.LOADED*/"loaded");
  4771. }
  4772. /**
  4773. *@private
  4774. *设置滑块的位置信息。
  4775. */
  4776. __proto.setBarPoint=function(){
  4777. if (this.isVertical)this._bar.x=Math.round((this._bg.width-this._bar.width)*0.5);
  4778. else this._bar.y=Math.round((this._bg.height-this._bar.height)*0.5);
  4779. }
  4780. /**@inheritDoc */
  4781. __proto.measureWidth=function(){
  4782. return Math.max(this._bg.width,this._bar.width);
  4783. }
  4784. /**@inheritDoc */
  4785. __proto.measureHeight=function(){
  4786. return Math.max(this._bg.height,this._bar.height);
  4787. }
  4788. /**@inheritDoc */
  4789. __proto._sizeChanged=function(){
  4790. _super.prototype._sizeChanged.call(this);
  4791. if (this.isVertical)this._bg.height=this.height;
  4792. else this._bg.width=this.width;
  4793. this.setBarPoint();
  4794. this.changeValue();
  4795. }
  4796. /**
  4797. *设置滑动条的信息。
  4798. *@param min 滑块的最小值。
  4799. *@param max 滑块的最小值。
  4800. *@param value 滑块的当前值。
  4801. */
  4802. __proto.setSlider=function(min,max,value){
  4803. this._value=-1;
  4804. this._min=min;
  4805. this._max=max > min ? max :min;
  4806. this.value=value < min ? min :value > max ? max :value;
  4807. }
  4808. /**
  4809. *@private
  4810. *改变滑块的位置值。
  4811. */
  4812. __proto.changeValue=function(){
  4813. if (this.tick !=0){
  4814. var pow=Math.pow(10,(this._tick+"").length-1);
  4815. this._value=Math.round(Math.round(this._value / this._tick)*this._tick *pow)/ pow;
  4816. }
  4817. this._value=this._value > this._max ? this._max :this._value < this._min ? this._min :this._value;
  4818. var num=this._max-this._min;
  4819. if (num===0)num=1;
  4820. if (this.isVertical){
  4821. this._bar.y=(this._value-this._min)/ num *(this.height-this._bar.height);
  4822. if(this._progress)this._progress.height=this._bar._y+0.5*this._bar.height;
  4823. }
  4824. else{
  4825. this._bar.x=(this._value-this._min)/ num *(this.width-this._bar.width);
  4826. if(this._progress)this._progress.width=this._bar._x+0.5*this._bar.width;
  4827. }
  4828. }
  4829. /**
  4830. *@private
  4831. *滑动条的 <code>Event.MOUSE_DOWN</code> 事件侦听处理函数。
  4832. */
  4833. __proto.onBgMouseDown=function(e){
  4834. var point=this._bg.getMousePoint();
  4835. if (this.isVertical)this.value=point.y / (this.height-this._bar.height)*(this._max-this._min)+this._min;
  4836. else this.value=point.x / (this.width-this._bar.width)*(this._max-this._min)+this._min;
  4837. }
  4838. /**@inheritDoc */
  4839. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  4840. this._dataSource=value;
  4841. if ((typeof value=='number')|| (typeof value=='string'))this.value=Number(value);
  4842. else Laya.superSet(UIComponent,this,'dataSource',value);
  4843. });
  4844. /**
  4845. *@copy laya.ui.Image#skin
  4846. */
  4847. __getset(0,__proto,'skin',function(){
  4848. return this._skin;
  4849. },function(value){
  4850. if (this._skin !=value){
  4851. this._skin=value;
  4852. if (this._skin&&!Loader.getRes(this._skin)){
  4853. Laya.loader.load([this._skin,this._skin.replace(".png","$bar.png")],Handler.create(this,this._skinLoaded));
  4854. }else{
  4855. this._skinLoaded();
  4856. }
  4857. }
  4858. });
  4859. /**
  4860. *滑动的刻度值,滑动数值为tick的整数倍。默认值为1。
  4861. */
  4862. __getset(0,__proto,'tick',function(){
  4863. return this._tick;
  4864. },function(value){
  4865. if (this._tick !=value){
  4866. this._tick=value;
  4867. this.callLater(this.changeValue);
  4868. }
  4869. });
  4870. /**
  4871. *<p>当前实例的背景图( <code>Image</code> )和滑块按钮( <code>Button</code> )实例的有效缩放网格数据。</p>
  4872. *<p>数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。
  4873. *<ul><li>例如:"4,4,4,4,1"</li></ul></p>
  4874. *@see laya.ui.AutoBitmap.sizeGrid
  4875. */
  4876. __getset(0,__proto,'sizeGrid',function(){
  4877. return this._bg.sizeGrid;
  4878. },function(value){
  4879. this._bg.sizeGrid=value;
  4880. this._bar.sizeGrid=value;
  4881. if (this._progress)this._progress.sizeGrid=this._bar.sizeGrid;
  4882. });
  4883. /**
  4884. *一个布尔值,指定是否允许通过点击滑动条改变 <code>Slider</code> 的 <code>value</code> 属性值。
  4885. */
  4886. __getset(0,__proto,'allowClickBack',function(){
  4887. return this._allowClickBack;
  4888. },function(value){
  4889. if (this._allowClickBack !=value){
  4890. this._allowClickBack=value;
  4891. if (value)this._bg.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onBgMouseDown);
  4892. else this._bg.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onBgMouseDown);
  4893. }
  4894. });
  4895. /**
  4896. *获取或设置表示最高位置的数字。 默认值为100。
  4897. */
  4898. __getset(0,__proto,'max',function(){
  4899. return this._max;
  4900. },function(value){
  4901. if (this._max !=value){
  4902. this._max=value;
  4903. this.callLater(this.changeValue);
  4904. }
  4905. });
  4906. /**
  4907. *获取或设置表示最低位置的数字。 默认值为0。
  4908. */
  4909. __getset(0,__proto,'min',function(){
  4910. return this._min;
  4911. },function(value){
  4912. if (this._min !=value){
  4913. this._min=value;
  4914. this.callLater(this.changeValue);
  4915. }
  4916. });
  4917. /**
  4918. *表示滑块按钮的引用。
  4919. */
  4920. __getset(0,__proto,'bar',function(){
  4921. return this._bar;
  4922. });
  4923. /**
  4924. *获取或设置表示当前滑块位置的数字。
  4925. */
  4926. __getset(0,__proto,'value',function(){
  4927. return this._value;
  4928. },function(num){
  4929. if (this._value !=num){
  4930. var oldValue=this._value;
  4931. this._value=num;
  4932. this.changeValue();
  4933. if (this._value !=oldValue){
  4934. this.sendChangeEvent();
  4935. }
  4936. }
  4937. });
  4938. __static(Slider,
  4939. ['label',function(){return this.label=new Label();}
  4940. ]);
  4941. return Slider;
  4942. })(UIComponent)
  4943. /**
  4944. *游戏中心插件
  4945. *@author xiaosong
  4946. *@date 2018-12-26
  4947. */
  4948. //class laya.ui.MoreGame extends laya.ui.View
  4949. var MoreGame=(function(_super){
  4950. var GameBox,GameItem;
  4951. function MoreGame(type){
  4952. /**是否停止缓动,默认晃动**/
  4953. this.gameStopHD=false;
  4954. /**icon动画**/
  4955. this.iconImgTl=null;
  4956. /**iconImage**/
  4957. this._iconImage=null;
  4958. /**更多游戏容器**/
  4959. this._moreBox=null;
  4960. /**游戏内盒子容器**/
  4961. this._gameBox=null;
  4962. /**屏幕方向,默认0 横屏,1竖屏**/
  4963. this.screenType=0;
  4964. /**更多游戏配置数据**/
  4965. this._moreGameDataUrl="https://abc.layabox.com/public/more/gamelist2.json";
  4966. /**图片尺寸设置信息**/
  4967. this._iconImageObj=null;
  4968. /**图标点击回调**/
  4969. this.clickCallBack=null;
  4970. /**关闭盒子回调**/
  4971. this.closeCallBack=null;
  4972. /**是否在显示中**/
  4973. this.isShow=false;
  4974. /**系统信息**/
  4975. this.dinfo=null;
  4976. /**统计数据地址**/
  4977. this.ErrorUrlHttps="https://elastic.layabox.com/";
  4978. /**统计类型**/
  4979. this.tongjiType="bdm";
  4980. (type===void 0)&& (type=0);
  4981. MoreGame.__super.call(this);
  4982. this.screenType=type;
  4983. this.init();
  4984. }
  4985. __class(MoreGame,'laya.ui.MoreGame',_super);
  4986. var __proto=MoreGame.prototype;
  4987. /**
  4988. *获取字符串时间戳,例如:2018-7-6
  4989. *@param _timestamp
  4990. *@return
  4991. *
  4992. */
  4993. __proto.getLocalDateString=function(_timestamp){
  4994. (_timestamp===void 0)&& (_timestamp=0);
  4995. var timeStr=this.getDateByTimestamp(_timestamp).toLocaleDateString();
  4996. if(Browser.onLimixiu || Browser.onMiniGame){
  4997. var date=new Date();
  4998. timeStr=MoreGame.toLocaleDateString(date.getTime());
  4999. };
  5000. var reg=new RegExp("/","g");
  5001. timeStr=timeStr.replace(reg,"-");
  5002. return timeStr;
  5003. }
  5004. __proto.getDateByTimestamp=function(_timestamp){
  5005. (_timestamp===void 0)&& (_timestamp=0);
  5006. if (!_timestamp || _timestamp=="")return /*__JS__ */new Date();
  5007. return /*__JS__ */new Date(_timestamp);
  5008. }
  5009. /**
  5010. *发送统计信息
  5011. *@param etype 统计数据类型
  5012. *@param errorInfo 报错信息
  5013. *@param pro 统计扩展数据
  5014. */
  5015. __proto.reportError=function(etype,errorInfo,pro){
  5016. (errorInfo===void 0)&& (errorInfo="");
  5017. pro=pro || {};
  5018. var now=/*__JS__ */Date.now();
  5019. var date=new Date(now+0);
  5020. pro.date=date.toLocaleString();
  5021. pro.etype=etype;
  5022. if (etype !="error"){
  5023. if (etype !="statistics"){
  5024. etype="statistics";
  5025. }
  5026. }
  5027. pro.version="V0.0.1";
  5028. pro.gameId=10100;
  5029. pro.dinfo=this.dinfo;
  5030. pro.channel=-1000;
  5031. pro.msg=errorInfo;
  5032. pro["@timestamp"]=/*__JS__ */date.toISOString();
  5033. pro.user=this.getUserId();
  5034. pro.openid=this.getOpenId();
  5035. var rdate=MoreGame.getDay(date);
  5036. pro.rdate=rdate;
  5037. pro.day=date.getDate()+"";
  5038. pro.hour=date.getHours()+"";
  5039. pro.minute=date.getMinutes()+"";
  5040. pro.gameurl=/*__JS__ */document.baseURI;
  5041. pro.regTime=0;
  5042. if (etype=="error"){
  5043. this.sendLog(pro,this.tongjiType+"error-"+rdate.substring(0,6)+"/"+etype+"/",etype);
  5044. }else{
  5045. this.sendLog(pro,this.tongjiType+"-"+rdate.substring(0,6)+"/"+etype+"/",etype);
  5046. }
  5047. }
  5048. /**获取用户userid**/
  5049. __proto.getUserId=function(){
  5050. var userid=parseInt(LocalStorage.getItem("layauserid")+"")||-1;
  5051. if(userid==-1){
  5052. userid=this.randRange(0,1000000000);
  5053. LocalStorage.setItem("layauserid",userid+"");
  5054. }
  5055. return userid;
  5056. }
  5057. /**获取用户的openid**/
  5058. __proto.getOpenId=function(){
  5059. var str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  5060. var openId=LocalStorage.getItem("openid");
  5061. if(openId==null || openId==""){
  5062. openId="";
  5063. for(var i=0,sz=32;i<sz;i++){
  5064. var random=this.randRange(0,62);
  5065. openId+=str.charAt(random);
  5066. }
  5067. LocalStorage.setItem("openid",openId);
  5068. }
  5069. return openId;
  5070. }
  5071. __proto.sendLog=function(pro,path,btype){
  5072. var _$this=this;
  5073. var htt=new HttpRequest();
  5074. htt.on(/*laya.events.Event.ERROR*/"error",this,function(p,bt,e){
  5075. if (e && e.indexOf("[404]")!=-1){
  5076. var htt1=new HttpRequest();
  5077. htt1.send(_$this.ErrorUrlHttps+"garbage/"+bt+"/",JSON.stringify(p),"post","text",["Content-Type","application/json"]);
  5078. }
  5079. },[pro,btype]);
  5080. if(Browser.onBDMiniGame){
  5081. pro.gameurl="";
  5082. }
  5083. htt.send(this.ErrorUrlHttps+path,JSON.stringify(pro),"post","text",["Content-Type","application/json"]);
  5084. }
  5085. __proto.initEvent=function(){
  5086. this.on(/*laya.events.Event.CLICK*/"click",this,this.onIconClick);
  5087. }
  5088. __proto.onStageResize=function(){
  5089. var scale=Math.min(Laya.stage.width / Laya.stage.designWidth,Laya.stage.height / Laya.stage.designHeight);
  5090. if(Laya.stage.width < 720)
  5091. scale=0.9;
  5092. if(this._moreBox){
  5093. this._moreBox.scale(scale,scale);
  5094. }
  5095. if(this._gameBox){
  5096. this._gameBox.scale(scale,scale);
  5097. }
  5098. }
  5099. /**
  5100. *晃动效果
  5101. *@param target
  5102. *@param tTime
  5103. *@param sacleNum
  5104. *@param lastSacleNum
  5105. *@return
  5106. */
  5107. __proto.tada=function(target,tTime,sacleNum,lastSacleNum){
  5108. (sacleNum===void 0)&& (sacleNum=1.1);
  5109. (lastSacleNum===void 0)&& (lastSacleNum=1);
  5110. var tl=new TimeLine();
  5111. tl.reset();
  5112. tl.to(target,{scaleX:sacleNum,scaleY:sacleNum,rotation:3},tTime *0.1)
  5113. .to(target,{scaleX:sacleNum,scaleY:sacleNum,rotation:-3},tTime *0.1)
  5114. .to(target,{scaleX:sacleNum,scaleY:sacleNum,rotation:3},tTime *0.1)
  5115. .to(target,{scaleX:sacleNum,scaleY:sacleNum,rotation:-3},tTime *0.1)
  5116. .to(target,{scaleX:sacleNum,scaleY:sacleNum,rotation:3},tTime *0.1)
  5117. .to(target,{scaleX:sacleNum,scaleY:sacleNum,rotation:-3},tTime *0.1)
  5118. .to(target,{scaleX:sacleNum,scaleY:sacleNum,rotation:3},tTime *0.1)
  5119. .to(target,{scaleX:sacleNum,scaleY:sacleNum,rotation:-3},tTime *0.1)
  5120. .to(target,{scaleX:sacleNum,scaleY:sacleNum,rotation:3},tTime *0.1)
  5121. .to(target,{scaleX:lastSacleNum,scaleY:lastSacleNum,rotation:0},tTime *0.1);
  5122. tl.play(0);
  5123. return tl;
  5124. }
  5125. /**销毁插件**/
  5126. __proto.dispose=function(){
  5127. this.removeEvent();
  5128. this.gameStopHD=true;
  5129. MoreGame._moreGameData=null;
  5130. this._iconImageObj=null;
  5131. this.clickCallBack=null;
  5132. this.closeCallBack=null;
  5133. if(this.iconImgTl){
  5134. this.iconImgTl.offAll(/*laya.events.Event.COMPLETE*/"complete");
  5135. this.iconImgTl=null;
  5136. }
  5137. if(this._moreBox){
  5138. this._moreBox.removeChildren();
  5139. this._moreBox=null;
  5140. }
  5141. if(this._gameBox){
  5142. this._gameBox.removeChildren();
  5143. this._gameBox=null;
  5144. }
  5145. if(this._iconImage){
  5146. this._iconImage.removeSelf();
  5147. this._iconImage=null;
  5148. }
  5149. }
  5150. /**
  5151. *设置icon的显示状态
  5152. *@param type
  5153. */
  5154. __proto.onSetIconType=function(type){
  5155. this.gameStopHD=!type;
  5156. this.visible=type;
  5157. }
  5158. /**检测晃动**/
  5159. __proto.checkIconImgHD=function(){
  5160. if(!this.iconImgTl)
  5161. this.iconImgTl=this.tada(this._iconImage,1200,1.1,0.9);
  5162. else
  5163. this.iconImgTl.play(0);
  5164. this.iconImgTl.on(/*laya.events.Event.COMPLETE*/"complete",this,this.onTlComplete);
  5165. }
  5166. __proto.onTlComplete=function(){
  5167. if(this.parent){
  5168. this._iconImage.scale(0.9,0.9);
  5169. this._iconImage.rotation=0;
  5170. if (this.gameStopHD && this.iconImgTl){
  5171. this.iconImgTl.offAll(/*laya.events.Event.COMPLETE*/"complete");
  5172. this.iconImgTl=null;
  5173. return;
  5174. }
  5175. Laya.timer.once(1000,this,this.onYanChiPlay);
  5176. }else{
  5177. if(this.iconImgTl){
  5178. this.iconImgTl.offAll();
  5179. this.iconImgTl=null;
  5180. }
  5181. }
  5182. }
  5183. __proto.onYanChiPlay=function(){
  5184. if(this.parent && this.iconImgTl){
  5185. this.iconImgTl.play(0);
  5186. }else{
  5187. if(this.iconImgTl){
  5188. this.iconImgTl.offAll(/*laya.events.Event.COMPLETE*/"complete");
  5189. this.iconImgTl=null;
  5190. }
  5191. }
  5192. }
  5193. __proto.removeEvent=function(){
  5194. this.off(/*laya.events.Event.CLICK*/"click",this,this.onIconClick);
  5195. }
  5196. __proto.onIconClick=function(){
  5197. this.isShow=true;
  5198. this.clickCallBack !=null && this.clickCallBack.run();
  5199. var localCurrentTime=LocalStorage.getItem("currentTime");
  5200. var currentTime=this.getLocalDateString();
  5201. if(localCurrentTime !=currentTime){
  5202. LocalStorage.setItem("currentTime",currentTime);
  5203. this.reportError(MoreGame._moreGameData.statid1);
  5204. }else{
  5205. this.reportError(MoreGame._moreGameData.statid2);
  5206. }
  5207. this.onResLoaded();
  5208. }
  5209. __proto.onResLoaded=function(){
  5210. if(!this._moreBox){
  5211. this._moreBox=new Box();
  5212. Laya.stage.addChild(this._moreBox);
  5213. this._moreBox.zOrder=99999;
  5214. this._moreBox.left=this._moreBox.right=this._moreBox.top=this._moreBox.bottom=0;
  5215. var allBgImg=this.onCreateImage(MoreGame.onGetAtlasDanImgUrl("img_white_bg"),this._moreBox);
  5216. allBgImg.top=allBgImg.left=allBgImg.right=allBgImg.bottom=0;
  5217. allBgImg.sizeGrid="1,1,1,1,1";
  5218. var hlineImg=this.onCreateImage(MoreGame.onGetAtlasDanImgUrl("hengfengexian"),this._moreBox);
  5219. hlineImg.left=hlineImg.right=0;
  5220. hlineImg.y=132;
  5221. hlineImg.alpha=0.2;
  5222. var jiantouImg=this.onCreateImage(MoreGame.onGetAtlasDanImgUrl("img_font_jingcai"),this._moreBox);
  5223. jiantouImg.on(/*laya.events.Event.CLICK*/"click",this,this.onJiantouImgClick);
  5224. if(this.isQMP()&& this.screenType){
  5225. jiantouImg.pos(15,70);
  5226. }else{
  5227. jiantouImg.pos(15,45);
  5228. };
  5229. var gamelist=new List();
  5230. this._moreBox.addChild(gamelist);
  5231. gamelist.itemRender=GameBox;
  5232. gamelist.selectEnable=true;
  5233. gamelist.vScrollBarSkin="";
  5234. gamelist.scrollBar.autoHide=true;
  5235. gamelist.scrollBar.elasticDistance=250;
  5236. gamelist.renderHandler=new Handler(this,this.onGameListRender);
  5237. var tempGameListArr=MoreGame._moreGameData.marvellousGame.gameList;
  5238. var gameListArr=[];
  5239. gameListArr.push(tempGameListArr[0]);
  5240. gameListArr.push(tempGameListArr[1]);
  5241. var getRomdomArr=this.RandomNumBoth(gameListArr.length,tempGameListArr.length-gameListArr.length,tempGameListArr.length);
  5242. if(!getRomdomArr){
  5243. this.visible=false;
  5244. return;
  5245. }
  5246. try{
  5247. for(var i=0,sz=getRomdomArr.length;i<sz;i++){
  5248. var index=getRomdomArr[i];
  5249. gameListArr.push(tempGameListArr[index]);
  5250. }
  5251. MoreGame._moreGameData.marvellousGame.gameList=[];
  5252. MoreGame._moreGameData.marvellousGame.gameList=gameListArr;
  5253. gamelist.array=MoreGame._moreGameData.marvellousGame.gameList;
  5254. }
  5255. catch(error){
  5256. gamelist.array=MoreGame._moreGameData.marvellousGame.gameList;
  5257. }
  5258. if(this.screenType){
  5259. gamelist.spaceY=10;
  5260. gamelist.width=690;
  5261. if(this.isQMP()){
  5262. gamelist.height=Laya.stage.height+130;
  5263. }else{
  5264. gamelist.height=1139;
  5265. }
  5266. gamelist.y=139;
  5267. gamelist.centerX=0;
  5268. }else{
  5269. }
  5270. this.onStageResize();
  5271. }else{
  5272. this._moreBox.visible=true;
  5273. }
  5274. }
  5275. /**
  5276. *取出随机数,maxNum为 取出随机数的个数
  5277. *@param minNum 最小值 2
  5278. *@param maxNum 最大数值 14
  5279. *@param maxcount 最大范围 12
  5280. *@return
  5281. */
  5282. __proto.RandomNumBoth=function(minNum,maxNum,maxcount){
  5283. var arr=[];
  5284. for(var i=minNum;i<maxcount;i++){
  5285. arr.push(i);
  5286. };
  5287. var numArr=[];
  5288. var arrLength=arr.length;
  5289. for(i=0;i<arrLength;i++){
  5290. var Rand=arr.length;
  5291. var number=Math.floor(Math.random()*arr.length);
  5292. numArr.push(arr[number]);
  5293. arr.splice(number,1);
  5294. if(arr.length <=arrLength-maxNum){
  5295. return numArr;
  5296. }
  5297. }
  5298. return null;
  5299. }
  5300. /**
  5301. *是否是全面屏 包括 安卓跟苹果
  5302. *@return
  5303. */
  5304. __proto.isQMP=function(){
  5305. var isBoo=false;
  5306. var tempBL=0;
  5307. if(Laya.stage.screenMode==/*laya.display.Stage.SCREEN_HORIZONTAL*/"horizontal"){
  5308. tempBL=Browser.height%9;
  5309. }else{
  5310. tempBL=Browser.width%9;
  5311. }
  5312. if(Browser.onAndroid && tempBL==0){
  5313. var tempBL2=0;
  5314. if(Laya.stage.screenMode==/*laya.display.Stage.SCREEN_HORIZONTAL*/"horizontal"){
  5315. tempBL2=Browser.width;
  5316. }else{
  5317. tempBL2=Browser.height;
  5318. }
  5319. if([2280,2160,2244,3120,2248,2340,2310].indexOf(tempBL2)!=-1){
  5320. isBoo=true;
  5321. }
  5322. };
  5323. var onIPhoneX=/iPhone/gi.test(Browser.window.navigator.userAgent)&& (Math.min(Browser.clientHeight,Browser.clientWidth)==375 && Math.max(Browser.clientHeight,Browser.clientWidth)==812);
  5324. var onIPhoneXR=(Math.min(Browser.clientHeight,Browser.clientWidth)==414 && Math.max(Browser.clientHeight,Browser.clientWidth)==896);
  5325. if((((Browser.onMiniGame || Browser.onBDMiniGame)&& !Browser.onAndroid))&&(onIPhoneX || onIPhoneXR)){
  5326. isBoo=true;
  5327. }
  5328. return isBoo;
  5329. }
  5330. /**
  5331. *创建一个圆角矩形
  5332. *@param width
  5333. *@param height
  5334. *@param circleNum
  5335. *@return
  5336. */
  5337. __proto.onDrawShapes=function(yuanWidth,yuanHeight,circleNum,isTeShu){
  5338. (circleNum===void 0)&& (circleNum=5);
  5339. (isTeShu===void 0)&& (isTeShu=false);
  5340. var isTeShuCircleNum=circleNum;
  5341. if(isTeShu)
  5342. isTeShuCircleNum=0;
  5343. var sprite=new Sprite();
  5344. sprite.graphics.drawPath(0,0,[
  5345. ["moveTo",circleNum,0],
  5346. ["lineTo",105,0],
  5347. ["arcTo",yuanWidth,0,yuanWidth,circleNum,circleNum],
  5348. ["lineTo",yuanWidth,yuanHeight],
  5349. ["arcTo",yuanWidth,yuanHeight+circleNum,105,yuanHeight+circleNum,isTeShuCircleNum],
  5350. ["lineTo",circleNum,yuanHeight+circleNum],
  5351. ["arcTo",0,yuanHeight+circleNum,0,yuanHeight,isTeShuCircleNum],
  5352. ["lineTo",0,circleNum],
  5353. ["arcTo",0,0,circleNum,0,circleNum],
  5354. ["closePath"]],{
  5355. fillStyle:"#ff0000"
  5356. });
  5357. return sprite;
  5358. }
  5359. /**
  5360. *创建遮罩的对象
  5361. *@param url
  5362. *@param parent
  5363. *@return
  5364. */
  5365. __proto.onCreateMaskImg=function(url,parent){
  5366. var kuangImg=this.onCreateImage(MoreGame.onGetAtlasDanImgUrl("dayuan"),parent);
  5367. var iconImg=this.onCreateImage(url,kuangImg);
  5368. iconImg.pos(11,10);
  5369. var sprite=new Sprite();
  5370. sprite.graphics.drawCircle(71,74,68,"#ff0000");
  5371. iconImg.mask=sprite;
  5372. kuangImg.scale(0.7,0.7);
  5373. return kuangImg;
  5374. }
  5375. /**
  5376. *渲染更多游戏列表
  5377. *@param item
  5378. *@param index
  5379. */
  5380. __proto.onGameListRender=function(item,index){
  5381. var gameList=MoreGame._moreGameData.marvellousGame.gameList;
  5382. if(index < 0 || index > gameList.length-1)
  5383. return;
  5384. var gameObj=gameList[index];
  5385. item.init(gameObj,this.screenType,new Handler(this,this.onItemClickCallBack));
  5386. }
  5387. /**
  5388. *单元点击回调
  5389. *@param itemData
  5390. */
  5391. __proto.onItemClickCallBack=function(itemData){
  5392. var _$this=this;
  5393. if(!/*__JS__ */swan.navigateToMiniProgram)
  5394. return;
  5395. var appKey=itemData.appKey;
  5396. var path=itemData.path;
  5397. var extendInfo=itemData.extendInfo;
  5398. /*__JS__ */swan.navigateToMiniProgram({
  5399. appKey:appKey,
  5400. path:path,
  5401. extraData:extendInfo,
  5402. success:function success (e){
  5403. },
  5404. fail:function fail (e){
  5405. },
  5406. complete:function complete (e){
  5407. _$this.reportError(itemData.statid);
  5408. }.bind(this)
  5409. });
  5410. }
  5411. /**更多游戏返回按钮点击**/
  5412. __proto.onJiantouImgClick=function(type){
  5413. this.isShow=false;
  5414. if(this._moreBox){
  5415. this._moreBox.visible=false;
  5416. }
  5417. this.closeCallBack !=null && this.closeCallBack.run();
  5418. }
  5419. /**
  5420. *创建文本
  5421. *@param str
  5422. *@param parent
  5423. *@param width
  5424. *@param height
  5425. *@param size
  5426. *@param color
  5427. *@param wordwarp
  5428. *@param align
  5429. *@param leading
  5430. *@return
  5431. */
  5432. __proto.onCreateLabel=function(str,parent,size,color,wordwarp,align,leading){
  5433. (size===void 0)&& (size=24);
  5434. (color===void 0)&& (color="#000000");
  5435. (wordwarp===void 0)&& (wordwarp=false);
  5436. (align===void 0)&& (align="center");
  5437. (leading===void 0)&& (leading=10);
  5438. var label=new Label();
  5439. label.text=str;
  5440. label.font="Microsoft YaHei";
  5441. label.fontSize=size;
  5442. label.color=color;
  5443. label.bold=true;
  5444. label.leading=leading;
  5445. label.valign="middle";
  5446. label.align=align;
  5447. label.wordWrap=wordwarp;
  5448. parent.addChild(label);
  5449. return label;
  5450. }
  5451. /**
  5452. *创建图片
  5453. *@param url
  5454. *@param parent 图片的父容器
  5455. *@return
  5456. */
  5457. __proto.onCreateImage=function(url,parent){
  5458. var image=new Image();
  5459. image.skin=url;
  5460. parent.addChild(image);
  5461. return image;
  5462. }
  5463. /**初始化判断当前是否显示插件**/
  5464. __proto.init=function(){
  5465. var userAgent=Browser.window.navigator.userAgent;
  5466. var onBDMiniGame=userAgent.indexOf('SwanGame')>-1;
  5467. this.visible=false;
  5468. if(onBDMiniGame){
  5469. this.dinfo=JSON.stringify(/*__JS__ */laya.bd.mini.BMiniAdapter.systemInfo);
  5470. this.onGetAdvsListData();
  5471. }
  5472. }
  5473. /**
  5474. *生成指定范围的随机数
  5475. *@param minNum 最小值
  5476. *@param maxNum 最大值
  5477. */
  5478. __proto.randRange=function(minNum,maxNum){
  5479. return (Math.floor(Math.random()*(maxNum-minNum+1))+minNum);
  5480. }
  5481. /**
  5482. *获取广告列表数据信息
  5483. */
  5484. __proto.onGetAdvsListData=function(){
  5485. var _this=this;
  5486. var random=this.randRange(10000,1000000);
  5487. var url=this._moreGameDataUrl+"?"+random;
  5488. MoreGame._http.open("get",url,true);
  5489. MoreGame._http.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
  5490. MoreGame._http.responseType="text";
  5491. MoreGame._http.onerror=function (e){
  5492. _this._onError(e);
  5493. }
  5494. MoreGame._http.onload=function (e){
  5495. _this._onLoad(e);
  5496. }
  5497. MoreGame._http.send(null);
  5498. }
  5499. /**
  5500. *@private
  5501. *请求出错侦的听处理函数。
  5502. *@param e 事件对象。
  5503. */
  5504. __proto._onError=function(e){
  5505. this.error("Request failed Status:"+MoreGame._http.status+" text:"+MoreGame._http.statusText);
  5506. }
  5507. /**
  5508. *@private
  5509. *请求消息返回的侦听处理函数。
  5510. *@param e 事件对象。
  5511. */
  5512. __proto._onLoad=function(e){
  5513. var http=MoreGame._http;
  5514. var status=http.status!==undefined ? http.status :200;
  5515. if (status===200 || status===204 || status===0){
  5516. this.complete();
  5517. }else {
  5518. this.error("["+http.status+"]"+http.statusText+":"+http.responseURL);
  5519. }
  5520. }
  5521. /**
  5522. *@private
  5523. *请求错误的处理函数。
  5524. *@param message 错误信息。
  5525. */
  5526. __proto.error=function(message){
  5527. this.event(/*laya.events.Event.ERROR*/"error",message);
  5528. }
  5529. /**
  5530. *@private
  5531. *请求成功完成的处理函数。
  5532. */
  5533. __proto.complete=function(){
  5534. var flag=true;
  5535. try {
  5536. var tempData=MoreGame._http.response || MoreGame._http.responseText;
  5537. MoreGame._moreGameData=JSON.parse(tempData);
  5538. this.initUI();
  5539. }catch (e){
  5540. flag=false;
  5541. this.error(e.message);
  5542. }
  5543. }
  5544. /**初始化UI显示**/
  5545. __proto.initUI=function(){
  5546. if(MoreGame._moreGameData.isOpen && this.screenType){
  5547. if(!this._iconImage){
  5548. this._iconImage=new Image();
  5549. this.addChild(this._iconImage);
  5550. }
  5551. this._iconImage.skin=MoreGame.onGetImgSkinUrl(MoreGame._moreGameData.icon);
  5552. if(this._iconImageObj){
  5553. this._iconImage.size(this._iconImageObj.width,this._iconImageObj.height);
  5554. this._iconImage.pivot(this._iconImageObj.width/2,this._iconImageObj.height/2);
  5555. this._iconImage.pos(this._iconImageObj.width/2,this._iconImageObj.height/2);
  5556. }
  5557. this.visible=true;
  5558. this.initEvent();
  5559. this.gameStopHD=false;
  5560. this.checkIconImgHD();
  5561. }else{
  5562. this.visible=false;
  5563. }
  5564. }
  5565. /**
  5566. *设置icon的宽高尺寸
  5567. *@param width
  5568. *@param height
  5569. */
  5570. __proto.setIconSize=function(w,h){
  5571. if(this._iconImage){
  5572. this._iconImage.size(w,h);
  5573. this._iconImage.pivot(w/2,h/2);
  5574. this._iconImage.pos(w/2,h/2);
  5575. }
  5576. this._iconImageObj={width:w,height:h};
  5577. }
  5578. MoreGame.toLocaleDateString=function(dateNum){
  5579. return MoreGame.getDateFormatStr(dateNum,"/");
  5580. }
  5581. MoreGame.getDateFormatStr=function(stamp,formatStr){
  5582. (formatStr===void 0)&& (formatStr="yynndd");
  5583. var date=new Date(stamp);
  5584. var yy=date.getFullYear();
  5585. var nn=date.getMonth()+1;
  5586. var dd=date.getDate();
  5587. var hh=date.getHours();
  5588. var mm=date.getMinutes();
  5589. var ss=date.getSeconds();
  5590. switch(formatStr){
  5591. case "yynndd":
  5592. return yy.toString()+"年"+nn.toString()+"月"+dd.toString()+"日";
  5593. break ;
  5594. case "/":
  5595. return yy.toString()+"/"+nn.toString()+"/"+dd.toString();
  5596. break ;
  5597. }
  5598. return yy.toString()+"年"+nn.toString()+"月"+dd.toString()+"日"+hh.toString()+"时"+mm.toString()+"分"+ss.toString()+"秒";
  5599. }
  5600. MoreGame.getDay=function(sdate){
  5601. var month=sdate.getMonth()+1;
  5602. var day=sdate.getDate();
  5603. var result=sdate.getFullYear()+""+(month < 10?"0"+month:month)+""+(day < 10?"0"+day:day);
  5604. return result;
  5605. }
  5606. MoreGame.onGetAtlasDanImgUrl=function(url){
  5607. return MoreGame._moreGameData.imgPath+MoreGame._moreGameData.atlas+url+".png";
  5608. }
  5609. MoreGame.onGetImgSkinUrl=function(resUrl){
  5610. return MoreGame._moreGameData.imgPath+resUrl;
  5611. }
  5612. MoreGame.onGetIconImgSkinUrl=function(resUrl){
  5613. return MoreGame._moreGameData.iconPath+resUrl;
  5614. }
  5615. MoreGame._moreGameData=null;
  5616. __static(MoreGame,
  5617. ['_http',function(){return this._http=new Browser.window.XMLHttpRequest();}
  5618. ]);
  5619. MoreGame.__init$=function(){
  5620. /**
  5621. *有渲染游戏单元
  5622. *@author xiaosong
  5623. *@date-2019-03-26
  5624. */
  5625. //class GameBox extends laya.ui.Box
  5626. GameBox=(function(_super){
  5627. function GameBox(){
  5628. /**游戏类型**/
  5629. this.titleLabel=null;
  5630. /**游戏列表容器**/
  5631. this.gameListBox=null;
  5632. GameBox.__super.call(this);
  5633. }
  5634. __class(GameBox,'',_super);
  5635. var __proto=GameBox.prototype;
  5636. /**
  5637. *初始化列表数据
  5638. *@param data
  5639. */
  5640. __proto.init=function(data,screenType,callBack){
  5641. if(!this.titleLabel){
  5642. this.titleLabel=this.onCreateLabel(data.title,this,32,"#3d3939");
  5643. this.titleLabel.pos(8,0);
  5644. this.titleLabel.size(162,50);
  5645. }else{
  5646. this.titleLabel.text=data.title;
  5647. }
  5648. if(!this.gameListBox){
  5649. this.gameListBox=new Box();
  5650. this.addChild(this.gameListBox);
  5651. var tempX=0;
  5652. var tempY=65;
  5653. var tempWidth=175;
  5654. for(var i=0,sz=data.gameList.length;i<sz;i++){
  5655. var gameitem=new GameItem();
  5656. gameitem.init(data.gameList[i],screenType,callBack);
  5657. gameitem.x=tempX+i *tempWidth;
  5658. gameitem.y=tempY;
  5659. this.gameListBox.addChild(gameitem);
  5660. }
  5661. }else{
  5662. for(i=0,sz=this.gameListBox._children.length;i<sz;i++){
  5663. gameitem=this.gameListBox._children[i];
  5664. gameitem.init(data.gameList[i],screenType,callBack);
  5665. }
  5666. }
  5667. this.size(695,340);
  5668. }
  5669. /**
  5670. *创建文本
  5671. *@param str
  5672. *@param parent
  5673. *@param width
  5674. *@param height
  5675. *@param size
  5676. *@param color
  5677. *@param wordwarp
  5678. *@return
  5679. */
  5680. __proto.onCreateLabel=function(str,parent,size,color,bold){
  5681. (size===void 0)&& (size=26);
  5682. (color===void 0)&& (color="#000000");
  5683. (bold===void 0)&& (bold=true);
  5684. var label=new Label();
  5685. label.text=str;
  5686. label.font="Microsoft YaHei";
  5687. label.fontSize=size;
  5688. label.color=color;
  5689. label.bold=bold;
  5690. label.leading=10;
  5691. label.valign="middle";
  5692. label.align="center";
  5693. label.overflow="hidden";
  5694. parent.addChild(label);
  5695. return label;
  5696. }
  5697. return GameBox;
  5698. })(Box)
  5699. /**
  5700. *更多游戏单元
  5701. *@author xiaosong
  5702. *@date 2018-12-26
  5703. */
  5704. //class GameItem extends laya.ui.Box
  5705. GameItem=(function(_super){
  5706. function GameItem(){
  5707. /**icon框**/
  5708. this.kuangImg=null;
  5709. /**icon名字**/
  5710. this.iconNameLabel=null;
  5711. /**icon图标**/
  5712. this.iconImg=null;
  5713. /**玩一玩按钮**/
  5714. this.playImg=null;
  5715. /**渲染单元数据**/
  5716. this.itemData=null;
  5717. /**回调方法**/
  5718. this.callBackHandler=null;
  5719. GameItem.__super.call(this);
  5720. }
  5721. __class(GameItem,'',_super);
  5722. var __proto=GameItem.prototype;
  5723. __proto.MoveGameItem=function(){}
  5724. /**注册事件监听**/
  5725. __proto.initEvent=function(){
  5726. this.on(/*laya.events.Event.CLICK*/"click",this,this.onItemClick);
  5727. }
  5728. __proto.onItemClick=function(){
  5729. this.callBackHandler !=null && this.callBackHandler.runWith([this.itemData]);
  5730. }
  5731. /**
  5732. *初始化单元数据
  5733. *@param data
  5734. */
  5735. __proto.init=function(data,screenType,callBack){
  5736. this.itemData=data;
  5737. this.callBackHandler=callBack;
  5738. if(!this.kuangImg)
  5739. this.kuangImg=this.onCreateImage(MoreGame.onGetAtlasDanImgUrl("dayuan"),this);
  5740. else{
  5741. this.kuangImg.skin=MoreGame.onGetAtlasDanImgUrl("dayuan");
  5742. }
  5743. if(!this.iconImg){
  5744. this.iconImg=this.onCreateImage(MoreGame.onGetIconImgSkinUrl(data.icon),this);
  5745. var sprite=new Sprite();
  5746. sprite.graphics.drawCircle(71,74,68,"#ff0000");
  5747. this.iconImg.mask=sprite;
  5748. this.iconImg.pos(13,10);
  5749. }else{
  5750. this.iconImg.skin=MoreGame.onGetIconImgSkinUrl(data.icon);
  5751. }
  5752. if(!this.iconNameLabel){
  5753. this.iconNameLabel=this.onCreateLabel(data.name,this,28,"#3d3939");
  5754. this.iconNameLabel.pos(7,165);
  5755. }else{
  5756. this.iconNameLabel.text=data.name;
  5757. }
  5758. if(!this.playImg){
  5759. this.playImg=this.onCreateImage(MoreGame.onGetAtlasDanImgUrl("img_play"),this);
  5760. this.playImg.pos(12,210);
  5761. }else{
  5762. this.playImg.skin=MoreGame.onGetAtlasDanImgUrl("img_play");
  5763. }
  5764. this.size(165,270);
  5765. this.initEvent();
  5766. }
  5767. /**
  5768. *创建文本
  5769. *@param str
  5770. *@param parent
  5771. *@param width
  5772. *@param height
  5773. *@param size
  5774. *@param color
  5775. *@param wordwarp
  5776. *@return
  5777. */
  5778. __proto.onCreateLabel=function(str,parent,size,color,bold){
  5779. (size===void 0)&& (size=24);
  5780. (color===void 0)&& (color="#000000");
  5781. (bold===void 0)&& (bold=false);
  5782. var label=new Label();
  5783. label.text=str;
  5784. label.font="Microsoft YaHei";
  5785. label.fontSize=size;
  5786. label.color=color;
  5787. label.bold=bold;
  5788. label.leading=10;
  5789. label.valign="middle";
  5790. label.align="center";
  5791. label.size(152,44);
  5792. label.overflow="hidden";
  5793. parent.addChild(label);
  5794. return label;
  5795. }
  5796. /**
  5797. *创建图片
  5798. *@param url
  5799. *@param parent 图片的父容器
  5800. *@return
  5801. */
  5802. __proto.onCreateImage=function(url,parent){
  5803. var image=new Image();
  5804. image.skin=url;
  5805. parent.addChild(image);
  5806. return image;
  5807. }
  5808. return GameItem;
  5809. })(Box)
  5810. }
  5811. return MoreGame;
  5812. })(View)
  5813. /**
  5814. *<code>Dialog</code> 组件是一个弹出对话框,实现对话框弹出,拖动,模式窗口功能。
  5815. *可以通过UIConfig设置弹出框背景透明度,模式窗口点击边缘是否关闭等
  5816. *通过设置zOrder属性,可以更改弹出的层次
  5817. *通过设置popupEffect和closeEffect可以设置弹出效果和关闭效果,如果不想有任何弹出关闭效果,可以设置前述属性为空
  5818. *
  5819. *@example <caption>以下示例代码,创建了一个 <code>Dialog</code> 实例。</caption>
  5820. *package
  5821. *{
  5822. *import laya.ui.Dialog;
  5823. *import laya.utils.Handler;
  5824. *public class Dialog_Example
  5825. *{
  5826. *private var dialog:Dialog_Instance;
  5827. *public function Dialog_Example()
  5828. *{
  5829. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  5830. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  5831. *Laya.loader.load("resource/ui/btn_close.png",Handler.create(this,onLoadComplete));//加载资源。
  5832. *}
  5833. *private function onLoadComplete():void
  5834. *{
  5835. *dialog=new Dialog_Instance();//创建一个 Dialog_Instance 类的实例对象 dialog。
  5836. *dialog.dragArea="0,0,150,50";//设置 dialog 的拖拽区域。
  5837. *dialog.show();//显示 dialog。
  5838. *dialog.closeHandler=new Handler(this,onClose);//设置 dialog 的关闭函数处理器。
  5839. *}
  5840. *private function onClose(name:String):void
  5841. *{
  5842. *if (name==Dialog.CLOSE)
  5843. *{
  5844. *trace("通过点击 name 为"+name+"的组件,关闭了dialog。");
  5845. *}
  5846. *}
  5847. *}
  5848. *}
  5849. *import laya.ui.Button;
  5850. *import laya.ui.Dialog;
  5851. *import laya.ui.Image;
  5852. *class Dialog_Instance extends Dialog
  5853. *{
  5854. *function Dialog_Instance():void
  5855. *{
  5856. *var bg:Image=new Image("resource/ui/bg.png");
  5857. *bg.sizeGrid="40,10,5,10";
  5858. *bg.width=150;
  5859. *bg.height=250;
  5860. *addChild(bg);
  5861. *var image:Image=new Image("resource/ui/image.png");
  5862. *addChild(image);
  5863. *var button:Button=new Button("resource/ui/btn_close.png");
  5864. *button.name=Dialog.CLOSE;//设置button的name属性值。
  5865. *button.x=0;
  5866. *button.y=0;
  5867. *addChild(button);
  5868. *}
  5869. *}
  5870. *@example
  5871. *Laya.init(640,800);//设置游戏画布宽高、渲染模式
  5872. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  5873. *var dialog;
  5874. *Laya.loader.load("resource/ui/btn_close.png",laya.utils.Handler.create(this,loadComplete));//加载资源
  5875. *(function (_super){//新建一个类Dialog_Instance继承自laya.ui.Dialog。
  5876. *function Dialog_Instance(){
  5877. *Dialog_Instance.__super.call(this);//初始化父类
  5878. *var bg=new laya.ui.Image("resource/ui/bg.png");//新建一个 Image 类的实例 bg 。
  5879. *bg.sizeGrid="10,40,10,5";//设置 bg 的网格信息。
  5880. *bg.width=150;//设置 bg 的宽度。
  5881. *bg.height=250;//设置 bg 的高度。
  5882. *this.addChild(bg);//将 bg 添加到显示列表。
  5883. *var image=new laya.ui.Image("resource/ui/image.png");//新建一个 Image 类的实例 image 。
  5884. *this.addChild(image);//将 image 添加到显示列表。
  5885. *var button=new laya.ui.Button("resource/ui/btn_close.png");//新建一个 Button 类的实例 bg 。
  5886. *button.name=laya.ui.Dialog.CLOSE;//设置 button 的 name 属性值。
  5887. *button.x=0;//设置 button 对象的属性 x 的值,用于控制 button 对象的显示位置。
  5888. *button.y=0;//设置 button 对象的属性 y 的值,用于控制 button 对象的显示位置。
  5889. *this.addChild(button);//将 button 添加到显示列表。
  5890. *};
  5891. *Laya.class(Dialog_Instance,"mypackage.dialogExample.Dialog_Instance",_super);//注册类Dialog_Instance。
  5892. *})(laya.ui.Dialog);
  5893. *function loadComplete(){
  5894. *console.log("资源加载完成!");
  5895. *dialog=new mypackage.dialogExample.Dialog_Instance();//创建一个 Dialog_Instance 类的实例对象 dialog。
  5896. *dialog.dragArea="0,0,150,50";//设置 dialog 的拖拽区域。
  5897. *dialog.show();//显示 dialog。
  5898. *dialog.closeHandler=new laya.utils.Handler(this,onClose);//设置 dialog 的关闭函数处理器。
  5899. *}
  5900. *function onClose(name){
  5901. *if (name==laya.ui.Dialog.CLOSE){
  5902. *console.log("通过点击 name 为"+name+"的组件,关闭了dialog。");
  5903. *}
  5904. *}
  5905. *@example
  5906. *import Dialog=laya.ui.Dialog;
  5907. *import Handler=laya.utils.Handler;
  5908. *class Dialog_Example {
  5909. *private dialog:Dialog_Instance;
  5910. *constructor(){
  5911. *Laya.init(640,800);//设置游戏画布宽高。
  5912. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  5913. *Laya.loader.load("resource/ui/btn_close.png",Handler.create(this,this.onLoadComplete));//加载资源。
  5914. *}
  5915. *private onLoadComplete():void {
  5916. *this.dialog=new Dialog_Instance();//创建一个 Dialog_Instance 类的实例对象 dialog。
  5917. *this.dialog.dragArea="0,0,150,50";//设置 dialog 的拖拽区域。
  5918. *this.dialog.show();//显示 dialog。
  5919. *this.dialog.closeHandler=new Handler(this,this.onClose);//设置 dialog 的关闭函数处理器。
  5920. *}
  5921. *private onClose(name:string):void {
  5922. *if (name==Dialog.CLOSE){
  5923. *console.log("通过点击 name 为"+name+"的组件,关闭了dialog。");
  5924. *}
  5925. *}
  5926. *}
  5927. *import Button=laya.ui.Button;
  5928. *class Dialog_Instance extends Dialog {
  5929. *Dialog_Instance():void {
  5930. *var bg:laya.ui.Image=new laya.ui.Image("resource/ui/bg.png");
  5931. *bg.sizeGrid="40,10,5,10";
  5932. *bg.width=150;
  5933. *bg.height=250;
  5934. *this.addChild(bg);
  5935. *var image:laya.ui.Image=new laya.ui.Image("resource/ui/image.png");
  5936. *this.addChild(image);
  5937. *var button:Button=new Button("resource/ui/btn_close.png");
  5938. *button.name=Dialog.CLOSE;//设置button的name属性值。
  5939. *button.x=0;
  5940. *button.y=0;
  5941. *this.addChild(button);
  5942. *}
  5943. *}
  5944. */
  5945. //class laya.ui.Dialog extends laya.ui.View
  5946. var Dialog=(function(_super){
  5947. function Dialog(){
  5948. /**
  5949. *对话框被关闭时会触发的回调函数处理器。
  5950. *<p>回调函数参数为用户点击的按钮名字name:String。</p>
  5951. */
  5952. this.closeHandler=null;
  5953. /**
  5954. *弹出对话框效果,可以设置一个效果代替默认的弹出效果,如果不想有任何效果,可以赋值为null
  5955. *全局默认弹出效果可以通过manager.popupEffect修改
  5956. */
  5957. this.popupEffect=null;
  5958. /**
  5959. *关闭对话框效果,可以设置一个效果代替默认的关闭效果,如果不想有任何效果,可以赋值为null
  5960. *全局默认关闭效果可以通过manager.closeEffect修改
  5961. */
  5962. this.closeEffect=null;
  5963. /**组名称*/
  5964. this.group=null;
  5965. /**是否是模式窗口*/
  5966. this.isModal=false;
  5967. /**是否显示弹出效果*/
  5968. this.isShowEffect=true;
  5969. /**指定对话框是否居中弹。<p>如果值为true,则居中弹出,否则,则根据对象坐标显示,默认为true。</p>*/
  5970. this.isPopupCenter=true;
  5971. /**关闭类型,点击name为"close","cancel","sure","no","yes","no"的按钮时,会自动记录点击按钮的名称*/
  5972. this.closeType=null;
  5973. /**@private */
  5974. this._dragArea=null;
  5975. /**@private */
  5976. this._param=null;
  5977. /**@private */
  5978. this._effectTween=null;
  5979. Dialog.__super.call(this);
  5980. this.popupEffect=Dialog.manager.popupEffectHandler;
  5981. this.closeEffect=Dialog.manager.closeEffectHandler;
  5982. this._dealDragArea();
  5983. this.on(/*laya.events.Event.CLICK*/"click",this,this._onClick);
  5984. }
  5985. __class(Dialog,'laya.ui.Dialog',_super);
  5986. var __proto=Dialog.prototype;
  5987. /**@private 提取拖拽区域*/
  5988. __proto._dealDragArea=function(){
  5989. var dragTarget=this.getChildByName("drag");
  5990. if (dragTarget){
  5991. this.dragArea=dragTarget._x+","+dragTarget._y+","+dragTarget.width+","+dragTarget.height;
  5992. dragTarget.removeSelf();
  5993. }
  5994. }
  5995. /**@private */
  5996. __proto._onMouseDown=function(e){
  5997. var point=this.getMousePoint();
  5998. if (this._dragArea.contains(point.x,point.y))this.startDrag();
  5999. else this.stopDrag();
  6000. }
  6001. /**@private 处理默认点击事件*/
  6002. __proto._onClick=function(e){
  6003. var btn=e.target;
  6004. if (btn){
  6005. switch (btn.name){
  6006. case "close":
  6007. case "cancel":
  6008. case "sure":
  6009. case "no":
  6010. case "ok":
  6011. case "yes":
  6012. this.close(btn.name);
  6013. return;
  6014. }
  6015. }
  6016. }
  6017. /**@inheritDoc */
  6018. __proto.open=function(closeOther,param){
  6019. (closeOther===void 0)&& (closeOther=true);
  6020. this._dealDragArea();
  6021. this._param=param;
  6022. Dialog.manager.open(this,closeOther,this.isShowEffect);
  6023. Dialog.manager.lock(false);
  6024. }
  6025. /**
  6026. *关闭对话框。
  6027. *@param type 关闭的原因,会传递给onClosed函数
  6028. */
  6029. __proto.close=function(type){
  6030. this.closeType=type;
  6031. Dialog.manager.close(this);
  6032. }
  6033. /**@inheritDoc */
  6034. __proto.destroy=function(destroyChild){
  6035. (destroyChild===void 0)&& (destroyChild=true);
  6036. this.closeHandler=null;
  6037. this.popupEffect=null;
  6038. this.closeEffect=null;
  6039. this._dragArea=null;
  6040. _super.prototype.destroy.call(this,destroyChild);
  6041. }
  6042. /**
  6043. *显示对话框(以非模式窗口方式显示)。
  6044. *@param closeOther 是否关闭其它的对话框。若值为true则关闭其它对话框。
  6045. *@param showEffect 是否显示弹出效果
  6046. */
  6047. __proto.show=function(closeOther,showEffect){
  6048. (closeOther===void 0)&& (closeOther=false);
  6049. (showEffect===void 0)&& (showEffect=true);
  6050. this._open(false,closeOther,showEffect);
  6051. }
  6052. /**
  6053. *显示对话框(以模式窗口方式显示)。
  6054. *@param closeOther 是否关闭其它的对话框。若值为true则关闭其它对话框。
  6055. *@param showEffect 是否显示弹出效果
  6056. */
  6057. __proto.popup=function(closeOther,showEffect){
  6058. (closeOther===void 0)&& (closeOther=false);
  6059. (showEffect===void 0)&& (showEffect=true);
  6060. this._open(true,closeOther,showEffect);
  6061. }
  6062. /**@private */
  6063. __proto._open=function(modal,closeOther,showEffect){
  6064. this.isModal=modal;
  6065. this.isShowEffect=showEffect;
  6066. Dialog.manager.lock(true);
  6067. this.open(closeOther);
  6068. }
  6069. /**
  6070. *用来指定对话框的拖拽区域。默认值为"0,0,0,0"。
  6071. *<p><b>格式:</b>构成一个矩形所需的 x,y,width,heith 值,用逗号连接为字符串。
  6072. *例如:"0,0,100,200"。</p>
  6073. *@see #includeExamplesSummary 请参考示例
  6074. */
  6075. __getset(0,__proto,'dragArea',function(){
  6076. if (this._dragArea)return this._dragArea.toString();
  6077. return null;
  6078. },function(value){
  6079. if (value){
  6080. var a=UIUtils.fillArray([0,0,0,0],value,Number);
  6081. this._dragArea=new Rectangle(a[0],a[1],a[2],a[3]);
  6082. this.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onMouseDown);
  6083. }else {
  6084. this._dragArea=null;
  6085. this.off(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this._onMouseDown);
  6086. }
  6087. });
  6088. /**弹出框的显示状态;如果弹框处于显示中,则为true,否则为false;*/
  6089. __getset(0,__proto,'isPopup',function(){
  6090. return this.parent !=null;
  6091. });
  6092. /**@inheritDoc */
  6093. __getset(0,__proto,'zOrder',_super.prototype._$get_zOrder,function(value){
  6094. Laya.superSet(View,this,'zOrder',value);
  6095. Dialog.manager._checkMask();
  6096. });
  6097. /**对话框管理容器,所有的对话框都在该容器内,并且受管理器管理,可以自定义自己的管理器,来更改窗口管理的流程。
  6098. *任意对话框打开和关闭,都会触发管理类的open和close事件*/
  6099. __getset(1,Dialog,'manager',function(){
  6100. return Dialog._manager=Dialog._manager|| new DialogManager();
  6101. },function(value){
  6102. Dialog._manager=value;
  6103. });
  6104. Dialog.setLockView=function(view){
  6105. Dialog.manager.setLockView(view);
  6106. }
  6107. Dialog.lock=function(value){
  6108. Dialog.manager.lock(value);
  6109. }
  6110. Dialog.closeAll=function(){
  6111. Dialog.manager.closeAll();
  6112. }
  6113. Dialog.getDialogsByGroup=function(group){
  6114. return Dialog.manager.getDialogsByGroup(group);
  6115. }
  6116. Dialog.closeByGroup=function(group){
  6117. return Dialog.manager.closeByGroup(group);
  6118. }
  6119. Dialog.CLOSE="close";
  6120. Dialog.CANCEL="cancel";
  6121. Dialog.SURE="sure";
  6122. Dialog.NO="no";
  6123. Dialog.YES="yes";
  6124. Dialog.OK="ok";
  6125. Dialog._manager=null;
  6126. return Dialog;
  6127. })(View)
  6128. /**
  6129. *<code>ViewStack</code> 类用于视图堆栈类,用于视图的显示等设置处理。
  6130. */
  6131. //class laya.ui.ViewStack extends laya.ui.Box
  6132. var ViewStack=(function(_super){
  6133. function ViewStack(){
  6134. /**@private */
  6135. this._items=null;
  6136. /**@private */
  6137. this._selectedIndex=0;
  6138. ViewStack.__super.call(this);
  6139. this._setIndexHandler=Handler.create(this,this.setIndex,null,false);
  6140. }
  6141. __class(ViewStack,'laya.ui.ViewStack',_super);
  6142. var __proto=ViewStack.prototype;
  6143. Laya.imps(__proto,{"laya.ui.IItem":true})
  6144. /**
  6145. *批量设置视图对象。
  6146. *@param views 视图对象数组。
  6147. */
  6148. __proto.setItems=function(views){
  6149. this.removeChildren();
  6150. var index=0;
  6151. for (var i=0,n=views.length;i < n;i++){
  6152. var item=views[i];
  6153. if (item){
  6154. item.name="item"+index;
  6155. this.addChild(item);
  6156. index++;
  6157. }
  6158. }
  6159. this.initItems();
  6160. }
  6161. /**
  6162. *添加视图。
  6163. *@internal 添加视图对象,并设置此视图对象的<code>name</code> 属性。
  6164. *@param view 需要添加的视图对象。
  6165. */
  6166. __proto.addItem=function(view){
  6167. view.name="item"+this._items.length;
  6168. this.addChild(view);
  6169. this.initItems();
  6170. }
  6171. __proto._afterInited=function(){
  6172. this.initItems();
  6173. }
  6174. /**
  6175. *初始化视图对象集合。
  6176. */
  6177. __proto.initItems=function(){
  6178. this._items=[];
  6179. for (var i=0;i < 10000;i++){
  6180. var item=this.getChildByName("item"+i);
  6181. if (item==null){
  6182. break ;
  6183. }
  6184. this._items.push(item);
  6185. item.visible=(i==this._selectedIndex);
  6186. }
  6187. }
  6188. /**
  6189. *@private
  6190. *通过对象的索引设置项对象的 <code>selected</code> 属性值。
  6191. *@param index 需要设置的对象的索引。
  6192. *@param selected 表示对象的选中状态。
  6193. */
  6194. __proto.setSelect=function(index,selected){
  6195. if (this._items && index >-1 && index < this._items.length){
  6196. this._items[index].visible=selected;
  6197. }
  6198. }
  6199. /**
  6200. *@private
  6201. *设置属性<code>selectedIndex</code>的值。
  6202. *@param index 选中项索引值。
  6203. */
  6204. __proto.setIndex=function(index){
  6205. this.selectedIndex=index;
  6206. }
  6207. /**@inheritDoc */
  6208. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  6209. this._dataSource=value;
  6210. if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string')){
  6211. this.selectedIndex=parseInt(value);
  6212. }else {
  6213. for (var prop in this._dataSource){
  6214. if (this.hasOwnProperty(prop)){
  6215. this[prop]=this._dataSource[prop];
  6216. }
  6217. }
  6218. }
  6219. });
  6220. /**
  6221. *表示当前视图索引。
  6222. */
  6223. __getset(0,__proto,'selectedIndex',function(){
  6224. return this._selectedIndex;
  6225. },function(value){
  6226. if (this._selectedIndex !=value){
  6227. this.setSelect(this._selectedIndex,false);
  6228. this._selectedIndex=value;
  6229. this.setSelect(this._selectedIndex,true);
  6230. }
  6231. });
  6232. /**
  6233. *获取或设置当前选择的项对象。
  6234. */
  6235. __getset(0,__proto,'selection',function(){
  6236. return this._selectedIndex >-1 && this._selectedIndex < this._items.length ? this._items[this._selectedIndex] :null;
  6237. },function(value){
  6238. this.selectedIndex=this._items.indexOf(value);
  6239. });
  6240. /**
  6241. *视图集合数组。
  6242. */
  6243. __getset(0,__proto,'items',function(){
  6244. return this._items;
  6245. });
  6246. /**
  6247. *索引设置处理器。
  6248. *<p>默认回调参数:index:int</p>
  6249. */
  6250. __getset(0,__proto,'setIndexHandler',function(){
  6251. return this._setIndexHandler;
  6252. },function(value){
  6253. this._setIndexHandler=value;
  6254. });
  6255. return ViewStack;
  6256. })(Box)
  6257. /**
  6258. *<code>LayoutBox</code> 是一个布局容器类。
  6259. */
  6260. //class laya.ui.LayoutBox extends laya.ui.Box
  6261. var LayoutBox=(function(_super){
  6262. function LayoutBox(){
  6263. /**@private */
  6264. this._space=0;
  6265. /**@private */
  6266. this._align="none";
  6267. /**@private */
  6268. this._itemChanged=false;
  6269. LayoutBox.__super.call(this);
  6270. }
  6271. __class(LayoutBox,'laya.ui.LayoutBox',_super);
  6272. var __proto=LayoutBox.prototype;
  6273. /**@inheritDoc */
  6274. __proto.addChild=function(child){
  6275. child.on(/*laya.events.Event.RESIZE*/"resize",this,this.onResize);
  6276. this._setItemChanged();
  6277. return laya.display.Node.prototype.addChild.call(this,child);
  6278. }
  6279. __proto.onResize=function(e){
  6280. this._setItemChanged();
  6281. }
  6282. /**@inheritDoc */
  6283. __proto.addChildAt=function(child,index){
  6284. child.on(/*laya.events.Event.RESIZE*/"resize",this,this.onResize);
  6285. this._setItemChanged();
  6286. return laya.display.Node.prototype.addChildAt.call(this,child,index);
  6287. }
  6288. /**@inheritDoc */
  6289. __proto.removeChildAt=function(index){
  6290. this.getChildAt(index).off(/*laya.events.Event.RESIZE*/"resize",this,this.onResize);
  6291. this._setItemChanged();
  6292. return laya.display.Node.prototype.removeChildAt.call(this,index);
  6293. }
  6294. /**刷新。*/
  6295. __proto.refresh=function(){
  6296. this._setItemChanged();
  6297. }
  6298. /**
  6299. *改变子对象的布局。
  6300. */
  6301. __proto.changeItems=function(){
  6302. this._itemChanged=false;
  6303. }
  6304. /**
  6305. *排序项目列表。可通过重写改变默认排序规则。
  6306. *@param items 项目列表。
  6307. */
  6308. __proto.sortItem=function(items){
  6309. if (items)items.sort(function(a,b){return a.y-b.y;});
  6310. }
  6311. __proto._setItemChanged=function(){
  6312. if (!this._itemChanged){
  6313. this._itemChanged=true;
  6314. this.callLater(this.changeItems);
  6315. }
  6316. }
  6317. /**子对象的间隔。*/
  6318. __getset(0,__proto,'space',function(){
  6319. return this._space;
  6320. },function(value){
  6321. this._space=value;
  6322. this._setItemChanged();
  6323. });
  6324. /**子对象对齐方式。*/
  6325. __getset(0,__proto,'align',function(){
  6326. return this._align;
  6327. },function(value){
  6328. this._align=value;
  6329. this._setItemChanged();
  6330. });
  6331. return LayoutBox;
  6332. })(Box)
  6333. /**
  6334. *<code>Group</code> 是一个可以自动布局的项集合控件。
  6335. *<p> <code>Group</code> 的默认项对象为 <code>Button</code> 类实例。
  6336. *<code>Group</code> 是 <code>Tab</code> 和 <code>RadioGroup</code> 的基类。</p>
  6337. */
  6338. //class laya.ui.UIGroup extends laya.ui.Box
  6339. var UIGroup=(function(_super){
  6340. function UIGroup(labels,skin){
  6341. /**
  6342. *改变 <code>Group</code> 的选择项时执行的处理器,(默认返回参数: 项索引(index:int))。
  6343. */
  6344. this.selectHandler=null;
  6345. /**@private */
  6346. this._items=null;
  6347. /**@private */
  6348. this._selectedIndex=-1;
  6349. /**@private */
  6350. this._skin=null;
  6351. /**@private */
  6352. this._direction="horizontal";
  6353. /**@private */
  6354. this._space=0;
  6355. /**@private */
  6356. this._labels=null;
  6357. /**@private */
  6358. this._labelColors=null;
  6359. /**@private */
  6360. this._labelFont=null;
  6361. /**@private */
  6362. this._labelStrokeColor=null;
  6363. /**@private */
  6364. this._strokeColors=null;
  6365. /**@private */
  6366. this._labelStroke=NaN;
  6367. /**@private */
  6368. this._labelSize=0;
  6369. /**@private */
  6370. this._labelBold=false;
  6371. /**@private */
  6372. this._labelPadding=null;
  6373. /**@private */
  6374. this._labelAlign=null;
  6375. /**@private */
  6376. this._stateNum=0;
  6377. /**@private */
  6378. this._labelChanged=false;
  6379. UIGroup.__super.call(this);
  6380. this.skin=skin;
  6381. this.labels=labels;
  6382. }
  6383. __class(UIGroup,'laya.ui.UIGroup',_super);
  6384. var __proto=UIGroup.prototype;
  6385. Laya.imps(__proto,{"laya.ui.IItem":true})
  6386. /**@inheritDoc */
  6387. __proto.preinitialize=function(){
  6388. this.mouseEnabled=true;
  6389. }
  6390. /**@inheritDoc */
  6391. __proto.destroy=function(destroyChild){
  6392. (destroyChild===void 0)&& (destroyChild=true);
  6393. laya.ui.UIComponent.prototype.destroy.call(this,destroyChild);
  6394. this._items && (this._items.length=0);
  6395. this._items=null;
  6396. this.selectHandler=null;
  6397. }
  6398. /**
  6399. *添加一个项对象,返回此项对象的索引id。
  6400. *
  6401. *@param item 需要添加的项对象。
  6402. *@param autoLayOut 是否自动布局,如果为true,会根据 <code>direction</code> 和 <code>space</code> 属性计算item的位置。
  6403. *@return
  6404. */
  6405. __proto.addItem=function(item,autoLayOut){
  6406. (autoLayOut===void 0)&& (autoLayOut=true);
  6407. var display=item;
  6408. var index=this._items.length;
  6409. display.name="item"+index;
  6410. this.addChild(display);
  6411. this.initItems();
  6412. if (autoLayOut && index > 0){
  6413. var preItem=this._items [index-1];
  6414. if (this._direction=="horizontal"){
  6415. display.x=preItem._x+preItem.width+this._space;
  6416. }else {
  6417. display.y=preItem._y+preItem.height+this._space;
  6418. }
  6419. }else {
  6420. if (autoLayOut){
  6421. display.x=0;
  6422. display.y=0;
  6423. }
  6424. }
  6425. return index;
  6426. }
  6427. /**
  6428. *删除一个项对象。
  6429. *@param item 需要删除的项对象。
  6430. *@param autoLayOut 是否自动布局,如果为true,会根据 <code>direction</code> 和 <code>space</code> 属性计算item的位置。
  6431. */
  6432. __proto.delItem=function(item,autoLayOut){
  6433. (autoLayOut===void 0)&& (autoLayOut=true);
  6434. var index=this._items.indexOf(item);
  6435. if (index !=-1){
  6436. var display=item;
  6437. this.removeChild(display);
  6438. for (var i=index+1,n=this._items.length;i < n;i++){
  6439. var child=this._items [i];
  6440. child.name="item"+(i-1);
  6441. if (autoLayOut){
  6442. if (this._direction=="horizontal"){
  6443. child.x-=display.width+this._space;
  6444. }else {
  6445. child.y-=display.height+this._space;
  6446. }
  6447. }
  6448. }
  6449. this.initItems();
  6450. if (this._selectedIndex >-1){
  6451. var newIndex=0;
  6452. newIndex=this._selectedIndex < this._items.length ? this._selectedIndex :(this._selectedIndex-1);
  6453. this._selectedIndex=-1;
  6454. this.selectedIndex=newIndex;
  6455. }
  6456. }
  6457. }
  6458. __proto._afterInited=function(){
  6459. this.initItems();
  6460. }
  6461. /**
  6462. *初始化项对象们。
  6463. */
  6464. __proto.initItems=function(){
  6465. this._items || (this._items=[]);
  6466. this._items.length=0;
  6467. for (var i=0;i < 10000;i++){
  6468. var item=this.getChildByName("item"+i);
  6469. if (item==null)break ;
  6470. this._items.push(item);
  6471. item.selected=(i===this._selectedIndex);
  6472. item.clickHandler=Handler.create(this,this.itemClick,[i],false);
  6473. }
  6474. }
  6475. /**
  6476. *@private
  6477. *项对象的点击事件侦听处理函数。
  6478. *@param index 项索引。
  6479. */
  6480. __proto.itemClick=function(index){
  6481. this.selectedIndex=index;
  6482. }
  6483. /**
  6484. *@private
  6485. *通过对象的索引设置项对象的 <code>selected</code> 属性值。
  6486. *@param index 需要设置的项对象的索引。
  6487. *@param selected 表示项对象的选中状态。
  6488. */
  6489. __proto.setSelect=function(index,selected){
  6490. if (this._items && index >-1 && index < this._items.length)this._items[index].selected=selected;
  6491. }
  6492. __proto._skinLoaded=function(){
  6493. this._setLabelChanged();
  6494. this.event(/*laya.events.Event.LOADED*/"loaded");
  6495. }
  6496. /**
  6497. *@private
  6498. *创建一个项显示对象。
  6499. *@param skin 项对象的皮肤。
  6500. *@param label 项对象标签。
  6501. */
  6502. __proto.createItem=function(skin,label){
  6503. return null;
  6504. }
  6505. /**
  6506. *@private
  6507. *更改项对象的属性值。
  6508. */
  6509. __proto.changeLabels=function(){
  6510. this._labelChanged=false;
  6511. if (this._items){
  6512. var left=0
  6513. for (var i=0,n=this._items.length;i < n;i++){
  6514. var btn=this._items [i];
  6515. this._skin && (btn.skin=this._skin);
  6516. this._labelColors && (btn.labelColors=this._labelColors);
  6517. this._labelSize && (btn.labelSize=this._labelSize);
  6518. this._labelStroke && (btn.labelStroke=this._labelStroke);
  6519. this._labelStrokeColor && (btn.labelStrokeColor=this._labelStrokeColor);
  6520. this._strokeColors && (btn.strokeColors=this._strokeColors);
  6521. this._labelBold && (btn.labelBold=this._labelBold);
  6522. this._labelPadding && (btn.labelPadding=this._labelPadding);
  6523. this._labelAlign && (btn.labelAlign=this._labelAlign);
  6524. this._stateNum && (btn.stateNum=this._stateNum);
  6525. this._labelFont && (btn.labelFont=this._labelFont);
  6526. if (this._direction==="horizontal"){
  6527. btn.y=0;
  6528. btn.x=left;
  6529. left+=btn.width+this._space;
  6530. }else {
  6531. btn.x=0;
  6532. btn.y=left;
  6533. left+=btn.height+this._space;
  6534. }
  6535. }
  6536. }
  6537. this._sizeChanged();
  6538. }
  6539. /**@inheritDoc */
  6540. __proto.commitMeasure=function(){
  6541. this.runCallLater(this.changeLabels);
  6542. }
  6543. /**@private */
  6544. __proto._setLabelChanged=function(){
  6545. if (!this._labelChanged){
  6546. this._labelChanged=true;
  6547. this.callLater(this.changeLabels);
  6548. }
  6549. }
  6550. /**
  6551. *<p>描边颜色,以字符串表示。</p>
  6552. *默认值为 "#000000"(黑色);
  6553. *@see laya.display.Text.strokeColor()
  6554. */
  6555. __getset(0,__proto,'labelStrokeColor',function(){
  6556. return this._labelStrokeColor;
  6557. },function(value){
  6558. if (this._labelStrokeColor !=value){
  6559. this._labelStrokeColor=value;
  6560. this._setLabelChanged();
  6561. }
  6562. });
  6563. /**
  6564. *@copy laya.ui.Image#skin
  6565. */
  6566. __getset(0,__proto,'skin',function(){
  6567. return this._skin;
  6568. },function(value){
  6569. if (this._skin !=value){
  6570. this._skin=value;
  6571. if (this._skin&&!Loader.getRes(this._skin)){
  6572. Laya.loader.load(this._skin,Handler.create(this,this._skinLoaded),null,/*laya.net.Loader.IMAGE*/"image",1);
  6573. }else{
  6574. this._skinLoaded();
  6575. }
  6576. }
  6577. });
  6578. /**
  6579. *表示当前选择的项索引。默认值为-1。
  6580. */
  6581. __getset(0,__proto,'selectedIndex',function(){
  6582. return this._selectedIndex;
  6583. },function(value){
  6584. if (this._selectedIndex !=value){
  6585. this.setSelect(this._selectedIndex,false);
  6586. this._selectedIndex=value;
  6587. this.setSelect(value,true);
  6588. this.event(/*laya.events.Event.CHANGE*/"change");
  6589. this.selectHandler && this.selectHandler.runWith(this._selectedIndex);
  6590. }
  6591. });
  6592. /**
  6593. *标签集合字符串。以逗号做分割,如"item0,item1,item2,item3,item4,item5"。
  6594. */
  6595. __getset(0,__proto,'labels',function(){
  6596. return this._labels;
  6597. },function(value){
  6598. if (this._labels !=value){
  6599. this._labels=value;
  6600. this.removeChildren();
  6601. this._setLabelChanged();
  6602. if (this._labels){
  6603. var a=this._labels.split(",");
  6604. for (var i=0,n=a.length;i < n;i++){
  6605. var item=this.createItem(this._skin,a[i]);
  6606. item.name="item"+i;
  6607. this.addChild(item);
  6608. }
  6609. }
  6610. this.initItems();
  6611. }
  6612. });
  6613. /**
  6614. *<p>表示各个状态下的描边颜色。</p>
  6615. *@see laya.display.Text.strokeColor()
  6616. */
  6617. __getset(0,__proto,'strokeColors',function(){
  6618. return this._strokeColors;
  6619. },function(value){
  6620. if (this._strokeColors !=value){
  6621. this._strokeColors=value;
  6622. this._setLabelChanged();
  6623. }
  6624. });
  6625. /**
  6626. *@copy laya.ui.Button#labelColors()
  6627. */
  6628. __getset(0,__proto,'labelColors',function(){
  6629. return this._labelColors;
  6630. },function(value){
  6631. if (this._labelColors !=value){
  6632. this._labelColors=value;
  6633. this._setLabelChanged();
  6634. }
  6635. });
  6636. /**
  6637. *<p>描边宽度(以像素为单位)。</p>
  6638. *默认值0,表示不描边。
  6639. *@see laya.display.Text.stroke()
  6640. */
  6641. __getset(0,__proto,'labelStroke',function(){
  6642. return this._labelStroke;
  6643. },function(value){
  6644. if (this._labelStroke !=value){
  6645. this._labelStroke=value;
  6646. this._setLabelChanged();
  6647. }
  6648. });
  6649. /**
  6650. *表示按钮文本标签的字体大小。
  6651. */
  6652. __getset(0,__proto,'labelSize',function(){
  6653. return this._labelSize;
  6654. },function(value){
  6655. if (this._labelSize !=value){
  6656. this._labelSize=value;
  6657. this._setLabelChanged();
  6658. }
  6659. });
  6660. /**
  6661. *表示按钮的状态值,以数字表示,默认为3态。
  6662. *@see laya.ui.Button#stateNum
  6663. */
  6664. __getset(0,__proto,'stateNum',function(){
  6665. return this._stateNum;
  6666. },function(value){
  6667. if (this._stateNum !=value){
  6668. this._stateNum=value;
  6669. this._setLabelChanged();
  6670. }
  6671. });
  6672. /**
  6673. *表示按钮文本标签是否为粗体字。
  6674. */
  6675. __getset(0,__proto,'labelBold',function(){
  6676. return this._labelBold;
  6677. },function(value){
  6678. if (this._labelBold !=value){
  6679. this._labelBold=value;
  6680. this._setLabelChanged();
  6681. }
  6682. });
  6683. /**
  6684. *表示按钮文本标签的字体名称,以字符串形式表示。
  6685. *@see laya.display.Text.font()
  6686. */
  6687. __getset(0,__proto,'labelFont',function(){
  6688. return this._labelFont;
  6689. },function(value){
  6690. if (this._labelFont !=value){
  6691. this._labelFont=value;
  6692. this._setLabelChanged();
  6693. }
  6694. });
  6695. /**
  6696. *表示按钮文本标签的边距。
  6697. *<p><b>格式:</b>"上边距,右边距,下边距,左边距"。</p>
  6698. */
  6699. __getset(0,__proto,'labelPadding',function(){
  6700. return this._labelPadding;
  6701. },function(value){
  6702. if (this._labelPadding !=value){
  6703. this._labelPadding=value;
  6704. this._setLabelChanged();
  6705. }
  6706. });
  6707. /**
  6708. *布局方向。
  6709. *<p>默认值为"horizontal"。</p>
  6710. *<p><b>取值:</b>
  6711. *<li>"horizontal":表示水平布局。</li>
  6712. *<li>"vertical":表示垂直布局。</li>
  6713. *</p>
  6714. */
  6715. __getset(0,__proto,'direction',function(){
  6716. return this._direction;
  6717. },function(value){
  6718. this._direction=value;
  6719. this._setLabelChanged();
  6720. });
  6721. /**
  6722. *项对象们之间的间隔(以像素为单位)。
  6723. */
  6724. __getset(0,__proto,'space',function(){
  6725. return this._space;
  6726. },function(value){
  6727. this._space=value;
  6728. this._setLabelChanged();
  6729. });
  6730. /**
  6731. *项对象们的存放数组。
  6732. */
  6733. __getset(0,__proto,'items',function(){
  6734. return this._items;
  6735. });
  6736. /**
  6737. *获取或设置当前选择的项对象。
  6738. */
  6739. __getset(0,__proto,'selection',function(){
  6740. return this._selectedIndex >-1 && this._selectedIndex < this._items.length ? this._items[this._selectedIndex] :null;
  6741. },function(value){
  6742. this.selectedIndex=this._items.indexOf(value);
  6743. });
  6744. /**@inheritDoc */
  6745. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  6746. this._dataSource=value;
  6747. if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string'))this.selectedIndex=parseInt(value);
  6748. else if ((value instanceof Array))this.labels=(value).join(",");
  6749. else Laya.superSet(Box,this,'dataSource',value);
  6750. });
  6751. return UIGroup;
  6752. })(Box)
  6753. /**
  6754. *<code>CheckBox</code> 组件显示一个小方框,该方框内可以有选中标记。
  6755. *<code>CheckBox</code> 组件还可以显示可选的文本标签,默认该标签位于 CheckBox 右侧。
  6756. *<p><code>CheckBox</code> 使用 <code>dataSource</code>赋值时的的默认属性是:<code>selected</code>。</p>
  6757. *
  6758. *@example <caption>以下示例代码,创建了一个 <code>CheckBox</code> 实例。</caption>
  6759. *package
  6760. *{
  6761. *import laya.ui.CheckBox;
  6762. *import laya.utils.Handler;
  6763. *public class CheckBox_Example
  6764. *{
  6765. *public function CheckBox_Example()
  6766. *{
  6767. *Laya.init(640,800);//设置游戏画布宽高。
  6768. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  6769. *Laya.loader.load("resource/ui/check.png",Handler.create(this,onLoadComplete));//加载资源。
  6770. *}
  6771. *private function onLoadComplete():void
  6772. *{
  6773. *trace("资源加载完成!");
  6774. *var checkBox:CheckBox=new CheckBox("resource/ui/check.png","这个是一个CheckBox组件。");//创建一个 CheckBox 类的实例对象 checkBox ,传入它的皮肤skin和标签label。
  6775. *checkBox.x=100;//设置 checkBox 对象的属性 x 的值,用于控制 checkBox 对象的显示位置。
  6776. *checkBox.y=100;//设置 checkBox 对象的属性 y 的值,用于控制 checkBox 对象的显示位置。
  6777. *checkBox.clickHandler=new Handler(this,onClick,[checkBox]);//设置 checkBox 的点击事件处理器。
  6778. *Laya.stage.addChild(checkBox);//将此 checkBox 对象添加到显示列表。
  6779. *}
  6780. *private function onClick(checkBox:CheckBox):void
  6781. *{
  6782. *trace("输出选中状态: checkBox.selected = "+checkBox.selected);
  6783. *}
  6784. *}
  6785. *}
  6786. *@example
  6787. *Laya.init(640,800);//设置游戏画布宽高
  6788. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  6789. *Laya.loader.load("resource/ui/check.png",laya.utils.Handler.create(this,loadComplete));//加载资源
  6790. *function loadComplete()
  6791. *{
  6792. *console.log("资源加载完成!");
  6793. *var checkBox:laya.ui.CheckBox=new laya.ui.CheckBox("resource/ui/check.png","这个是一个CheckBox组件。");//创建一个 CheckBox 类的类的实例对象 checkBox ,传入它的皮肤skin和标签label。
  6794. *checkBox.x=100;//设置 checkBox 对象的属性 x 的值,用于控制 checkBox 对象的显示位置。
  6795. *checkBox.y=100;//设置 checkBox 对象的属性 y 的值,用于控制 checkBox 对象的显示位置。
  6796. *checkBox.clickHandler=new laya.utils.Handler(this,this.onClick,[checkBox],false);//设置 checkBox 的点击事件处理器。
  6797. *Laya.stage.addChild(checkBox);//将此 checkBox 对象添加到显示列表。
  6798. *}
  6799. *function onClick(checkBox)
  6800. *{
  6801. *console.log("checkBox.selected = ",checkBox.selected);
  6802. *}
  6803. *@example
  6804. *import CheckBox=laya.ui.CheckBox;
  6805. *import Handler=laya.utils.Handler;
  6806. *class CheckBox_Example{
  6807. *constructor()
  6808. *{
  6809. *Laya.init(640,800);
  6810. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  6811. *Laya.loader.load("resource/ui/check.png",Handler.create(this,this.onLoadComplete));//加载资源。
  6812. *}
  6813. *private onLoadComplete()
  6814. *{
  6815. *var checkBox:CheckBox=new CheckBox("resource/ui/check.png","这个是一个CheckBox组件。");//创建一个 CheckBox 类的实例对象 checkBox ,传入它的皮肤skin和标签label。
  6816. *checkBox.x=100;//设置 checkBox 对象的属性 x 的值,用于控制 checkBox 对象的显示位置。
  6817. *checkBox.y=100;//设置 checkBox 对象的属性 y 的值,用于控制 checkBox 对象的显示位置。
  6818. *checkBox.clickHandler=new Handler(this,this.onClick,[checkBox]);//设置 checkBox 的点击事件处理器。
  6819. *Laya.stage.addChild(checkBox);//将此 checkBox 对象添加到显示列表。
  6820. *}
  6821. *private onClick(checkBox:CheckBox):void
  6822. *{
  6823. *console.log("输出选中状态: checkBox.selected = "+checkBox.selected);
  6824. *}
  6825. *}
  6826. */
  6827. //class laya.ui.CheckBox extends laya.ui.Button
  6828. var CheckBox=(function(_super){
  6829. /**
  6830. *创建一个新的 <code>CheckBox</code> 组件实例。
  6831. *@param skin 皮肤资源地址。
  6832. *@param label 文本标签的内容。
  6833. */
  6834. function CheckBox(skin,label){
  6835. (label===void 0)&& (label="");
  6836. CheckBox.__super.call(this,skin,label);
  6837. }
  6838. __class(CheckBox,'laya.ui.CheckBox',_super);
  6839. var __proto=CheckBox.prototype;
  6840. /**@inheritDoc */
  6841. __proto.preinitialize=function(){
  6842. laya.ui.UIComponent.prototype.preinitialize.call(this);
  6843. this.toggle=true;
  6844. this._autoSize=false;
  6845. }
  6846. /**@inheritDoc */
  6847. __proto.initialize=function(){
  6848. _super.prototype.initialize.call(this);
  6849. this.createText();
  6850. this._text.align="left";
  6851. this._text.valign="top";
  6852. this._text.width=0;
  6853. }
  6854. /**@inheritDoc */
  6855. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  6856. this._dataSource=value;
  6857. if ((typeof value=='boolean'))this.selected=value;
  6858. else if ((typeof value=='string'))this.selected=value==="true";
  6859. else Laya.superSet(Button,this,'dataSource',value);
  6860. });
  6861. return CheckBox;
  6862. })(Button)
  6863. /**
  6864. *<code>Tree</code> 控件使用户可以查看排列为可扩展树的层次结构数据。
  6865. *
  6866. *@example
  6867. *package
  6868. *{
  6869. *import laya.ui.Tree;
  6870. *import laya.utils.Browser;
  6871. *import laya.utils.Handler;
  6872. *public class Tree_Example
  6873. *{
  6874. *public function Tree_Example()
  6875. *{
  6876. *Laya.init(640,800);
  6877. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  6878. *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png","resource/ui/clip_selectBox.png","resource/ui/clip_tree_folder.png","resource/ui/clip_tree_arrow.png"],Handler.create(this,onLoadComplete));
  6879. *}
  6880. *private function onLoadComplete():void
  6881. *{
  6882. *var xmlString:String;//创建一个xml字符串,用于存储树结构数据。
  6883. *xmlString="&lt;root&gt;&lt;item label='box1'&gt;&lt;abc label='child1'/&gt;&lt;abc label='child2'/&gt;&lt;abc label='child3'/&gt;&lt;abc label='child4'/&gt;&lt;abc label='child5'/&gt;&lt;/item&gt;&lt;item label='box2'&gt;&lt;abc label='child1'/&gt;&lt;abc label='child2'/&gt;&lt;abc label='child3'/&gt;&lt;abc label='child4'/&gt;&lt;/item&gt;&lt;/root&gt;";
  6884. *var domParser:*=new Browser.window.DOMParser();//创建一个DOMParser实例domParser。
  6885. *var xml:*=domParser.parseFromString(xmlString,"text/xml");//解析xml字符。
  6886. *var tree:Tree=new Tree();//创建一个 Tree 类的实例对象 tree 。
  6887. *tree.scrollBarSkin="resource/ui/vscroll.png";//设置 tree 的皮肤。
  6888. *tree.itemRender=Item;//设置 tree 的项渲染器。
  6889. *tree.xml=xml;//设置 tree 的树结构数据。
  6890. *tree.x=100;//设置 tree 对象的属性 x 的值,用于控制 tree 对象的显示位置。
  6891. *tree.y=100;//设置 tree 对象的属性 y 的值,用于控制 tree 对象的显示位置。
  6892. *tree.width=200;//设置 tree 的宽度。
  6893. *tree.height=100;//设置 tree 的高度。
  6894. *Laya.stage.addChild(tree);//将 tree 添加到显示列表。
  6895. *}
  6896. *}
  6897. *}
  6898. *import laya.ui.Box;
  6899. *import laya.ui.Clip;
  6900. *import laya.ui.Label;
  6901. *class Item extends Box
  6902. *{
  6903. *public function Item()
  6904. *{
  6905. *this.name="render";
  6906. *this.right=0;
  6907. *this.left=0;
  6908. *var selectBox:Clip=new Clip("resource/ui/clip_selectBox.png",1,2);
  6909. *selectBox.name="selectBox";
  6910. *selectBox.height=24;
  6911. *selectBox.x=13;
  6912. *selectBox.y=0;
  6913. *selectBox.left=12;
  6914. *addChild(selectBox);
  6915. *var folder:Clip=new Clip("resource/ui/clip_tree_folder.png",1,3);
  6916. *folder.name="folder";
  6917. *folder.x=14;
  6918. *folder.y=4;
  6919. *addChild(folder);
  6920. *var label:Label=new Label("treeItem");
  6921. *label.name="label";
  6922. *label.color="#ffff00";
  6923. *label.width=150;
  6924. *label.height=22;
  6925. *label.x=33;
  6926. *label.y=1;
  6927. *label.left=33;
  6928. *label.right=0;
  6929. *addChild(label);
  6930. *var arrow:Clip=new Clip("resource/ui/clip_tree_arrow.png",1,2);
  6931. *arrow.name="arrow";
  6932. *arrow.x=0;
  6933. *arrow.y=5;
  6934. *addChild(arrow);
  6935. *}
  6936. *}
  6937. *@example
  6938. *Laya.init(640,800);//设置游戏画布宽高、渲染模式
  6939. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  6940. *var res=["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png","resource/ui/clip_selectBox.png","resource/ui/clip_tree_folder.png","resource/ui/clip_tree_arrow.png"];
  6941. *Laya.loader.load(res,new laya.utils.Handler(this,onLoadComplete));
  6942. *function onLoadComplete(){
  6943. *var xmlString;//创建一个xml字符串,用于存储树结构数据。
  6944. *xmlString="&lt;root&gt;&lt;item label='box1'&gt;&lt;abc label='child1'/&gt;&lt;abc label='child2'/&gt;&lt;abc label='child3'/&gt;&lt;abc label='child4'/&gt;&lt;abc label='child5'/&gt;&lt;/item&gt;&lt;item label='box2'&gt;&lt;abc label='child1'/&gt;&lt;abc label='child2'/&gt;&lt;abc label='child3'/&gt;&lt;abc label='child4'/&gt;&lt;/item&gt;&lt;/root&gt;";
  6945. *var domParser=new laya.utils.Browser.window.DOMParser();//创建一个DOMParser实例domParser。
  6946. *var xml=domParser.parseFromString(xmlString,"text/xml");//解析xml字符。
  6947. *var tree=new laya.ui.Tree();//创建一个 Tree 类的实例对象 tree 。
  6948. *tree.scrollBarSkin="resource/ui/vscroll.png";//设置 tree 的皮肤。
  6949. *tree.itemRender=mypackage.treeExample.Item;//设置 tree 的项渲染器。
  6950. *tree.xml=xml;//设置 tree 的树结构数据。
  6951. *tree.x=100;//设置 tree 对象的属性 x 的值,用于控制 tree 对象的显示位置。
  6952. *tree.y=100;//设置 tree 对象的属性 y 的值,用于控制 tree 对象的显示位置。
  6953. *tree.width=200;//设置 tree 的宽度。
  6954. *tree.height=100;//设置 tree 的高度。
  6955. *Laya.stage.addChild(tree);//将 tree 添加到显示列表。
  6956. *}
  6957. *(function (_super){
  6958. *function Item(){
  6959. *Item.__super.call(this);//初始化父类。
  6960. *this.right=0;
  6961. *this.left=0;
  6962. *var selectBox=new laya.ui.Clip("resource/ui/clip_selectBox.png",1,2);
  6963. *selectBox.name="selectBox";//设置 selectBox 的name 为“selectBox”时,将被识别为树结构的项的背景。2帧:悬停时背景、选中时背景。
  6964. *selectBox.height=24;
  6965. *selectBox.x=13;
  6966. *selectBox.y=0;
  6967. *selectBox.left=12;
  6968. *this.addChild(selectBox);//需要使用this.访问父类的属性或方法。
  6969. *var folder=new laya.ui.Clip("resource/ui/clip_tree_folder.png",1,3);
  6970. *folder.name="folder";//设置 folder 的name 为“folder”时,将被识别为树结构的文件夹开启状态图表。2帧:折叠状态、打开状态。
  6971. *folder.x=14;
  6972. *folder.y=4;
  6973. *this.addChild(folder);
  6974. *var label=new laya.ui.Label("treeItem");
  6975. *label.name="label";//设置 label 的name 为“label”时,此值将用于树结构数据赋值。
  6976. *label.color="#ffff00";
  6977. *label.width=150;
  6978. *label.height=22;
  6979. *label.x=33;
  6980. *label.y=1;
  6981. *label.left=33;
  6982. *label.right=0;
  6983. *this.addChild(label);
  6984. *var arrow=new laya.ui.Clip("resource/ui/clip_tree_arrow.png",1,2);
  6985. *arrow.name="arrow";//设置 arrow 的name 为“arrow”时,将被识别为树结构的文件夹开启状态图表。2帧:折叠状态、打开状态。
  6986. *arrow.x=0;
  6987. *arrow.y=5;
  6988. *this.addChild(arrow);
  6989. *};
  6990. *Laya.class(Item,"mypackage.treeExample.Item",_super);//注册类 Item 。
  6991. *})(laya.ui.Box);
  6992. *@example
  6993. *import Tree=laya.ui.Tree;
  6994. *import Browser=laya.utils.Browser;
  6995. *import Handler=laya.utils.Handler;
  6996. *class Tree_Example {
  6997. *constructor(){
  6998. *Laya.init(640,800);
  6999. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  7000. *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png","resource/ui/vscroll$up.png","resource/ui/clip_selectBox.png","resource/ui/clip_tree_folder * . * png","resource/ui/clip_tree_arrow.png"],Handler.create(this,this.onLoadComplete));
  7001. *}
  7002. *private onLoadComplete():void {
  7003. *var xmlString:String;//创建一个xml字符串,用于存储树结构数据。
  7004. *xmlString="&lt;root&gt;&lt;item label='box1'&gt;&lt;abc label='child1'/&gt;&lt;abc label='child2'/&gt;&lt;abc label='child3'/&gt;&lt;abc label='child4'/&gt;&lt;abc label='child5'/&gt;&lt;/item&gt;&lt;item label='box2'&gt;&lt;abc * label='child1'/&gt;&lt;abc label='child2'/&gt;&lt;abc label='child3'/&gt;&lt;abc label='child4'/&gt;&lt;/item&gt;&lt;/root&gt;";
  7005. *var domParser:any=new Browser.window.DOMParser();//创建一个DOMParser实例domParser。
  7006. *var xml:any=domParser.parseFromString(xmlString,"text/xml");//解析xml字符。
  7007. *var tree:Tree=new Tree();//创建一个 Tree 类的实例对象 tree 。
  7008. *tree.scrollBarSkin="resource/ui/vscroll.png";//设置 tree 的皮肤。
  7009. *tree.itemRender=Item;//设置 tree 的项渲染器。
  7010. *tree.xml=xml;//设置 tree 的树结构数据。
  7011. *tree.x=100;//设置 tree 对象的属性 x 的值,用于控制 tree 对象的显示位置。
  7012. *tree.y=100;//设置 tree 对象的属性 y 的值,用于控制 tree 对象的显示位置。
  7013. *tree.width=200;//设置 tree 的宽度。
  7014. *tree.height=100;//设置 tree 的高度。
  7015. *Laya.stage.addChild(tree);//将 tree 添加到显示列表。
  7016. *}
  7017. *}
  7018. *import Box=laya.ui.Box;
  7019. *import Clip=laya.ui.Clip;
  7020. *import Label=laya.ui.Label;
  7021. *class Item extends Box {
  7022. *constructor(){
  7023. *super();
  7024. *this.name="render";
  7025. *this.right=0;
  7026. *this.left=0;
  7027. *var selectBox:Clip=new Clip("resource/ui/clip_selectBox.png",1,2);
  7028. *selectBox.name="selectBox";
  7029. *selectBox.height=24;
  7030. *selectBox.x=13;
  7031. *selectBox.y=0;
  7032. *selectBox.left=12;
  7033. *this.addChild(selectBox);
  7034. *var folder:Clip=new Clip("resource/ui/clip_tree_folder.png",1,3);
  7035. *folder.name="folder";
  7036. *folder.x=14;
  7037. *folder.y=4;
  7038. *this.addChild(folder);
  7039. *var label:Label=new Label("treeItem");
  7040. *label.name="label";
  7041. *label.color="#ffff00";
  7042. *label.width=150;
  7043. *label.height=22;
  7044. *label.x=33;
  7045. *label.y=1;
  7046. *label.left=33;
  7047. *label.right=0;
  7048. *this.addChild(label);
  7049. *var arrow:Clip=new Clip("resource/ui/clip_tree_arrow.png",1,2);
  7050. *arrow.name="arrow";
  7051. *arrow.x=0;
  7052. *arrow.y=5;
  7053. *this.addChild(arrow);
  7054. *}
  7055. *}
  7056. */
  7057. //class laya.ui.Tree extends laya.ui.Box
  7058. var Tree=(function(_super){
  7059. function Tree(){
  7060. /**@private */
  7061. this._list=null;
  7062. /**@private */
  7063. this._source=null;
  7064. /**@private */
  7065. this._renderHandler=null;
  7066. /**@private */
  7067. this._spaceLeft=10;
  7068. /**@private */
  7069. this._spaceBottom=0;
  7070. /**@private */
  7071. this._keepStatus=true;
  7072. Tree.__super.call(this);
  7073. this.width=this.height=200;
  7074. }
  7075. __class(Tree,'laya.ui.Tree',_super);
  7076. var __proto=Tree.prototype;
  7077. Laya.imps(__proto,{"laya.ui.IRender":true})
  7078. /**@inheritDoc */
  7079. __proto.destroy=function(destroyChild){
  7080. (destroyChild===void 0)&& (destroyChild=true);
  7081. laya.ui.UIComponent.prototype.destroy.call(this,destroyChild);
  7082. this._list && this._list.destroy(destroyChild);
  7083. this._list=null;
  7084. this._source=null;
  7085. this._renderHandler=null;
  7086. }
  7087. /**@inheritDoc */
  7088. __proto.createChildren=function(){
  7089. this.addChild(this._list=new List());
  7090. this._list.renderHandler=Handler.create(this,this.renderItem,null,false);
  7091. this._list.repeatX=1;
  7092. this._list.on(/*laya.events.Event.CHANGE*/"change",this,this.onListChange);
  7093. }
  7094. /**
  7095. *@private
  7096. *此对象包含的<code>List</code>实例的<code>Event.CHANGE</code>事件侦听处理函数。
  7097. */
  7098. __proto.onListChange=function(e){
  7099. this.event(/*laya.events.Event.CHANGE*/"change");
  7100. }
  7101. /**
  7102. *@private
  7103. *获取数据源集合。
  7104. */
  7105. __proto.getArray=function(){
  7106. var arr=[];
  7107. var item;
  7108. /*for each*/for(var $each_item in this._source){
  7109. item=this._source[$each_item];
  7110. if (this.getParentOpenStatus(item)){
  7111. item.x=this._spaceLeft *this.getDepth(item);
  7112. arr.push(item);
  7113. }
  7114. }
  7115. return arr;
  7116. }
  7117. /**
  7118. *@private
  7119. *获取项对象的深度。
  7120. */
  7121. __proto.getDepth=function(item,num){
  7122. (num===void 0)&& (num=0);
  7123. if (item.nodeParent==null)return num;
  7124. else return this.getDepth(item.nodeParent,num+1);
  7125. }
  7126. /**
  7127. *@private
  7128. *获取项对象的上一级的打开状态。
  7129. */
  7130. __proto.getParentOpenStatus=function(item){
  7131. var parent=item.nodeParent;
  7132. if (parent==null){
  7133. return true;
  7134. }else {
  7135. if (parent.isOpen){
  7136. if (parent.nodeParent !=null)return this.getParentOpenStatus(parent);
  7137. else return true;
  7138. }else {
  7139. return false;
  7140. }
  7141. }
  7142. }
  7143. /**
  7144. *@private
  7145. *渲染一个项对象。
  7146. *@param cell 一个项对象。
  7147. *@param index 项的索引。
  7148. */
  7149. __proto.renderItem=function(cell,index){
  7150. var item=cell.dataSource;
  7151. if (item){
  7152. cell.left=item.x;
  7153. var arrow=cell.getChildByName("arrow");
  7154. if (arrow){
  7155. if (item.hasChild){
  7156. arrow.visible=true;
  7157. arrow.index=item.isOpen ? 1 :0;
  7158. arrow.tag=index;
  7159. arrow.off(/*laya.events.Event.CLICK*/"click",this,this.onArrowClick);
  7160. arrow.on(/*laya.events.Event.CLICK*/"click",this,this.onArrowClick);
  7161. }else {
  7162. arrow.visible=false;
  7163. }
  7164. };
  7165. var folder=cell.getChildByName("folder");
  7166. if (folder){
  7167. if (folder.clipY==2){
  7168. folder.index=item.isDirectory ? 0 :1;
  7169. }else {
  7170. folder.index=item.isDirectory ? item.isOpen ? 1 :0 :2;
  7171. }
  7172. }
  7173. this._renderHandler && this._renderHandler.runWith([cell,index]);
  7174. }
  7175. }
  7176. /**
  7177. *@private
  7178. */
  7179. __proto.onArrowClick=function(e){
  7180. var arrow=e.currentTarget;
  7181. var index=arrow.tag;
  7182. this._list.array[index].isOpen=!this._list.array[index].isOpen;
  7183. this.event(/*laya.events.Event.OPEN*/"open");
  7184. this._list.array=this.getArray();
  7185. }
  7186. /**
  7187. *设置指定项索引的项对象的打开状态。
  7188. *@param index 项索引。
  7189. *@param isOpen 是否处于打开状态。
  7190. */
  7191. __proto.setItemState=function(index,isOpen){
  7192. if (!this._list.array[index])return;
  7193. this._list.array[index].isOpen=isOpen;
  7194. this._list.array=this.getArray();
  7195. }
  7196. /**
  7197. *刷新项列表。
  7198. */
  7199. __proto.fresh=function(){
  7200. this._list.array=this.getArray();
  7201. this.repaint();
  7202. }
  7203. /**
  7204. *@private
  7205. *解析并处理XML类型的数据源。
  7206. */
  7207. __proto.parseXml=function(xml,source,nodeParent,isRoot){
  7208. var obj;
  7209. var list=xml.childNodes;
  7210. var childCount=list.length;
  7211. if (!isRoot){
  7212. obj={};
  7213. var list2=xml.attributes;
  7214. var attrs;
  7215. /*for each*/for(var $each_attrs in list2){
  7216. attrs=list2[$each_attrs];
  7217. var prop=attrs.nodeName;
  7218. var value=attrs.nodeValue;
  7219. obj[prop]=value=="true" ? true :value=="false" ? false :value;
  7220. }
  7221. obj.nodeParent=nodeParent;
  7222. if (childCount > 0)obj.isDirectory=true;
  7223. obj.hasChild=childCount > 0;
  7224. source.push(obj);
  7225. }
  7226. for (var i=0;i < childCount;i++){
  7227. var node=list[i];
  7228. this.parseXml(node,source,obj,false);
  7229. }
  7230. }
  7231. /**
  7232. *@private
  7233. *处理数据项的打开状态。
  7234. */
  7235. __proto.parseOpenStatus=function(oldSource,newSource){
  7236. for (var i=0,n=newSource.length;i < n;i++){
  7237. var newItem=newSource[i];
  7238. if (newItem.isDirectory){
  7239. for (var j=0,m=oldSource.length;j < m;j++){
  7240. var oldItem=oldSource[j];
  7241. if (oldItem.isDirectory && this.isSameParent(oldItem,newItem)&& newItem.label==oldItem.label){
  7242. newItem.isOpen=oldItem.isOpen;
  7243. break ;
  7244. }
  7245. }
  7246. }
  7247. }
  7248. }
  7249. /**
  7250. *@private
  7251. *判断两个项对象在树结构中的父节点是否相同。
  7252. *@param item1 项对象。
  7253. *@param item2 项对象。
  7254. *@return 如果父节点相同值为true,否则值为false。
  7255. */
  7256. __proto.isSameParent=function(item1,item2){
  7257. if (item1.nodeParent==null && item2.nodeParent==null)return true;
  7258. else if (item1.nodeParent==null || item2.nodeParent==null)return false
  7259. else {
  7260. if (item1.nodeParent.label==item2.nodeParent.label)return this.isSameParent(item1.nodeParent,item2.nodeParent);
  7261. else return false;
  7262. }
  7263. }
  7264. /**
  7265. *更新项列表,显示指定键名的数据项。
  7266. *@param key 键名。
  7267. */
  7268. __proto.filter=function(key){
  7269. if (Boolean(key)){
  7270. var result=[];
  7271. this.getFilterSource(this._source,result,key);
  7272. this._list.array=result;
  7273. }else {
  7274. this._list.array=this.getArray();
  7275. }
  7276. }
  7277. /**
  7278. *@private
  7279. *获取数据源中指定键名的值。
  7280. */
  7281. __proto.getFilterSource=function(array,result,key){
  7282. key=key.toLocaleLowerCase();
  7283. var item;
  7284. /*for each*/for(var $each_item in array){
  7285. item=array[$each_item];
  7286. if (!item.isDirectory && String(item.label).toLowerCase().indexOf(key)>-1){
  7287. item.x=0;
  7288. result.push(item);
  7289. }
  7290. if (item.child && item.child.length > 0){
  7291. this.getFilterSource(item.child,result,key);
  7292. }
  7293. }
  7294. }
  7295. /**
  7296. *每一项之间的间隔距离(以像素为单位)。
  7297. */
  7298. __getset(0,__proto,'spaceBottom',function(){
  7299. return this._list.spaceY;
  7300. },function(value){
  7301. this._list.spaceY=value;
  7302. });
  7303. /**
  7304. *数据源发生变化后,是否保持之前打开状态,默认为true。
  7305. *<p><b>取值:</b>
  7306. *<li>true:保持之前打开状态。</li>
  7307. *<li>false:不保持之前打开状态。</li>
  7308. *</p>
  7309. */
  7310. __getset(0,__proto,'keepStatus',function(){
  7311. return this._keepStatus;
  7312. },function(value){
  7313. this._keepStatus=value;
  7314. });
  7315. /**
  7316. *此对象包含的<code>List</code>实例的单元格渲染器。
  7317. *<p><b>取值:</b>
  7318. *<ol>
  7319. *<li>单元格类对象。</li>
  7320. *<li> UI 的 JSON 描述。</li>
  7321. *</ol></p>
  7322. */
  7323. __getset(0,__proto,'itemRender',function(){
  7324. return this._list.itemRender;
  7325. },function(value){
  7326. this._list.itemRender=value;
  7327. });
  7328. /**
  7329. *列表数据源,只包含当前可视节点数据。
  7330. */
  7331. __getset(0,__proto,'array',function(){
  7332. return this._list.array;
  7333. },function(value){
  7334. if (this._keepStatus && this._list.array && value){
  7335. this.parseOpenStatus(this._list.array,value);
  7336. }
  7337. this._source=value;
  7338. this._list.array=this.getArray();
  7339. });
  7340. /**
  7341. *单元格鼠标事件处理器。
  7342. *<p>默认返回参数(e:Event,index:int)。</p>
  7343. */
  7344. __getset(0,__proto,'mouseHandler',function(){
  7345. return this._list.mouseHandler;
  7346. },function(value){
  7347. this._list.mouseHandler=value;
  7348. });
  7349. /**@inheritDoc */
  7350. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  7351. this._dataSource=value;
  7352. Laya.superSet(Box,this,'dataSource',value);
  7353. });
  7354. /**
  7355. *数据源,全部节点数据。
  7356. */
  7357. __getset(0,__proto,'source',function(){
  7358. return this._source;
  7359. });
  7360. /**滚动条*/
  7361. __getset(0,__proto,'scrollBar',function(){
  7362. return this._list.scrollBar;
  7363. });
  7364. /**
  7365. *此对象包含的<code>List</code>实例对象。
  7366. */
  7367. __getset(0,__proto,'list',function(){
  7368. return this._list;
  7369. });
  7370. /**
  7371. *滚动条皮肤。
  7372. */
  7373. __getset(0,__proto,'scrollBarSkin',function(){
  7374. return this._list.vScrollBarSkin;
  7375. },function(value){
  7376. this._list.vScrollBarSkin=value;
  7377. });
  7378. /**
  7379. *<code>Tree</code> 实例的渲染处理器。
  7380. */
  7381. __getset(0,__proto,'renderHandler',function(){
  7382. return this._renderHandler;
  7383. },function(value){
  7384. this._renderHandler=value;
  7385. });
  7386. /**
  7387. *表示当前选择的项索引。
  7388. */
  7389. __getset(0,__proto,'selectedIndex',function(){
  7390. return this._list.selectedIndex;
  7391. },function(value){
  7392. this._list.selectedIndex=value;
  7393. });
  7394. /**
  7395. *左侧缩进距离(以像素为单位)。
  7396. */
  7397. __getset(0,__proto,'spaceLeft',function(){
  7398. return this._spaceLeft;
  7399. },function(value){
  7400. this._spaceLeft=value;
  7401. });
  7402. /**
  7403. *当前选中的项对象的数据源。
  7404. */
  7405. __getset(0,__proto,'selectedItem',function(){
  7406. return this._list.selectedItem;
  7407. },function(value){
  7408. this._list.selectedItem=value;
  7409. });
  7410. /**
  7411. *@inheritDoc
  7412. */
  7413. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  7414. Laya.superSet(Box,this,'width',value);
  7415. this._list.width=value;
  7416. });
  7417. /**@inheritDoc */
  7418. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  7419. Laya.superSet(Box,this,'height',value);
  7420. this._list.height=value;
  7421. });
  7422. /**
  7423. *xml结构的数据源。
  7424. */
  7425. __getset(0,__proto,'xml',null,function(value){
  7426. var arr=[];
  7427. this.parseXml(value.childNodes[0],arr,null,true);
  7428. this.array=arr;
  7429. });
  7430. /**
  7431. *表示选择的树节点项的<code>path</code>属性值。
  7432. */
  7433. __getset(0,__proto,'selectedPath',function(){
  7434. if (this._list.selectedItem){
  7435. return this._list.selectedItem.path;
  7436. }
  7437. return null;
  7438. });
  7439. return Tree;
  7440. })(Box)
  7441. /**
  7442. *<code>Panel</code> 是一个面板容器类。
  7443. */
  7444. //class laya.ui.Panel extends laya.ui.Box
  7445. var Panel=(function(_super){
  7446. function Panel(){
  7447. /**@private */
  7448. this._content=null;
  7449. /**@private */
  7450. this._vScrollBar=null;
  7451. /**@private */
  7452. this._hScrollBar=null;
  7453. /**@private */
  7454. this._scrollChanged=false;
  7455. /**@private */
  7456. this._usedCache=null;
  7457. /**@private */
  7458. this._elasticEnabled=false;
  7459. Panel.__super.call(this);
  7460. this.width=this.height=100;
  7461. }
  7462. __class(Panel,'laya.ui.Panel',_super);
  7463. var __proto=Panel.prototype;
  7464. /**@inheritDoc */
  7465. __proto.destroy=function(destroyChild){
  7466. (destroyChild===void 0)&& (destroyChild=true);
  7467. laya.ui.UIComponent.prototype.destroy.call(this,destroyChild);
  7468. this._content && this._content.destroy(destroyChild);
  7469. this._vScrollBar && this._vScrollBar.destroy(destroyChild);
  7470. this._hScrollBar && this._hScrollBar.destroy(destroyChild);
  7471. this._vScrollBar=null;
  7472. this._hScrollBar=null;
  7473. this._content=null;
  7474. }
  7475. /**@inheritDoc */
  7476. __proto.destroyChildren=function(){
  7477. this._content.destroyChildren();
  7478. }
  7479. /**@inheritDoc */
  7480. __proto.createChildren=function(){
  7481. laya.display.Node.prototype.addChild.call(this,this._content=new Box());
  7482. }
  7483. /**@inheritDoc */
  7484. __proto.addChild=function(child){
  7485. child.on(/*laya.events.Event.RESIZE*/"resize",this,this.onResize);
  7486. this._setScrollChanged();
  7487. return this._content.addChild(child);
  7488. }
  7489. /**
  7490. *@private
  7491. *子对象的 <code>Event.RESIZE</code> 事件侦听处理函数。
  7492. */
  7493. __proto.onResize=function(){
  7494. this._setScrollChanged();
  7495. }
  7496. /**@inheritDoc */
  7497. __proto.addChildAt=function(child,index){
  7498. child.on(/*laya.events.Event.RESIZE*/"resize",this,this.onResize);
  7499. this._setScrollChanged();
  7500. return this._content.addChildAt(child,index);
  7501. }
  7502. /**@inheritDoc */
  7503. __proto.removeChild=function(child){
  7504. child.off(/*laya.events.Event.RESIZE*/"resize",this,this.onResize);
  7505. this._setScrollChanged();
  7506. return this._content.removeChild(child);
  7507. }
  7508. /**@inheritDoc */
  7509. __proto.removeChildAt=function(index){
  7510. this.getChildAt(index).off(/*laya.events.Event.RESIZE*/"resize",this,this.onResize);
  7511. this._setScrollChanged();
  7512. return this._content.removeChildAt(index);
  7513. }
  7514. /**@inheritDoc */
  7515. __proto.removeChildren=function(beginIndex,endIndex){
  7516. (beginIndex===void 0)&& (beginIndex=0);
  7517. (endIndex===void 0)&& (endIndex=0x7fffffff);
  7518. this._content.removeChildren(beginIndex,endIndex);
  7519. this._setScrollChanged();
  7520. return this;
  7521. }
  7522. /**@inheritDoc */
  7523. __proto.getChildAt=function(index){
  7524. return this._content.getChildAt(index);
  7525. }
  7526. /**@inheritDoc */
  7527. __proto.getChildByName=function(name){
  7528. return this._content.getChildByName(name);
  7529. }
  7530. /**@inheritDoc */
  7531. __proto.getChildIndex=function(child){
  7532. return this._content.getChildIndex(child);
  7533. }
  7534. /**@private */
  7535. __proto.changeScroll=function(){
  7536. this._scrollChanged=false;
  7537. var contentW=this.contentWidth || 1;
  7538. var contentH=this.contentHeight || 1;
  7539. var vscroll=this._vScrollBar;
  7540. var hscroll=this._hScrollBar;
  7541. var vShow=vscroll && contentH > this._height;
  7542. var hShow=hscroll && contentW > this._width;
  7543. var showWidth=vShow ? this._width-vscroll.width :this._width;
  7544. var showHeight=hShow ? this._height-hscroll.height :this._height;
  7545. if (vscroll){
  7546. vscroll.x=this._width-vscroll.width;
  7547. vscroll.y=0;
  7548. vscroll.height=this._height-(hShow ? hscroll.height :0);
  7549. vscroll.scrollSize=Math.max(this._height *0.033,1);
  7550. vscroll.thumbPercent=showHeight / contentH;
  7551. vscroll.setScroll(0,contentH-showHeight,vscroll.value);
  7552. }
  7553. if (hscroll){
  7554. hscroll.x=0;
  7555. hscroll.y=this._height-hscroll.height;
  7556. hscroll.width=this._width-(vShow ? vscroll.width :0);
  7557. hscroll.scrollSize=Math.max(this._width *0.033,1);
  7558. hscroll.thumbPercent=showWidth / contentW;
  7559. hscroll.setScroll(0,contentW-showWidth,hscroll.value);
  7560. }
  7561. }
  7562. /**@inheritDoc */
  7563. __proto._sizeChanged=function(){
  7564. laya.ui.UIComponent.prototype._sizeChanged.call(this);
  7565. this.setContentSize(this._width,this._height);
  7566. }
  7567. /**
  7568. *@private
  7569. *设置内容的宽度、高度(以像素为单位)。
  7570. *@param width 宽度。
  7571. *@param height 高度。
  7572. */
  7573. __proto.setContentSize=function(width,height){
  7574. var content=this._content;
  7575. content.width=width;
  7576. content.height=height;
  7577. content._style.scrollRect || (content.scrollRect=Rectangle.create());
  7578. content._style.scrollRect.setTo(0,0,width,height);
  7579. content.scrollRect=content.scrollRect;
  7580. }
  7581. /**
  7582. *@private
  7583. *滚动条的<code><code>Event.MOUSE_DOWN</code>事件侦听处理函数。</code>事件侦听处理函数。
  7584. *@param scrollBar 滚动条对象。
  7585. *@param e Event 对象。
  7586. */
  7587. __proto.onScrollBarChange=function(scrollBar){
  7588. var rect=this._content._style.scrollRect;
  7589. if (rect){
  7590. var start=Math.round(scrollBar.value);
  7591. scrollBar.isVertical ? rect.y=start :rect.x=start;
  7592. this._content.scrollRect=rect;
  7593. }
  7594. }
  7595. /**
  7596. *<p>滚动内容容器至设定的垂直、水平方向滚动条位置。</p>
  7597. *@param x 水平方向滚动条属性value值。滚动条位置数字。
  7598. *@param y 垂直方向滚动条属性value值。滚动条位置数字。
  7599. */
  7600. __proto.scrollTo=function(x,y){
  7601. (x===void 0)&& (x=0);
  7602. (y===void 0)&& (y=0);
  7603. if (this.vScrollBar)this.vScrollBar.value=y;
  7604. if (this.hScrollBar)this.hScrollBar.value=x;
  7605. }
  7606. /**
  7607. *刷新滚动内容。
  7608. */
  7609. __proto.refresh=function(){
  7610. this.changeScroll();
  7611. }
  7612. __proto.onScrollStart=function(){
  7613. this._usedCache || (this._usedCache=Laya.superGet(Box,this,'cacheAs'));
  7614. Laya.superSet(Box,this,'cacheAs',"none");
  7615. this._hScrollBar && this._hScrollBar.once(/*laya.events.Event.END*/"end",this,this.onScrollEnd);
  7616. this._vScrollBar && this._vScrollBar.once(/*laya.events.Event.END*/"end",this,this.onScrollEnd);
  7617. }
  7618. __proto.onScrollEnd=function(){
  7619. Laya.superSet(Box,this,'cacheAs',this._usedCache);
  7620. }
  7621. /**@private */
  7622. __proto._setScrollChanged=function(){
  7623. if (!this._scrollChanged){
  7624. this._scrollChanged=true;
  7625. this.callLater(this.changeScroll);
  7626. }
  7627. }
  7628. /**@inheritDoc */
  7629. __getset(0,__proto,'numChildren',function(){
  7630. return this._content.numChildren;
  7631. });
  7632. /**
  7633. *水平方向滚动条皮肤。
  7634. */
  7635. __getset(0,__proto,'hScrollBarSkin',function(){
  7636. return this._hScrollBar ? this._hScrollBar.skin :null;
  7637. },function(value){
  7638. if (this._hScrollBar==null){
  7639. laya.display.Node.prototype.addChild.call(this,this._hScrollBar=new HScrollBar());
  7640. this._hScrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onScrollBarChange,[this._hScrollBar]);
  7641. this._hScrollBar.target=this._content;
  7642. this._hScrollBar.elasticDistance=this._elasticEnabled ? 200 :0;
  7643. this._setScrollChanged();
  7644. }
  7645. this._hScrollBar.skin=value;
  7646. });
  7647. /**
  7648. *@private
  7649. *获取内容宽度(以像素为单位)。
  7650. */
  7651. __getset(0,__proto,'contentWidth',function(){
  7652. var max=0;
  7653. for (var i=this._content.numChildren-1;i >-1;i--){
  7654. var comp=this._content.getChildAt(i);
  7655. max=Math.max(comp._x+comp.width *comp.scaleX-comp.pivotX,max);
  7656. }
  7657. return max;
  7658. });
  7659. /**
  7660. *@private
  7661. *获取内容高度(以像素为单位)。
  7662. */
  7663. __getset(0,__proto,'contentHeight',function(){
  7664. var max=0;
  7665. for (var i=this._content.numChildren-1;i >-1;i--){
  7666. var comp=this._content.getChildAt(i);
  7667. max=Math.max(comp._y+comp.height *comp.scaleY-comp.pivotY,max);
  7668. }
  7669. return max;
  7670. });
  7671. /**
  7672. *@inheritDoc
  7673. */
  7674. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  7675. Laya.superSet(Box,this,'width',value);
  7676. this._setScrollChanged();
  7677. });
  7678. /**
  7679. *水平方向滚动条对象。
  7680. */
  7681. __getset(0,__proto,'hScrollBar',function(){
  7682. return this._hScrollBar;
  7683. });
  7684. /**
  7685. *获取内容容器对象。
  7686. */
  7687. __getset(0,__proto,'content',function(){
  7688. return this._content;
  7689. });
  7690. /**@inheritDoc */
  7691. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  7692. Laya.superSet(Box,this,'height',value);
  7693. this._setScrollChanged();
  7694. });
  7695. /**
  7696. *垂直方向滚动条皮肤。
  7697. */
  7698. __getset(0,__proto,'vScrollBarSkin',function(){
  7699. return this._vScrollBar ? this._vScrollBar.skin :null;
  7700. },function(value){
  7701. if (this._vScrollBar==null){
  7702. laya.display.Node.prototype.addChild.call(this,this._vScrollBar=new VScrollBar());
  7703. this._vScrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onScrollBarChange,[this._vScrollBar]);
  7704. this._vScrollBar.target=this._content;
  7705. this._vScrollBar.elasticDistance=this._elasticEnabled ? 200 :0;
  7706. this._setScrollChanged();
  7707. }
  7708. this._vScrollBar.skin=value;
  7709. });
  7710. /**
  7711. *垂直方向滚动条对象。
  7712. */
  7713. __getset(0,__proto,'vScrollBar',function(){
  7714. return this._vScrollBar;
  7715. });
  7716. /**@inheritDoc */
  7717. __getset(0,__proto,'cacheAs',_super.prototype._$get_cacheAs,function(value){
  7718. Laya.superSet(Box,this,'cacheAs',value);
  7719. this._usedCache=null;
  7720. if (value!=="none"){
  7721. this._hScrollBar && this._hScrollBar.on(/*laya.events.Event.START*/"start",this,this.onScrollStart);
  7722. this._vScrollBar && this._vScrollBar.on(/*laya.events.Event.START*/"start",this,this.onScrollStart);
  7723. }else {
  7724. this._hScrollBar && this._hScrollBar.off(/*laya.events.Event.START*/"start",this,this.onScrollStart);
  7725. this._vScrollBar && this._vScrollBar.off(/*laya.events.Event.START*/"start",this,this.onScrollStart);
  7726. }
  7727. });
  7728. /**是否开启橡皮筋效果*/
  7729. __getset(0,__proto,'elasticEnabled',function(){
  7730. return this._elasticEnabled;
  7731. },function(value){
  7732. this._elasticEnabled=value;
  7733. if (this._vScrollBar){
  7734. this._vScrollBar.elasticDistance=value ? 200 :0;
  7735. }
  7736. if (this._hScrollBar){
  7737. this._hScrollBar.elasticDistance=value ? 200 :0;
  7738. }
  7739. });
  7740. return Panel;
  7741. })(Box)
  7742. /**
  7743. *<code>List</code> 控件可显示项目列表。默认为垂直方向列表。可通过UI编辑器自定义列表。
  7744. *
  7745. *@example <caption>以下示例代码,创建了一个 <code>List</code> 实例。</caption>
  7746. *package
  7747. *{
  7748. *import laya.ui.List;
  7749. *import laya.utils.Handler;
  7750. *public class List_Example
  7751. *{
  7752. *public function List_Example()
  7753. *{
  7754. *Laya.init(640,800,"false");//设置游戏画布宽高、渲染模式。
  7755. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  7756. *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"],Handler.create(this,onLoadComplete));
  7757. *}
  7758. *private function onLoadComplete():void
  7759. *{
  7760. *var arr:Array=[];//创建一个数组,用于存贮列表的数据信息。
  7761. *for (var i:int=0;i &lt;20;i++)
  7762. *{
  7763. *arr.push({label:"item"+i});
  7764. *}
  7765. *var list:List=new List();//创建一个 List 类的实例对象 list 。
  7766. *list.itemRender=Item;//设置 list 的单元格渲染器。
  7767. *list.repeatX=1;//设置 list 的水平方向单元格数量。
  7768. *list.repeatY=10;//设置 list 的垂直方向单元格数量。
  7769. *list.vScrollBarSkin="resource/ui/vscroll.png";//设置 list 的垂直方向滚动条皮肤。
  7770. *list.array=arr;//设置 list 的列表数据源。
  7771. *list.pos(100,100);//设置 list 的位置。
  7772. *list.selectEnable=true;//设置 list 可选。
  7773. *list.selectHandler=new Handler(this,onSelect);//设置 list 改变选择项执行的处理器。
  7774. *Laya.stage.addChild(list);//将 list 添加到显示列表。
  7775. *}
  7776. *private function onSelect(index:int):void
  7777. *{
  7778. *trace("当前选择的项目索引: index= ",index);
  7779. *}
  7780. *}
  7781. *}
  7782. *import laya.ui.Box;
  7783. *import laya.ui.Label;
  7784. *class Item extends Box
  7785. *{
  7786. *public function Item()
  7787. *{
  7788. *graphics.drawRect(0,0,100,20,null,"#ff0000");
  7789. *var label:Label=new Label();
  7790. *label.text="100000";
  7791. *label.name="label";//设置 label 的name属性值。
  7792. *label.size(100,20);
  7793. *addChild(label);
  7794. *}
  7795. *}
  7796. *@example
  7797. *(function (_super){
  7798. *function Item(){
  7799. *Item.__super.call(this);//初始化父类
  7800. *this.graphics.drawRect(0,0,100,20,"#ff0000");
  7801. *var label=new laya.ui.Label();//创建一个 Label 类的实例对象 label 。
  7802. *label.text="100000";//设置 label 的文本内容。
  7803. *label.name="label";//设置 label 的name属性值。
  7804. *label.size(100,20);//设置 label 的宽度、高度。
  7805. *this.addChild(label);//将 label 添加到显示列表。
  7806. *};
  7807. *Laya.class(Item,"mypackage.listExample.Item",_super);//注册类 Item 。
  7808. *})(laya.ui.Box);
  7809. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  7810. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  7811. *var res=["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"];
  7812. *Laya.loader.load(res,new laya.utils.Handler(this,onLoadComplete));//加载资源。
  7813. *function onLoadComplete(){
  7814. *var arr=[];//创建一个数组,用于存贮列表的数据信息。
  7815. *for (var i=0;i &lt;20;i++){
  7816. *arr.push({label:"item"+i});
  7817. *}
  7818. *var list=new laya.ui.List();//创建一个 List 类的实例对象 list 。
  7819. *list.itemRender=mypackage.listExample.Item;//设置 list 的单元格渲染器。
  7820. *list.repeatX=1;//设置 list 的水平方向单元格数量。
  7821. *list.repeatY=10;//设置 list 的垂直方向单元格数量。
  7822. *list.vScrollBarSkin="resource/ui/vscroll.png";//设置 list 的垂直方向滚动条皮肤。
  7823. *list.array=arr;//设置 list 的列表数据源。
  7824. *list.pos(100,100);//设置 list 的位置。
  7825. *list.selectEnable=true;//设置 list 可选。
  7826. *list.selectHandler=new laya.utils.Handler(this,onSelect);//设置 list 改变选择项执行的处理器。
  7827. *Laya.stage.addChild(list);//将 list 添加到显示列表。
  7828. *}
  7829. *function onSelect(index)
  7830. *{
  7831. *console.log("当前选择的项目索引: index= ",index);
  7832. *}
  7833. *
  7834. *@example
  7835. *import List=laya.ui.List;
  7836. *import Handler=laya.utils.Handler;
  7837. *public class List_Example {
  7838. *public List_Example(){
  7839. *Laya.init(640,800);//设置游戏画布宽高。
  7840. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  7841. *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"],Handler.create(this,this.onLoadComplete));
  7842. *}
  7843. *private onLoadComplete():void {
  7844. *var arr=[];//创建一个数组,用于存贮列表的数据信息。
  7845. *for (var i:number=0;i &lt;20;i++)
  7846. *{
  7847. *arr.push({label:"item"+i });
  7848. *}
  7849. *var list:List=new List();//创建一个 List 类的实例对象 list 。
  7850. *list.itemRender=Item;//设置 list 的单元格渲染器。
  7851. *list.repeatX=1;//设置 list 的水平方向单元格数量。
  7852. *list.repeatY=10;//设置 list 的垂直方向单元格数量。
  7853. *list.vScrollBarSkin="resource/ui/vscroll.png";//设置 list 的垂直方向滚动条皮肤。
  7854. *list.array=arr;//设置 list 的列表数据源。
  7855. *list.pos(100,100);//设置 list 的位置。
  7856. *list.selectEnable=true;//设置 list 可选。
  7857. *list.selectHandler=new Handler(this,this.onSelect);//设置 list 改变选择项执行的处理器。
  7858. *Laya.stage.addChild(list);//将 list 添加到显示列表。
  7859. *}
  7860. *private onSelect(index:number):void {
  7861. *console.log("当前选择的项目索引: index= ",index);
  7862. *}
  7863. *}
  7864. *import Box=laya.ui.Box;
  7865. *import Label=laya.ui.Label;
  7866. *class Item extends Box {
  7867. *constructor(){
  7868. *this.graphics.drawRect(0,0,100,20,null,"#ff0000");
  7869. *var label:Label=new Label();
  7870. *label.text="100000";
  7871. *label.name="label";//设置 label 的name属性值。
  7872. *label.size(100,20);
  7873. *this.addChild(label);
  7874. *}
  7875. *}
  7876. */
  7877. //class laya.ui.List extends laya.ui.Box
  7878. var List=(function(_super){
  7879. function List(){
  7880. /**改变 <code>List</code> 的选择项时执行的处理器,(默认返回参数: 项索引(index:int))。*/
  7881. this.selectHandler=null;
  7882. /**单元格渲染处理器(默认返回参数cell:Box,index:int)。*/
  7883. this.renderHandler=null;
  7884. /**单元格鼠标事件处理器(默认返回参数e:Event,index:int)。*/
  7885. this.mouseHandler=null;
  7886. /**指定是否可以选择,若值为true则可以选择,否则不可以选择。 @default false*/
  7887. this.selectEnable=false;
  7888. /**最大分页数。*/
  7889. this.totalPage=0;
  7890. /**@private */
  7891. this._$componentType="List";
  7892. /**@private */
  7893. this._content=null;
  7894. /**@private */
  7895. this._scrollBar=null;
  7896. /**@private */
  7897. this._itemRender=null;
  7898. /**@private */
  7899. this._repeatX=0;
  7900. /**@private */
  7901. this._repeatY=0;
  7902. /**@private */
  7903. this._repeatX2=0;
  7904. /**@private */
  7905. this._repeatY2=0;
  7906. /**@private */
  7907. this._spaceX=0;
  7908. /**@private */
  7909. this._spaceY=0;
  7910. /**@private */
  7911. this._array=null;
  7912. /**@private */
  7913. this._startIndex=0;
  7914. /**@private */
  7915. this._selectedIndex=-1;
  7916. /**@private */
  7917. this._page=0;
  7918. /**@private */
  7919. this._isVertical=true;
  7920. /**@private */
  7921. this._cellSize=20;
  7922. /**@private */
  7923. this._cellOffset=0;
  7924. /**@private */
  7925. this._isMoved=false;
  7926. /**是否缓存内容,如果数据源较少,并且list内无动画,设置此属性为true能大大提高性能 */
  7927. this.cacheContent=false;
  7928. /**@private */
  7929. this._createdLine=0;
  7930. /**@private */
  7931. this._cellChanged=false;
  7932. /**@private */
  7933. this._usedCache=null;
  7934. /**@private */
  7935. this._elasticEnabled=false;
  7936. this._preLen=0;
  7937. List.__super.call(this);
  7938. this._cells=[];
  7939. this._offset=new Point();
  7940. }
  7941. __class(List,'laya.ui.List',_super);
  7942. var __proto=List.prototype;
  7943. Laya.imps(__proto,{"laya.ui.IRender":true,"laya.ui.IItem":true})
  7944. /**@inheritDoc */
  7945. __proto.destroy=function(destroyChild){
  7946. (destroyChild===void 0)&& (destroyChild=true);
  7947. this._content && this._content.destroy(destroyChild);
  7948. this._scrollBar && this._scrollBar.destroy(destroyChild);
  7949. laya.ui.UIComponent.prototype.destroy.call(this,destroyChild);
  7950. this._content=null;
  7951. this._scrollBar=null;
  7952. this._itemRender=null;
  7953. this._cells=null;
  7954. this._array=null;
  7955. this.selectHandler=this.renderHandler=this.mouseHandler=null;
  7956. }
  7957. /**@inheritDoc */
  7958. __proto.createChildren=function(){
  7959. this.addChild(this._content=new Box());
  7960. }
  7961. __proto.onScrollStart=function(){
  7962. this._usedCache || (this._usedCache=Laya.superGet(Box,this,'cacheAs'));
  7963. Laya.superSet(Box,this,'cacheAs',"none");
  7964. this._scrollBar.once(/*laya.events.Event.END*/"end",this,this.onScrollEnd);
  7965. }
  7966. __proto.onScrollEnd=function(){
  7967. Laya.superSet(Box,this,'cacheAs',this._usedCache);
  7968. }
  7969. __proto._removePreScrollBar=function(){
  7970. var preNode=this.removeChildByName("scrollBar");
  7971. if (preNode)preNode.destroy(true);
  7972. }
  7973. /**
  7974. *@private
  7975. *更改单元格的信息。
  7976. *@internal 在此销毁、创建单元格,并设置单元格的位置等属性。相当于此列表内容发送改变时调用此函数。
  7977. */
  7978. __proto.changeCells=function(){
  7979. this._cellChanged=false;
  7980. if (this._itemRender){
  7981. this.scrollBar=this.getChildByName("scrollBar");
  7982. var cell=this._getOneCell();
  7983. var cellWidth=(cell.width+this._spaceX)|| 1;
  7984. var cellHeight=(cell.height+this._spaceY)|| 1;
  7985. if (this._width > 0)this._repeatX2=this._isVertical ? Math.round(this._width / cellWidth):Math.ceil(this._width / cellWidth);
  7986. if (this._height > 0)this._repeatY2=this._isVertical ? Math.ceil(this._height / cellHeight):Math.round(this._height / cellHeight);
  7987. var listWidth=this._width ? this._width :(cellWidth *this.repeatX-this._spaceX);
  7988. var listHeight=this._height ? this._height :(cellHeight *this.repeatY-this._spaceY);
  7989. this._cellSize=this._isVertical ? cellHeight :cellWidth;
  7990. this._cellOffset=this._isVertical ? (cellHeight *Math.max(this._repeatY2,this._repeatY)-listHeight-this._spaceY):(cellWidth *Math.max(this._repeatX2,this._repeatX)-listWidth-this._spaceX);
  7991. if (this._isVertical && this.vScrollBarSkin)this._scrollBar.height=listHeight;
  7992. else if (!this._isVertical && this.hScrollBarSkin)this._scrollBar.width=listWidth;
  7993. this.setContentSize(listWidth,listHeight);
  7994. var numX=this._isVertical ? this.repeatX :this.repeatY;
  7995. var numY=(this._isVertical ? this.repeatY :this.repeatX)+(this._scrollBar ? 1 :0);
  7996. this._createItems(0,numX,numY);
  7997. this._createdLine=numY;
  7998. if (this._array){
  7999. this.array=this._array;
  8000. this.runCallLater(this.renderItems);
  8001. }
  8002. }
  8003. }
  8004. __proto._getOneCell=function(){
  8005. if (this._cells.length===0){
  8006. var item=this.createItem();
  8007. this._offset.setTo(item._x,item._y);
  8008. if (this.cacheContent)return item;
  8009. this._cells.push(item);
  8010. }
  8011. return this._cells[0];
  8012. }
  8013. __proto._createItems=function(startY,numX,numY){
  8014. var box=this._content;
  8015. var cell=this._getOneCell();
  8016. var cellWidth=cell.width+this._spaceX;
  8017. var cellHeight=cell.height+this._spaceY;
  8018. if (this.cacheContent){
  8019. var cacheBox=new Box();
  8020. cacheBox.cacheAs="normal";
  8021. cacheBox.pos((this._isVertical ? 0 :startY)*cellWidth,(this._isVertical ? startY :0)*cellHeight);
  8022. this._content.addChild(cacheBox);
  8023. box=cacheBox;
  8024. }else {
  8025. var arr=[];
  8026. for (var i=this._cells.length-1;i >-1;i--){
  8027. var item=this._cells[i];
  8028. item.removeSelf();
  8029. arr.push(item);
  8030. }
  8031. this._cells.length=0;
  8032. }
  8033. for (var k=startY;k < numY;k++){
  8034. for (var l=0;l < numX;l++){
  8035. if (arr && arr.length){
  8036. cell=arr.pop();
  8037. }else {
  8038. cell=this.createItem();
  8039. }
  8040. cell.x=(this._isVertical ? l :k)*cellWidth-box._x;
  8041. cell.y=(this._isVertical ? k :l)*cellHeight-box._y;
  8042. cell.name="item"+(k *numX+l);
  8043. box.addChild(cell);
  8044. this.addCell(cell);
  8045. }
  8046. }
  8047. }
  8048. __proto.createItem=function(){
  8049. var arr=[];
  8050. if ((typeof this._itemRender=='function')){
  8051. var box=new this._itemRender();
  8052. }else {
  8053. box=SceneUtils.createComp(this._itemRender,null,null,arr)
  8054. }
  8055. if (arr.length==0 && box["_watchMap"]){
  8056. var watchMap=box["_watchMap"];
  8057. for (var name in watchMap){
  8058. var a=watchMap[name];
  8059. for (var i=0;i < a.length;i++){
  8060. var watcher=a[i];
  8061. arr.push(watcher.comp,watcher.prop,watcher.value)
  8062. }
  8063. }
  8064. }
  8065. if (arr.length)box["_$bindData"]=arr;
  8066. return box;
  8067. }
  8068. /**
  8069. *@private
  8070. *添加单元格。
  8071. *@param cell 需要添加的单元格对象。
  8072. */
  8073. __proto.addCell=function(cell){
  8074. cell.on(/*laya.events.Event.CLICK*/"click",this,this.onCellMouse);
  8075. cell.on(/*laya.events.Event.RIGHT_CLICK*/"rightclick",this,this.onCellMouse);
  8076. cell.on(/*laya.events.Event.MOUSE_OVER*/"mouseover",this,this.onCellMouse);
  8077. cell.on(/*laya.events.Event.MOUSE_OUT*/"mouseout",this,this.onCellMouse);
  8078. cell.on(/*laya.events.Event.MOUSE_DOWN*/"mousedown",this,this.onCellMouse);
  8079. cell.on(/*laya.events.Event.MOUSE_UP*/"mouseup",this,this.onCellMouse);
  8080. this._cells.push(cell);
  8081. }
  8082. __proto._afterInited=function(){
  8083. this.initItems();
  8084. }
  8085. /**
  8086. *初始化单元格信息。
  8087. */
  8088. __proto.initItems=function(){
  8089. if (!this._itemRender && this.getChildByName("item0")!=null){
  8090. this.repeatX=1;
  8091. var count=0;
  8092. count=0;
  8093. for (var i=0;i < 10000;i++){
  8094. var cell=this.getChildByName("item"+i);
  8095. if (cell){
  8096. this.addCell(cell);
  8097. count++;
  8098. continue ;
  8099. }
  8100. break ;
  8101. }
  8102. this.repeatY=count;
  8103. }
  8104. }
  8105. /**
  8106. *设置可视区域大小。
  8107. *<p>以(0,0,width参数,height参数)组成的矩形区域为可视区域。</p>
  8108. *@param width 可视区域宽度。
  8109. *@param height 可视区域高度。
  8110. */
  8111. __proto.setContentSize=function(width,height){
  8112. this._content.width=width;
  8113. this._content.height=height;
  8114. if (this._scrollBar || this._offset.x !=0 || this._offset.y !=0){
  8115. this._content._style.scrollRect || (this._content.scrollRect=Rectangle.create());
  8116. this._content._style.scrollRect.setTo(-this._offset.x,-this._offset.y,width,height);
  8117. this._content.scrollRect=this._content.scrollRect;
  8118. }
  8119. this.event(/*laya.events.Event.RESIZE*/"resize");
  8120. }
  8121. /**
  8122. *@private
  8123. *单元格的鼠标事件侦听处理函数。
  8124. */
  8125. __proto.onCellMouse=function(e){
  8126. if (e.type===/*laya.events.Event.MOUSE_DOWN*/"mousedown")this._isMoved=false;
  8127. var cell=e.currentTarget;
  8128. var index=this._startIndex+this._cells.indexOf(cell);
  8129. if (index < 0)return;
  8130. if (e.type===/*laya.events.Event.CLICK*/"click" || e.type===/*laya.events.Event.RIGHT_CLICK*/"rightclick"){
  8131. if (this.selectEnable && !this._isMoved)this.selectedIndex=index;
  8132. else this.changeCellState(cell,true,0);
  8133. }else if ((e.type===/*laya.events.Event.MOUSE_OVER*/"mouseover" || e.type===/*laya.events.Event.MOUSE_OUT*/"mouseout")&& this._selectedIndex!==index){
  8134. this.changeCellState(cell,e.type===/*laya.events.Event.MOUSE_OVER*/"mouseover",0);
  8135. }
  8136. this.mouseHandler && this.mouseHandler.runWith([e,index]);
  8137. }
  8138. /**
  8139. *@private
  8140. *改变单元格的可视状态。
  8141. *@param cell 单元格对象。
  8142. *@param visable 是否显示。
  8143. *@param index 单元格的属性 <code>index</code> 值。
  8144. */
  8145. __proto.changeCellState=function(cell,visible,index){
  8146. var selectBox=cell.getChildByName("selectBox");
  8147. if (selectBox){
  8148. this.selectEnable=true;
  8149. selectBox.visible=visible;
  8150. selectBox.index=index;
  8151. }
  8152. }
  8153. /**@inheritDoc */
  8154. __proto._sizeChanged=function(){
  8155. laya.ui.UIComponent.prototype._sizeChanged.call(this);
  8156. this.setContentSize(this.width,this.height);
  8157. if (this._scrollBar)this.callLater(this.onScrollBarChange);
  8158. }
  8159. /**
  8160. *@private
  8161. *滚动条的 <code>Event.CHANGE</code> 事件侦听处理函数。
  8162. */
  8163. __proto.onScrollBarChange=function(e){
  8164. this.runCallLater(this.changeCells);
  8165. var scrollValue=this._scrollBar.value;
  8166. var lineX=(this._isVertical ? this.repeatX :this.repeatY);
  8167. var lineY=(this._isVertical ? this.repeatY :this.repeatX);
  8168. var scrollLine=Math.floor(scrollValue / this._cellSize);
  8169. if (!this.cacheContent){
  8170. var index=scrollLine *lineX;
  8171. var num=0;
  8172. if (index > this._startIndex){
  8173. num=index-this._startIndex;
  8174. var down=true;
  8175. var toIndex=this._startIndex+lineX *(lineY+1);
  8176. this._isMoved=true;
  8177. }else if (index < this._startIndex){
  8178. num=this._startIndex-index;
  8179. down=false;
  8180. toIndex=this._startIndex-1;
  8181. this._isMoved=true;
  8182. }
  8183. for (var i=0;i < num;i++){
  8184. if (down){
  8185. var cell=this._cells.shift();
  8186. this._cells[this._cells.length]=cell;
  8187. var cellIndex=toIndex+i;
  8188. }else {
  8189. cell=this._cells.pop();
  8190. this._cells.unshift(cell);
  8191. cellIndex=toIndex-i;
  8192. };
  8193. var pos=Math.floor(cellIndex / lineX)*this._cellSize;
  8194. this._isVertical ? cell.y=pos :cell.x=pos;
  8195. this.renderItem(cell,cellIndex);
  8196. }
  8197. this._startIndex=index;
  8198. this.changeSelectStatus();
  8199. }else {
  8200. num=(lineY+1);
  8201. if (this._createdLine-scrollLine < num){
  8202. this._createItems(this._createdLine,lineX,this._createdLine+num);
  8203. this.renderItems(this._createdLine *lineX,0);
  8204. this._createdLine+=num;
  8205. }
  8206. };
  8207. var r=this._content._style.scrollRect;
  8208. if (this._isVertical){
  8209. r.y=scrollValue-this._offset.y;
  8210. r.x=-this._offset.x;
  8211. }else {
  8212. r.y=-this._offset.y;
  8213. r.x=scrollValue-this._offset.x;
  8214. }
  8215. this._content.scrollRect=r;
  8216. }
  8217. __proto.posCell=function(cell,cellIndex){
  8218. if (!this._scrollBar)return;
  8219. var lineX=(this._isVertical ? this.repeatX :this.repeatY);
  8220. var lineY=(this._isVertical ? this.repeatY :this.repeatX);
  8221. var pos=Math.floor(cellIndex / lineX)*this._cellSize;
  8222. this._isVertical ? cell._y=pos :cell.x=pos;
  8223. }
  8224. /**
  8225. *@private
  8226. *改变单元格的选择状态。
  8227. */
  8228. __proto.changeSelectStatus=function(){
  8229. for (var i=0,n=this._cells.length;i < n;i++){
  8230. this.changeCellState(this._cells[i],this._selectedIndex===this._startIndex+i,1);
  8231. }
  8232. }
  8233. /**
  8234. *@private
  8235. *渲染单元格列表。
  8236. */
  8237. __proto.renderItems=function(from,to){
  8238. (from===void 0)&& (from=0);
  8239. (to===void 0)&& (to=0);
  8240. for (var i=from,n=to || this._cells.length;i < n;i++){
  8241. this.renderItem(this._cells[i],this._startIndex+i);
  8242. }
  8243. this.changeSelectStatus();
  8244. }
  8245. /**
  8246. *渲染一个单元格。
  8247. *@param cell 需要渲染的单元格对象。
  8248. *@param index 单元格索引。
  8249. */
  8250. __proto.renderItem=function(cell,index){
  8251. if (this._array && index >=0 && index < this._array.length){
  8252. cell.visible=true;
  8253. if (cell["_$bindData"]){
  8254. cell["_dataSource"]=this._array[index];
  8255. this._bindData(cell,this._array[index]);
  8256. }else cell.dataSource=this._array[index];
  8257. if (!this.cacheContent){
  8258. this.posCell(cell,index);
  8259. }
  8260. if (this.hasListener(/*laya.events.Event.RENDER*/"render"))this.event(/*laya.events.Event.RENDER*/"render",[cell,index]);
  8261. if (this.renderHandler)this.renderHandler.runWith([cell,index]);
  8262. }else {
  8263. cell.visible=false;
  8264. cell.dataSource=null;
  8265. }
  8266. }
  8267. __proto._bindData=function(cell,data){
  8268. var arr=cell._$bindData;
  8269. for (var i=0,n=arr.length;i < n;i++){
  8270. var ele=arr[i++];
  8271. var prop=arr[i++];
  8272. var value=arr[i];
  8273. var fun=UIUtils.getBindFun(value);
  8274. ele[prop]=fun.call(this,data);
  8275. }
  8276. }
  8277. /**
  8278. *更新数据源,不刷新list,只增加滚动长度
  8279. *@param array 数据源
  8280. */
  8281. __proto.updateArray=function(array){
  8282. this._array=array;
  8283. var freshStart=0;
  8284. if (this._array){
  8285. freshStart=this._preLen-this._startIndex;
  8286. if (freshStart >=0)
  8287. this.renderItems(freshStart);
  8288. this._preLen=this._array.length;
  8289. }
  8290. if (this._scrollBar){
  8291. var length=array.length;
  8292. var numX=this._isVertical ? this.repeatX :this.repeatY;
  8293. var numY=this._isVertical ? this.repeatY :this.repeatX;
  8294. var lineCount=Math.ceil(length / numX);
  8295. if (lineCount >=numY){
  8296. this._scrollBar.thumbPercent=numY / lineCount;
  8297. this._scrollBar.slider["_max"]=(lineCount-numY)*this._cellSize+this._cellOffset;
  8298. }
  8299. }
  8300. }
  8301. /**
  8302. *刷新列表数据源。
  8303. */
  8304. __proto.refresh=function(){
  8305. this.array=this._array;
  8306. }
  8307. /**
  8308. *获取单元格数据源。
  8309. *@param index 单元格索引。
  8310. */
  8311. __proto.getItem=function(index){
  8312. if (index >-1 && index < this._array.length){
  8313. return this._array[index];
  8314. }
  8315. return null;
  8316. }
  8317. /**
  8318. *修改单元格数据源。
  8319. *@param index 单元格索引。
  8320. *@param source 单元格数据源。
  8321. */
  8322. __proto.changeItem=function(index,source){
  8323. if (index >-1 && index < this._array.length){
  8324. this._array[index]=source;
  8325. if (index >=this._startIndex && index < this._startIndex+this._cells.length){
  8326. this.renderItem(this.getCell(index),index);
  8327. }
  8328. }
  8329. }
  8330. /**
  8331. *设置单元格数据源。
  8332. *@param index 单元格索引。
  8333. *@param source 单元格数据源。
  8334. */
  8335. __proto.setItem=function(index,source){
  8336. this.changeItem(index,source);
  8337. }
  8338. /**
  8339. *添加单元格数据源。
  8340. *@param souce 数据源。
  8341. */
  8342. __proto.addItem=function(souce){
  8343. this._array.push(souce);
  8344. this.array=this._array;
  8345. }
  8346. /**
  8347. *添加单元格数据源到对应的数据索引处。
  8348. *@param souce 单元格数据源。
  8349. *@param index 索引。
  8350. */
  8351. __proto.addItemAt=function(souce,index){
  8352. this._array.splice(index,0,souce);
  8353. this.array=this._array;
  8354. }
  8355. /**
  8356. *通过数据源索引删除单元格数据源。
  8357. *@param index 需要删除的数据源索引值。
  8358. */
  8359. __proto.deleteItem=function(index){
  8360. this._array.splice(index,1);
  8361. this.array=this._array;
  8362. }
  8363. /**
  8364. *通过可视单元格索引,获取单元格。
  8365. *@param index 可视单元格索引。
  8366. *@return 单元格对象。
  8367. */
  8368. __proto.getCell=function(index){
  8369. this.runCallLater(this.changeCells);
  8370. if (index >-1 && this._cells){
  8371. return this._cells[(index-this._startIndex)% this._cells.length];
  8372. }
  8373. return null;
  8374. }
  8375. /**
  8376. *<p>滚动列表,以设定的数据索引对应的单元格为当前可视列表的第一项。</p>
  8377. *@param index 单元格在数据列表中的索引。
  8378. */
  8379. __proto.scrollTo=function(index){
  8380. if (this._scrollBar){
  8381. var numX=this._isVertical ? this.repeatX :this.repeatY;
  8382. this._scrollBar.value=Math.floor(index / numX)*this._cellSize;
  8383. }else {
  8384. this.startIndex=index;
  8385. }
  8386. }
  8387. /**
  8388. *<p>缓动滚动列表,以设定的数据索引对应的单元格为当前可视列表的第一项。</p>
  8389. *@param index 单元格在数据列表中的索引。
  8390. *@param time 缓动时间。
  8391. *@param complete 缓动结束回掉
  8392. */
  8393. __proto.tweenTo=function(index,time,complete){
  8394. (time===void 0)&& (time=200);
  8395. if (this._scrollBar){
  8396. this._scrollBar.stopScroll();
  8397. var numX=this._isVertical ? this.repeatX :this.repeatY;
  8398. Tween.to(this._scrollBar,{value:Math.floor(index / numX)*this._cellSize},time,null,complete,0,true);
  8399. }else {
  8400. this.startIndex=index;
  8401. if (complete)complete.run();
  8402. }
  8403. }
  8404. /**@private */
  8405. __proto._setCellChanged=function(){
  8406. if (!this._cellChanged){
  8407. this._cellChanged=true;
  8408. this.callLater(this.changeCells);
  8409. }
  8410. }
  8411. __proto.commitMeasure=function(){
  8412. this.runCallLater(this.changeCells);
  8413. }
  8414. /**@inheritDoc */
  8415. __getset(0,__proto,'cacheAs',_super.prototype._$get_cacheAs,function(value){
  8416. Laya.superSet(Box,this,'cacheAs',value);
  8417. if (this._scrollBar){
  8418. this._usedCache=null;
  8419. if (value!=="none")this._scrollBar.on(/*laya.events.Event.START*/"start",this,this.onScrollStart);
  8420. else this._scrollBar.off(/*laya.events.Event.START*/"start",this,this.onScrollStart);
  8421. }
  8422. });
  8423. /**
  8424. *获取对 <code>List</code> 组件所包含的内容容器 <code>Box</code> 组件的引用。
  8425. */
  8426. __getset(0,__proto,'content',function(){
  8427. return this._content;
  8428. });
  8429. /**@inheritDoc */
  8430. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  8431. if (value !=this._height){
  8432. Laya.superSet(Box,this,'height',value);
  8433. this._setCellChanged();
  8434. }
  8435. });
  8436. /**
  8437. *单元格渲染器。
  8438. *<p><b>取值:</b>
  8439. *<ol>
  8440. *<li>单元格类对象。</li>
  8441. *<li> UI 的 JSON 描述。</li>
  8442. *</ol></p>
  8443. */
  8444. __getset(0,__proto,'itemRender',function(){
  8445. return this._itemRender;
  8446. },function(value){
  8447. if (this._itemRender !=value){
  8448. this._itemRender=value;
  8449. for (var i=this._cells.length-1;i >-1;i--){
  8450. this._cells[i].destroy();
  8451. }
  8452. this._cells.length=0;
  8453. this._setCellChanged();
  8454. }
  8455. });
  8456. /**
  8457. *垂直方向滚动条皮肤。
  8458. */
  8459. __getset(0,__proto,'vScrollBarSkin',function(){
  8460. return this._scrollBar ? this._scrollBar.skin :null;
  8461. },function(value){
  8462. this._removePreScrollBar();
  8463. var scrollBar=new VScrollBar();
  8464. scrollBar.name="scrollBar";
  8465. scrollBar.right=0;
  8466. scrollBar.skin=value;
  8467. scrollBar.elasticDistance=this._elasticEnabled ? 200 :0;
  8468. this.scrollBar=scrollBar;
  8469. this.addChild(scrollBar);
  8470. this._setCellChanged();
  8471. });
  8472. /**
  8473. *列表的当前页码。
  8474. */
  8475. __getset(0,__proto,'page',function(){
  8476. return this._page;
  8477. },function(value){
  8478. this._page=value
  8479. if (this._array){
  8480. this._page=value > 0 ? value :0;
  8481. this._page=this._page < this.totalPage ? this._page :this.totalPage-1;
  8482. this.startIndex=this._page *this.repeatX *this.repeatY;
  8483. }
  8484. });
  8485. /**
  8486. *水平方向滚动条皮肤。
  8487. */
  8488. __getset(0,__proto,'hScrollBarSkin',function(){
  8489. return this._scrollBar ? this._scrollBar.skin :null;
  8490. },function(value){
  8491. this._removePreScrollBar();
  8492. var scrollBar=new HScrollBar();
  8493. scrollBar.name="scrollBar";
  8494. scrollBar.bottom=0;
  8495. scrollBar.skin=value;
  8496. scrollBar.elasticDistance=this._elasticEnabled ? 200 :0;
  8497. this.scrollBar=scrollBar;
  8498. this.addChild(scrollBar);
  8499. this._setCellChanged();
  8500. });
  8501. /**
  8502. *水平方向显示的单元格数量。
  8503. */
  8504. __getset(0,__proto,'repeatX',function(){
  8505. return this._repeatX > 0 ? this._repeatX :this._repeatX2 > 0 ? this._repeatX2 :1;
  8506. },function(value){
  8507. this._repeatX=value;
  8508. this._setCellChanged();
  8509. });
  8510. /**
  8511. *获取对 <code>List</code> 组件所包含的滚动条 <code>ScrollBar</code> 组件的引用。
  8512. */
  8513. __getset(0,__proto,'scrollBar',function(){
  8514. return this._scrollBar;
  8515. },function(value){
  8516. if (this._scrollBar !=value){
  8517. this._scrollBar=value;
  8518. if (value){
  8519. this._isVertical=this._scrollBar.isVertical;
  8520. this.addChild(this._scrollBar);
  8521. this._scrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onScrollBarChange);
  8522. }
  8523. }
  8524. });
  8525. /**@inheritDoc */
  8526. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  8527. if (value !=this._width){
  8528. Laya.superSet(Box,this,'width',value);
  8529. this._setCellChanged();
  8530. }
  8531. });
  8532. /**
  8533. *垂直方向显示的单元格数量。
  8534. */
  8535. __getset(0,__proto,'repeatY',function(){
  8536. return this._repeatY > 0 ? this._repeatY :this._repeatY2 > 0 ? this._repeatY2 :1;
  8537. },function(value){
  8538. this._repeatY=value;
  8539. this._setCellChanged();
  8540. });
  8541. /**
  8542. *水平方向显示的单元格之间的间距(以像素为单位)。
  8543. */
  8544. __getset(0,__proto,'spaceX',function(){
  8545. return this._spaceX;
  8546. },function(value){
  8547. this._spaceX=value;
  8548. this._setCellChanged();
  8549. });
  8550. /**
  8551. *垂直方向显示的单元格之间的间距(以像素为单位)。
  8552. */
  8553. __getset(0,__proto,'spaceY',function(){
  8554. return this._spaceY;
  8555. },function(value){
  8556. this._spaceY=value;
  8557. this._setCellChanged();
  8558. });
  8559. /**
  8560. *表示当前选择的项索引。selectedIndex值更改会引起list重新渲染
  8561. */
  8562. __getset(0,__proto,'selectedIndex',function(){
  8563. return this._selectedIndex;
  8564. },function(value){
  8565. if (this._selectedIndex !=value){
  8566. this._selectedIndex=value;
  8567. this.changeSelectStatus();
  8568. this.event(/*laya.events.Event.CHANGE*/"change");
  8569. this.selectHandler && this.selectHandler.runWith(value);
  8570. this.startIndex=this._startIndex;
  8571. }
  8572. });
  8573. /**
  8574. *当前选中的单元格数据源。
  8575. */
  8576. __getset(0,__proto,'selectedItem',function(){
  8577. return this._selectedIndex !=-1 ? this._array[this._selectedIndex] :null;
  8578. },function(value){
  8579. this.selectedIndex=this._array.indexOf(value);
  8580. });
  8581. /**
  8582. *列表的数据总个数。
  8583. */
  8584. __getset(0,__proto,'length',function(){
  8585. return this._array ? this._array.length :0;
  8586. });
  8587. /**
  8588. *获取或设置当前选择的单元格对象。
  8589. */
  8590. __getset(0,__proto,'selection',function(){
  8591. return this.getCell(this._selectedIndex);
  8592. },function(value){
  8593. this.selectedIndex=this._startIndex+this._cells.indexOf(value);
  8594. });
  8595. /**
  8596. *当前显示的单元格列表的开始索引。
  8597. */
  8598. __getset(0,__proto,'startIndex',function(){
  8599. return this._startIndex;
  8600. },function(value){
  8601. this._startIndex=value > 0 ? value :0;
  8602. this.callLater(this.renderItems);
  8603. });
  8604. /**
  8605. *列表数据源。
  8606. */
  8607. __getset(0,__proto,'array',function(){
  8608. return this._array;
  8609. },function(value){
  8610. this.runCallLater(this.changeCells);
  8611. this._array=value || [];
  8612. this._preLen=this._array.length;
  8613. var length=this._array.length;
  8614. this.totalPage=Math.ceil(length / (this.repeatX *this.repeatY));
  8615. this._selectedIndex=this._selectedIndex < length ? this._selectedIndex :length-1;
  8616. this.startIndex=this._startIndex;
  8617. if (this._scrollBar){
  8618. this._scrollBar.stopScroll();
  8619. var numX=this._isVertical ? this.repeatX :this.repeatY;
  8620. var numY=this._isVertical ? this.repeatY :this.repeatX;
  8621. var lineCount=Math.ceil(length / numX);
  8622. var total=this._cellOffset > 0 ? this.totalPage+1 :this.totalPage;
  8623. if (total > 1 && lineCount >=numY){
  8624. this._scrollBar.scrollSize=this._cellSize;
  8625. this._scrollBar.thumbPercent=numY / lineCount;
  8626. this._scrollBar.setScroll(0,(lineCount-numY)*this._cellSize+this._cellOffset,this._scrollBar.value);
  8627. this._scrollBar.target=this._content;
  8628. }else {
  8629. this._scrollBar.setScroll(0,0,0);
  8630. this._scrollBar.target=this._content;
  8631. }
  8632. }
  8633. });
  8634. /**@inheritDoc */
  8635. __getset(0,__proto,'dataSource',_super.prototype._$get_dataSource,function(value){
  8636. this._dataSource=value;
  8637. if (((typeof value=='number')&& Math.floor(value)==value)|| (typeof value=='string'))this.selectedIndex=parseInt(value);
  8638. else if ((value instanceof Array))this.array=value
  8639. else Laya.superSet(Box,this,'dataSource',value);
  8640. });
  8641. /**
  8642. *单元格集合。
  8643. */
  8644. __getset(0,__proto,'cells',function(){
  8645. this.runCallLater(this.changeCells);
  8646. return this._cells;
  8647. });
  8648. /**是否开启橡皮筋效果*/
  8649. __getset(0,__proto,'elasticEnabled',function(){
  8650. return this._elasticEnabled;
  8651. },function(value){
  8652. this._elasticEnabled=value;
  8653. if (this._scrollBar){
  8654. this._scrollBar.elasticDistance=value?200:0;
  8655. }
  8656. });
  8657. return List;
  8658. })(Box)
  8659. /**
  8660. *<code>TextInput</code> 类用于创建显示对象以显示和输入文本。
  8661. *
  8662. *@example <caption>以下示例代码,创建了一个 <code>TextInput</code> 实例。</caption>
  8663. *package
  8664. *{
  8665. *import laya.display.Stage;
  8666. *import laya.ui.TextInput;
  8667. *import laya.utils.Handler;
  8668. *public class TextInput_Example
  8669. *{
  8670. *public function TextInput_Example()
  8671. *{
  8672. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  8673. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  8674. *Laya.loader.load(["resource/ui/input.png"],Handler.create(this,onLoadComplete));//加载资源。
  8675. *}
  8676. *private function onLoadComplete():void
  8677. *{
  8678. *var textInput:TextInput=new TextInput("这是一个TextInput实例。");//创建一个 TextInput 类的实例对象 textInput 。
  8679. *textInput.skin="resource/ui/input.png";//设置 textInput 的皮肤。
  8680. *textInput.sizeGrid="4,4,4,4";//设置 textInput 的网格信息。
  8681. *textInput.color="#008fff";//设置 textInput 的文本颜色。
  8682. *textInput.font="Arial";//设置 textInput 的文本字体。
  8683. *textInput.bold=true;//设置 textInput 的文本显示为粗体。
  8684. *textInput.fontSize=30;//设置 textInput 的字体大小。
  8685. *textInput.wordWrap=true;//设置 textInput 的文本自动换行。
  8686. *textInput.x=100;//设置 textInput 对象的属性 x 的值,用于控制 textInput 对象的显示位置。
  8687. *textInput.y=100;//设置 textInput 对象的属性 y 的值,用于控制 textInput 对象的显示位置。
  8688. *textInput.width=300;//设置 textInput 的宽度。
  8689. *textInput.height=200;//设置 textInput 的高度。
  8690. *Laya.stage.addChild(textInput);//将 textInput 添加到显示列表。
  8691. *}
  8692. *}
  8693. *}
  8694. *@example
  8695. *Laya.init(640,800);//设置游戏画布宽高
  8696. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  8697. *Laya.loader.load(["resource/ui/input.png"],laya.utils.Handler.create(this,onLoadComplete));//加载资源。
  8698. *function onLoadComplete(){
  8699. *var textInput=new laya.ui.TextInput("这是一个TextInput实例。");//创建一个 TextInput 类的实例对象 textInput 。
  8700. *textInput.skin="resource/ui/input.png";//设置 textInput 的皮肤。
  8701. *textInput.sizeGrid="4,4,4,4";//设置 textInput 的网格信息。
  8702. *textInput.color="#008fff";//设置 textInput 的文本颜色。
  8703. *textInput.font="Arial";//设置 textInput 的文本字体。
  8704. *textInput.bold=true;//设置 textInput 的文本显示为粗体。
  8705. *textInput.fontSize=30;//设置 textInput 的字体大小。
  8706. *textInput.wordWrap=true;//设置 textInput 的文本自动换行。
  8707. *textInput.x=100;//设置 textInput 对象的属性 x 的值,用于控制 textInput 对象的显示位置。
  8708. *textInput.y=100;//设置 textInput 对象的属性 y 的值,用于控制 textInput 对象的显示位置。
  8709. *textInput.width=300;//设置 textInput 的宽度。
  8710. *textInput.height=200;//设置 textInput 的高度。
  8711. *Laya.stage.addChild(textInput);//将 textInput 添加到显示列表。
  8712. *}
  8713. *@example
  8714. *import Stage=laya.display.Stage;
  8715. *import TextInput=laya.ui.TextInput;
  8716. *import Handler=laya.utils.Handler;
  8717. *class TextInput_Example {
  8718. *constructor(){
  8719. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  8720. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  8721. *Laya.loader.load(["resource/ui/input.png"],Handler.create(this,this.onLoadComplete));//加载资源。
  8722. *}
  8723. *private onLoadComplete():void {
  8724. *var textInput:TextInput=new TextInput("这是一个TextInput实例。");//创建一个 TextInput 类的实例对象 textInput 。
  8725. *textInput.skin="resource/ui/input.png";//设置 textInput 的皮肤。
  8726. *textInput.sizeGrid="4,4,4,4";//设置 textInput 的网格信息。
  8727. *textInput.color="#008fff";//设置 textInput 的文本颜色。
  8728. *textInput.font="Arial";//设置 textInput 的文本字体。
  8729. *textInput.bold=true;//设置 textInput 的文本显示为粗体。
  8730. *textInput.fontSize=30;//设置 textInput 的字体大小。
  8731. *textInput.wordWrap=true;//设置 textInput 的文本自动换行。
  8732. *textInput.x=100;//设置 textInput 对象的属性 x 的值,用于控制 textInput 对象的显示位置。
  8733. *textInput.y=100;//设置 textInput 对象的属性 y 的值,用于控制 textInput 对象的显示位置。
  8734. *textInput.width=300;//设置 textInput 的宽度。
  8735. *textInput.height=200;//设置 textInput 的高度。
  8736. *Laya.stage.addChild(textInput);//将 textInput 添加到显示列表。
  8737. *}
  8738. *}
  8739. */
  8740. //class laya.ui.TextInput extends laya.ui.Label
  8741. var TextInput=(function(_super){
  8742. function TextInput(text){
  8743. /**@private */
  8744. this._bg=null;
  8745. /**@private */
  8746. this._skin=null;
  8747. TextInput.__super.call(this);
  8748. (text===void 0)&& (text="");
  8749. this.text=text;
  8750. this.skin=this.skin;
  8751. }
  8752. __class(TextInput,'laya.ui.TextInput',_super);
  8753. var __proto=TextInput.prototype;
  8754. /**@inheritDoc */
  8755. __proto.preinitialize=function(){
  8756. this.mouseEnabled=true;
  8757. }
  8758. /**@inheritDoc */
  8759. __proto.destroy=function(destroyChild){
  8760. (destroyChild===void 0)&& (destroyChild=true);
  8761. _super.prototype.destroy.call(this,destroyChild);
  8762. this._bg && this._bg.destroy();
  8763. this._bg=null;
  8764. }
  8765. /**@inheritDoc */
  8766. __proto.createChildren=function(){
  8767. this.addChild(this._tf=new Input());
  8768. this._tf.padding=Styles.inputLabelPadding;
  8769. this._tf.on(/*laya.events.Event.INPUT*/"input",this,this._onInput);
  8770. this._tf.on(/*laya.events.Event.ENTER*/"enter",this,this._onEnter);
  8771. this._tf.on(/*laya.events.Event.BLUR*/"blur",this,this._onBlur);
  8772. this._tf.on(/*laya.events.Event.FOCUS*/"focus",this,this._onFocus);
  8773. }
  8774. /**
  8775. *@private
  8776. */
  8777. __proto._onFocus=function(){
  8778. this.event(/*laya.events.Event.FOCUS*/"focus",this);
  8779. }
  8780. /**
  8781. *@private
  8782. */
  8783. __proto._onBlur=function(){
  8784. this.event(/*laya.events.Event.BLUR*/"blur",this);
  8785. }
  8786. /**
  8787. *@private
  8788. */
  8789. __proto._onInput=function(){
  8790. this.event(/*laya.events.Event.INPUT*/"input",this);
  8791. }
  8792. /**
  8793. *@private
  8794. */
  8795. __proto._onEnter=function(){
  8796. this.event(/*laya.events.Event.ENTER*/"enter",this);
  8797. }
  8798. /**@inheritDoc */
  8799. __proto.initialize=function(){
  8800. this.width=128;
  8801. this.height=22;
  8802. }
  8803. __proto._skinLoaded=function(){
  8804. this._bg || (this.graphics=this._bg=new AutoBitmap());
  8805. this._bg.source=Loader.getRes(this._skin);
  8806. this._width && (this._bg.width=this._width);
  8807. this._height && (this._bg.height=this._height);
  8808. this._sizeChanged();
  8809. this.event(/*laya.events.Event.LOADED*/"loaded");
  8810. }
  8811. /**选中输入框内的文本。*/
  8812. __proto.select=function(){
  8813. (this._tf).select();
  8814. }
  8815. __proto.setSelection=function(startIndex,endIndex){
  8816. (this._tf).setSelection(startIndex,endIndex);
  8817. }
  8818. /**
  8819. *当前文本内容字符串。
  8820. *@see laya.display.Text.text
  8821. */
  8822. __getset(0,__proto,'text',_super.prototype._$get_text,function(value){
  8823. if (this._tf.text !=value){
  8824. value=value+"";
  8825. this._tf.text=value;
  8826. this.event(/*laya.events.Event.CHANGE*/"change");
  8827. }
  8828. });
  8829. /**
  8830. *表示此对象包含的文本背景 <code>AutoBitmap</code> 组件实例。
  8831. */
  8832. __getset(0,__proto,'bg',function(){
  8833. return this._bg;
  8834. },function(value){
  8835. this.graphics=this._bg=value;
  8836. });
  8837. /**
  8838. *<p>指示当前是否是文本域。</p>
  8839. *值为true表示当前是文本域,否则不是文本域。
  8840. */
  8841. __getset(0,__proto,'multiline',function(){
  8842. return (this._tf).multiline;
  8843. },function(value){
  8844. (this._tf).multiline=value;
  8845. });
  8846. /**
  8847. *@copy laya.ui.Image#skin
  8848. */
  8849. __getset(0,__proto,'skin',function(){
  8850. return this._skin;
  8851. },function(value){
  8852. if (this._skin !=value){
  8853. this._skin=value;
  8854. if (this._skin&&!Loader.getRes(this._skin)){
  8855. Laya.loader.load(this._skin,Handler.create(this,this._skinLoaded),null,/*laya.net.Loader.IMAGE*/"image",1);
  8856. }else{
  8857. this._skinLoaded();
  8858. }
  8859. }
  8860. });
  8861. /**
  8862. *<p>当前实例的背景图( <code>AutoBitmap</code> )实例的有效缩放网格数据。</p>
  8863. *<p>数据格式:"上边距,右边距,下边距,左边距,是否重复填充(值为0:不重复填充,1:重复填充)",以逗号分隔。
  8864. *<ul><li>例如:"4,4,4,4,1"</li></ul></p>
  8865. *@see laya.ui.AutoBitmap.sizeGrid
  8866. */
  8867. __getset(0,__proto,'sizeGrid',function(){
  8868. return this._bg && this._bg.sizeGrid ? this._bg.sizeGrid.join(","):null;
  8869. },function(value){
  8870. this._bg || (this.graphics=this._bg=new AutoBitmap());
  8871. this._bg.sizeGrid=UIUtils.fillArray(Styles.defaultSizeGrid,value,Number);
  8872. });
  8873. /**@inheritDoc */
  8874. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  8875. Laya.superSet(Label,this,'width',value);
  8876. this._bg && (this._bg.width=value);
  8877. });
  8878. /**@inheritDoc */
  8879. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  8880. Laya.superSet(Label,this,'height',value);
  8881. this._bg && (this._bg.height=value);
  8882. });
  8883. /**
  8884. *设置可编辑状态。
  8885. */
  8886. __getset(0,__proto,'editable',function(){
  8887. return (this._tf).editable;
  8888. },function(value){
  8889. (this._tf).editable=value;
  8890. });
  8891. /**限制输入的字符。*/
  8892. __getset(0,__proto,'restrict',function(){
  8893. return (this._tf).restrict;
  8894. },function(pattern){
  8895. (this._tf).restrict=pattern;
  8896. });
  8897. /**
  8898. *@copy laya.display.Input#prompt
  8899. */
  8900. __getset(0,__proto,'prompt',function(){
  8901. return (this._tf).prompt;
  8902. },function(value){
  8903. (this._tf).prompt=value;
  8904. });
  8905. /**
  8906. *@copy laya.display.Input#promptColor
  8907. */
  8908. __getset(0,__proto,'promptColor',function(){
  8909. return (this._tf).promptColor;
  8910. },function(value){
  8911. (this._tf).promptColor=value;
  8912. });
  8913. /**
  8914. *@copy laya.display.Input#maxChars
  8915. */
  8916. __getset(0,__proto,'maxChars',function(){
  8917. return (this._tf).maxChars;
  8918. },function(value){
  8919. (this._tf).maxChars=value;
  8920. });
  8921. /**
  8922. *@copy laya.display.Input#focus
  8923. */
  8924. __getset(0,__proto,'focus',function(){
  8925. return (this._tf).focus;
  8926. },function(value){
  8927. (this._tf).focus=value;
  8928. });
  8929. /**
  8930. *@copy laya.display.Input#type
  8931. */
  8932. __getset(0,__proto,'type',function(){
  8933. return (this._tf).type;
  8934. },function(value){
  8935. (this._tf).type=value;
  8936. });
  8937. return TextInput;
  8938. })(Label)
  8939. /**
  8940. *自适应缩放容器,容器设置大小后,容器大小始终保持stage大小,子内容按照原始最小宽高比缩放
  8941. */
  8942. //class laya.ui.ScaleBox extends laya.ui.Box
  8943. var ScaleBox=(function(_super){
  8944. function ScaleBox(){
  8945. this._oldW=0;
  8946. this._oldH=0;
  8947. ScaleBox.__super.call(this);
  8948. }
  8949. __class(ScaleBox,'laya.ui.ScaleBox',_super);
  8950. var __proto=ScaleBox.prototype;
  8951. __proto.onEnable=function(){
  8952. Laya.stage.on("resize",this,this.onResize);
  8953. this.onResize();
  8954. }
  8955. __proto.onDisable=function(){
  8956. Laya.stage.off("resize",this,this.onResize);
  8957. }
  8958. __proto.onResize=function(){
  8959. if (this.width > 0 && this.height > 0){
  8960. var scale=Math.min(Laya.stage.width / this._oldW,Laya.stage.height / this._oldH);
  8961. Laya.superSet(Box,this,'width',Laya.stage.width);
  8962. Laya.superSet(Box,this,'height',Laya.stage.height);
  8963. this.scale(scale,scale);
  8964. }
  8965. }
  8966. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  8967. Laya.superSet(Box,this,'width',value);
  8968. this._oldW=value;
  8969. });
  8970. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  8971. Laya.superSet(Box,this,'height',value);
  8972. this._oldH=value;
  8973. });
  8974. return ScaleBox;
  8975. })(Box)
  8976. /**
  8977. *<code>Radio</code> 控件使用户可在一组互相排斥的选择中做出一种选择。
  8978. *用户一次只能选择 <code>Radio</code> 组中的一个成员。选择未选中的组成员将取消选择该组中当前所选的 <code>Radio</code> 控件。
  8979. *@see laya.ui.RadioGroup
  8980. */
  8981. //class laya.ui.Radio extends laya.ui.Button
  8982. var Radio=(function(_super){
  8983. function Radio(skin,label){
  8984. /**@private */
  8985. this._value=null;
  8986. (label===void 0)&& (label="");
  8987. Radio.__super.call(this,skin,label);
  8988. }
  8989. __class(Radio,'laya.ui.Radio',_super);
  8990. var __proto=Radio.prototype;
  8991. /**@inheritDoc */
  8992. __proto.destroy=function(destroyChild){
  8993. (destroyChild===void 0)&& (destroyChild=true);
  8994. _super.prototype.destroy.call(this,destroyChild);
  8995. this._value=null;
  8996. }
  8997. /**@inheritDoc */
  8998. __proto.preinitialize=function(){
  8999. laya.ui.UIComponent.prototype.preinitialize.call(this);
  9000. this.toggle=false;
  9001. this._autoSize=false;
  9002. }
  9003. /**@inheritDoc */
  9004. __proto.initialize=function(){
  9005. _super.prototype.initialize.call(this);
  9006. this.createText();
  9007. this._text.align="left";
  9008. this._text.valign="top";
  9009. this._text.width=0;
  9010. this.on(/*laya.events.Event.CLICK*/"click",this,this.onClick);
  9011. }
  9012. /**
  9013. *@private
  9014. *对象的<code>Event.CLICK</code>事件侦听处理函数。
  9015. */
  9016. __proto.onClick=function(e){
  9017. this.selected=true;
  9018. }
  9019. /**
  9020. *获取或设置 <code>Radio</code> 关联的可选用户定义值。
  9021. */
  9022. __getset(0,__proto,'value',function(){
  9023. return this._value !=null ? this._value :this.label;
  9024. },function(obj){
  9025. this._value=obj;
  9026. });
  9027. return Radio;
  9028. })(Button)
  9029. /**
  9030. *字体切片,简化版的位图字体,只需设置一个切片图片和文字内容即可使用,效果同位图字体
  9031. *使用方式:设置位图字体皮肤skin,设置皮肤对应的字体内容sheet(如果多行,可以使用空格换行),示例:
  9032. *fontClip.skin="font1.png";//设置皮肤
  9033. *fontClip.sheet="abc123 456";//设置皮肤对应的内容,空格换行。此皮肤为2行5列(显示时skin会被等分为2行5列),第一行对应的文字为"abc123",第二行为"456"
  9034. *fontClip.value="a1326";//显示"a1326"文字
  9035. */
  9036. //class laya.ui.FontClip extends laya.ui.Clip
  9037. var FontClip=(function(_super){
  9038. function FontClip(skin,sheet){
  9039. /**数值*/
  9040. this._valueArr=null;
  9041. /**文字内容数组**/
  9042. this._indexMap=null;
  9043. /**位图字体内容**/
  9044. this._sheet=null;
  9045. /**@private */
  9046. this._direction="horizontal";
  9047. /**X方向间隙*/
  9048. this._spaceX=0;
  9049. /**Y方向间隙*/
  9050. this._spaceY=0;
  9051. /**@private 水平对齐方式*/
  9052. this._align="left";
  9053. /**@private 显示文字宽*/
  9054. this._wordsW=0;
  9055. /**@private 显示文字高*/
  9056. this._wordsH=0;
  9057. FontClip.__super.call(this);
  9058. if (skin)this.skin=skin;
  9059. if (sheet)this.sheet=sheet;
  9060. }
  9061. __class(FontClip,'laya.ui.FontClip',_super);
  9062. var __proto=FontClip.prototype;
  9063. __proto.createChildren=function(){
  9064. this._bitmap=new AutoBitmap();
  9065. this.on(/*laya.events.Event.LOADED*/"loaded",this,this._onClipLoaded);
  9066. }
  9067. /**
  9068. *资源加载完毕
  9069. */
  9070. __proto._onClipLoaded=function(){
  9071. this.callLater(this.changeValue);
  9072. }
  9073. /**渲染数值*/
  9074. __proto.changeValue=function(){
  9075. if (!this._sources)return;
  9076. if (!this._valueArr)return;
  9077. this.graphics.clear(true);
  9078. var texture;
  9079. texture=this._sources[0];
  9080. if (!texture)return;
  9081. var isHorizontal=(this._direction==="horizontal");
  9082. if (isHorizontal){
  9083. this._wordsW=this._valueArr.length *(texture.sourceWidth+this.spaceX);
  9084. this._wordsH=texture.sourceHeight;
  9085. }else{
  9086. this._wordsW=texture.sourceWidth;
  9087. this._wordsH=(texture.sourceHeight+this.spaceY)*this._valueArr.length;
  9088. };
  9089. var dX=0;
  9090. if (this._width){
  9091. switch(this._align){
  9092. case "center":
  9093. dX=0.5 *(this._width-this._wordsW);
  9094. break ;
  9095. case "right":
  9096. dX=this._width-this._wordsW;
  9097. break ;
  9098. default :
  9099. dX=0;
  9100. }
  9101. }
  9102. for (var i=0,sz=this._valueArr.length;i < sz;i++){
  9103. var index=this._indexMap[this._valueArr.charAt(i)];
  9104. if (!this.sources[index])continue ;
  9105. texture=this.sources[index];
  9106. if (isHorizontal)this.graphics.drawImage(texture,dX+i *(texture.sourceWidth+this.spaceX),0,texture.sourceWidth,texture.sourceHeight);
  9107. else this.graphics.drawImage(texture,0+dX,i *(texture.sourceHeight+this.spaceY),texture.sourceWidth,texture.sourceHeight);
  9108. }
  9109. if (!this._width){
  9110. this._widget.resetLayoutX();
  9111. this.callLater(this._sizeChanged);
  9112. }
  9113. if (!this._height){
  9114. this._widget.resetLayoutY();
  9115. this.callLater(this._sizeChanged);
  9116. }
  9117. }
  9118. __proto.measureWidth=function(){
  9119. return this._wordsW;
  9120. }
  9121. __proto.measureHeight=function(){
  9122. return this._wordsH;
  9123. }
  9124. __proto.destroy=function(destroyChild){
  9125. (destroyChild===void 0)&& (destroyChild=true);
  9126. this._valueArr=null;
  9127. this._indexMap=null;
  9128. this.graphics.clear(true);
  9129. this.removeSelf();
  9130. this.off(/*laya.events.Event.LOADED*/"loaded",this,this._onClipLoaded);
  9131. _super.prototype.destroy.call(this,destroyChild);
  9132. }
  9133. /**
  9134. *设置位图字体内容,空格代表换行。比如"abc123 456",代表第一行对应的文字为"abc123",第二行为"456"
  9135. */
  9136. __getset(0,__proto,'sheet',function(){
  9137. return this._sheet;
  9138. },function(value){
  9139. value+="";
  9140. this._sheet=value;
  9141. var arr=value.split(" ");
  9142. this._clipX=String(arr[0]).length;
  9143. this.clipY=arr.length;
  9144. this._indexMap={};
  9145. for (var i=0;i < this._clipY;i++){
  9146. var line=arr[i].split("");
  9147. for (var j=0,n=line.length;j < n;j++){
  9148. this._indexMap[line[j]]=i *this._clipX+j;
  9149. }
  9150. }
  9151. });
  9152. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  9153. Laya.superSet(Clip,this,'height',value);
  9154. this.callLater(this.changeValue);
  9155. });
  9156. /**
  9157. *布局方向。
  9158. *<p>默认值为"horizontal"。</p>
  9159. *<p><b>取值:</b>
  9160. *<li>"horizontal":表示水平布局。</li>
  9161. *<li>"vertical":表示垂直布局。</li>
  9162. *</p>
  9163. */
  9164. __getset(0,__proto,'direction',function(){
  9165. return this._direction;
  9166. },function(value){
  9167. this._direction=value;
  9168. this.callLater(this.changeValue);
  9169. });
  9170. /**
  9171. *设置位图字体的显示内容
  9172. */
  9173. __getset(0,__proto,'value',function(){
  9174. if (!this._valueArr)return "";
  9175. return this._valueArr;
  9176. },function(value){
  9177. value+="";
  9178. this._valueArr=value;
  9179. this.callLater(this.changeValue);
  9180. });
  9181. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  9182. Laya.superSet(Clip,this,'width',value);
  9183. this.callLater(this.changeValue);
  9184. });
  9185. /**X方向文字间隙*/
  9186. __getset(0,__proto,'spaceX',function(){
  9187. return this._spaceX;
  9188. },function(value){
  9189. this._spaceX=value;
  9190. if (this._direction==="horizontal")this.callLater(this.changeValue);
  9191. });
  9192. /**Y方向文字间隙*/
  9193. __getset(0,__proto,'spaceY',function(){
  9194. return this._spaceY;
  9195. },function(value){
  9196. this._spaceY=value;
  9197. if (!(this._direction==="horizontal"))this.callLater(this.changeValue);
  9198. });
  9199. /**水平对齐方式*/
  9200. __getset(0,__proto,'align',function(){
  9201. return this._align;
  9202. },function(v){
  9203. this._align=v;
  9204. this.callLater(this.changeValue);
  9205. });
  9206. return FontClip;
  9207. })(Clip)
  9208. /**
  9209. *广告插件
  9210. *@author 小松
  9211. *@date-2018-09-19
  9212. */
  9213. //class laya.ui.AdvImage extends laya.ui.Image
  9214. var AdvImage=(function(_super){
  9215. function AdvImage(skin){
  9216. /**广告列表数据**/
  9217. this.advsListArr=[];
  9218. /**资源列表请求地址**/
  9219. this.resUrl="https://unioncdn.layabox.com/config/iconlist.json";
  9220. /**广告列表信息**/
  9221. this._data=[];
  9222. /**每6分钟重新请求一次新广告列表**/
  9223. this._resquestTime=360000;
  9224. /**微信跳转appid**/
  9225. this._appid=null;
  9226. /**播放索引**/
  9227. this._playIndex=0;
  9228. /**轮播间隔时间**/
  9229. this._lunboTime=5000;
  9230. AdvImage.__super.call(this);
  9231. this._http=new Browser.window.XMLHttpRequest();
  9232. this.skin=skin;
  9233. this.setLoadUrl();
  9234. this.init();
  9235. this.size(120,120);
  9236. }
  9237. __class(AdvImage,'laya.ui.AdvImage',_super);
  9238. var __proto=AdvImage.prototype;
  9239. /**设置导量加载地址**/
  9240. __proto.setLoadUrl=function(){
  9241. if(Browser.onLimixiu){
  9242. this.resUrl="https://abc.layabox.com/public/wyw/gconfig.json";
  9243. }
  9244. }
  9245. __proto.init=function(){
  9246. if(this.isSupportJump()){
  9247. if(Browser.onMiniGame || Browser.onBDMiniGame){
  9248. Laya.timer.loop(this._resquestTime,this,this.onGetAdvsListData);
  9249. }
  9250. this.onGetAdvsListData();
  9251. this.initEvent();
  9252. }else
  9253. this.visible=false;
  9254. }
  9255. __proto.initEvent=function(){
  9256. this.on(/*laya.events.Event.CLICK*/"click",this,this.onAdvsImgClick);
  9257. }
  9258. __proto.onAdvsImgClick=function(){
  9259. var currentJumpUrl=this.getCurrentAppidObj();
  9260. if(currentJumpUrl)
  9261. this.jumptoGame();
  9262. }
  9263. __proto.revertAdvsData=function(){
  9264. if(this.advsListArr[this._playIndex]){
  9265. this.visible=true;
  9266. if(Browser.onLimixiu){
  9267. var ww="https://abc.layabox.com/public/icon/";
  9268. this.visible=true;
  9269. var advsObj=this.advsListArr[this._playIndex];
  9270. if(advsObj){
  9271. if(Browser.onLimixiu &&/*__JS__ */GameStatusInfo.gameId==advsObj.gameid){
  9272. this.onLunbo();
  9273. }else{
  9274. this.skin=ww+advsObj.iconUrl;
  9275. this.size(103,126);
  9276. }
  9277. }
  9278. }else{
  9279. this.skin=this.advsListArr[this._playIndex];
  9280. }
  9281. }
  9282. }
  9283. /**当前小游戏环境是否支持游戏跳转功能**/
  9284. __proto.isSupportJump=function(){
  9285. if(Browser.onMiniGame){
  9286. var isSupperJump=(typeof /*__JS__ */wx.navigateToMiniProgram=='function');
  9287. return isSupperJump;
  9288. }else if(Browser.onLimixiu){
  9289. if(/*__JS__ */BK.QQ.skipGame)
  9290. return true;
  9291. }else if(Browser.onBDMiniGame)
  9292. return true;
  9293. return false;
  9294. }
  9295. /**
  9296. *跳转游戏
  9297. *@param callBack Function 回调参数说明:type 0 跳转成功;1跳转失败;2跳转接口调用成功
  9298. */
  9299. __proto.jumptoGame=function(){
  9300. var _$this=this;
  9301. var advsObj=this.advsListArr[this._playIndex];
  9302. var desGameId=parseInt(advsObj.gameid);
  9303. var extendInfo=advsObj.extendInfo;
  9304. var path=advsObj.path;
  9305. if(Browser.onLimixiu){
  9306. if(!advsObj.isLunBo){
  9307. if(!advsObj.isLunBo){
  9308. var gameAdvsObj=LocalStorage.getJSON("gameObj");
  9309. if(!gameAdvsObj){
  9310. gameAdvsObj={};
  9311. }
  9312. if(!gameAdvsObj[advsObj.gameid]){
  9313. gameAdvsObj[advsObj.gameid]={};
  9314. }
  9315. gameAdvsObj[advsObj.gameid]={isclick:true};
  9316. LocalStorage.setJSON("gameObj",gameAdvsObj);
  9317. this.advsListArr.splice(this._playIndex,1);
  9318. }
  9319. }
  9320. /*__JS__ */BK.QQ.skipGame(desGameId,extendInfo);
  9321. this.updateAdvsInfo();
  9322. }else if(Browser.onMiniGame){
  9323. if(this.isSupportJump()){
  9324. /*__JS__ */wx.navigateToMiniProgram({
  9325. appId:this._appid,
  9326. path:"",
  9327. extraData:"",
  9328. envVersion:"release",
  9329. success:function success (){
  9330. console.log("-------------跳转成功--------------");
  9331. },
  9332. fail:function fail (){
  9333. console.log("-------------跳转失败--------------");
  9334. },
  9335. complete:function complete (){
  9336. console.log("-------------跳转接口调用成功--------------");
  9337. _$this.updateAdvsInfo();
  9338. }.bind(this)
  9339. });
  9340. }
  9341. }else if(Browser.onBDMiniGame){
  9342. }else{
  9343. this.visible=false;
  9344. }
  9345. }
  9346. __proto.updateAdvsInfo=function(){
  9347. this.visible=false;
  9348. this.onLunbo();
  9349. Laya.timer.loop(this._lunboTime,this,this.onLunbo);
  9350. }
  9351. __proto.onLunbo=function(){
  9352. if(this._playIndex >=this.advsListArr.length-1)
  9353. this._playIndex=0;
  9354. else
  9355. this._playIndex+=1;
  9356. this.visible=true;
  9357. this.revertAdvsData();
  9358. }
  9359. /**获取轮播数据**/
  9360. __proto.getCurrentAppidObj=function(){
  9361. return this.advsListArr[this._playIndex];
  9362. }
  9363. /**
  9364. *获取广告列表数据信息
  9365. */
  9366. __proto.onGetAdvsListData=function(){
  9367. var _this=this;
  9368. var random=AdvImage.randRange(10000,1000000);
  9369. var url=this.resUrl+"?"+random;
  9370. this._http.open("get",url,true);
  9371. this._http.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
  9372. this._http.responseType="text";
  9373. this._http.onerror=function (e){
  9374. _this._onError(e);
  9375. }
  9376. this._http.onload=function (e){
  9377. _this._onLoad(e);
  9378. }
  9379. this._http.send(null);
  9380. }
  9381. /**
  9382. *@private
  9383. *请求出错侦的听处理函数。
  9384. *@param e 事件对象。
  9385. */
  9386. __proto._onError=function(e){
  9387. this.error("Request failed Status:"+this._http.status+" text:"+this._http.statusText);
  9388. }
  9389. /**
  9390. *@private
  9391. *请求消息返回的侦听处理函数。
  9392. *@param e 事件对象。
  9393. */
  9394. __proto._onLoad=function(e){
  9395. var http=this._http;
  9396. var status=http.status!==undefined ? http.status :200;
  9397. if (status===200 || status===204 || status===0){
  9398. this.complete();
  9399. }else {
  9400. this.error("["+http.status+"]"+http.statusText+":"+http.responseURL);
  9401. }
  9402. }
  9403. /**
  9404. *@private
  9405. *请求错误的处理函数。
  9406. *@param message 错误信息。
  9407. */
  9408. __proto.error=function(message){
  9409. this.event(/*laya.events.Event.ERROR*/"error",message);
  9410. }
  9411. /**
  9412. *@private
  9413. *请求成功完成的处理函数。
  9414. */
  9415. __proto.complete=function(){
  9416. var flag=true;
  9417. try {
  9418. this._data=this._http.response || this._http.responseText;
  9419. this._data=JSON.parse(this._data);
  9420. if(Browser.onLimixiu){
  9421. this.advsListArr=this.getAdvsQArr(this._data);
  9422. if(this.advsListArr.length){
  9423. this.updateAdvsInfo();
  9424. this.revertAdvsData();
  9425. }else{
  9426. this.visible=false;
  9427. }
  9428. }else{
  9429. this.advsListArr=this._data.list;
  9430. this._appid=this._data.appid;
  9431. this.updateAdvsInfo();
  9432. this.revertAdvsData();
  9433. }
  9434. }catch (e){
  9435. flag=false;
  9436. this.error(e.message);
  9437. }
  9438. }
  9439. /**转换数据**/
  9440. __proto.getAdvsQArr=function(data){
  9441. var tempArr=[];
  9442. var gameAdvsObj=LocalStorage.getJSON("gameObj");
  9443. for(var key in data){
  9444. var tempObj=data[key];
  9445. if(gameAdvsObj && gameAdvsObj[tempObj.gameid] && !tempObj.isQiangZhi)
  9446. continue ;
  9447. tempArr.push(tempObj);
  9448. }
  9449. return tempArr;
  9450. }
  9451. /**
  9452. *@private
  9453. *清除当前请求。
  9454. */
  9455. __proto.clear=function(){
  9456. var http=this._http;
  9457. http.onerror=http.onabort=http.onprogress=http.onload=null;
  9458. }
  9459. __proto.destroy=function(destroyChild){
  9460. (destroyChild===void 0)&& (destroyChild=true);
  9461. Laya.timer.clear(this,this.onLunbo);
  9462. _super.prototype.destroy.call(this,true);
  9463. this.clear();
  9464. Laya.timer.clear(this,this.onGetAdvsListData);
  9465. }
  9466. AdvImage.randRange=function(minNum,maxNum){
  9467. return (Math.floor(Math.random()*(maxNum-minNum+1))+minNum);
  9468. }
  9469. return AdvImage;
  9470. })(Image)
  9471. /**
  9472. *
  9473. *使用 <code>VScrollBar</code> (垂直 <code>ScrollBar</code> )控件,可以在因数据太多而不能在显示区域完全显示时控制显示的数据部分。
  9474. *
  9475. *@example <caption>以下示例代码,创建了一个 <code>VScrollBar</code> 实例。</caption>
  9476. *package
  9477. *{
  9478. *import laya.ui.vScrollBar;
  9479. *import laya.ui.VScrollBar;
  9480. *import laya.utils.Handler;
  9481. *public class VScrollBar_Example
  9482. *{
  9483. *private var vScrollBar:VScrollBar;
  9484. *public function VScrollBar_Example()
  9485. *{
  9486. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  9487. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9488. *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"],Handler.create(this,onLoadComplete));
  9489. *}
  9490. *private function onLoadComplete():void
  9491. *{
  9492. *vScrollBar=new VScrollBar();//创建一个 vScrollBar 类的实例对象 hScrollBar 。
  9493. *vScrollBar.skin="resource/ui/vscroll.png";//设置 vScrollBar 的皮肤。
  9494. *vScrollBar.x=100;//设置 vScrollBar 对象的属性 x 的值,用于控制 vScrollBar 对象的显示位置。
  9495. *vScrollBar.y=100;//设置 vScrollBar 对象的属性 y 的值,用于控制 vScrollBar 对象的显示位置。
  9496. *vScrollBar.changeHandler=new Handler(this,onChange);//设置 vScrollBar 的滚动变化处理器。
  9497. *Laya.stage.addChild(vScrollBar);//将此 vScrollBar 对象添加到显示列表。
  9498. *}
  9499. *private function onChange(value:Number):void
  9500. *{
  9501. *trace("滚动条的位置: value="+value);
  9502. *}
  9503. *}
  9504. *}
  9505. *@example
  9506. *Laya.init(640,800);//设置游戏画布宽高
  9507. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  9508. *var vScrollBar;
  9509. *var res=["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"];
  9510. *Laya.loader.load(res,laya.utils.Handler.create(this,onLoadComplete));//加载资源。
  9511. *function onLoadComplete(){
  9512. *vScrollBar=new laya.ui.VScrollBar();//创建一个 vScrollBar 类的实例对象 hScrollBar 。
  9513. *vScrollBar.skin="resource/ui/vscroll.png";//设置 vScrollBar 的皮肤。
  9514. *vScrollBar.x=100;//设置 vScrollBar 对象的属性 x 的值,用于控制 vScrollBar 对象的显示位置。
  9515. *vScrollBar.y=100;//设置 vScrollBar 对象的属性 y 的值,用于控制 vScrollBar 对象的显示位置。
  9516. *vScrollBar.changeHandler=new laya.utils.Handler(this,onChange);//设置 vScrollBar 的滚动变化处理器。
  9517. *Laya.stage.addChild(vScrollBar);//将此 vScrollBar 对象添加到显示列表。
  9518. *}
  9519. *function onChange(value){
  9520. *console.log("滚动条的位置: value="+value);
  9521. *}
  9522. *@example
  9523. *import VScrollBar=laya.ui.VScrollBar;
  9524. *import Handler=laya.utils.Handler;
  9525. *class VScrollBar_Example {
  9526. *private vScrollBar:VScrollBar;
  9527. *constructor(){
  9528. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  9529. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9530. *Laya.loader.load(["resource/ui/vscroll.png","resource/ui/vscroll$bar.png","resource/ui/vscroll$down.png","resource/ui/vscroll$up.png"],Handler.create(this,this.onLoadComplete));
  9531. *}
  9532. *private onLoadComplete():void {
  9533. *this.vScrollBar=new VScrollBar();//创建一个 vScrollBar 类的实例对象 hScrollBar 。
  9534. *this.vScrollBar.skin="resource/ui/vscroll.png";//设置 vScrollBar 的皮肤。
  9535. *this.vScrollBar.x=100;//设置 vScrollBar 对象的属性 x 的值,用于控制 vScrollBar 对象的显示位置。
  9536. *this.vScrollBar.y=100;//设置 vScrollBar 对象的属性 y 的值,用于控制 vScrollBar 对象的显示位置。
  9537. *this.vScrollBar.changeHandler=new Handler(this,this.onChange);//设置 vScrollBar 的滚动变化处理器。
  9538. *Laya.stage.addChild(this.vScrollBar);//将此 vScrollBar 对象添加到显示列表。
  9539. *}
  9540. *private onChange(value:number):void {
  9541. *console.log("滚动条的位置: value="+value);
  9542. *}
  9543. *}
  9544. */
  9545. //class laya.ui.VScrollBar extends laya.ui.ScrollBar
  9546. var VScrollBar=(function(_super){
  9547. function VScrollBar(){
  9548. VScrollBar.__super.call(this);;
  9549. }
  9550. __class(VScrollBar,'laya.ui.VScrollBar',_super);
  9551. return VScrollBar;
  9552. })(ScrollBar)
  9553. /**
  9554. *使用 <code>VSlider</code> 控件,用户可以通过在滑块轨道的终点之间移动滑块来选择值。
  9555. *<p> <code>VSlider</code> 控件采用垂直方向。滑块轨道从下往上扩展,而标签位于轨道的左右两侧。</p>
  9556. *
  9557. *@example <caption>以下示例代码,创建了一个 <code>VSlider</code> 实例。</caption>
  9558. *package
  9559. *{
  9560. *import laya.ui.HSlider;
  9561. *import laya.ui.VSlider;
  9562. *import laya.utils.Handler;
  9563. *public class VSlider_Example
  9564. *{
  9565. *private var vSlider:VSlider;
  9566. *public function VSlider_Example()
  9567. *{
  9568. *Laya.init(640,800);//设置游戏画布宽高。
  9569. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9570. *Laya.loader.load(["resource/ui/vslider.png","resource/ui/vslider$bar.png"],Handler.create(this,onLoadComplete));//加载资源。
  9571. *}
  9572. *private function onLoadComplete():void
  9573. *{
  9574. *vSlider=new VSlider();//创建一个 VSlider 类的实例对象 vSlider 。
  9575. *vSlider.skin="resource/ui/vslider.png";//设置 vSlider 的皮肤。
  9576. *vSlider.min=0;//设置 vSlider 最低位置值。
  9577. *vSlider.max=10;//设置 vSlider 最高位置值。
  9578. *vSlider.value=2;//设置 vSlider 当前位置值。
  9579. *vSlider.tick=1;//设置 vSlider 刻度值。
  9580. *vSlider.x=100;//设置 vSlider 对象的属性 x 的值,用于控制 vSlider 对象的显示位置。
  9581. *vSlider.y=100;//设置 vSlider 对象的属性 y 的值,用于控制 vSlider 对象的显示位置。
  9582. *vSlider.changeHandler=new Handler(this,onChange);//设置 vSlider 位置变化处理器。
  9583. *Laya.stage.addChild(vSlider);//把 vSlider 添加到显示列表。
  9584. *}
  9585. *private function onChange(value:Number):void
  9586. *{
  9587. *trace("滑块的位置: value="+value);
  9588. *}
  9589. *}
  9590. *}
  9591. *@example
  9592. *Laya.init(640,800);//设置游戏画布宽高
  9593. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  9594. *var vSlider;
  9595. *Laya.loader.load(["resource/ui/vslider.png","resource/ui/vslider$bar.png"],laya.utils.Handler.create(this,onLoadComplete));//加载资源。
  9596. *function onLoadComplete(){
  9597. *vSlider=new laya.ui.VSlider();//创建一个 VSlider 类的实例对象 vSlider 。
  9598. *vSlider.skin="resource/ui/vslider.png";//设置 vSlider 的皮肤。
  9599. *vSlider.min=0;//设置 vSlider 最低位置值。
  9600. *vSlider.max=10;//设置 vSlider 最高位置值。
  9601. *vSlider.value=2;//设置 vSlider 当前位置值。
  9602. *vSlider.tick=1;//设置 vSlider 刻度值。
  9603. *vSlider.x=100;//设置 vSlider 对象的属性 x 的值,用于控制 vSlider 对象的显示位置。
  9604. *vSlider.y=100;//设置 vSlider 对象的属性 y 的值,用于控制 vSlider 对象的显示位置。
  9605. *vSlider.changeHandler=new laya.utils.Handler(this,onChange);//设置 vSlider 位置变化处理器。
  9606. *Laya.stage.addChild(vSlider);//把 vSlider 添加到显示列表。
  9607. *}
  9608. *function onChange(value){
  9609. *console.log("滑块的位置: value="+value);
  9610. *}
  9611. *@example
  9612. *import HSlider=laya.ui.HSlider;
  9613. *import VSlider=laya.ui.VSlider;
  9614. *import Handler=laya.utils.Handler;
  9615. *class VSlider_Example {
  9616. *private vSlider:VSlider;
  9617. *constructor(){
  9618. *Laya.init(640,800);//设置游戏画布宽高。
  9619. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9620. *Laya.loader.load(["resource/ui/vslider.png","resource/ui/vslider$bar.png"],Handler.create(this,this.onLoadComplete));//加载资源。
  9621. *}
  9622. *private onLoadComplete():void {
  9623. *this.vSlider=new VSlider();//创建一个 VSlider 类的实例对象 vSlider 。
  9624. *this.vSlider.skin="resource/ui/vslider.png";//设置 vSlider 的皮肤。
  9625. *this.vSlider.min=0;//设置 vSlider 最低位置值。
  9626. *this.vSlider.max=10;//设置 vSlider 最高位置值。
  9627. *this.vSlider.value=2;//设置 vSlider 当前位置值。
  9628. *this.vSlider.tick=1;//设置 vSlider 刻度值。
  9629. *this.vSlider.x=100;//设置 vSlider 对象的属性 x 的值,用于控制 vSlider 对象的显示位置。
  9630. *this.vSlider.y=100;//设置 vSlider 对象的属性 y 的值,用于控制 vSlider 对象的显示位置。
  9631. *this.vSlider.changeHandler=new Handler(this,this.onChange);//设置 vSlider 位置变化处理器。
  9632. *Laya.stage.addChild(this.vSlider);//把 vSlider 添加到显示列表。
  9633. *}
  9634. *private onChange(value:number):void {
  9635. *console.log("滑块的位置: value="+value);
  9636. *}
  9637. *}
  9638. *@see laya.ui.Slider
  9639. */
  9640. //class laya.ui.VSlider extends laya.ui.Slider
  9641. var VSlider=(function(_super){
  9642. function VSlider(){
  9643. VSlider.__super.call(this);;
  9644. }
  9645. __class(VSlider,'laya.ui.VSlider',_super);
  9646. return VSlider;
  9647. })(Slider)
  9648. /**
  9649. *使用 <code>HScrollBar</code> (水平 <code>ScrollBar</code> )控件,可以在因数据太多而不能在显示区域完全显示时控制显示的数据部分。
  9650. *@example <caption>以下示例代码,创建了一个 <code>HScrollBar</code> 实例。</caption>
  9651. *package
  9652. *{
  9653. *import laya.ui.HScrollBar;
  9654. *import laya.utils.Handler;
  9655. *public class HScrollBar_Example
  9656. *{
  9657. *private var hScrollBar:HScrollBar;
  9658. *public function HScrollBar_Example()
  9659. *{
  9660. *Laya.init(640,800);//设置游戏画布宽高。
  9661. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9662. *Laya.loader.load(["resource/ui/hscroll.png","resource/ui/hscroll$bar.png","resource/ui/hscroll$down.png","resource/ui/hscroll$up.png"],Handler.create(this,onLoadComplete));//加载资源。
  9663. *}
  9664. *private function onLoadComplete():void
  9665. *{
  9666. *hScrollBar=new HScrollBar();//创建一个 HScrollBar 类的实例对象 hScrollBar 。
  9667. *hScrollBar.skin="resource/ui/hscroll.png";//设置 hScrollBar 的皮肤。
  9668. *hScrollBar.x=100;//设置 hScrollBar 对象的属性 x 的值,用于控制 hScrollBar 对象的显示位置。
  9669. *hScrollBar.y=100;//设置 hScrollBar 对象的属性 y 的值,用于控制 hScrollBar 对象的显示位置。
  9670. *hScrollBar.changeHandler=new Handler(this,onChange);//设置 hScrollBar 的滚动变化处理器。
  9671. *Laya.stage.addChild(hScrollBar);//将此 hScrollBar 对象添加到显示列表。
  9672. *}
  9673. *private function onChange(value:Number):void
  9674. *{
  9675. *trace("滚动条的位置: value="+value);
  9676. *}
  9677. *}
  9678. *}
  9679. *@example
  9680. *Laya.init(640,800);//设置游戏画布宽高
  9681. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  9682. *var hScrollBar;
  9683. *var res=["resource/ui/hscroll.png","resource/ui/hscroll$bar.png","resource/ui/hscroll$down.png","resource/ui/hscroll$up.png"];
  9684. *Laya.loader.load(res,laya.utils.Handler.create(this,onLoadComplete));//加载资源。
  9685. *function onLoadComplete(){
  9686. *console.log("资源加载完成!");
  9687. *hScrollBar=new laya.ui.HScrollBar();//创建一个 HScrollBar 类的实例对象 hScrollBar 。
  9688. *hScrollBar.skin="resource/ui/hscroll.png";//设置 hScrollBar 的皮肤。
  9689. *hScrollBar.x=100;//设置 hScrollBar 对象的属性 x 的值,用于控制 hScrollBar 对象的显示位置。
  9690. *hScrollBar.y=100;//设置 hScrollBar 对象的属性 y 的值,用于控制 hScrollBar 对象的显示位置。
  9691. *hScrollBar.changeHandler=new laya.utils.Handler(this,onChange);//设置 hScrollBar 的滚动变化处理器。
  9692. *Laya.stage.addChild(hScrollBar);//将此 hScrollBar 对象添加到显示列表。
  9693. *}
  9694. *function onChange(value)
  9695. *{
  9696. *console.log("滚动条的位置: value="+value);
  9697. *}
  9698. *@example
  9699. *import HScrollBar=laya.ui.HScrollBar;
  9700. *import Handler=laya.utils.Handler;
  9701. *class HScrollBar_Example {
  9702. *private hScrollBar:HScrollBar;
  9703. *constructor(){
  9704. *Laya.init(640,800);//设置游戏画布宽高。
  9705. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9706. *Laya.loader.load(["resource/ui/hscroll.png","resource/ui/hscroll$bar.png","resource/ui/hscroll$down.png","resource/ui/hscroll$up.png"],Handler.create(this,this.onLoadComplete));//加载资源。
  9707. *}
  9708. *private onLoadComplete():void {
  9709. *this.hScrollBar=new HScrollBar();//创建一个 HScrollBar 类的实例对象 hScrollBar 。
  9710. *this.hScrollBar.skin="resource/ui/hscroll.png";//设置 hScrollBar 的皮肤。
  9711. *this.hScrollBar.x=100;//设置 hScrollBar 对象的属性 x 的值,用于控制 hScrollBar 对象的显示位置。
  9712. *this.hScrollBar.y=100;//设置 hScrollBar 对象的属性 y 的值,用于控制 hScrollBar 对象的显示位置。
  9713. *this.hScrollBar.changeHandler=new Handler(this,this.onChange);//设置 hScrollBar 的滚动变化处理器。
  9714. *Laya.stage.addChild(this.hScrollBar);//将此 hScrollBar 对象添加到显示列表。
  9715. *}
  9716. *private onChange(value:number):void {
  9717. *console.log("滚动条的位置: value="+value);
  9718. *}
  9719. *}
  9720. */
  9721. //class laya.ui.HScrollBar extends laya.ui.ScrollBar
  9722. var HScrollBar=(function(_super){
  9723. function HScrollBar(){
  9724. HScrollBar.__super.call(this);;
  9725. }
  9726. __class(HScrollBar,'laya.ui.HScrollBar',_super);
  9727. var __proto=HScrollBar.prototype;
  9728. /**@inheritDoc */
  9729. __proto.initialize=function(){
  9730. _super.prototype.initialize.call(this);
  9731. this.slider.isVertical=false;
  9732. }
  9733. return HScrollBar;
  9734. })(ScrollBar)
  9735. /**
  9736. *使用 <code>HSlider</code> 控件,用户可以通过在滑块轨道的终点之间移动滑块来选择值。
  9737. *<p> <code>HSlider</code> 控件采用水平方向。滑块轨道从左向右扩展,而标签位于轨道的顶部或底部。</p>
  9738. *
  9739. *@example <caption>以下示例代码,创建了一个 <code>HSlider</code> 实例。</caption>
  9740. *package
  9741. *{
  9742. *import laya.ui.HSlider;
  9743. *import laya.utils.Handler;
  9744. *public class HSlider_Example
  9745. *{
  9746. *private var hSlider:HSlider;
  9747. *public function HSlider_Example()
  9748. *{
  9749. *Laya.init(640,800);//设置游戏画布宽高。
  9750. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9751. *Laya.loader.load(["resource/ui/hslider.png","resource/ui/hslider$bar.png"],Handler.create(this,onLoadComplete));//加载资源。
  9752. *}
  9753. *private function onLoadComplete():void
  9754. *{
  9755. *hSlider=new HSlider();//创建一个 HSlider 类的实例对象 hSlider 。
  9756. *hSlider.skin="resource/ui/hslider.png";//设置 hSlider 的皮肤。
  9757. *hSlider.min=0;//设置 hSlider 最低位置值。
  9758. *hSlider.max=10;//设置 hSlider 最高位置值。
  9759. *hSlider.value=2;//设置 hSlider 当前位置值。
  9760. *hSlider.tick=1;//设置 hSlider 刻度值。
  9761. *hSlider.x=100;//设置 hSlider 对象的属性 x 的值,用于控制 hSlider 对象的显示位置。
  9762. *hSlider.y=100;//设置 hSlider 对象的属性 y 的值,用于控制 hSlider 对象的显示位置。
  9763. *hSlider.changeHandler=new Handler(this,onChange);//设置 hSlider 位置变化处理器。
  9764. *Laya.stage.addChild(hSlider);//把 hSlider 添加到显示列表。
  9765. *}
  9766. *private function onChange(value:Number):void
  9767. *{
  9768. *trace("滑块的位置: value="+value);
  9769. *}
  9770. *}
  9771. *}
  9772. *@example
  9773. *Laya.init(640,800,"canvas");//设置游戏画布宽高、渲染模式
  9774. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  9775. *var hSlider;
  9776. *var res=["resource/ui/hslider.png","resource/ui/hslider$bar.png"];
  9777. *Laya.loader.load(res,laya.utils.Handler.create(this,onLoadComplete));
  9778. *function onLoadComplete(){
  9779. *console.log("资源加载完成!");
  9780. *hSlider=new laya.ui.HSlider();//创建一个 HSlider 类的实例对象 hSlider 。
  9781. *hSlider.skin="resource/ui/hslider.png";//设置 hSlider 的皮肤。
  9782. *hSlider.min=0;//设置 hSlider 最低位置值。
  9783. *hSlider.max=10;//设置 hSlider 最高位置值。
  9784. *hSlider.value=2;//设置 hSlider 当前位置值。
  9785. *hSlider.tick=1;//设置 hSlider 刻度值。
  9786. *hSlider.x=100;//设置 hSlider 对象的属性 x 的值,用于控制 hSlider 对象的显示位置。
  9787. *hSlider.y=100;//设置 hSlider 对象的属性 y 的值,用于控制 hSlider 对象的显示位置。
  9788. *hSlider.changeHandler=new laya.utils.Handler(this,onChange);//设置 hSlider 位置变化处理器。
  9789. *Laya.stage.addChild(hSlider);//把 hSlider 添加到显示列表。
  9790. *}
  9791. *function onChange(value)
  9792. *{
  9793. *console.log("滑块的位置: value="+value);
  9794. *}
  9795. *@example
  9796. *import Handler=laya.utils.Handler;
  9797. *import HSlider=laya.ui.HSlider;
  9798. *class HSlider_Example {
  9799. *private hSlider:HSlider;
  9800. *constructor(){
  9801. *Laya.init(640,800);//设置游戏画布宽高。
  9802. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9803. *Laya.loader.load(["resource/ui/hslider.png","resource/ui/hslider$bar.png"],Handler.create(this,this.onLoadComplete));//加载资源。
  9804. *}
  9805. *private onLoadComplete():void {
  9806. *this.hSlider=new HSlider();//创建一个 HSlider 类的实例对象 hSlider 。
  9807. *this.hSlider.skin="resource/ui/hslider.png";//设置 hSlider 的皮肤。
  9808. *this.hSlider.min=0;//设置 hSlider 最低位置值。
  9809. *this.hSlider.max=10;//设置 hSlider 最高位置值。
  9810. *this.hSlider.value=2;//设置 hSlider 当前位置值。
  9811. *this.hSlider.tick=1;//设置 hSlider 刻度值。
  9812. *this.hSlider.x=100;//设置 hSlider 对象的属性 x 的值,用于控制 hSlider 对象的显示位置。
  9813. *this.hSlider.y=100;//设置 hSlider 对象的属性 y 的值,用于控制 hSlider 对象的显示位置。
  9814. *this.hSlider.changeHandler=new Handler(this,this.onChange);//设置 hSlider 位置变化处理器。
  9815. *Laya.stage.addChild(this.hSlider);//把 hSlider 添加到显示列表。
  9816. *}
  9817. *private onChange(value:number):void {
  9818. *console.log("滑块的位置: value="+value);
  9819. *}
  9820. *}
  9821. *
  9822. *@see laya.ui.Slider
  9823. */
  9824. //class laya.ui.HSlider extends laya.ui.Slider
  9825. var HSlider=(function(_super){
  9826. /**
  9827. *创建一个 <code>HSlider</code> 类实例。
  9828. *@param skin 皮肤。
  9829. */
  9830. function HSlider(skin){
  9831. HSlider.__super.call(this,skin);
  9832. this.isVertical=false;
  9833. }
  9834. __class(HSlider,'laya.ui.HSlider',_super);
  9835. return HSlider;
  9836. })(Slider)
  9837. /**
  9838. *<code>HBox</code> 是一个水平布局容器类。
  9839. */
  9840. //class laya.ui.HBox extends laya.ui.LayoutBox
  9841. var HBox=(function(_super){
  9842. function HBox(){
  9843. HBox.__super.call(this);;
  9844. }
  9845. __class(HBox,'laya.ui.HBox',_super);
  9846. var __proto=HBox.prototype;
  9847. /**@inheritDoc */
  9848. __proto.sortItem=function(items){
  9849. if (items)items.sort(function(a,b){return a.x-b.x;});
  9850. }
  9851. /**@inheritDoc */
  9852. __proto.changeItems=function(){
  9853. this._itemChanged=false;
  9854. var items=[];
  9855. var maxHeight=0;
  9856. for (var i=0,n=this.numChildren;i < n;i++){
  9857. var item=this.getChildAt(i);
  9858. if (item){
  9859. items.push(item);
  9860. maxHeight=this._height?this._height:Math.max(maxHeight,item.height *item.scaleY);
  9861. }
  9862. }
  9863. this.sortItem(items);
  9864. var left=0;
  9865. for (i=0,n=items.length;i < n;i++){
  9866. item=items[i];
  9867. item.x=left;
  9868. left+=item.width *item.scaleX+this._space;
  9869. if (this._align=="top"){
  9870. item.y=0;
  9871. }else if (this._align=="middle"){
  9872. item.y=(maxHeight-item.height *item.scaleY)*0.5;
  9873. }else if (this._align=="bottom"){
  9874. item.y=maxHeight-item.height *item.scaleY;
  9875. }
  9876. }
  9877. this._sizeChanged();
  9878. }
  9879. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  9880. if (this._height !=value){
  9881. Laya.superSet(LayoutBox,this,'height',value);
  9882. this.callLater(this.changeItems);
  9883. }
  9884. });
  9885. HBox.NONE="none";
  9886. HBox.TOP="top";
  9887. HBox.MIDDLE="middle";
  9888. HBox.BOTTOM="bottom";
  9889. return HBox;
  9890. })(LayoutBox)
  9891. /**
  9892. *<code>RadioGroup</code> 控件定义一组 <code>Radio</code> 控件,这些控件相互排斥;
  9893. *因此,用户每次只能选择一个 <code>Radio</code> 控件。
  9894. *
  9895. *@example <caption>以下示例代码,创建了一个 <code>RadioGroup</code> 实例。</caption>
  9896. *package
  9897. *{
  9898. *import laya.ui.Radio;
  9899. *import laya.ui.RadioGroup;
  9900. *import laya.utils.Handler;
  9901. *public class RadioGroup_Example
  9902. *{
  9903. *public function RadioGroup_Example()
  9904. *{
  9905. *Laya.init(640,800);//设置游戏画布宽高。
  9906. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9907. *Laya.loader.load(["resource/ui/radio.png"],Handler.create(this,onLoadComplete));//加载资源。
  9908. *}
  9909. *private function onLoadComplete():void
  9910. *{
  9911. *var radioGroup:RadioGroup=new RadioGroup();//创建一个 RadioGroup 类的实例对象 radioGroup 。
  9912. *radioGroup.pos(100,100);//设置 radioGroup 的位置信息。
  9913. *radioGroup.labels="item0,item1,item2";//设置 radioGroup 的标签集。
  9914. *radioGroup.skin="resource/ui/radio.png";//设置 radioGroup 的皮肤。
  9915. *radioGroup.space=10;//设置 radioGroup 的项间隔距离。
  9916. *radioGroup.selectHandler=new Handler(this,onSelect);//设置 radioGroup 的选择项发生改变时执行的处理器。
  9917. *Laya.stage.addChild(radioGroup);//将 radioGroup 添加到显示列表。
  9918. *}
  9919. *private function onSelect(index:int):void
  9920. *{
  9921. *trace("当前选择的单选按钮索引: index= ",index);
  9922. *}
  9923. *}
  9924. *}
  9925. *@example
  9926. *Laya.init(640,800);//设置游戏画布宽高、渲染模式
  9927. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  9928. *Laya.loader.load(["resource/ui/radio.png"],laya.utils.Handler.create(this,onLoadComplete));
  9929. *function onLoadComplete(){
  9930. *var radioGroup=new laya.ui.RadioGroup();//创建一个 RadioGroup 类的实例对象 radioGroup 。
  9931. *radioGroup.pos(100,100);//设置 radioGroup 的位置信息。
  9932. *radioGroup.labels="item0,item1,item2";//设置 radioGroup 的标签集。
  9933. *radioGroup.skin="resource/ui/radio.png";//设置 radioGroup 的皮肤。
  9934. *radioGroup.space=10;//设置 radioGroup 的项间隔距离。
  9935. *radioGroup.selectHandler=new laya.utils.Handler(this,onSelect);//设置 radioGroup 的选择项发生改变时执行的处理器。
  9936. *Laya.stage.addChild(radioGroup);//将 radioGroup 添加到显示列表。
  9937. *}
  9938. *function onSelect(index){
  9939. *console.log("当前选择的单选按钮索引: index= ",index);
  9940. *}
  9941. *@example
  9942. *import Radio=laya.ui.Radio;
  9943. *import RadioGroup=laya.ui.RadioGroup;
  9944. *import Handler=laya.utils.Handler;
  9945. *class RadioGroup_Example {
  9946. *constructor(){
  9947. *Laya.init(640,800);//设置游戏画布宽高。
  9948. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  9949. *Laya.loader.load(["resource/ui/radio.png"],Handler.create(this,this.onLoadComplete));//加载资源。
  9950. *}
  9951. *private onLoadComplete():void {
  9952. *var radioGroup:RadioGroup=new RadioGroup();//创建一个 RadioGroup 类的实例对象 radioGroup 。
  9953. *radioGroup.pos(100,100);//设置 radioGroup 的位置信息。
  9954. *radioGroup.labels="item0,item1,item2";//设置 radioGroup 的标签集。
  9955. *radioGroup.skin="resource/ui/radio.png";//设置 radioGroup 的皮肤。
  9956. *radioGroup.space=10;//设置 radioGroup 的项间隔距离。
  9957. *radioGroup.selectHandler=new Handler(this,this.onSelect);//设置 radioGroup 的选择项发生改变时执行的处理器。
  9958. *Laya.stage.addChild(radioGroup);//将 radioGroup 添加到显示列表。
  9959. *}
  9960. *private onSelect(index:number):void {
  9961. *console.log("当前选择的单选按钮索引: index= ",index);
  9962. *}
  9963. *}
  9964. */
  9965. //class laya.ui.RadioGroup extends laya.ui.UIGroup
  9966. var RadioGroup=(function(_super){
  9967. function RadioGroup(){
  9968. RadioGroup.__super.call(this);;
  9969. }
  9970. __class(RadioGroup,'laya.ui.RadioGroup',_super);
  9971. var __proto=RadioGroup.prototype;
  9972. /**@inheritDoc */
  9973. __proto.createItem=function(skin,label){
  9974. return new Radio(skin,label);
  9975. }
  9976. return RadioGroup;
  9977. })(UIGroup)
  9978. /**
  9979. *<code>VBox</code> 是一个垂直布局容器类。
  9980. */
  9981. //class laya.ui.VBox extends laya.ui.LayoutBox
  9982. var VBox=(function(_super){
  9983. function VBox(){
  9984. VBox.__super.call(this);;
  9985. }
  9986. __class(VBox,'laya.ui.VBox',_super);
  9987. var __proto=VBox.prototype;
  9988. /**@inheritDoc */
  9989. __proto.changeItems=function(){
  9990. this._itemChanged=false;
  9991. var items=[];
  9992. var maxWidth=0;
  9993. for (var i=0,n=this.numChildren;i < n;i++){
  9994. var item=this.getChildAt(i);
  9995. if (item){
  9996. items.push(item);
  9997. maxWidth=this._width?this._width:Math.max(maxWidth,item.width *item.scaleX);
  9998. }
  9999. }
  10000. this.sortItem(items);
  10001. var top=0;
  10002. for (i=0,n=items.length;i < n;i++){
  10003. item=items[i];
  10004. item.y=top;
  10005. top+=item.height *item.scaleY+this._space;
  10006. if (this._align=="left"){
  10007. item.x=0;
  10008. }else if (this._align=="center"){
  10009. item.x=(maxWidth-item.width *item.scaleX)*0.5;
  10010. }else if (this._align=="right"){
  10011. item.x=maxWidth-item.width *item.scaleX;
  10012. }
  10013. }
  10014. this._sizeChanged();
  10015. }
  10016. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  10017. if (this._width !=value){
  10018. Laya.superSet(LayoutBox,this,'width',value);
  10019. this.callLater(this.changeItems);
  10020. }
  10021. });
  10022. VBox.NONE="none";
  10023. VBox.LEFT="left";
  10024. VBox.CENTER="center";
  10025. VBox.RIGHT="right";
  10026. return VBox;
  10027. })(LayoutBox)
  10028. /**
  10029. *<code>TextArea</code> 类用于创建显示对象以显示和输入文本。
  10030. *@example <caption>以下示例代码,创建了一个 <code>TextArea</code> 实例。</caption>
  10031. *package
  10032. *{
  10033. *import laya.ui.TextArea;
  10034. *import laya.utils.Handler;
  10035. *public class TextArea_Example
  10036. *{
  10037. *public function TextArea_Example()
  10038. *{
  10039. *Laya.init(640,800);//设置游戏画布宽高。
  10040. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  10041. *Laya.loader.load(["resource/ui/input.png"],Handler.create(this,onLoadComplete));//加载资源。
  10042. *}
  10043. *private function onLoadComplete():void
  10044. *{
  10045. *var textArea:TextArea=new TextArea("这个一个TextArea实例。");//创建一个 TextArea 类的实例对象 textArea 。
  10046. *textArea.skin="resource/ui/input.png";//设置 textArea 的皮肤。
  10047. *textArea.sizeGrid="4,4,4,4";//设置 textArea 的网格信息。
  10048. *textArea.color="#008fff";//设置 textArea 的文本颜色。
  10049. *textArea.font="Arial";//设置 textArea 的字体。
  10050. *textArea.bold=true;//设置 textArea 的文本显示为粗体。
  10051. *textArea.fontSize=20;//设置 textArea 的文本字体大小。
  10052. *textArea.wordWrap=true;//设置 textArea 的文本自动换行。
  10053. *textArea.x=100;//设置 textArea 对象的属性 x 的值,用于控制 textArea 对象的显示位置。
  10054. *textArea.y=100;//设置 textArea 对象的属性 y 的值,用于控制 textArea 对象的显示位置。
  10055. *textArea.width=300;//设置 textArea 的宽度。
  10056. *textArea.height=200;//设置 textArea 的高度。
  10057. *Laya.stage.addChild(textArea);//将 textArea 添加到显示列表。
  10058. *}
  10059. *}
  10060. *}
  10061. *@example
  10062. *Laya.init(640,800);//设置游戏画布宽高、渲染模式
  10063. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  10064. *Laya.loader.load(["resource/ui/input.png"],laya.utils.Handler.create(this,onLoadComplete));//加载资源。
  10065. *function onLoadComplete(){
  10066. *var textArea=new laya.ui.TextArea("这个一个TextArea实例。");//创建一个 TextArea 类的实例对象 textArea 。
  10067. *textArea.skin="resource/ui/input.png";//设置 textArea 的皮肤。
  10068. *textArea.sizeGrid="4,4,4,4";//设置 textArea 的网格信息。
  10069. *textArea.color="#008fff";//设置 textArea 的文本颜色。
  10070. *textArea.font="Arial";//设置 textArea 的字体。
  10071. *textArea.bold=true;//设置 textArea 的文本显示为粗体。
  10072. *textArea.fontSize=20;//设置 textArea 的文本字体大小。
  10073. *textArea.wordWrap=true;//设置 textArea 的文本自动换行。
  10074. *textArea.x=100;//设置 textArea 对象的属性 x 的值,用于控制 textArea 对象的显示位置。
  10075. *textArea.y=100;//设置 textArea 对象的属性 y 的值,用于控制 textArea 对象的显示位置。
  10076. *textArea.width=300;//设置 textArea 的宽度。
  10077. *textArea.height=200;//设置 textArea 的高度。
  10078. *Laya.stage.addChild(textArea);//将 textArea 添加到显示列表。
  10079. *}
  10080. *@example
  10081. *import TextArea=laya.ui.TextArea;
  10082. *import Handler=laya.utils.Handler;
  10083. *class TextArea_Example {
  10084. *constructor(){
  10085. *Laya.init(640,800);//设置游戏画布宽高、渲染模式。
  10086. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  10087. *Laya.loader.load(["resource/ui/input.png"],Handler.create(this,this.onLoadComplete));//加载资源。
  10088. *}
  10089. *private onLoadComplete():void {
  10090. *var textArea:TextArea=new TextArea("这个一个TextArea实例。");//创建一个 TextArea 类的实例对象 textArea 。
  10091. *textArea.skin="resource/ui/input.png";//设置 textArea 的皮肤。
  10092. *textArea.sizeGrid="4,4,4,4";//设置 textArea 的网格信息。
  10093. *textArea.color="#008fff";//设置 textArea 的文本颜色。
  10094. *textArea.font="Arial";//设置 textArea 的字体。
  10095. *textArea.bold=true;//设置 textArea 的文本显示为粗体。
  10096. *textArea.fontSize=20;//设置 textArea 的文本字体大小。
  10097. *textArea.wordWrap=true;//设置 textArea 的文本自动换行。
  10098. *textArea.x=100;//设置 textArea 对象的属性 x 的值,用于控制 textArea 对象的显示位置。
  10099. *textArea.y=100;//设置 textArea 对象的属性 y 的值,用于控制 textArea 对象的显示位置。
  10100. *textArea.width=300;//设置 textArea 的宽度。
  10101. *textArea.height=200;//设置 textArea 的高度。
  10102. *Laya.stage.addChild(textArea);//将 textArea 添加到显示列表。
  10103. *}
  10104. *}
  10105. */
  10106. //class laya.ui.TextArea extends laya.ui.TextInput
  10107. var TextArea=(function(_super){
  10108. function TextArea(text){
  10109. /**@private */
  10110. this._vScrollBar=null;
  10111. /**@private */
  10112. this._hScrollBar=null;
  10113. (text===void 0)&& (text="");
  10114. TextArea.__super.call(this,text);
  10115. this.on(/*laya.events.Event.CHANGE*/"change",this,this._onTextChange);
  10116. }
  10117. __class(TextArea,'laya.ui.TextArea',_super);
  10118. var __proto=TextArea.prototype;
  10119. __proto._onTextChange=function(){
  10120. this.callLater(this.changeScroll);
  10121. }
  10122. __proto.destroy=function(destroyChild){
  10123. (destroyChild===void 0)&& (destroyChild=true);
  10124. _super.prototype.destroy.call(this,destroyChild);
  10125. this._vScrollBar && this._vScrollBar.destroy();
  10126. this._hScrollBar && this._hScrollBar.destroy();
  10127. this._vScrollBar=null;
  10128. this._hScrollBar=null;
  10129. }
  10130. __proto.initialize=function(){
  10131. this.width=180;
  10132. this.height=150;
  10133. this._tf.wordWrap=true;
  10134. this.multiline=true;
  10135. }
  10136. __proto.onVBarChanged=function(e){
  10137. if (this._tf.scrollY !=this._vScrollBar.value){
  10138. this._tf.scrollY=this._vScrollBar.value;
  10139. }
  10140. }
  10141. __proto.onHBarChanged=function(e){
  10142. if (this._tf.scrollX !=this._hScrollBar.value){
  10143. this._tf.scrollX=this._hScrollBar.value;
  10144. }
  10145. }
  10146. __proto.changeScroll=function(){
  10147. var vShow=this._vScrollBar && this._tf.maxScrollY > 0;
  10148. var hShow=this._hScrollBar && this._tf.maxScrollX > 0;
  10149. var showWidth=vShow ? this._width-this._vScrollBar.width :this._width;
  10150. var showHeight=hShow ? this._height-this._hScrollBar.height :this._height;
  10151. var padding=this._tf.padding || Styles.labelPadding;
  10152. this._tf.width=showWidth;
  10153. this._tf.height=showHeight;
  10154. if (this._vScrollBar){
  10155. this._vScrollBar.x=this._width-this._vScrollBar.width-padding[2];
  10156. this._vScrollBar.y=padding[1];
  10157. this._vScrollBar.height=this._height-(hShow ? this._hScrollBar.height :0)-padding[1]-padding[3];
  10158. this._vScrollBar.scrollSize=1;
  10159. this._vScrollBar.thumbPercent=showHeight / Math.max(this._tf.textHeight,showHeight);
  10160. this._vScrollBar.setScroll(1,this._tf.maxScrollY,this._tf.scrollY);
  10161. this._vScrollBar.visible=vShow;
  10162. }
  10163. if (this._hScrollBar){
  10164. this._hScrollBar.x=padding[0];
  10165. this._hScrollBar.y=this._height-this._hScrollBar.height-padding[3];
  10166. this._hScrollBar.width=this._width-(vShow ? this._vScrollBar.width :0)-padding[0]-padding[2];
  10167. this._hScrollBar.scrollSize=Math.max(showWidth *0.033,1);
  10168. this._hScrollBar.thumbPercent=showWidth / Math.max(this._tf.textWidth,showWidth);
  10169. this._hScrollBar.setScroll(0,this.maxScrollX,this.scrollX);
  10170. this._hScrollBar.visible=hShow;
  10171. }
  10172. }
  10173. /**滚动到某个位置*/
  10174. __proto.scrollTo=function(y){
  10175. this.commitMeasure();
  10176. this._tf.scrollY=y;
  10177. }
  10178. /**垂直滚动值*/
  10179. __getset(0,__proto,'scrollY',function(){
  10180. return this._tf.scrollY;
  10181. });
  10182. __getset(0,__proto,'width',_super.prototype._$get_width,function(value){
  10183. Laya.superSet(TextInput,this,'width',value);
  10184. this.callLater(this.changeScroll);
  10185. });
  10186. /**水平滚动条实体*/
  10187. __getset(0,__proto,'hScrollBar',function(){
  10188. return this._hScrollBar;
  10189. });
  10190. __getset(0,__proto,'height',_super.prototype._$get_height,function(value){
  10191. Laya.superSet(TextInput,this,'height',value);
  10192. this.callLater(this.changeScroll);
  10193. });
  10194. /**水平滚动最大值*/
  10195. __getset(0,__proto,'maxScrollX',function(){
  10196. return this._tf.maxScrollX;
  10197. });
  10198. /**垂直滚动条皮肤*/
  10199. __getset(0,__proto,'vScrollBarSkin',function(){
  10200. return this._vScrollBar ? this._vScrollBar.skin :null;
  10201. },function(value){
  10202. if (this._vScrollBar==null){
  10203. this.addChild(this._vScrollBar=new VScrollBar());
  10204. this._vScrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onVBarChanged);
  10205. this._vScrollBar.target=this._tf;
  10206. this.callLater(this.changeScroll);
  10207. }
  10208. this._vScrollBar.skin=value;
  10209. });
  10210. /**水平滚动条皮肤*/
  10211. __getset(0,__proto,'hScrollBarSkin',function(){
  10212. return this._hScrollBar ? this._hScrollBar.skin :null;
  10213. },function(value){
  10214. if (this._hScrollBar==null){
  10215. this.addChild(this._hScrollBar=new HScrollBar());
  10216. this._hScrollBar.on(/*laya.events.Event.CHANGE*/"change",this,this.onHBarChanged);
  10217. this._hScrollBar.mouseWheelEnable=false;
  10218. this._hScrollBar.target=this._tf;
  10219. this.callLater(this.changeScroll);
  10220. }
  10221. this._hScrollBar.skin=value;
  10222. });
  10223. /**垂直滚动条实体*/
  10224. __getset(0,__proto,'vScrollBar',function(){
  10225. return this._vScrollBar;
  10226. });
  10227. /**垂直滚动最大值*/
  10228. __getset(0,__proto,'maxScrollY',function(){
  10229. return this._tf.maxScrollY;
  10230. });
  10231. /**水平滚动值*/
  10232. __getset(0,__proto,'scrollX',function(){
  10233. return this._tf.scrollX;
  10234. });
  10235. return TextArea;
  10236. })(TextInput)
  10237. /**
  10238. *<code>Tab</code> 组件用来定义选项卡按钮组。 *
  10239. *@internal <p>属性:<code>selectedIndex</code> 的默认值为-1。</p>
  10240. *
  10241. *@example <caption>以下示例代码,创建了一个 <code>Tab</code> 实例。</caption>
  10242. *package
  10243. *{
  10244. *import laya.ui.Tab;
  10245. *import laya.utils.Handler;
  10246. *public class Tab_Example
  10247. *{
  10248. *public function Tab_Example()
  10249. *{
  10250. *Laya.init(640,800);//设置游戏画布宽高。
  10251. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  10252. *Laya.loader.load(["resource/ui/tab.png"],Handler.create(this,onLoadComplete));//加载资源。
  10253. *}
  10254. *private function onLoadComplete():void
  10255. *{
  10256. *var tab:Tab=new Tab();//创建一个 Tab 类的实例对象 tab 。
  10257. *tab.skin="resource/ui/tab.png";//设置 tab 的皮肤。
  10258. *tab.labels="item0,item1,item2";//设置 tab 的标签集。
  10259. *tab.x=100;//设置 tab 对象的属性 x 的值,用于控制 tab 对象的显示位置。
  10260. *tab.y=100;//设置 tab 对象的属性 y 的值,用于控制 tab 对象的显示位置。
  10261. *tab.selectHandler=new Handler(this,onSelect);//设置 tab 的选择项发生改变时执行的处理器。
  10262. *Laya.stage.addChild(tab);//将 tab 添到显示列表。
  10263. *}
  10264. *private function onSelect(index:int):void
  10265. *{
  10266. *trace("当前选择的表情页索引: index= ",index);
  10267. *}
  10268. *}
  10269. *}
  10270. *@example
  10271. *Laya.init(640,800);//设置游戏画布宽高
  10272. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色
  10273. *Laya.loader.load(["resource/ui/tab.png"],laya.utils.Handler.create(this,onLoadComplete));
  10274. *function onLoadComplete(){
  10275. *var tab=new laya.ui.Tab();//创建一个 Tab 类的实例对象 tab 。
  10276. *tab.skin="resource/ui/tab.png";//设置 tab 的皮肤。
  10277. *tab.labels="item0,item1,item2";//设置 tab 的标签集。
  10278. *tab.x=100;//设置 tab 对象的属性 x 的值,用于控制 tab 对象的显示位置。
  10279. *tab.y=100;//设置 tab 对象的属性 y 的值,用于控制 tab 对象的显示位置。
  10280. *tab.selectHandler=new laya.utils.Handler(this,onSelect);//设置 tab 的选择项发生改变时执行的处理器。
  10281. *Laya.stage.addChild(tab);//将 tab 添到显示列表。
  10282. *}
  10283. *function onSelect(index){
  10284. *console.log("当前选择的标签页索引: index= ",index);
  10285. *}
  10286. *@example
  10287. *import Tab=laya.ui.Tab;
  10288. *import Handler=laya.utils.Handler;
  10289. *class Tab_Example {
  10290. *constructor(){
  10291. *Laya.init(640,800);//设置游戏画布宽高。
  10292. *Laya.stage.bgColor="#efefef";//设置画布的背景颜色。
  10293. *Laya.loader.load(["resource/ui/tab.png"],Handler.create(this,this.onLoadComplete));//加载资源。
  10294. *}
  10295. *private onLoadComplete():void {
  10296. *var tab:Tab=new Tab();//创建一个 Tab 类的实例对象 tab 。
  10297. *tab.skin="resource/ui/tab.png";//设置 tab 的皮肤。
  10298. *tab.labels="item0,item1,item2";//设置 tab 的标签集。
  10299. *tab.x=100;//设置 tab 对象的属性 x 的值,用于控制 tab 对象的显示位置。
  10300. *tab.y=100;//设置 tab 对象的属性 y 的值,用于控制 tab 对象的显示位置。
  10301. *tab.selectHandler=new Handler(this,this.onSelect);//设置 tab 的选择项发生改变时执行的处理器。
  10302. *Laya.stage.addChild(tab);//将 tab 添到显示列表。
  10303. *}
  10304. *private onSelect(index:number):void {
  10305. *console.log("当前选择的表情页索引: index= ",index);
  10306. *}
  10307. *}
  10308. */
  10309. //class laya.ui.Tab extends laya.ui.UIGroup
  10310. var Tab=(function(_super){
  10311. function Tab(){
  10312. Tab.__super.call(this);;
  10313. }
  10314. __class(Tab,'laya.ui.Tab',_super);
  10315. var __proto=Tab.prototype;
  10316. /**
  10317. *@private
  10318. *@inheritDoc
  10319. */
  10320. __proto.createItem=function(skin,label){
  10321. return new Button(skin,label);
  10322. }
  10323. return Tab;
  10324. })(UIGroup)
  10325. Laya.__init([MoreGame,View]);
  10326. })(window,document,Laya);