babylon.gui.d.ts 160 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959
  1. declare module BABYLON.GUI {
  2. /**
  3. * Class used to specific a value and its associated unit
  4. */
  5. export class ValueAndUnit {
  6. /** defines the unit to store */
  7. unit: number;
  8. /** defines a boolean indicating if the value can be negative */
  9. negativeValueAllowed: boolean;
  10. private _value;
  11. private _originalUnit;
  12. /**
  13. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  14. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  15. */
  16. ignoreAdaptiveScaling: boolean;
  17. /**
  18. * Creates a new ValueAndUnit
  19. * @param value defines the value to store
  20. * @param unit defines the unit to store
  21. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  22. */
  23. constructor(value: number,
  24. /** defines the unit to store */
  25. unit?: number,
  26. /** defines a boolean indicating if the value can be negative */
  27. negativeValueAllowed?: boolean);
  28. /** Gets a boolean indicating if the value is a percentage */
  29. get isPercentage(): boolean;
  30. /** Gets a boolean indicating if the value is store as pixel */
  31. get isPixel(): boolean;
  32. /** Gets direct internal value */
  33. get internalValue(): number;
  34. /**
  35. * Gets value as pixel
  36. * @param host defines the root host
  37. * @param refValue defines the reference value for percentages
  38. * @returns the value as pixel
  39. */
  40. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  41. /**
  42. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  43. * @param value defines the value to store
  44. * @param unit defines the unit to store
  45. * @returns the current ValueAndUnit
  46. */
  47. updateInPlace(value: number, unit?: number): ValueAndUnit;
  48. /**
  49. * Gets the value accordingly to its unit
  50. * @param host defines the root host
  51. * @returns the value
  52. */
  53. getValue(host: AdvancedDynamicTexture): number;
  54. /**
  55. * Gets a string representation of the value
  56. * @param host defines the root host
  57. * @param decimals defines an optional number of decimals to display
  58. * @returns a string
  59. */
  60. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61. /**
  62. * Store a value parsed from a string
  63. * @param source defines the source string
  64. * @returns true if the value was successfully parsed
  65. */
  66. fromString(source: string | number): boolean;
  67. private static _Regex;
  68. private static _UNITMODE_PERCENTAGE;
  69. private static _UNITMODE_PIXEL;
  70. /** UNITMODE_PERCENTAGE */
  71. static get UNITMODE_PERCENTAGE(): number;
  72. /** UNITMODE_PIXEL */
  73. static get UNITMODE_PIXEL(): number;
  74. }
  75. }
  76. declare module BABYLON.GUI {
  77. /**
  78. * Define a style used by control to automatically setup properties based on a template.
  79. * Only support font related properties so far
  80. */
  81. export class Style implements BABYLON.IDisposable {
  82. private _fontFamily;
  83. private _fontStyle;
  84. private _fontWeight;
  85. /** @hidden */
  86. _host: AdvancedDynamicTexture;
  87. /** @hidden */
  88. _fontSize: ValueAndUnit;
  89. /**
  90. * BABYLON.Observable raised when the style values are changed
  91. */
  92. onChangedObservable: BABYLON.Observable<Style>;
  93. /**
  94. * Creates a new style object
  95. * @param host defines the AdvancedDynamicTexture which hosts this style
  96. */
  97. constructor(host: AdvancedDynamicTexture);
  98. /**
  99. * Gets or sets the font size
  100. */
  101. get fontSize(): string | number;
  102. set fontSize(value: string | number);
  103. /**
  104. * Gets or sets the font family
  105. */
  106. get fontFamily(): string;
  107. set fontFamily(value: string);
  108. /**
  109. * Gets or sets the font style
  110. */
  111. get fontStyle(): string;
  112. set fontStyle(value: string);
  113. /** Gets or sets font weight */
  114. get fontWeight(): string;
  115. set fontWeight(value: string);
  116. /** Dispose all associated resources */
  117. dispose(): void;
  118. }
  119. }
  120. declare module BABYLON.GUI {
  121. /**
  122. * Class used to transport BABYLON.Vector2 information for pointer events
  123. */
  124. export class Vector2WithInfo extends BABYLON.Vector2 {
  125. /** defines the current mouse button index */
  126. buttonIndex: number;
  127. /**
  128. * Creates a new Vector2WithInfo
  129. * @param source defines the vector2 data to transport
  130. * @param buttonIndex defines the current mouse button index
  131. */
  132. constructor(source: BABYLON.Vector2,
  133. /** defines the current mouse button index */
  134. buttonIndex?: number);
  135. }
  136. /** Class used to provide 2D matrix features */
  137. export class Matrix2D {
  138. /** Gets the internal array of 6 floats used to store matrix data */
  139. m: Float32Array;
  140. /**
  141. * Creates a new matrix
  142. * @param m00 defines value for (0, 0)
  143. * @param m01 defines value for (0, 1)
  144. * @param m10 defines value for (1, 0)
  145. * @param m11 defines value for (1, 1)
  146. * @param m20 defines value for (2, 0)
  147. * @param m21 defines value for (2, 1)
  148. */
  149. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  150. /**
  151. * Fills the matrix from direct values
  152. * @param m00 defines value for (0, 0)
  153. * @param m01 defines value for (0, 1)
  154. * @param m10 defines value for (1, 0)
  155. * @param m11 defines value for (1, 1)
  156. * @param m20 defines value for (2, 0)
  157. * @param m21 defines value for (2, 1)
  158. * @returns the current modified matrix
  159. */
  160. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  161. /**
  162. * Gets matrix determinant
  163. * @returns the determinant
  164. */
  165. determinant(): number;
  166. /**
  167. * Inverses the matrix and stores it in a target matrix
  168. * @param result defines the target matrix
  169. * @returns the current matrix
  170. */
  171. invertToRef(result: Matrix2D): Matrix2D;
  172. /**
  173. * Multiplies the current matrix with another one
  174. * @param other defines the second operand
  175. * @param result defines the target matrix
  176. * @returns the current matrix
  177. */
  178. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  179. /**
  180. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  181. * @param x defines the x coordinate to transform
  182. * @param y defines the x coordinate to transform
  183. * @param result defines the target vector2
  184. * @returns the current matrix
  185. */
  186. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  187. /**
  188. * Creates an identity matrix
  189. * @returns a new matrix
  190. */
  191. static Identity(): Matrix2D;
  192. /**
  193. * Creates a translation matrix and stores it in a target matrix
  194. * @param x defines the x coordinate of the translation
  195. * @param y defines the y coordinate of the translation
  196. * @param result defines the target matrix
  197. */
  198. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  199. /**
  200. * Creates a scaling matrix and stores it in a target matrix
  201. * @param x defines the x coordinate of the scaling
  202. * @param y defines the y coordinate of the scaling
  203. * @param result defines the target matrix
  204. */
  205. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  206. /**
  207. * Creates a rotation matrix and stores it in a target matrix
  208. * @param angle defines the rotation angle
  209. * @param result defines the target matrix
  210. */
  211. static RotationToRef(angle: number, result: Matrix2D): void;
  212. private static _TempPreTranslationMatrix;
  213. private static _TempPostTranslationMatrix;
  214. private static _TempRotationMatrix;
  215. private static _TempScalingMatrix;
  216. private static _TempCompose0;
  217. private static _TempCompose1;
  218. private static _TempCompose2;
  219. /**
  220. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  221. * @param tx defines the x coordinate of the translation
  222. * @param ty defines the y coordinate of the translation
  223. * @param angle defines the rotation angle
  224. * @param scaleX defines the x coordinate of the scaling
  225. * @param scaleY defines the y coordinate of the scaling
  226. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  227. * @param result defines the target matrix
  228. */
  229. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  230. }
  231. }
  232. declare module BABYLON.GUI {
  233. /**
  234. * Class used to store 2D control sizes
  235. */
  236. export class Measure {
  237. /** defines left coordinate */
  238. left: number;
  239. /** defines top coordinate */
  240. top: number;
  241. /** defines width dimension */
  242. width: number;
  243. /** defines height dimension */
  244. height: number;
  245. /**
  246. * Creates a new measure
  247. * @param left defines left coordinate
  248. * @param top defines top coordinate
  249. * @param width defines width dimension
  250. * @param height defines height dimension
  251. */
  252. constructor(
  253. /** defines left coordinate */
  254. left: number,
  255. /** defines top coordinate */
  256. top: number,
  257. /** defines width dimension */
  258. width: number,
  259. /** defines height dimension */
  260. height: number);
  261. /**
  262. * Copy from another measure
  263. * @param other defines the other measure to copy from
  264. */
  265. copyFrom(other: Measure): void;
  266. /**
  267. * Copy from a group of 4 floats
  268. * @param left defines left coordinate
  269. * @param top defines top coordinate
  270. * @param width defines width dimension
  271. * @param height defines height dimension
  272. */
  273. copyFromFloats(left: number, top: number, width: number, height: number): void;
  274. /**
  275. * Computes the axis aligned bounding box measure for two given measures
  276. * @param a Input measure
  277. * @param b Input measure
  278. * @param result the resulting bounding measure
  279. */
  280. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  281. /**
  282. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  283. * @param transform the matrix to transform the measure before computing the AABB
  284. * @param result the resulting AABB
  285. */
  286. transformToRef(transform: Matrix2D, result: Measure): void;
  287. /**
  288. * Check equality between this measure and another one
  289. * @param other defines the other measures
  290. * @returns true if both measures are equals
  291. */
  292. isEqualsTo(other: Measure): boolean;
  293. /**
  294. * Creates an empty measure
  295. * @returns a new measure
  296. */
  297. static Empty(): Measure;
  298. }
  299. }
  300. declare module BABYLON.GUI {
  301. /**
  302. * Interface used to define a control that can receive focus
  303. */
  304. export interface IFocusableControl {
  305. /**
  306. * Function called when the control receives the focus
  307. */
  308. onFocus(): void;
  309. /**
  310. * Function called when the control loses the focus
  311. */
  312. onBlur(): void;
  313. /**
  314. * Function called to let the control handle keyboard events
  315. * @param evt defines the current keyboard event
  316. */
  317. processKeyboard(evt: KeyboardEvent): void;
  318. /**
  319. * Function called to get the list of controls that should not steal the focus from this control
  320. * @returns an array of controls
  321. */
  322. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  323. }
  324. /**
  325. * Class used to create texture to support 2D GUI elements
  326. * @see http://doc.babylonjs.com/how_to/gui
  327. */
  328. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  329. private _isDirty;
  330. private _renderObserver;
  331. private _resizeObserver;
  332. private _preKeyboardObserver;
  333. private _pointerMoveObserver;
  334. private _pointerObserver;
  335. private _canvasPointerOutObserver;
  336. private _background;
  337. /** @hidden */
  338. _rootContainer: Container;
  339. /** @hidden */
  340. _lastPickedControl: Control;
  341. /** @hidden */
  342. _lastControlOver: {
  343. [pointerId: number]: Control;
  344. };
  345. /** @hidden */
  346. _lastControlDown: {
  347. [pointerId: number]: Control;
  348. };
  349. /** @hidden */
  350. _capturingControl: {
  351. [pointerId: number]: Control;
  352. };
  353. /** @hidden */
  354. _shouldBlockPointer: boolean;
  355. /** @hidden */
  356. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  357. /** @hidden */
  358. _linkedControls: Control[];
  359. private _isFullscreen;
  360. private _fullscreenViewport;
  361. private _idealWidth;
  362. private _idealHeight;
  363. private _useSmallestIdeal;
  364. private _renderAtIdealSize;
  365. private _focusedControl;
  366. private _blockNextFocusCheck;
  367. private _renderScale;
  368. private _rootElement;
  369. private _cursorChanged;
  370. /**
  371. * Define type to string to ensure compatibility across browsers
  372. * Safari doesn't support DataTransfer constructor
  373. */
  374. private _clipboardData;
  375. /**
  376. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  377. */
  378. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  379. /**
  380. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  381. */
  382. onControlPickedObservable: BABYLON.Observable<Control>;
  383. /**
  384. * BABYLON.Observable event triggered before layout is evaluated
  385. */
  386. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  387. /**
  388. * BABYLON.Observable event triggered after the layout was evaluated
  389. */
  390. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  391. /**
  392. * BABYLON.Observable event triggered before the texture is rendered
  393. */
  394. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  395. /**
  396. * BABYLON.Observable event triggered after the texture was rendered
  397. */
  398. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  399. /**
  400. * Gets or sets a boolean defining if alpha is stored as premultiplied
  401. */
  402. premulAlpha: boolean;
  403. /**
  404. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  405. * Useful when you want more antialiasing
  406. */
  407. get renderScale(): number;
  408. set renderScale(value: number);
  409. /** Gets or sets the background color */
  410. get background(): string;
  411. set background(value: string);
  412. /**
  413. * Gets or sets the ideal width used to design controls.
  414. * The GUI will then rescale everything accordingly
  415. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  416. */
  417. get idealWidth(): number;
  418. set idealWidth(value: number);
  419. /**
  420. * Gets or sets the ideal height used to design controls.
  421. * The GUI will then rescale everything accordingly
  422. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  423. */
  424. get idealHeight(): number;
  425. set idealHeight(value: number);
  426. /**
  427. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  428. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  429. */
  430. get useSmallestIdeal(): boolean;
  431. set useSmallestIdeal(value: boolean);
  432. /**
  433. * Gets or sets a boolean indicating if adaptive scaling must be used
  434. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  435. */
  436. get renderAtIdealSize(): boolean;
  437. set renderAtIdealSize(value: boolean);
  438. /**
  439. * Gets the underlying layer used to render the texture when in fullscreen mode
  440. */
  441. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  442. /**
  443. * Gets the root container control
  444. */
  445. get rootContainer(): Container;
  446. /**
  447. * Returns an array containing the root container.
  448. * This is mostly used to let the Inspector introspects the ADT
  449. * @returns an array containing the rootContainer
  450. */
  451. getChildren(): Array<Container>;
  452. /**
  453. * Will return all controls that are inside this texture
  454. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  455. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  456. * @return all child controls
  457. */
  458. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  459. /**
  460. * Gets or sets the current focused control
  461. */
  462. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  463. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  464. /**
  465. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  466. */
  467. get isForeground(): boolean;
  468. set isForeground(value: boolean);
  469. /**
  470. * Gets or set information about clipboardData
  471. */
  472. get clipboardData(): string;
  473. set clipboardData(value: string);
  474. /**
  475. * Creates a new AdvancedDynamicTexture
  476. * @param name defines the name of the texture
  477. * @param width defines the width of the texture
  478. * @param height defines the height of the texture
  479. * @param scene defines the hosting scene
  480. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  481. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  482. */
  483. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  484. /**
  485. * Get the current class name of the texture useful for serialization or dynamic coding.
  486. * @returns "AdvancedDynamicTexture"
  487. */
  488. getClassName(): string;
  489. /**
  490. * Function used to execute a function on all controls
  491. * @param func defines the function to execute
  492. * @param container defines the container where controls belong. If null the root container will be used
  493. */
  494. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  495. private _useInvalidateRectOptimization;
  496. /**
  497. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  498. */
  499. get useInvalidateRectOptimization(): boolean;
  500. set useInvalidateRectOptimization(value: boolean);
  501. private _invalidatedRectangle;
  502. /**
  503. * Invalidates a rectangle area on the gui texture
  504. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  505. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  506. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  507. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  508. */
  509. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  510. /**
  511. * Marks the texture as dirty forcing a complete update
  512. */
  513. markAsDirty(): void;
  514. /**
  515. * Helper function used to create a new style
  516. * @returns a new style
  517. * @see http://doc.babylonjs.com/how_to/gui#styles
  518. */
  519. createStyle(): Style;
  520. /**
  521. * Adds a new control to the root container
  522. * @param control defines the control to add
  523. * @returns the current texture
  524. */
  525. addControl(control: Control): AdvancedDynamicTexture;
  526. /**
  527. * Removes a control from the root container
  528. * @param control defines the control to remove
  529. * @returns the current texture
  530. */
  531. removeControl(control: Control): AdvancedDynamicTexture;
  532. /**
  533. * Release all resources
  534. */
  535. dispose(): void;
  536. private _onResize;
  537. /** @hidden */
  538. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  539. /**
  540. * Get screen coordinates for a vector3
  541. * @param position defines the position to project
  542. * @param worldMatrix defines the world matrix to use
  543. * @returns the projected position
  544. */
  545. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  546. private _checkUpdate;
  547. private _clearMeasure;
  548. private _render;
  549. /** @hidden */
  550. _changeCursor(cursor: string): void;
  551. /** @hidden */
  552. _registerLastControlDown(control: Control, pointerId: number): void;
  553. private _doPicking;
  554. /** @hidden */
  555. _cleanControlAfterRemovalFromList(list: {
  556. [pointerId: number]: Control;
  557. }, control: Control): void;
  558. /** @hidden */
  559. _cleanControlAfterRemoval(control: Control): void;
  560. /** Attach to all scene events required to support pointer events */
  561. attach(): void;
  562. /** @hidden */
  563. private onClipboardCopy;
  564. /** @hidden */
  565. private onClipboardCut;
  566. /** @hidden */
  567. private onClipboardPaste;
  568. /**
  569. * Register the clipboard Events onto the canvas
  570. */
  571. registerClipboardEvents(): void;
  572. /**
  573. * Unregister the clipboard Events from the canvas
  574. */
  575. unRegisterClipboardEvents(): void;
  576. /**
  577. * Connect the texture to a hosting mesh to enable interactions
  578. * @param mesh defines the mesh to attach to
  579. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  580. */
  581. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  582. /**
  583. * Move the focus to a specific control
  584. * @param control defines the control which will receive the focus
  585. */
  586. moveFocusToControl(control: IFocusableControl): void;
  587. private _manageFocus;
  588. private _attachToOnPointerOut;
  589. /**
  590. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  591. * @param mesh defines the mesh which will receive the texture
  592. * @param width defines the texture width (1024 by default)
  593. * @param height defines the texture height (1024 by default)
  594. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  595. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  596. * @returns a new AdvancedDynamicTexture
  597. */
  598. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  599. /**
  600. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  601. * In this mode the texture will rely on a layer for its rendering.
  602. * This allows it to be treated like any other layer.
  603. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  604. * LayerMask is set through advancedTexture.layer.layerMask
  605. * @param name defines name for the texture
  606. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  607. * @param scene defines the hsoting scene
  608. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  609. * @returns a new AdvancedDynamicTexture
  610. */
  611. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  612. }
  613. }
  614. declare module BABYLON.GUI {
  615. /**
  616. * Root class used for all 2D controls
  617. * @see http://doc.babylonjs.com/how_to/gui#controls
  618. */
  619. export class Control {
  620. /** defines the name of the control */
  621. name?: string | undefined;
  622. /**
  623. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  624. */
  625. static AllowAlphaInheritance: boolean;
  626. private _alpha;
  627. private _alphaSet;
  628. private _zIndex;
  629. /** @hidden */
  630. _host: AdvancedDynamicTexture;
  631. /** Gets or sets the control parent */
  632. parent: BABYLON.Nullable<Container>;
  633. /** @hidden */
  634. _currentMeasure: Measure;
  635. private _fontFamily;
  636. private _fontStyle;
  637. private _fontWeight;
  638. private _fontSize;
  639. private _font;
  640. /** @hidden */
  641. _width: ValueAndUnit;
  642. /** @hidden */
  643. _height: ValueAndUnit;
  644. /** @hidden */
  645. protected _fontOffset: {
  646. ascent: number;
  647. height: number;
  648. descent: number;
  649. };
  650. private _color;
  651. private _style;
  652. private _styleObserver;
  653. /** @hidden */
  654. protected _horizontalAlignment: number;
  655. /** @hidden */
  656. protected _verticalAlignment: number;
  657. /** @hidden */
  658. protected _isDirty: boolean;
  659. /** @hidden */
  660. protected _wasDirty: boolean;
  661. /** @hidden */
  662. _tempParentMeasure: Measure;
  663. /** @hidden */
  664. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  665. /** @hidden */
  666. protected _cachedParentMeasure: Measure;
  667. private _paddingLeft;
  668. private _paddingRight;
  669. private _paddingTop;
  670. private _paddingBottom;
  671. /** @hidden */
  672. _left: ValueAndUnit;
  673. /** @hidden */
  674. _top: ValueAndUnit;
  675. private _scaleX;
  676. private _scaleY;
  677. private _rotation;
  678. private _transformCenterX;
  679. private _transformCenterY;
  680. /** @hidden */
  681. _transformMatrix: Matrix2D;
  682. /** @hidden */
  683. protected _invertTransformMatrix: Matrix2D;
  684. /** @hidden */
  685. protected _transformedPosition: BABYLON.Vector2;
  686. private _isMatrixDirty;
  687. private _cachedOffsetX;
  688. private _cachedOffsetY;
  689. private _isVisible;
  690. private _isHighlighted;
  691. /** @hidden */
  692. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  693. private _fontSet;
  694. private _dummyVector2;
  695. private _downCount;
  696. private _enterCount;
  697. private _doNotRender;
  698. private _downPointerIds;
  699. protected _isEnabled: boolean;
  700. protected _disabledColor: string;
  701. /** @hidden */
  702. protected _rebuildLayout: boolean;
  703. /** @hidden */
  704. _isClipped: boolean;
  705. /** @hidden */
  706. _automaticSize: boolean;
  707. /** @hidden */
  708. _tag: any;
  709. /**
  710. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  711. */
  712. uniqueId: number;
  713. /**
  714. * Gets or sets an object used to store user defined information for the node
  715. */
  716. metadata: any;
  717. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  718. isHitTestVisible: boolean;
  719. /** Gets or sets a boolean indicating if the control can block pointer events */
  720. isPointerBlocker: boolean;
  721. /** Gets or sets a boolean indicating if the control can be focusable */
  722. isFocusInvisible: boolean;
  723. /**
  724. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  725. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  726. */
  727. clipChildren: boolean;
  728. /**
  729. * Gets or sets a boolean indicating that control content must be clipped
  730. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  731. */
  732. clipContent: boolean;
  733. /**
  734. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  735. */
  736. useBitmapCache: boolean;
  737. private _cacheData;
  738. private _shadowOffsetX;
  739. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  740. get shadowOffsetX(): number;
  741. set shadowOffsetX(value: number);
  742. private _shadowOffsetY;
  743. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  744. get shadowOffsetY(): number;
  745. set shadowOffsetY(value: number);
  746. private _shadowBlur;
  747. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  748. get shadowBlur(): number;
  749. set shadowBlur(value: number);
  750. private _shadowColor;
  751. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  752. get shadowColor(): string;
  753. set shadowColor(value: string);
  754. /** Gets or sets the cursor to use when the control is hovered */
  755. hoverCursor: string;
  756. /** @hidden */
  757. protected _linkOffsetX: ValueAndUnit;
  758. /** @hidden */
  759. protected _linkOffsetY: ValueAndUnit;
  760. /** Gets the control type name */
  761. get typeName(): string;
  762. /**
  763. * Get the current class name of the control.
  764. * @returns current class name
  765. */
  766. getClassName(): string;
  767. /**
  768. * An event triggered when the pointer move over the control.
  769. */
  770. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  771. /**
  772. * An event triggered when the pointer move out of the control.
  773. */
  774. onPointerOutObservable: BABYLON.Observable<Control>;
  775. /**
  776. * An event triggered when the pointer taps the control
  777. */
  778. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  779. /**
  780. * An event triggered when pointer up
  781. */
  782. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  783. /**
  784. * An event triggered when a control is clicked on
  785. */
  786. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  787. /**
  788. * An event triggered when pointer enters the control
  789. */
  790. onPointerEnterObservable: BABYLON.Observable<Control>;
  791. /**
  792. * An event triggered when the control is marked as dirty
  793. */
  794. onDirtyObservable: BABYLON.Observable<Control>;
  795. /**
  796. * An event triggered before drawing the control
  797. */
  798. onBeforeDrawObservable: BABYLON.Observable<Control>;
  799. /**
  800. * An event triggered after the control was drawn
  801. */
  802. onAfterDrawObservable: BABYLON.Observable<Control>;
  803. /**
  804. * Get the hosting AdvancedDynamicTexture
  805. */
  806. get host(): AdvancedDynamicTexture;
  807. /** Gets or set information about font offsets (used to render and align text) */
  808. get fontOffset(): {
  809. ascent: number;
  810. height: number;
  811. descent: number;
  812. };
  813. set fontOffset(offset: {
  814. ascent: number;
  815. height: number;
  816. descent: number;
  817. });
  818. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  819. get alpha(): number;
  820. set alpha(value: number);
  821. /**
  822. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  823. */
  824. get isHighlighted(): boolean;
  825. set isHighlighted(value: boolean);
  826. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  827. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  828. */
  829. get scaleX(): number;
  830. set scaleX(value: number);
  831. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  832. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  833. */
  834. get scaleY(): number;
  835. set scaleY(value: number);
  836. /** Gets or sets the rotation angle (0 by default)
  837. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  838. */
  839. get rotation(): number;
  840. set rotation(value: number);
  841. /** Gets or sets the transformation center on Y axis (0 by default)
  842. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  843. */
  844. get transformCenterY(): number;
  845. set transformCenterY(value: number);
  846. /** Gets or sets the transformation center on X axis (0 by default)
  847. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  848. */
  849. get transformCenterX(): number;
  850. set transformCenterX(value: number);
  851. /**
  852. * Gets or sets the horizontal alignment
  853. * @see http://doc.babylonjs.com/how_to/gui#alignments
  854. */
  855. get horizontalAlignment(): number;
  856. set horizontalAlignment(value: number);
  857. /**
  858. * Gets or sets the vertical alignment
  859. * @see http://doc.babylonjs.com/how_to/gui#alignments
  860. */
  861. get verticalAlignment(): number;
  862. set verticalAlignment(value: number);
  863. /**
  864. * Gets or sets control width
  865. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  866. */
  867. get width(): string | number;
  868. set width(value: string | number);
  869. /**
  870. * Gets or sets the control width in pixel
  871. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  872. */
  873. get widthInPixels(): number;
  874. set widthInPixels(value: number);
  875. /**
  876. * Gets or sets control height
  877. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  878. */
  879. get height(): string | number;
  880. set height(value: string | number);
  881. /**
  882. * Gets or sets control height in pixel
  883. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  884. */
  885. get heightInPixels(): number;
  886. set heightInPixels(value: number);
  887. /** Gets or set font family */
  888. get fontFamily(): string;
  889. set fontFamily(value: string);
  890. /** Gets or sets font style */
  891. get fontStyle(): string;
  892. set fontStyle(value: string);
  893. /** Gets or sets font weight */
  894. get fontWeight(): string;
  895. set fontWeight(value: string);
  896. /**
  897. * Gets or sets style
  898. * @see http://doc.babylonjs.com/how_to/gui#styles
  899. */
  900. get style(): BABYLON.Nullable<Style>;
  901. set style(value: BABYLON.Nullable<Style>);
  902. /** @hidden */
  903. get _isFontSizeInPercentage(): boolean;
  904. /** Gets or sets font size in pixels */
  905. get fontSizeInPixels(): number;
  906. set fontSizeInPixels(value: number);
  907. /** Gets or sets font size */
  908. get fontSize(): string | number;
  909. set fontSize(value: string | number);
  910. /** Gets or sets foreground color */
  911. get color(): string;
  912. set color(value: string);
  913. /** Gets or sets z index which is used to reorder controls on the z axis */
  914. get zIndex(): number;
  915. set zIndex(value: number);
  916. /** Gets or sets a boolean indicating if the control can be rendered */
  917. get notRenderable(): boolean;
  918. set notRenderable(value: boolean);
  919. /** Gets or sets a boolean indicating if the control is visible */
  920. get isVisible(): boolean;
  921. set isVisible(value: boolean);
  922. /** Gets a boolean indicating that the control needs to update its rendering */
  923. get isDirty(): boolean;
  924. /**
  925. * Gets the current linked mesh (or null if none)
  926. */
  927. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  928. /**
  929. * Gets or sets a value indicating the padding to use on the left of the control
  930. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  931. */
  932. get paddingLeft(): string | number;
  933. set paddingLeft(value: string | number);
  934. /**
  935. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  936. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  937. */
  938. get paddingLeftInPixels(): number;
  939. set paddingLeftInPixels(value: number);
  940. /**
  941. * Gets or sets a value indicating the padding to use on the right of the control
  942. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  943. */
  944. get paddingRight(): string | number;
  945. set paddingRight(value: string | number);
  946. /**
  947. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  948. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  949. */
  950. get paddingRightInPixels(): number;
  951. set paddingRightInPixels(value: number);
  952. /**
  953. * Gets or sets a value indicating the padding to use on the top of the control
  954. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  955. */
  956. get paddingTop(): string | number;
  957. set paddingTop(value: string | number);
  958. /**
  959. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  960. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  961. */
  962. get paddingTopInPixels(): number;
  963. set paddingTopInPixels(value: number);
  964. /**
  965. * Gets or sets a value indicating the padding to use on the bottom of the control
  966. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  967. */
  968. get paddingBottom(): string | number;
  969. set paddingBottom(value: string | number);
  970. /**
  971. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  972. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  973. */
  974. get paddingBottomInPixels(): number;
  975. set paddingBottomInPixels(value: number);
  976. /**
  977. * Gets or sets a value indicating the left coordinate of the control
  978. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  979. */
  980. get left(): string | number;
  981. set left(value: string | number);
  982. /**
  983. * Gets or sets a value indicating the left coordinate in pixels of the control
  984. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  985. */
  986. get leftInPixels(): number;
  987. set leftInPixels(value: number);
  988. /**
  989. * Gets or sets a value indicating the top coordinate of the control
  990. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  991. */
  992. get top(): string | number;
  993. set top(value: string | number);
  994. /**
  995. * Gets or sets a value indicating the top coordinate in pixels of the control
  996. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  997. */
  998. get topInPixels(): number;
  999. set topInPixels(value: number);
  1000. /**
  1001. * Gets or sets a value indicating the offset on X axis to the linked mesh
  1002. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1003. */
  1004. get linkOffsetX(): string | number;
  1005. set linkOffsetX(value: string | number);
  1006. /**
  1007. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  1008. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1009. */
  1010. get linkOffsetXInPixels(): number;
  1011. set linkOffsetXInPixels(value: number);
  1012. /**
  1013. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  1014. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1015. */
  1016. get linkOffsetY(): string | number;
  1017. set linkOffsetY(value: string | number);
  1018. /**
  1019. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  1020. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1021. */
  1022. get linkOffsetYInPixels(): number;
  1023. set linkOffsetYInPixels(value: number);
  1024. /** Gets the center coordinate on X axis */
  1025. get centerX(): number;
  1026. /** Gets the center coordinate on Y axis */
  1027. get centerY(): number;
  1028. /** Gets or sets if control is Enabled*/
  1029. get isEnabled(): boolean;
  1030. set isEnabled(value: boolean);
  1031. /** Gets or sets background color of control if it's disabled*/
  1032. get disabledColor(): string;
  1033. set disabledColor(value: string);
  1034. /**
  1035. * Creates a new control
  1036. * @param name defines the name of the control
  1037. */
  1038. constructor(
  1039. /** defines the name of the control */
  1040. name?: string | undefined);
  1041. /** @hidden */
  1042. protected _getTypeName(): string;
  1043. /**
  1044. * Gets the first ascendant in the hierarchy of the given type
  1045. * @param className defines the required type
  1046. * @returns the ascendant or null if not found
  1047. */
  1048. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  1049. /** @hidden */
  1050. _resetFontCache(): void;
  1051. /**
  1052. * Determines if a container is an ascendant of the current control
  1053. * @param container defines the container to look for
  1054. * @returns true if the container is one of the ascendant of the control
  1055. */
  1056. isAscendant(container: Control): boolean;
  1057. /**
  1058. * Gets coordinates in local control space
  1059. * @param globalCoordinates defines the coordinates to transform
  1060. * @returns the new coordinates in local space
  1061. */
  1062. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  1063. /**
  1064. * Gets coordinates in local control space
  1065. * @param globalCoordinates defines the coordinates to transform
  1066. * @param result defines the target vector2 where to store the result
  1067. * @returns the current control
  1068. */
  1069. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  1070. /**
  1071. * Gets coordinates in parent local control space
  1072. * @param globalCoordinates defines the coordinates to transform
  1073. * @returns the new coordinates in parent local space
  1074. */
  1075. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  1076. /**
  1077. * Move the current control to a vector3 position projected onto the screen.
  1078. * @param position defines the target position
  1079. * @param scene defines the hosting scene
  1080. */
  1081. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  1082. /**
  1083. * Will store all controls that have this control as ascendant in a given array
  1084. * @param results defines the array where to store the descendants
  1085. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  1086. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  1087. */
  1088. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  1089. /**
  1090. * Will return all controls that have this control as ascendant
  1091. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  1092. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  1093. * @return all child controls
  1094. */
  1095. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  1096. /**
  1097. * Link current control with a target mesh
  1098. * @param mesh defines the mesh to link with
  1099. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1100. */
  1101. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  1102. /** @hidden */
  1103. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  1104. /** @hidden */
  1105. _offsetLeft(offset: number): void;
  1106. /** @hidden */
  1107. _offsetTop(offset: number): void;
  1108. /** @hidden */
  1109. _markMatrixAsDirty(): void;
  1110. /** @hidden */
  1111. _flagDescendantsAsMatrixDirty(): void;
  1112. /** @hidden */
  1113. _intersectsRect(rect: Measure): boolean;
  1114. /** @hidden */
  1115. protected invalidateRect(): void;
  1116. /** @hidden */
  1117. _markAsDirty(force?: boolean): void;
  1118. /** @hidden */
  1119. _markAllAsDirty(): void;
  1120. /** @hidden */
  1121. _link(host: AdvancedDynamicTexture): void;
  1122. /** @hidden */
  1123. protected _transform(context?: CanvasRenderingContext2D): void;
  1124. /** @hidden */
  1125. _renderHighlight(context: CanvasRenderingContext2D): void;
  1126. /** @hidden */
  1127. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  1128. /** @hidden */
  1129. protected _applyStates(context: CanvasRenderingContext2D): void;
  1130. /** @hidden */
  1131. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  1132. /** @hidden */
  1133. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1134. protected _evaluateClippingState(parentMeasure: Measure): void;
  1135. /** @hidden */
  1136. _measure(): void;
  1137. /** @hidden */
  1138. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1139. /** @hidden */
  1140. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1141. /** @hidden */
  1142. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1143. /** @hidden */
  1144. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1145. private static _ClipMeasure;
  1146. private _tmpMeasureA;
  1147. private _clip;
  1148. /** @hidden */
  1149. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  1150. /** @hidden */
  1151. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  1152. /**
  1153. * Tests if a given coordinates belong to the current control
  1154. * @param x defines x coordinate to test
  1155. * @param y defines y coordinate to test
  1156. * @returns true if the coordinates are inside the control
  1157. */
  1158. contains(x: number, y: number): boolean;
  1159. /** @hidden */
  1160. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1161. /** @hidden */
  1162. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  1163. /** @hidden */
  1164. _onPointerEnter(target: Control): boolean;
  1165. /** @hidden */
  1166. _onPointerOut(target: Control, force?: boolean): void;
  1167. /** @hidden */
  1168. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  1169. /** @hidden */
  1170. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1171. /** @hidden */
  1172. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  1173. /** @hidden */
  1174. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  1175. private _prepareFont;
  1176. /** Releases associated resources */
  1177. dispose(): void;
  1178. private static _HORIZONTAL_ALIGNMENT_LEFT;
  1179. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  1180. private static _HORIZONTAL_ALIGNMENT_CENTER;
  1181. private static _VERTICAL_ALIGNMENT_TOP;
  1182. private static _VERTICAL_ALIGNMENT_BOTTOM;
  1183. private static _VERTICAL_ALIGNMENT_CENTER;
  1184. /** HORIZONTAL_ALIGNMENT_LEFT */
  1185. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  1186. /** HORIZONTAL_ALIGNMENT_RIGHT */
  1187. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  1188. /** HORIZONTAL_ALIGNMENT_CENTER */
  1189. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  1190. /** VERTICAL_ALIGNMENT_TOP */
  1191. static get VERTICAL_ALIGNMENT_TOP(): number;
  1192. /** VERTICAL_ALIGNMENT_BOTTOM */
  1193. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  1194. /** VERTICAL_ALIGNMENT_CENTER */
  1195. static get VERTICAL_ALIGNMENT_CENTER(): number;
  1196. private static _FontHeightSizes;
  1197. /** @hidden */
  1198. static _GetFontOffset(font: string): {
  1199. ascent: number;
  1200. height: number;
  1201. descent: number;
  1202. };
  1203. /**
  1204. * Creates a stack panel that can be used to render headers
  1205. * @param control defines the control to associate with the header
  1206. * @param text defines the text of the header
  1207. * @param size defines the size of the header
  1208. * @param options defines options used to configure the header
  1209. * @returns a new StackPanel
  1210. * @ignore
  1211. * @hidden
  1212. */
  1213. static AddHeader: (control: Control, text: string, size: string | number, options: {
  1214. isHorizontal: boolean;
  1215. controlFirst: boolean;
  1216. }) => any;
  1217. /** @hidden */
  1218. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  1219. }
  1220. }
  1221. declare module BABYLON.GUI {
  1222. /**
  1223. * Root class for 2D containers
  1224. * @see http://doc.babylonjs.com/how_to/gui#containers
  1225. */
  1226. export class Container extends Control {
  1227. name?: string | undefined;
  1228. /** @hidden */
  1229. protected _children: Control[];
  1230. /** @hidden */
  1231. protected _measureForChildren: Measure;
  1232. /** @hidden */
  1233. protected _background: string;
  1234. /** @hidden */
  1235. protected _adaptWidthToChildren: boolean;
  1236. /** @hidden */
  1237. protected _adaptHeightToChildren: boolean;
  1238. /**
  1239. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  1240. */
  1241. logLayoutCycleErrors: boolean;
  1242. /**
  1243. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  1244. */
  1245. maxLayoutCycle: number;
  1246. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  1247. get adaptHeightToChildren(): boolean;
  1248. set adaptHeightToChildren(value: boolean);
  1249. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  1250. get adaptWidthToChildren(): boolean;
  1251. set adaptWidthToChildren(value: boolean);
  1252. /** Gets or sets background color */
  1253. get background(): string;
  1254. set background(value: string);
  1255. /** Gets the list of children */
  1256. get children(): Control[];
  1257. /**
  1258. * Creates a new Container
  1259. * @param name defines the name of the container
  1260. */
  1261. constructor(name?: string | undefined);
  1262. protected _getTypeName(): string;
  1263. _flagDescendantsAsMatrixDirty(): void;
  1264. /**
  1265. * Gets a child using its name
  1266. * @param name defines the child name to look for
  1267. * @returns the child control if found
  1268. */
  1269. getChildByName(name: string): BABYLON.Nullable<Control>;
  1270. /**
  1271. * Gets a child using its type and its name
  1272. * @param name defines the child name to look for
  1273. * @param type defines the child type to look for
  1274. * @returns the child control if found
  1275. */
  1276. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  1277. /**
  1278. * Search for a specific control in children
  1279. * @param control defines the control to look for
  1280. * @returns true if the control is in child list
  1281. */
  1282. containsControl(control: Control): boolean;
  1283. /**
  1284. * Adds a new control to the current container
  1285. * @param control defines the control to add
  1286. * @returns the current container
  1287. */
  1288. addControl(control: BABYLON.Nullable<Control>): Container;
  1289. /**
  1290. * Removes all controls from the current container
  1291. * @returns the current container
  1292. */
  1293. clearControls(): Container;
  1294. /**
  1295. * Removes a control from the current container
  1296. * @param control defines the control to remove
  1297. * @returns the current container
  1298. */
  1299. removeControl(control: Control): Container;
  1300. /** @hidden */
  1301. _reOrderControl(control: Control): void;
  1302. /** @hidden */
  1303. _offsetLeft(offset: number): void;
  1304. /** @hidden */
  1305. _offsetTop(offset: number): void;
  1306. /** @hidden */
  1307. _markAllAsDirty(): void;
  1308. /** @hidden */
  1309. protected _localDraw(context: CanvasRenderingContext2D): void;
  1310. /** @hidden */
  1311. _link(host: AdvancedDynamicTexture): void;
  1312. /** @hidden */
  1313. protected _beforeLayout(): void;
  1314. /** @hidden */
  1315. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1316. /** @hidden */
  1317. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  1318. protected _postMeasure(): void;
  1319. /** @hidden */
  1320. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  1321. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  1322. /** @hidden */
  1323. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1324. /** @hidden */
  1325. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1326. /** Releases associated resources */
  1327. dispose(): void;
  1328. }
  1329. }
  1330. declare module BABYLON.GUI {
  1331. /** Class used to create rectangle container */
  1332. export class Rectangle extends Container {
  1333. name?: string | undefined;
  1334. private _thickness;
  1335. private _cornerRadius;
  1336. /** Gets or sets border thickness */
  1337. get thickness(): number;
  1338. set thickness(value: number);
  1339. /** Gets or sets the corner radius angle */
  1340. get cornerRadius(): number;
  1341. set cornerRadius(value: number);
  1342. /**
  1343. * Creates a new Rectangle
  1344. * @param name defines the control name
  1345. */
  1346. constructor(name?: string | undefined);
  1347. protected _getTypeName(): string;
  1348. protected _localDraw(context: CanvasRenderingContext2D): void;
  1349. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1350. private _drawRoundedRect;
  1351. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1352. }
  1353. }
  1354. declare module BABYLON.GUI {
  1355. /**
  1356. * Enum that determines the text-wrapping mode to use.
  1357. */
  1358. export enum TextWrapping {
  1359. /**
  1360. * Clip the text when it's larger than Control.width; this is the default mode.
  1361. */
  1362. Clip = 0,
  1363. /**
  1364. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  1365. */
  1366. WordWrap = 1,
  1367. /**
  1368. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  1369. */
  1370. Ellipsis = 2
  1371. }
  1372. /**
  1373. * Class used to create text block control
  1374. */
  1375. export class TextBlock extends Control {
  1376. /**
  1377. * Defines the name of the control
  1378. */
  1379. name?: string | undefined;
  1380. private _text;
  1381. private _textWrapping;
  1382. private _textHorizontalAlignment;
  1383. private _textVerticalAlignment;
  1384. private _lines;
  1385. private _resizeToFit;
  1386. private _lineSpacing;
  1387. private _outlineWidth;
  1388. private _outlineColor;
  1389. /**
  1390. * An event triggered after the text is changed
  1391. */
  1392. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  1393. /**
  1394. * An event triggered after the text was broken up into lines
  1395. */
  1396. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  1397. /**
  1398. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  1399. */
  1400. get lines(): any[];
  1401. /**
  1402. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1403. */
  1404. get resizeToFit(): boolean;
  1405. /**
  1406. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1407. */
  1408. set resizeToFit(value: boolean);
  1409. /**
  1410. * Gets or sets a boolean indicating if text must be wrapped
  1411. */
  1412. get textWrapping(): TextWrapping | boolean;
  1413. /**
  1414. * Gets or sets a boolean indicating if text must be wrapped
  1415. */
  1416. set textWrapping(value: TextWrapping | boolean);
  1417. /**
  1418. * Gets or sets text to display
  1419. */
  1420. get text(): string;
  1421. /**
  1422. * Gets or sets text to display
  1423. */
  1424. set text(value: string);
  1425. /**
  1426. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1427. */
  1428. get textHorizontalAlignment(): number;
  1429. /**
  1430. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1431. */
  1432. set textHorizontalAlignment(value: number);
  1433. /**
  1434. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1435. */
  1436. get textVerticalAlignment(): number;
  1437. /**
  1438. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1439. */
  1440. set textVerticalAlignment(value: number);
  1441. /**
  1442. * Gets or sets line spacing value
  1443. */
  1444. set lineSpacing(value: string | number);
  1445. /**
  1446. * Gets or sets line spacing value
  1447. */
  1448. get lineSpacing(): string | number;
  1449. /**
  1450. * Gets or sets outlineWidth of the text to display
  1451. */
  1452. get outlineWidth(): number;
  1453. /**
  1454. * Gets or sets outlineWidth of the text to display
  1455. */
  1456. set outlineWidth(value: number);
  1457. /**
  1458. * Gets or sets outlineColor of the text to display
  1459. */
  1460. get outlineColor(): string;
  1461. /**
  1462. * Gets or sets outlineColor of the text to display
  1463. */
  1464. set outlineColor(value: string);
  1465. /**
  1466. * Creates a new TextBlock object
  1467. * @param name defines the name of the control
  1468. * @param text defines the text to display (emptry string by default)
  1469. */
  1470. constructor(
  1471. /**
  1472. * Defines the name of the control
  1473. */
  1474. name?: string | undefined, text?: string);
  1475. protected _getTypeName(): string;
  1476. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1477. private _drawText;
  1478. /** @hidden */
  1479. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  1480. protected _applyStates(context: CanvasRenderingContext2D): void;
  1481. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  1482. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  1483. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  1484. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  1485. protected _renderLines(context: CanvasRenderingContext2D): void;
  1486. /**
  1487. * Given a width constraint applied on the text block, find the expected height
  1488. * @returns expected height
  1489. */
  1490. computeExpectedHeight(): number;
  1491. dispose(): void;
  1492. }
  1493. }
  1494. declare module BABYLON.GUI {
  1495. /**
  1496. * Class used to create 2D images
  1497. */
  1498. export class Image extends Control {
  1499. name?: string | undefined;
  1500. private _workingCanvas;
  1501. private _domImage;
  1502. private _imageWidth;
  1503. private _imageHeight;
  1504. private _loaded;
  1505. private _stretch;
  1506. private _source;
  1507. private _autoScale;
  1508. private _sourceLeft;
  1509. private _sourceTop;
  1510. private _sourceWidth;
  1511. private _sourceHeight;
  1512. private _cellWidth;
  1513. private _cellHeight;
  1514. private _cellId;
  1515. private _populateNinePatchSlicesFromImage;
  1516. private _sliceLeft;
  1517. private _sliceRight;
  1518. private _sliceTop;
  1519. private _sliceBottom;
  1520. private _detectPointerOnOpaqueOnly;
  1521. /**
  1522. * BABYLON.Observable notified when the content is loaded
  1523. */
  1524. onImageLoadedObservable: BABYLON.Observable<Image>;
  1525. /**
  1526. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  1527. */
  1528. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  1529. /**
  1530. * Gets a boolean indicating that the content is loaded
  1531. */
  1532. get isLoaded(): boolean;
  1533. /**
  1534. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  1535. */
  1536. get populateNinePatchSlicesFromImage(): boolean;
  1537. set populateNinePatchSlicesFromImage(value: boolean);
  1538. /**
  1539. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  1540. * Beware using this as this will comsume more memory as the image has to be stored twice
  1541. */
  1542. get detectPointerOnOpaqueOnly(): boolean;
  1543. set detectPointerOnOpaqueOnly(value: boolean);
  1544. /**
  1545. * Gets or sets the left value for slicing (9-patch)
  1546. */
  1547. get sliceLeft(): number;
  1548. set sliceLeft(value: number);
  1549. /**
  1550. * Gets or sets the right value for slicing (9-patch)
  1551. */
  1552. get sliceRight(): number;
  1553. set sliceRight(value: number);
  1554. /**
  1555. * Gets or sets the top value for slicing (9-patch)
  1556. */
  1557. get sliceTop(): number;
  1558. set sliceTop(value: number);
  1559. /**
  1560. * Gets or sets the bottom value for slicing (9-patch)
  1561. */
  1562. get sliceBottom(): number;
  1563. set sliceBottom(value: number);
  1564. /**
  1565. * Gets or sets the left coordinate in the source image
  1566. */
  1567. get sourceLeft(): number;
  1568. set sourceLeft(value: number);
  1569. /**
  1570. * Gets or sets the top coordinate in the source image
  1571. */
  1572. get sourceTop(): number;
  1573. set sourceTop(value: number);
  1574. /**
  1575. * Gets or sets the width to capture in the source image
  1576. */
  1577. get sourceWidth(): number;
  1578. set sourceWidth(value: number);
  1579. /**
  1580. * Gets or sets the height to capture in the source image
  1581. */
  1582. get sourceHeight(): number;
  1583. set sourceHeight(value: number);
  1584. /**
  1585. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  1586. * @see http://doc.babylonjs.com/how_to/gui#image
  1587. */
  1588. get autoScale(): boolean;
  1589. set autoScale(value: boolean);
  1590. /** Gets or sets the streching mode used by the image */
  1591. get stretch(): number;
  1592. set stretch(value: number);
  1593. /** @hidden */
  1594. _rotate90(n: number): Image;
  1595. /**
  1596. * Gets or sets the internal DOM image used to render the control
  1597. */
  1598. set domImage(value: HTMLImageElement);
  1599. get domImage(): HTMLImageElement;
  1600. private _onImageLoaded;
  1601. private _extractNinePatchSliceDataFromImage;
  1602. /**
  1603. * Gets or sets image source url
  1604. */
  1605. set source(value: BABYLON.Nullable<string>);
  1606. /**
  1607. * Checks for svg document with icon id present
  1608. */
  1609. private _svgCheck;
  1610. /**
  1611. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  1612. * given external svg file and icon id
  1613. */
  1614. private _getSVGAttribs;
  1615. /**
  1616. * Gets or sets the cell width to use when animation sheet is enabled
  1617. * @see http://doc.babylonjs.com/how_to/gui#image
  1618. */
  1619. get cellWidth(): number;
  1620. set cellWidth(value: number);
  1621. /**
  1622. * Gets or sets the cell height to use when animation sheet is enabled
  1623. * @see http://doc.babylonjs.com/how_to/gui#image
  1624. */
  1625. get cellHeight(): number;
  1626. set cellHeight(value: number);
  1627. /**
  1628. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  1629. * @see http://doc.babylonjs.com/how_to/gui#image
  1630. */
  1631. get cellId(): number;
  1632. set cellId(value: number);
  1633. /**
  1634. * Creates a new Image
  1635. * @param name defines the control name
  1636. * @param url defines the image url
  1637. */
  1638. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  1639. /**
  1640. * Tests if a given coordinates belong to the current control
  1641. * @param x defines x coordinate to test
  1642. * @param y defines y coordinate to test
  1643. * @returns true if the coordinates are inside the control
  1644. */
  1645. contains(x: number, y: number): boolean;
  1646. protected _getTypeName(): string;
  1647. /** Force the control to synchronize with its content */
  1648. synchronizeSizeWithContent(): void;
  1649. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1650. private _prepareWorkingCanvasForOpaqueDetection;
  1651. private _drawImage;
  1652. _draw(context: CanvasRenderingContext2D): void;
  1653. private _renderCornerPatch;
  1654. private _renderNinePatch;
  1655. dispose(): void;
  1656. /** STRETCH_NONE */
  1657. static readonly STRETCH_NONE: number;
  1658. /** STRETCH_FILL */
  1659. static readonly STRETCH_FILL: number;
  1660. /** STRETCH_UNIFORM */
  1661. static readonly STRETCH_UNIFORM: number;
  1662. /** STRETCH_EXTEND */
  1663. static readonly STRETCH_EXTEND: number;
  1664. /** NINE_PATCH */
  1665. static readonly STRETCH_NINE_PATCH: number;
  1666. }
  1667. }
  1668. declare module BABYLON.GUI {
  1669. /**
  1670. * Class used to create 2D buttons
  1671. */
  1672. export class Button extends Rectangle {
  1673. name?: string | undefined;
  1674. /**
  1675. * Function called to generate a pointer enter animation
  1676. */
  1677. pointerEnterAnimation: () => void;
  1678. /**
  1679. * Function called to generate a pointer out animation
  1680. */
  1681. pointerOutAnimation: () => void;
  1682. /**
  1683. * Function called to generate a pointer down animation
  1684. */
  1685. pointerDownAnimation: () => void;
  1686. /**
  1687. * Function called to generate a pointer up animation
  1688. */
  1689. pointerUpAnimation: () => void;
  1690. /**
  1691. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1692. */
  1693. delegatePickingToChildren: boolean;
  1694. private _image;
  1695. /**
  1696. * Returns the image part of the button (if any)
  1697. */
  1698. get image(): BABYLON.Nullable<Image>;
  1699. private _textBlock;
  1700. /**
  1701. * Returns the image part of the button (if any)
  1702. */
  1703. get textBlock(): BABYLON.Nullable<TextBlock>;
  1704. /**
  1705. * Creates a new Button
  1706. * @param name defines the name of the button
  1707. */
  1708. constructor(name?: string | undefined);
  1709. protected _getTypeName(): string;
  1710. /** @hidden */
  1711. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1712. /** @hidden */
  1713. _onPointerEnter(target: Control): boolean;
  1714. /** @hidden */
  1715. _onPointerOut(target: Control, force?: boolean): void;
  1716. /** @hidden */
  1717. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  1718. /** @hidden */
  1719. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1720. /**
  1721. * Creates a new button made with an image and a text
  1722. * @param name defines the name of the button
  1723. * @param text defines the text of the button
  1724. * @param imageUrl defines the url of the image
  1725. * @returns a new Button
  1726. */
  1727. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  1728. /**
  1729. * Creates a new button made with an image
  1730. * @param name defines the name of the button
  1731. * @param imageUrl defines the url of the image
  1732. * @returns a new Button
  1733. */
  1734. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  1735. /**
  1736. * Creates a new button made with a text
  1737. * @param name defines the name of the button
  1738. * @param text defines the text of the button
  1739. * @returns a new Button
  1740. */
  1741. static CreateSimpleButton(name: string, text: string): Button;
  1742. /**
  1743. * Creates a new button made with an image and a centered text
  1744. * @param name defines the name of the button
  1745. * @param text defines the text of the button
  1746. * @param imageUrl defines the url of the image
  1747. * @returns a new Button
  1748. */
  1749. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  1750. }
  1751. }
  1752. declare module BABYLON.GUI {
  1753. /**
  1754. * Class used to create a 2D stack panel container
  1755. */
  1756. export class StackPanel extends Container {
  1757. name?: string | undefined;
  1758. private _isVertical;
  1759. private _manualWidth;
  1760. private _manualHeight;
  1761. private _doNotTrackManualChanges;
  1762. /**
  1763. * Gets or sets a boolean indicating that layou warnings should be ignored
  1764. */
  1765. ignoreLayoutWarnings: boolean;
  1766. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  1767. get isVertical(): boolean;
  1768. set isVertical(value: boolean);
  1769. /**
  1770. * Gets or sets panel width.
  1771. * This value should not be set when in horizontal mode as it will be computed automatically
  1772. */
  1773. set width(value: string | number);
  1774. get width(): string | number;
  1775. /**
  1776. * Gets or sets panel height.
  1777. * This value should not be set when in vertical mode as it will be computed automatically
  1778. */
  1779. set height(value: string | number);
  1780. get height(): string | number;
  1781. /**
  1782. * Creates a new StackPanel
  1783. * @param name defines control name
  1784. */
  1785. constructor(name?: string | undefined);
  1786. protected _getTypeName(): string;
  1787. /** @hidden */
  1788. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1789. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1790. protected _postMeasure(): void;
  1791. }
  1792. }
  1793. declare module BABYLON.GUI {
  1794. /**
  1795. * Class used to represent a 2D checkbox
  1796. */
  1797. export class Checkbox extends Control {
  1798. name?: string | undefined;
  1799. private _isChecked;
  1800. private _background;
  1801. private _checkSizeRatio;
  1802. private _thickness;
  1803. /** Gets or sets border thickness */
  1804. get thickness(): number;
  1805. set thickness(value: number);
  1806. /**
  1807. * BABYLON.Observable raised when isChecked property changes
  1808. */
  1809. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  1810. /** Gets or sets a value indicating the ratio between overall size and check size */
  1811. get checkSizeRatio(): number;
  1812. set checkSizeRatio(value: number);
  1813. /** Gets or sets background color */
  1814. get background(): string;
  1815. set background(value: string);
  1816. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1817. get isChecked(): boolean;
  1818. set isChecked(value: boolean);
  1819. /**
  1820. * Creates a new CheckBox
  1821. * @param name defines the control name
  1822. */
  1823. constructor(name?: string | undefined);
  1824. protected _getTypeName(): string;
  1825. /** @hidden */
  1826. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  1827. /** @hidden */
  1828. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  1829. /**
  1830. * Utility function to easily create a checkbox with a header
  1831. * @param title defines the label to use for the header
  1832. * @param onValueChanged defines the callback to call when value changes
  1833. * @returns a StackPanel containing the checkbox and a textBlock
  1834. */
  1835. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  1836. }
  1837. }
  1838. declare module BABYLON.GUI {
  1839. /**
  1840. * Class used to store key control properties
  1841. */
  1842. export class KeyPropertySet {
  1843. /** Width */
  1844. width?: string;
  1845. /** Height */
  1846. height?: string;
  1847. /** Left padding */
  1848. paddingLeft?: string;
  1849. /** Right padding */
  1850. paddingRight?: string;
  1851. /** Top padding */
  1852. paddingTop?: string;
  1853. /** Bottom padding */
  1854. paddingBottom?: string;
  1855. /** Foreground color */
  1856. color?: string;
  1857. /** Background color */
  1858. background?: string;
  1859. }
  1860. /**
  1861. * Class used to create virtual keyboard
  1862. */
  1863. export class VirtualKeyboard extends StackPanel {
  1864. /** BABYLON.Observable raised when a key is pressed */
  1865. onKeyPressObservable: BABYLON.Observable<string>;
  1866. /** Gets or sets default key button width */
  1867. defaultButtonWidth: string;
  1868. /** Gets or sets default key button height */
  1869. defaultButtonHeight: string;
  1870. /** Gets or sets default key button left padding */
  1871. defaultButtonPaddingLeft: string;
  1872. /** Gets or sets default key button right padding */
  1873. defaultButtonPaddingRight: string;
  1874. /** Gets or sets default key button top padding */
  1875. defaultButtonPaddingTop: string;
  1876. /** Gets or sets default key button bottom padding */
  1877. defaultButtonPaddingBottom: string;
  1878. /** Gets or sets default key button foreground color */
  1879. defaultButtonColor: string;
  1880. /** Gets or sets default key button background color */
  1881. defaultButtonBackground: string;
  1882. /** Gets or sets shift button foreground color */
  1883. shiftButtonColor: string;
  1884. /** Gets or sets shift button thickness*/
  1885. selectedShiftThickness: number;
  1886. /** Gets shift key state */
  1887. shiftState: number;
  1888. protected _getTypeName(): string;
  1889. private _createKey;
  1890. /**
  1891. * Adds a new row of keys
  1892. * @param keys defines the list of keys to add
  1893. * @param propertySets defines the associated property sets
  1894. */
  1895. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  1896. /**
  1897. * Set the shift key to a specific state
  1898. * @param shiftState defines the new shift state
  1899. */
  1900. applyShiftState(shiftState: number): void;
  1901. private _currentlyConnectedInputText;
  1902. private _connectedInputTexts;
  1903. private _onKeyPressObserver;
  1904. /** Gets the input text control currently attached to the keyboard */
  1905. get connectedInputText(): BABYLON.Nullable<InputText>;
  1906. /**
  1907. * Connects the keyboard with an input text control
  1908. *
  1909. * @param input defines the target control
  1910. */
  1911. connect(input: InputText): void;
  1912. /**
  1913. * Disconnects the keyboard from connected InputText controls
  1914. *
  1915. * @param input optionally defines a target control, otherwise all are disconnected
  1916. */
  1917. disconnect(input?: InputText): void;
  1918. private _removeConnectedInputObservables;
  1919. /**
  1920. * Release all resources
  1921. */
  1922. dispose(): void;
  1923. /**
  1924. * Creates a new keyboard using a default layout
  1925. *
  1926. * @param name defines control name
  1927. * @returns a new VirtualKeyboard
  1928. */
  1929. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  1930. }
  1931. }
  1932. declare module BABYLON.GUI {
  1933. /**
  1934. * Class used to create input text control
  1935. */
  1936. export class InputText extends Control implements IFocusableControl {
  1937. name?: string | undefined;
  1938. private _text;
  1939. private _placeholderText;
  1940. private _background;
  1941. private _focusedBackground;
  1942. private _focusedColor;
  1943. private _placeholderColor;
  1944. private _thickness;
  1945. private _margin;
  1946. private _autoStretchWidth;
  1947. private _maxWidth;
  1948. private _isFocused;
  1949. private _blinkTimeout;
  1950. private _blinkIsEven;
  1951. private _cursorOffset;
  1952. private _scrollLeft;
  1953. private _textWidth;
  1954. private _clickedCoordinate;
  1955. private _deadKey;
  1956. private _addKey;
  1957. private _currentKey;
  1958. private _isTextHighlightOn;
  1959. private _textHighlightColor;
  1960. private _highligherOpacity;
  1961. private _highlightedText;
  1962. private _startHighlightIndex;
  1963. private _endHighlightIndex;
  1964. private _cursorIndex;
  1965. private _onFocusSelectAll;
  1966. private _isPointerDown;
  1967. private _onClipboardObserver;
  1968. private _onPointerDblTapObserver;
  1969. /** @hidden */
  1970. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  1971. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  1972. promptMessage: string;
  1973. /** Force disable prompt on mobile device */
  1974. disableMobilePrompt: boolean;
  1975. /** BABYLON.Observable raised when the text changes */
  1976. onTextChangedObservable: BABYLON.Observable<InputText>;
  1977. /** BABYLON.Observable raised just before an entered character is to be added */
  1978. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  1979. /** BABYLON.Observable raised when the control gets the focus */
  1980. onFocusObservable: BABYLON.Observable<InputText>;
  1981. /** BABYLON.Observable raised when the control loses the focus */
  1982. onBlurObservable: BABYLON.Observable<InputText>;
  1983. /**Observable raised when the text is highlighted */
  1984. onTextHighlightObservable: BABYLON.Observable<InputText>;
  1985. /**Observable raised when copy event is triggered */
  1986. onTextCopyObservable: BABYLON.Observable<InputText>;
  1987. /** BABYLON.Observable raised when cut event is triggered */
  1988. onTextCutObservable: BABYLON.Observable<InputText>;
  1989. /** BABYLON.Observable raised when paste event is triggered */
  1990. onTextPasteObservable: BABYLON.Observable<InputText>;
  1991. /** BABYLON.Observable raised when a key event was processed */
  1992. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  1993. /** Gets or sets the maximum width allowed by the control */
  1994. get maxWidth(): string | number;
  1995. /** Gets the maximum width allowed by the control in pixels */
  1996. get maxWidthInPixels(): number;
  1997. set maxWidth(value: string | number);
  1998. /** Gets or sets the text highlighter transparency; default: 0.4 */
  1999. get highligherOpacity(): number;
  2000. set highligherOpacity(value: number);
  2001. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  2002. get onFocusSelectAll(): boolean;
  2003. set onFocusSelectAll(value: boolean);
  2004. /** Gets or sets the text hightlight color */
  2005. get textHighlightColor(): string;
  2006. set textHighlightColor(value: string);
  2007. /** Gets or sets control margin */
  2008. get margin(): string;
  2009. /** Gets control margin in pixels */
  2010. get marginInPixels(): number;
  2011. set margin(value: string);
  2012. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  2013. get autoStretchWidth(): boolean;
  2014. set autoStretchWidth(value: boolean);
  2015. /** Gets or sets border thickness */
  2016. get thickness(): number;
  2017. set thickness(value: number);
  2018. /** Gets or sets the background color when focused */
  2019. get focusedBackground(): string;
  2020. set focusedBackground(value: string);
  2021. /** Gets or sets the background color when focused */
  2022. get focusedColor(): string;
  2023. set focusedColor(value: string);
  2024. /** Gets or sets the background color */
  2025. get background(): string;
  2026. set background(value: string);
  2027. /** Gets or sets the placeholder color */
  2028. get placeholderColor(): string;
  2029. set placeholderColor(value: string);
  2030. /** Gets or sets the text displayed when the control is empty */
  2031. get placeholderText(): string;
  2032. set placeholderText(value: string);
  2033. /** Gets or sets the dead key flag */
  2034. get deadKey(): boolean;
  2035. set deadKey(flag: boolean);
  2036. /** Gets or sets the highlight text */
  2037. get highlightedText(): string;
  2038. set highlightedText(text: string);
  2039. /** Gets or sets if the current key should be added */
  2040. get addKey(): boolean;
  2041. set addKey(flag: boolean);
  2042. /** Gets or sets the value of the current key being entered */
  2043. get currentKey(): string;
  2044. set currentKey(key: string);
  2045. /** Gets or sets the text displayed in the control */
  2046. get text(): string;
  2047. set text(value: string);
  2048. /** Gets or sets control width */
  2049. get width(): string | number;
  2050. set width(value: string | number);
  2051. /**
  2052. * Creates a new InputText
  2053. * @param name defines the control name
  2054. * @param text defines the text of the control
  2055. */
  2056. constructor(name?: string | undefined, text?: string);
  2057. /** @hidden */
  2058. onBlur(): void;
  2059. /** @hidden */
  2060. onFocus(): void;
  2061. protected _getTypeName(): string;
  2062. /**
  2063. * Function called to get the list of controls that should not steal the focus from this control
  2064. * @returns an array of controls
  2065. */
  2066. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  2067. /** @hidden */
  2068. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  2069. /** @hidden */
  2070. private _updateValueFromCursorIndex;
  2071. /** @hidden */
  2072. private _processDblClick;
  2073. /** @hidden */
  2074. private _selectAllText;
  2075. /**
  2076. * Handles the keyboard event
  2077. * @param evt Defines the KeyboardEvent
  2078. */
  2079. processKeyboard(evt: KeyboardEvent): void;
  2080. /** @hidden */
  2081. private _onCopyText;
  2082. /** @hidden */
  2083. private _onCutText;
  2084. /** @hidden */
  2085. private _onPasteText;
  2086. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  2087. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2088. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  2089. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2090. protected _beforeRenderText(text: string): string;
  2091. dispose(): void;
  2092. }
  2093. }
  2094. declare module BABYLON.GUI {
  2095. /**
  2096. * Class used to create a 2D grid container
  2097. */
  2098. export class Grid extends Container {
  2099. name?: string | undefined;
  2100. private _rowDefinitions;
  2101. private _columnDefinitions;
  2102. private _cells;
  2103. private _childControls;
  2104. /**
  2105. * Gets the number of columns
  2106. */
  2107. get columnCount(): number;
  2108. /**
  2109. * Gets the number of rows
  2110. */
  2111. get rowCount(): number;
  2112. /** Gets the list of children */
  2113. get children(): Control[];
  2114. /** Gets the list of cells (e.g. the containers) */
  2115. get cells(): {
  2116. [key: string]: Container;
  2117. };
  2118. /**
  2119. * Gets the definition of a specific row
  2120. * @param index defines the index of the row
  2121. * @returns the row definition
  2122. */
  2123. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  2124. /**
  2125. * Gets the definition of a specific column
  2126. * @param index defines the index of the column
  2127. * @returns the column definition
  2128. */
  2129. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  2130. /**
  2131. * Adds a new row to the grid
  2132. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  2133. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  2134. * @returns the current grid
  2135. */
  2136. addRowDefinition(height: number, isPixel?: boolean): Grid;
  2137. /**
  2138. * Adds a new column to the grid
  2139. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  2140. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  2141. * @returns the current grid
  2142. */
  2143. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  2144. /**
  2145. * Update a row definition
  2146. * @param index defines the index of the row to update
  2147. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  2148. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  2149. * @returns the current grid
  2150. */
  2151. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  2152. /**
  2153. * Update a column definition
  2154. * @param index defines the index of the column to update
  2155. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  2156. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  2157. * @returns the current grid
  2158. */
  2159. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  2160. /**
  2161. * Gets the list of children stored in a specific cell
  2162. * @param row defines the row to check
  2163. * @param column defines the column to check
  2164. * @returns the list of controls
  2165. */
  2166. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  2167. /**
  2168. * Gets a string representing the child cell info (row x column)
  2169. * @param child defines the control to get info from
  2170. * @returns a string containing the child cell info (row x column)
  2171. */
  2172. getChildCellInfo(child: Control): string;
  2173. private _removeCell;
  2174. private _offsetCell;
  2175. /**
  2176. * Remove a column definition at specified index
  2177. * @param index defines the index of the column to remove
  2178. * @returns the current grid
  2179. */
  2180. removeColumnDefinition(index: number): Grid;
  2181. /**
  2182. * Remove a row definition at specified index
  2183. * @param index defines the index of the row to remove
  2184. * @returns the current grid
  2185. */
  2186. removeRowDefinition(index: number): Grid;
  2187. /**
  2188. * Adds a new control to the current grid
  2189. * @param control defines the control to add
  2190. * @param row defines the row where to add the control (0 by default)
  2191. * @param column defines the column where to add the control (0 by default)
  2192. * @returns the current grid
  2193. */
  2194. addControl(control: Control, row?: number, column?: number): Grid;
  2195. /**
  2196. * Removes a control from the current container
  2197. * @param control defines the control to remove
  2198. * @returns the current container
  2199. */
  2200. removeControl(control: Control): Container;
  2201. /**
  2202. * Creates a new Grid
  2203. * @param name defines control name
  2204. */
  2205. constructor(name?: string | undefined);
  2206. protected _getTypeName(): string;
  2207. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  2208. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2209. _flagDescendantsAsMatrixDirty(): void;
  2210. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  2211. /** Releases associated resources */
  2212. dispose(): void;
  2213. }
  2214. }
  2215. declare module BABYLON.GUI {
  2216. /** Class used to create color pickers */
  2217. export class ColorPicker extends Control {
  2218. name?: string | undefined;
  2219. private static _Epsilon;
  2220. private _colorWheelCanvas;
  2221. private _value;
  2222. private _tmpColor;
  2223. private _pointerStartedOnSquare;
  2224. private _pointerStartedOnWheel;
  2225. private _squareLeft;
  2226. private _squareTop;
  2227. private _squareSize;
  2228. private _h;
  2229. private _s;
  2230. private _v;
  2231. private _lastPointerDownID;
  2232. /**
  2233. * BABYLON.Observable raised when the value changes
  2234. */
  2235. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  2236. /** Gets or sets the color of the color picker */
  2237. get value(): BABYLON.Color3;
  2238. set value(value: BABYLON.Color3);
  2239. /**
  2240. * Gets or sets control width
  2241. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  2242. */
  2243. get width(): string | number;
  2244. set width(value: string | number);
  2245. /**
  2246. * Gets or sets control height
  2247. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  2248. */
  2249. get height(): string | number;
  2250. /** Gets or sets control height */
  2251. set height(value: string | number);
  2252. /** Gets or sets control size */
  2253. get size(): string | number;
  2254. set size(value: string | number);
  2255. /**
  2256. * Creates a new ColorPicker
  2257. * @param name defines the control name
  2258. */
  2259. constructor(name?: string | undefined);
  2260. protected _getTypeName(): string;
  2261. /** @hidden */
  2262. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2263. private _updateSquareProps;
  2264. private _drawGradientSquare;
  2265. private _drawCircle;
  2266. private _createColorWheelCanvas;
  2267. /** @hidden */
  2268. _draw(context: CanvasRenderingContext2D): void;
  2269. private _pointerIsDown;
  2270. private _updateValueFromPointer;
  2271. private _isPointOnSquare;
  2272. private _isPointOnWheel;
  2273. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2274. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  2275. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2276. /**
  2277. * This function expands the color picker by creating a color picker dialog with manual
  2278. * color value input and the ability to save colors into an array to be used later in
  2279. * subsequent launches of the dialogue.
  2280. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2281. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2282. * @returns picked color as a hex string and the saved colors array as hex strings.
  2283. */
  2284. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  2285. pickerWidth?: string;
  2286. pickerHeight?: string;
  2287. headerHeight?: string;
  2288. lastColor?: string;
  2289. swatchLimit?: number;
  2290. numSwatchesPerLine?: number;
  2291. savedColors?: Array<string>;
  2292. }): Promise<{
  2293. savedColors?: string[];
  2294. pickedColor: string;
  2295. }>;
  2296. }
  2297. }
  2298. declare module BABYLON.GUI {
  2299. /** Class used to create 2D ellipse containers */
  2300. export class Ellipse extends Container {
  2301. name?: string | undefined;
  2302. private _thickness;
  2303. /** Gets or sets border thickness */
  2304. get thickness(): number;
  2305. set thickness(value: number);
  2306. /**
  2307. * Creates a new Ellipse
  2308. * @param name defines the control name
  2309. */
  2310. constructor(name?: string | undefined);
  2311. protected _getTypeName(): string;
  2312. protected _localDraw(context: CanvasRenderingContext2D): void;
  2313. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2314. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  2315. }
  2316. }
  2317. declare module BABYLON.GUI {
  2318. /**
  2319. * Class used to create a password control
  2320. */
  2321. export class InputPassword extends InputText {
  2322. protected _beforeRenderText(text: string): string;
  2323. }
  2324. }
  2325. declare module BABYLON.GUI {
  2326. /** Class used to render 2D lines */
  2327. export class Line extends Control {
  2328. name?: string | undefined;
  2329. private _lineWidth;
  2330. private _x1;
  2331. private _y1;
  2332. private _x2;
  2333. private _y2;
  2334. private _dash;
  2335. private _connectedControl;
  2336. private _connectedControlDirtyObserver;
  2337. /** Gets or sets the dash pattern */
  2338. get dash(): Array<number>;
  2339. set dash(value: Array<number>);
  2340. /** Gets or sets the control connected with the line end */
  2341. get connectedControl(): Control;
  2342. set connectedControl(value: Control);
  2343. /** Gets or sets start coordinates on X axis */
  2344. get x1(): string | number;
  2345. set x1(value: string | number);
  2346. /** Gets or sets start coordinates on Y axis */
  2347. get y1(): string | number;
  2348. set y1(value: string | number);
  2349. /** Gets or sets end coordinates on X axis */
  2350. get x2(): string | number;
  2351. set x2(value: string | number);
  2352. /** Gets or sets end coordinates on Y axis */
  2353. get y2(): string | number;
  2354. set y2(value: string | number);
  2355. /** Gets or sets line width */
  2356. get lineWidth(): number;
  2357. set lineWidth(value: number);
  2358. /** Gets or sets horizontal alignment */
  2359. set horizontalAlignment(value: number);
  2360. /** Gets or sets vertical alignment */
  2361. set verticalAlignment(value: number);
  2362. private get _effectiveX2();
  2363. private get _effectiveY2();
  2364. /**
  2365. * Creates a new Line
  2366. * @param name defines the control name
  2367. */
  2368. constructor(name?: string | undefined);
  2369. protected _getTypeName(): string;
  2370. _draw(context: CanvasRenderingContext2D): void;
  2371. _measure(): void;
  2372. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2373. /**
  2374. * Move one end of the line given 3D cartesian coordinates.
  2375. * @param position Targeted world position
  2376. * @param scene BABYLON.Scene
  2377. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  2378. */
  2379. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  2380. /**
  2381. * Move one end of the line to a position in screen absolute space.
  2382. * @param projectedPosition Position in screen absolute space (X, Y)
  2383. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  2384. */
  2385. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  2386. }
  2387. }
  2388. declare module BABYLON.GUI {
  2389. /**
  2390. * Class used to store a point for a MultiLine object.
  2391. * The point can be pure 2D coordinates, a mesh or a control
  2392. */
  2393. export class MultiLinePoint {
  2394. private _multiLine;
  2395. private _x;
  2396. private _y;
  2397. private _control;
  2398. private _mesh;
  2399. private _controlObserver;
  2400. private _meshObserver;
  2401. /** @hidden */
  2402. _point: BABYLON.Vector2;
  2403. /**
  2404. * Creates a new MultiLinePoint
  2405. * @param multiLine defines the source MultiLine object
  2406. */
  2407. constructor(multiLine: MultiLine);
  2408. /** Gets or sets x coordinate */
  2409. get x(): string | number;
  2410. set x(value: string | number);
  2411. /** Gets or sets y coordinate */
  2412. get y(): string | number;
  2413. set y(value: string | number);
  2414. /** Gets or sets the control associated with this point */
  2415. get control(): BABYLON.Nullable<Control>;
  2416. set control(value: BABYLON.Nullable<Control>);
  2417. /** Gets or sets the mesh associated with this point */
  2418. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  2419. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  2420. /** Resets links */
  2421. resetLinks(): void;
  2422. /**
  2423. * Gets a translation vector
  2424. * @returns the translation vector
  2425. */
  2426. translate(): BABYLON.Vector2;
  2427. private _translatePoint;
  2428. /** Release associated resources */
  2429. dispose(): void;
  2430. }
  2431. }
  2432. declare module BABYLON.GUI {
  2433. /**
  2434. * Class used to create multi line control
  2435. */
  2436. export class MultiLine extends Control {
  2437. name?: string | undefined;
  2438. private _lineWidth;
  2439. private _dash;
  2440. private _points;
  2441. private _minX;
  2442. private _minY;
  2443. private _maxX;
  2444. private _maxY;
  2445. /**
  2446. * Creates a new MultiLine
  2447. * @param name defines the control name
  2448. */
  2449. constructor(name?: string | undefined);
  2450. /** Gets or sets dash pattern */
  2451. get dash(): Array<number>;
  2452. set dash(value: Array<number>);
  2453. /**
  2454. * Gets point stored at specified index
  2455. * @param index defines the index to look for
  2456. * @returns the requested point if found
  2457. */
  2458. getAt(index: number): MultiLinePoint;
  2459. /** Function called when a point is updated */
  2460. onPointUpdate: () => void;
  2461. /**
  2462. * Adds new points to the point collection
  2463. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  2464. * @returns the list of created MultiLinePoint
  2465. */
  2466. add(...items: (AbstractMesh | Control | {
  2467. x: string | number;
  2468. y: string | number;
  2469. })[]): MultiLinePoint[];
  2470. /**
  2471. * Adds a new point to the point collection
  2472. * @param item defines the item (mesh, control or 2d coordiantes) to add
  2473. * @returns the created MultiLinePoint
  2474. */
  2475. push(item?: (AbstractMesh | Control | {
  2476. x: string | number;
  2477. y: string | number;
  2478. })): MultiLinePoint;
  2479. /**
  2480. * Remove a specific value or point from the active point collection
  2481. * @param value defines the value or point to remove
  2482. */
  2483. remove(value: number | MultiLinePoint): void;
  2484. /**
  2485. * Resets this object to initial state (no point)
  2486. */
  2487. reset(): void;
  2488. /**
  2489. * Resets all links
  2490. */
  2491. resetLinks(): void;
  2492. /** Gets or sets line width */
  2493. get lineWidth(): number;
  2494. set lineWidth(value: number);
  2495. set horizontalAlignment(value: number);
  2496. set verticalAlignment(value: number);
  2497. protected _getTypeName(): string;
  2498. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  2499. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2500. _measure(): void;
  2501. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2502. dispose(): void;
  2503. }
  2504. }
  2505. declare module BABYLON.GUI {
  2506. /**
  2507. * Class used to create radio button controls
  2508. */
  2509. export class RadioButton extends Control {
  2510. name?: string | undefined;
  2511. private _isChecked;
  2512. private _background;
  2513. private _checkSizeRatio;
  2514. private _thickness;
  2515. /** Gets or sets border thickness */
  2516. get thickness(): number;
  2517. set thickness(value: number);
  2518. /** Gets or sets group name */
  2519. group: string;
  2520. /** BABYLON.Observable raised when isChecked is changed */
  2521. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  2522. /** Gets or sets a value indicating the ratio between overall size and check size */
  2523. get checkSizeRatio(): number;
  2524. set checkSizeRatio(value: number);
  2525. /** Gets or sets background color */
  2526. get background(): string;
  2527. set background(value: string);
  2528. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  2529. get isChecked(): boolean;
  2530. set isChecked(value: boolean);
  2531. /**
  2532. * Creates a new RadioButton
  2533. * @param name defines the control name
  2534. */
  2535. constructor(name?: string | undefined);
  2536. protected _getTypeName(): string;
  2537. _draw(context: CanvasRenderingContext2D): void;
  2538. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2539. /**
  2540. * Utility function to easily create a radio button with a header
  2541. * @param title defines the label to use for the header
  2542. * @param group defines the group to use for the radio button
  2543. * @param isChecked defines the initial state of the radio button
  2544. * @param onValueChanged defines the callback to call when value changes
  2545. * @returns a StackPanel containing the radio button and a textBlock
  2546. */
  2547. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  2548. }
  2549. }
  2550. declare module BABYLON.GUI {
  2551. /**
  2552. * Class used to create slider controls
  2553. */
  2554. export class BaseSlider extends Control {
  2555. name?: string | undefined;
  2556. protected _thumbWidth: ValueAndUnit;
  2557. private _minimum;
  2558. private _maximum;
  2559. private _value;
  2560. private _isVertical;
  2561. protected _barOffset: ValueAndUnit;
  2562. private _isThumbClamped;
  2563. protected _displayThumb: boolean;
  2564. private _step;
  2565. private _lastPointerDownID;
  2566. protected _effectiveBarOffset: number;
  2567. protected _renderLeft: number;
  2568. protected _renderTop: number;
  2569. protected _renderWidth: number;
  2570. protected _renderHeight: number;
  2571. protected _backgroundBoxLength: number;
  2572. protected _backgroundBoxThickness: number;
  2573. protected _effectiveThumbThickness: number;
  2574. /** BABYLON.Observable raised when the sldier value changes */
  2575. onValueChangedObservable: BABYLON.Observable<number>;
  2576. /** Gets or sets a boolean indicating if the thumb must be rendered */
  2577. get displayThumb(): boolean;
  2578. set displayThumb(value: boolean);
  2579. /** Gets or sets a step to apply to values (0 by default) */
  2580. get step(): number;
  2581. set step(value: number);
  2582. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  2583. get barOffset(): string | number;
  2584. /** Gets main bar offset in pixels*/
  2585. get barOffsetInPixels(): number;
  2586. set barOffset(value: string | number);
  2587. /** Gets or sets thumb width */
  2588. get thumbWidth(): string | number;
  2589. /** Gets thumb width in pixels */
  2590. get thumbWidthInPixels(): number;
  2591. set thumbWidth(value: string | number);
  2592. /** Gets or sets minimum value */
  2593. get minimum(): number;
  2594. set minimum(value: number);
  2595. /** Gets or sets maximum value */
  2596. get maximum(): number;
  2597. set maximum(value: number);
  2598. /** Gets or sets current value */
  2599. get value(): number;
  2600. set value(value: number);
  2601. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  2602. get isVertical(): boolean;
  2603. set isVertical(value: boolean);
  2604. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  2605. get isThumbClamped(): boolean;
  2606. set isThumbClamped(value: boolean);
  2607. /**
  2608. * Creates a new BaseSlider
  2609. * @param name defines the control name
  2610. */
  2611. constructor(name?: string | undefined);
  2612. protected _getTypeName(): string;
  2613. protected _getThumbPosition(): number;
  2614. protected _getThumbThickness(type: string): number;
  2615. protected _prepareRenderingData(type: string): void;
  2616. private _pointerIsDown;
  2617. /** @hidden */
  2618. protected _updateValueFromPointer(x: number, y: number): void;
  2619. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2620. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  2621. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2622. }
  2623. }
  2624. declare module BABYLON.GUI {
  2625. /**
  2626. * Class used to create slider controls
  2627. */
  2628. export class Slider extends BaseSlider {
  2629. name?: string | undefined;
  2630. private _background;
  2631. private _borderColor;
  2632. private _isThumbCircle;
  2633. protected _displayValueBar: boolean;
  2634. /** Gets or sets a boolean indicating if the value bar must be rendered */
  2635. get displayValueBar(): boolean;
  2636. set displayValueBar(value: boolean);
  2637. /** Gets or sets border color */
  2638. get borderColor(): string;
  2639. set borderColor(value: string);
  2640. /** Gets or sets background color */
  2641. get background(): string;
  2642. set background(value: string);
  2643. /** Gets or sets a boolean indicating if the thumb should be round or square */
  2644. get isThumbCircle(): boolean;
  2645. set isThumbCircle(value: boolean);
  2646. /**
  2647. * Creates a new Slider
  2648. * @param name defines the control name
  2649. */
  2650. constructor(name?: string | undefined);
  2651. protected _getTypeName(): string;
  2652. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  2653. }
  2654. }
  2655. declare module BABYLON.GUI {
  2656. /** Class used to create a RadioGroup
  2657. * which contains groups of radio buttons
  2658. */
  2659. export class SelectorGroup {
  2660. /** name of SelectorGroup */
  2661. name: string;
  2662. private _groupPanel;
  2663. private _selectors;
  2664. private _groupHeader;
  2665. /**
  2666. * Creates a new SelectorGroup
  2667. * @param name of group, used as a group heading
  2668. */
  2669. constructor(
  2670. /** name of SelectorGroup */
  2671. name: string);
  2672. /** Gets the groupPanel of the SelectorGroup */
  2673. get groupPanel(): StackPanel;
  2674. /** Gets the selectors array */
  2675. get selectors(): StackPanel[];
  2676. /** Gets and sets the group header */
  2677. get header(): string;
  2678. set header(label: string);
  2679. /** @hidden */
  2680. private _addGroupHeader;
  2681. /** @hidden*/
  2682. _getSelector(selectorNb: number): StackPanel | undefined;
  2683. /** Removes the selector at the given position
  2684. * @param selectorNb the position of the selector within the group
  2685. */
  2686. removeSelector(selectorNb: number): void;
  2687. }
  2688. /** Class used to create a CheckboxGroup
  2689. * which contains groups of checkbox buttons
  2690. */
  2691. export class CheckboxGroup extends SelectorGroup {
  2692. /** Adds a checkbox as a control
  2693. * @param text is the label for the selector
  2694. * @param func is the function called when the Selector is checked
  2695. * @param checked is true when Selector is checked
  2696. */
  2697. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  2698. /** @hidden */
  2699. _setSelectorLabel(selectorNb: number, label: string): void;
  2700. /** @hidden */
  2701. _setSelectorLabelColor(selectorNb: number, color: string): void;
  2702. /** @hidden */
  2703. _setSelectorButtonColor(selectorNb: number, color: string): void;
  2704. /** @hidden */
  2705. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  2706. }
  2707. /** Class used to create a RadioGroup
  2708. * which contains groups of radio buttons
  2709. */
  2710. export class RadioGroup extends SelectorGroup {
  2711. private _selectNb;
  2712. /** Adds a radio button as a control
  2713. * @param label is the label for the selector
  2714. * @param func is the function called when the Selector is checked
  2715. * @param checked is true when Selector is checked
  2716. */
  2717. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  2718. /** @hidden */
  2719. _setSelectorLabel(selectorNb: number, label: string): void;
  2720. /** @hidden */
  2721. _setSelectorLabelColor(selectorNb: number, color: string): void;
  2722. /** @hidden */
  2723. _setSelectorButtonColor(selectorNb: number, color: string): void;
  2724. /** @hidden */
  2725. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  2726. }
  2727. /** Class used to create a SliderGroup
  2728. * which contains groups of slider buttons
  2729. */
  2730. export class SliderGroup extends SelectorGroup {
  2731. /**
  2732. * Adds a slider to the SelectorGroup
  2733. * @param label is the label for the SliderBar
  2734. * @param func is the function called when the Slider moves
  2735. * @param unit is a string describing the units used, eg degrees or metres
  2736. * @param min is the minimum value for the Slider
  2737. * @param max is the maximum value for the Slider
  2738. * @param value is the start value for the Slider between min and max
  2739. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  2740. */
  2741. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  2742. /** @hidden */
  2743. _setSelectorLabel(selectorNb: number, label: string): void;
  2744. /** @hidden */
  2745. _setSelectorLabelColor(selectorNb: number, color: string): void;
  2746. /** @hidden */
  2747. _setSelectorButtonColor(selectorNb: number, color: string): void;
  2748. /** @hidden */
  2749. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  2750. }
  2751. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  2752. * @see http://doc.babylonjs.com/how_to/selector
  2753. */
  2754. export class SelectionPanel extends Rectangle {
  2755. /** name of SelectionPanel */
  2756. name: string;
  2757. /** an array of SelectionGroups */
  2758. groups: SelectorGroup[];
  2759. private _panel;
  2760. private _buttonColor;
  2761. private _buttonBackground;
  2762. private _headerColor;
  2763. private _barColor;
  2764. private _barHeight;
  2765. private _spacerHeight;
  2766. private _labelColor;
  2767. private _groups;
  2768. private _bars;
  2769. /**
  2770. * Creates a new SelectionPanel
  2771. * @param name of SelectionPanel
  2772. * @param groups is an array of SelectionGroups
  2773. */
  2774. constructor(
  2775. /** name of SelectionPanel */
  2776. name: string,
  2777. /** an array of SelectionGroups */
  2778. groups?: SelectorGroup[]);
  2779. protected _getTypeName(): string;
  2780. /** Gets or sets the headerColor */
  2781. get headerColor(): string;
  2782. set headerColor(color: string);
  2783. private _setHeaderColor;
  2784. /** Gets or sets the button color */
  2785. get buttonColor(): string;
  2786. set buttonColor(color: string);
  2787. private _setbuttonColor;
  2788. /** Gets or sets the label color */
  2789. get labelColor(): string;
  2790. set labelColor(color: string);
  2791. private _setLabelColor;
  2792. /** Gets or sets the button background */
  2793. get buttonBackground(): string;
  2794. set buttonBackground(color: string);
  2795. private _setButtonBackground;
  2796. /** Gets or sets the color of separator bar */
  2797. get barColor(): string;
  2798. set barColor(color: string);
  2799. private _setBarColor;
  2800. /** Gets or sets the height of separator bar */
  2801. get barHeight(): string;
  2802. set barHeight(value: string);
  2803. private _setBarHeight;
  2804. /** Gets or sets the height of spacers*/
  2805. get spacerHeight(): string;
  2806. set spacerHeight(value: string);
  2807. private _setSpacerHeight;
  2808. /** Adds a bar between groups */
  2809. private _addSpacer;
  2810. /** Add a group to the selection panel
  2811. * @param group is the selector group to add
  2812. */
  2813. addGroup(group: SelectorGroup): void;
  2814. /** Remove the group from the given position
  2815. * @param groupNb is the position of the group in the list
  2816. */
  2817. removeGroup(groupNb: number): void;
  2818. /** Change a group header label
  2819. * @param label is the new group header label
  2820. * @param groupNb is the number of the group to relabel
  2821. * */
  2822. setHeaderName(label: string, groupNb: number): void;
  2823. /** Change selector label to the one given
  2824. * @param label is the new selector label
  2825. * @param groupNb is the number of the groupcontaining the selector
  2826. * @param selectorNb is the number of the selector within a group to relabel
  2827. * */
  2828. relabel(label: string, groupNb: number, selectorNb: number): void;
  2829. /** For a given group position remove the selector at the given position
  2830. * @param groupNb is the number of the group to remove the selector from
  2831. * @param selectorNb is the number of the selector within the group
  2832. */
  2833. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  2834. /** For a given group position of correct type add a checkbox button
  2835. * @param groupNb is the number of the group to remove the selector from
  2836. * @param label is the label for the selector
  2837. * @param func is the function called when the Selector is checked
  2838. * @param checked is true when Selector is checked
  2839. */
  2840. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  2841. /** For a given group position of correct type add a radio button
  2842. * @param groupNb is the number of the group to remove the selector from
  2843. * @param label is the label for the selector
  2844. * @param func is the function called when the Selector is checked
  2845. * @param checked is true when Selector is checked
  2846. */
  2847. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  2848. /**
  2849. * For a given slider group add a slider
  2850. * @param groupNb is the number of the group to add the slider to
  2851. * @param label is the label for the Slider
  2852. * @param func is the function called when the Slider moves
  2853. * @param unit is a string describing the units used, eg degrees or metres
  2854. * @param min is the minimum value for the Slider
  2855. * @param max is the maximum value for the Slider
  2856. * @param value is the start value for the Slider between min and max
  2857. * @param onVal is the function used to format the value displayed, eg radians to degrees
  2858. */
  2859. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  2860. }
  2861. }
  2862. declare module BABYLON.GUI {
  2863. /**
  2864. * Class used to hold a the container for ScrollViewer
  2865. * @hidden
  2866. */
  2867. export class _ScrollViewerWindow extends Container {
  2868. parentClientWidth: number;
  2869. parentClientHeight: number;
  2870. /**
  2871. * Creates a new ScrollViewerWindow
  2872. * @param name of ScrollViewerWindow
  2873. */
  2874. constructor(name?: string);
  2875. protected _getTypeName(): string;
  2876. /** @hidden */
  2877. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2878. protected _postMeasure(): void;
  2879. }
  2880. }
  2881. declare module BABYLON.GUI {
  2882. /**
  2883. * Class used to create slider controls
  2884. */
  2885. export class ScrollBar extends BaseSlider {
  2886. name?: string | undefined;
  2887. private _background;
  2888. private _borderColor;
  2889. private _tempMeasure;
  2890. /** Gets or sets border color */
  2891. get borderColor(): string;
  2892. set borderColor(value: string);
  2893. /** Gets or sets background color */
  2894. get background(): string;
  2895. set background(value: string);
  2896. /**
  2897. * Creates a new Slider
  2898. * @param name defines the control name
  2899. */
  2900. constructor(name?: string | undefined);
  2901. protected _getTypeName(): string;
  2902. protected _getThumbThickness(): number;
  2903. _draw(context: CanvasRenderingContext2D): void;
  2904. private _first;
  2905. private _originX;
  2906. private _originY;
  2907. /** @hidden */
  2908. protected _updateValueFromPointer(x: number, y: number): void;
  2909. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2910. }
  2911. }
  2912. declare module BABYLON.GUI {
  2913. /**
  2914. * Class used to create slider controls
  2915. */
  2916. export class ImageScrollBar extends BaseSlider {
  2917. name?: string | undefined;
  2918. private _backgroundBaseImage;
  2919. private _backgroundImage;
  2920. private _thumbImage;
  2921. private _thumbBaseImage;
  2922. private _thumbLength;
  2923. private _thumbHeight;
  2924. private _barImageHeight;
  2925. private _tempMeasure;
  2926. /**
  2927. * Gets or sets the image used to render the background for horizontal bar
  2928. */
  2929. get backgroundImage(): Image;
  2930. set backgroundImage(value: Image);
  2931. /**
  2932. * Gets or sets the image used to render the thumb
  2933. */
  2934. get thumbImage(): Image;
  2935. set thumbImage(value: Image);
  2936. /**
  2937. * Gets or sets the length of the thumb
  2938. */
  2939. get thumbLength(): number;
  2940. set thumbLength(value: number);
  2941. /**
  2942. * Gets or sets the height of the thumb
  2943. */
  2944. get thumbHeight(): number;
  2945. set thumbHeight(value: number);
  2946. /**
  2947. * Gets or sets the height of the bar image
  2948. */
  2949. get barImageHeight(): number;
  2950. set barImageHeight(value: number);
  2951. /**
  2952. * Creates a new ImageScrollBar
  2953. * @param name defines the control name
  2954. */
  2955. constructor(name?: string | undefined);
  2956. protected _getTypeName(): string;
  2957. protected _getThumbThickness(): number;
  2958. _draw(context: CanvasRenderingContext2D): void;
  2959. private _first;
  2960. private _originX;
  2961. private _originY;
  2962. /** @hidden */
  2963. protected _updateValueFromPointer(x: number, y: number): void;
  2964. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  2965. }
  2966. }
  2967. declare module BABYLON.GUI {
  2968. /**
  2969. * Class used to hold a viewer window and sliders in a grid
  2970. */
  2971. export class ScrollViewer extends Rectangle {
  2972. private _grid;
  2973. private _horizontalBarSpace;
  2974. private _verticalBarSpace;
  2975. private _dragSpace;
  2976. private _horizontalBar;
  2977. private _verticalBar;
  2978. private _barColor;
  2979. private _barBackground;
  2980. private _barImage;
  2981. private _barBackgroundImage;
  2982. private _barSize;
  2983. private _endLeft;
  2984. private _endTop;
  2985. private _window;
  2986. private _pointerIsOver;
  2987. private _wheelPrecision;
  2988. private _onPointerObserver;
  2989. private _clientWidth;
  2990. private _clientHeight;
  2991. private _useImageBar;
  2992. private _thumbLength;
  2993. private _thumbHeight;
  2994. private _barImageHeight;
  2995. /**
  2996. * Gets the horizontal scrollbar
  2997. */
  2998. get horizontalBar(): ScrollBar | ImageScrollBar;
  2999. /**
  3000. * Gets the vertical scrollbar
  3001. */
  3002. get verticalBar(): ScrollBar | ImageScrollBar;
  3003. /**
  3004. * Adds a new control to the current container
  3005. * @param control defines the control to add
  3006. * @returns the current container
  3007. */
  3008. addControl(control: BABYLON.Nullable<Control>): Container;
  3009. /**
  3010. * Removes a control from the current container
  3011. * @param control defines the control to remove
  3012. * @returns the current container
  3013. */
  3014. removeControl(control: Control): Container;
  3015. /** Gets the list of children */
  3016. get children(): Control[];
  3017. _flagDescendantsAsMatrixDirty(): void;
  3018. /**
  3019. * Creates a new ScrollViewer
  3020. * @param name of ScrollViewer
  3021. */
  3022. constructor(name?: string, isImageBased?: boolean);
  3023. /** Reset the scroll viewer window to initial size */
  3024. resetWindow(): void;
  3025. protected _getTypeName(): string;
  3026. private _buildClientSizes;
  3027. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3028. protected _postMeasure(): void;
  3029. /**
  3030. * Gets or sets the mouse wheel precision
  3031. * from 0 to 1 with a default value of 0.05
  3032. * */
  3033. get wheelPrecision(): number;
  3034. set wheelPrecision(value: number);
  3035. /** Gets or sets the scroll bar container background color */
  3036. get scrollBackground(): string;
  3037. set scrollBackground(color: string);
  3038. /** Gets or sets the bar color */
  3039. get barColor(): string;
  3040. set barColor(color: string);
  3041. /** Gets or sets the bar image */
  3042. get thumbImage(): Image;
  3043. set thumbImage(value: Image);
  3044. /** Gets or sets the size of the bar */
  3045. get barSize(): number;
  3046. set barSize(value: number);
  3047. /** Gets or sets the length of the thumb */
  3048. get thumbLength(): number;
  3049. set thumbLength(value: number);
  3050. /** Gets or sets the height of the thumb */
  3051. get thumbHeight(): number;
  3052. set thumbHeight(value: number);
  3053. /** Gets or sets the height of the bar image */
  3054. get barImageHeight(): number;
  3055. set barImageHeight(value: number);
  3056. /** Gets or sets the bar background */
  3057. get barBackground(): string;
  3058. set barBackground(color: string);
  3059. /** Gets or sets the bar background image */
  3060. get barImage(): Image;
  3061. set barImage(value: Image);
  3062. /** @hidden */
  3063. private _updateScroller;
  3064. _link(host: AdvancedDynamicTexture): void;
  3065. /** @hidden */
  3066. private _addBar;
  3067. /** @hidden */
  3068. private _attachWheel;
  3069. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  3070. /** Releases associated resources */
  3071. dispose(): void;
  3072. }
  3073. }
  3074. declare module BABYLON.GUI {
  3075. /** Class used to render a grid */
  3076. export class DisplayGrid extends Control {
  3077. name?: string | undefined;
  3078. private _cellWidth;
  3079. private _cellHeight;
  3080. private _minorLineTickness;
  3081. private _minorLineColor;
  3082. private _majorLineTickness;
  3083. private _majorLineColor;
  3084. private _majorLineFrequency;
  3085. private _background;
  3086. private _displayMajorLines;
  3087. private _displayMinorLines;
  3088. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  3089. get displayMinorLines(): boolean;
  3090. set displayMinorLines(value: boolean);
  3091. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  3092. get displayMajorLines(): boolean;
  3093. set displayMajorLines(value: boolean);
  3094. /** Gets or sets background color (Black by default) */
  3095. get background(): string;
  3096. set background(value: string);
  3097. /** Gets or sets the width of each cell (20 by default) */
  3098. get cellWidth(): number;
  3099. set cellWidth(value: number);
  3100. /** Gets or sets the height of each cell (20 by default) */
  3101. get cellHeight(): number;
  3102. set cellHeight(value: number);
  3103. /** Gets or sets the tickness of minor lines (1 by default) */
  3104. get minorLineTickness(): number;
  3105. set minorLineTickness(value: number);
  3106. /** Gets or sets the color of minor lines (DarkGray by default) */
  3107. get minorLineColor(): string;
  3108. set minorLineColor(value: string);
  3109. /** Gets or sets the tickness of major lines (2 by default) */
  3110. get majorLineTickness(): number;
  3111. set majorLineTickness(value: number);
  3112. /** Gets or sets the color of major lines (White by default) */
  3113. get majorLineColor(): string;
  3114. set majorLineColor(value: string);
  3115. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  3116. get majorLineFrequency(): number;
  3117. set majorLineFrequency(value: number);
  3118. /**
  3119. * Creates a new GridDisplayRectangle
  3120. * @param name defines the control name
  3121. */
  3122. constructor(name?: string | undefined);
  3123. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  3124. protected _getTypeName(): string;
  3125. }
  3126. }
  3127. declare module BABYLON.GUI {
  3128. /**
  3129. * Class used to create slider controls based on images
  3130. */
  3131. export class ImageBasedSlider extends BaseSlider {
  3132. name?: string | undefined;
  3133. private _backgroundImage;
  3134. private _thumbImage;
  3135. private _valueBarImage;
  3136. private _tempMeasure;
  3137. get displayThumb(): boolean;
  3138. set displayThumb(value: boolean);
  3139. /**
  3140. * Gets or sets the image used to render the background
  3141. */
  3142. get backgroundImage(): Image;
  3143. set backgroundImage(value: Image);
  3144. /**
  3145. * Gets or sets the image used to render the value bar
  3146. */
  3147. get valueBarImage(): Image;
  3148. set valueBarImage(value: Image);
  3149. /**
  3150. * Gets or sets the image used to render the thumb
  3151. */
  3152. get thumbImage(): Image;
  3153. set thumbImage(value: Image);
  3154. /**
  3155. * Creates a new ImageBasedSlider
  3156. * @param name defines the control name
  3157. */
  3158. constructor(name?: string | undefined);
  3159. protected _getTypeName(): string;
  3160. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  3161. }
  3162. }
  3163. declare module BABYLON.GUI {
  3164. /**
  3165. * Forcing an export so that this code will execute
  3166. * @hidden
  3167. */
  3168. const name = "Statics";
  3169. }
  3170. declare module BABYLON.GUI {
  3171. /**
  3172. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  3173. */
  3174. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  3175. /**
  3176. * Define the instrumented AdvancedDynamicTexture.
  3177. */
  3178. texture: AdvancedDynamicTexture;
  3179. private _captureRenderTime;
  3180. private _renderTime;
  3181. private _captureLayoutTime;
  3182. private _layoutTime;
  3183. private _onBeginRenderObserver;
  3184. private _onEndRenderObserver;
  3185. private _onBeginLayoutObserver;
  3186. private _onEndLayoutObserver;
  3187. /**
  3188. * Gets the perf counter used to capture render time
  3189. */
  3190. get renderTimeCounter(): BABYLON.PerfCounter;
  3191. /**
  3192. * Gets the perf counter used to capture layout time
  3193. */
  3194. get layoutTimeCounter(): BABYLON.PerfCounter;
  3195. /**
  3196. * Enable or disable the render time capture
  3197. */
  3198. get captureRenderTime(): boolean;
  3199. set captureRenderTime(value: boolean);
  3200. /**
  3201. * Enable or disable the layout time capture
  3202. */
  3203. get captureLayoutTime(): boolean;
  3204. set captureLayoutTime(value: boolean);
  3205. /**
  3206. * Instantiates a new advanced dynamic texture instrumentation.
  3207. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  3208. * @param texture Defines the AdvancedDynamicTexture to instrument
  3209. */
  3210. constructor(
  3211. /**
  3212. * Define the instrumented AdvancedDynamicTexture.
  3213. */
  3214. texture: AdvancedDynamicTexture);
  3215. /**
  3216. * Dispose and release associated resources.
  3217. */
  3218. dispose(): void;
  3219. }
  3220. }
  3221. declare module BABYLON.GUI {
  3222. /**
  3223. * Class used to load GUI via XML.
  3224. */
  3225. export class XmlLoader {
  3226. private _nodes;
  3227. private _nodeTypes;
  3228. private _isLoaded;
  3229. private _objectAttributes;
  3230. private _parentClass;
  3231. /**
  3232. * Create a new xml loader
  3233. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  3234. */
  3235. constructor(parentClass?: null);
  3236. private _getChainElement;
  3237. private _getClassAttribute;
  3238. private _createGuiElement;
  3239. private _parseGrid;
  3240. private _parseElement;
  3241. private _prepareSourceElement;
  3242. private _parseElementsFromSource;
  3243. private _parseXml;
  3244. /**
  3245. * Gets if the loading has finished.
  3246. * @returns whether the loading has finished or not
  3247. */
  3248. isLoaded(): boolean;
  3249. /**
  3250. * Gets a loaded node / control by id.
  3251. * @param id the Controls id set in the xml
  3252. * @returns element of type Control
  3253. */
  3254. getNodeById(id: string): any;
  3255. /**
  3256. * Gets all loaded nodes / controls
  3257. * @returns Array of controls
  3258. */
  3259. getNodes(): any;
  3260. /**
  3261. * Initiates the xml layout loading
  3262. * @param xmlFile defines the xml layout to load
  3263. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  3264. * @param callback defines the callback called on layout load.
  3265. */
  3266. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  3267. }
  3268. }
  3269. declare module BABYLON.GUI {
  3270. /**
  3271. * Class used to create containers for controls
  3272. */
  3273. export class Container3D extends Control3D {
  3274. private _blockLayout;
  3275. /**
  3276. * Gets the list of child controls
  3277. */
  3278. protected _children: Control3D[];
  3279. /**
  3280. * Gets the list of child controls
  3281. */
  3282. get children(): Array<Control3D>;
  3283. /**
  3284. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  3285. * This is helpful to optimize layout operation when adding multiple children in a row
  3286. */
  3287. get blockLayout(): boolean;
  3288. set blockLayout(value: boolean);
  3289. /**
  3290. * Creates a new container
  3291. * @param name defines the container name
  3292. */
  3293. constructor(name?: string);
  3294. /**
  3295. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  3296. * @returns the current container
  3297. */
  3298. updateLayout(): Container3D;
  3299. /**
  3300. * Gets a boolean indicating if the given control is in the children of this control
  3301. * @param control defines the control to check
  3302. * @returns true if the control is in the child list
  3303. */
  3304. containsControl(control: Control3D): boolean;
  3305. /**
  3306. * Adds a control to the children of this control
  3307. * @param control defines the control to add
  3308. * @returns the current container
  3309. */
  3310. addControl(control: Control3D): Container3D;
  3311. /**
  3312. * This function will be called everytime a new control is added
  3313. */
  3314. protected _arrangeChildren(): void;
  3315. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  3316. /**
  3317. * Removes a control from the children of this control
  3318. * @param control defines the control to remove
  3319. * @returns the current container
  3320. */
  3321. removeControl(control: Control3D): Container3D;
  3322. protected _getTypeName(): string;
  3323. /**
  3324. * Releases all associated resources
  3325. */
  3326. dispose(): void;
  3327. /** Control rotation will remain unchanged */
  3328. static readonly UNSET_ORIENTATION: number;
  3329. /** Control will rotate to make it look at sphere central axis */
  3330. static readonly FACEORIGIN_ORIENTATION: number;
  3331. /** Control will rotate to make it look back at sphere central axis */
  3332. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  3333. /** Control will rotate to look at z axis (0, 0, 1) */
  3334. static readonly FACEFORWARD_ORIENTATION: number;
  3335. /** Control will rotate to look at negative z axis (0, 0, -1) */
  3336. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  3337. }
  3338. }
  3339. declare module BABYLON.GUI {
  3340. /**
  3341. * Class used to manage 3D user interface
  3342. * @see http://doc.babylonjs.com/how_to/gui3d
  3343. */
  3344. export class GUI3DManager implements BABYLON.IDisposable {
  3345. private _scene;
  3346. private _sceneDisposeObserver;
  3347. private _utilityLayer;
  3348. private _rootContainer;
  3349. private _pointerObserver;
  3350. private _pointerOutObserver;
  3351. /** @hidden */
  3352. _lastPickedControl: Control3D;
  3353. /** @hidden */
  3354. _lastControlOver: {
  3355. [pointerId: number]: Control3D;
  3356. };
  3357. /** @hidden */
  3358. _lastControlDown: {
  3359. [pointerId: number]: Control3D;
  3360. };
  3361. /**
  3362. * BABYLON.Observable raised when the point picked by the pointer events changed
  3363. */
  3364. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  3365. /** @hidden */
  3366. _sharedMaterials: {
  3367. [key: string]: BABYLON.Material;
  3368. };
  3369. /** Gets the hosting scene */
  3370. get scene(): BABYLON.Scene;
  3371. /** Gets associated utility layer */
  3372. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  3373. /**
  3374. * Creates a new GUI3DManager
  3375. * @param scene
  3376. */
  3377. constructor(scene?: BABYLON.Scene);
  3378. private _handlePointerOut;
  3379. private _doPicking;
  3380. /**
  3381. * Gets the root container
  3382. */
  3383. get rootContainer(): Container3D;
  3384. /**
  3385. * Gets a boolean indicating if the given control is in the root child list
  3386. * @param control defines the control to check
  3387. * @returns true if the control is in the root child list
  3388. */
  3389. containsControl(control: Control3D): boolean;
  3390. /**
  3391. * Adds a control to the root child list
  3392. * @param control defines the control to add
  3393. * @returns the current manager
  3394. */
  3395. addControl(control: Control3D): GUI3DManager;
  3396. /**
  3397. * Removes a control from the root child list
  3398. * @param control defines the control to remove
  3399. * @returns the current container
  3400. */
  3401. removeControl(control: Control3D): GUI3DManager;
  3402. /**
  3403. * Releases all associated resources
  3404. */
  3405. dispose(): void;
  3406. }
  3407. }
  3408. declare module BABYLON.GUI {
  3409. /**
  3410. * Class used to transport BABYLON.Vector3 information for pointer events
  3411. */
  3412. export class Vector3WithInfo extends BABYLON.Vector3 {
  3413. /** defines the current mouse button index */
  3414. buttonIndex: number;
  3415. /**
  3416. * Creates a new Vector3WithInfo
  3417. * @param source defines the vector3 data to transport
  3418. * @param buttonIndex defines the current mouse button index
  3419. */
  3420. constructor(source: BABYLON.Vector3,
  3421. /** defines the current mouse button index */
  3422. buttonIndex?: number);
  3423. }
  3424. }
  3425. declare module BABYLON.GUI {
  3426. /**
  3427. * Class used as base class for controls
  3428. */
  3429. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  3430. /** Defines the control name */
  3431. name?: string | undefined;
  3432. /** @hidden */
  3433. _host: GUI3DManager;
  3434. private _node;
  3435. private _downCount;
  3436. private _enterCount;
  3437. private _downPointerIds;
  3438. private _isVisible;
  3439. /** Gets or sets the control position in world space */
  3440. get position(): BABYLON.Vector3;
  3441. set position(value: BABYLON.Vector3);
  3442. /** Gets or sets the control scaling in world space */
  3443. get scaling(): BABYLON.Vector3;
  3444. set scaling(value: BABYLON.Vector3);
  3445. /** Callback used to start pointer enter animation */
  3446. pointerEnterAnimation: () => void;
  3447. /** Callback used to start pointer out animation */
  3448. pointerOutAnimation: () => void;
  3449. /** Callback used to start pointer down animation */
  3450. pointerDownAnimation: () => void;
  3451. /** Callback used to start pointer up animation */
  3452. pointerUpAnimation: () => void;
  3453. /**
  3454. * An event triggered when the pointer move over the control
  3455. */
  3456. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  3457. /**
  3458. * An event triggered when the pointer move out of the control
  3459. */
  3460. onPointerOutObservable: BABYLON.Observable<Control3D>;
  3461. /**
  3462. * An event triggered when the pointer taps the control
  3463. */
  3464. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  3465. /**
  3466. * An event triggered when pointer is up
  3467. */
  3468. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  3469. /**
  3470. * An event triggered when a control is clicked on (with a mouse)
  3471. */
  3472. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  3473. /**
  3474. * An event triggered when pointer enters the control
  3475. */
  3476. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  3477. /**
  3478. * Gets or sets the parent container
  3479. */
  3480. parent: BABYLON.Nullable<Container3D>;
  3481. private _behaviors;
  3482. /**
  3483. * Gets the list of attached behaviors
  3484. * @see http://doc.babylonjs.com/features/behaviour
  3485. */
  3486. get behaviors(): BABYLON.Behavior<Control3D>[];
  3487. /**
  3488. * Attach a behavior to the control
  3489. * @see http://doc.babylonjs.com/features/behaviour
  3490. * @param behavior defines the behavior to attach
  3491. * @returns the current control
  3492. */
  3493. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  3494. /**
  3495. * Remove an attached behavior
  3496. * @see http://doc.babylonjs.com/features/behaviour
  3497. * @param behavior defines the behavior to attach
  3498. * @returns the current control
  3499. */
  3500. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  3501. /**
  3502. * Gets an attached behavior by name
  3503. * @param name defines the name of the behavior to look for
  3504. * @see http://doc.babylonjs.com/features/behaviour
  3505. * @returns null if behavior was not found else the requested behavior
  3506. */
  3507. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  3508. /** Gets or sets a boolean indicating if the control is visible */
  3509. get isVisible(): boolean;
  3510. set isVisible(value: boolean);
  3511. /**
  3512. * Creates a new control
  3513. * @param name defines the control name
  3514. */
  3515. constructor(
  3516. /** Defines the control name */
  3517. name?: string | undefined);
  3518. /**
  3519. * Gets a string representing the class name
  3520. */
  3521. get typeName(): string;
  3522. /**
  3523. * Get the current class name of the control.
  3524. * @returns current class name
  3525. */
  3526. getClassName(): string;
  3527. protected _getTypeName(): string;
  3528. /**
  3529. * Gets the transform node used by this control
  3530. */
  3531. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  3532. /**
  3533. * Gets the mesh used to render this control
  3534. */
  3535. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  3536. /**
  3537. * Link the control as child of the given node
  3538. * @param node defines the node to link to. Use null to unlink the control
  3539. * @returns the current control
  3540. */
  3541. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  3542. /** @hidden **/
  3543. _prepareNode(scene: BABYLON.Scene): void;
  3544. /**
  3545. * Node creation.
  3546. * Can be overriden by children
  3547. * @param scene defines the scene where the node must be attached
  3548. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  3549. */
  3550. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  3551. /**
  3552. * Affect a material to the given mesh
  3553. * @param mesh defines the mesh which will represent the control
  3554. */
  3555. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  3556. /** @hidden */
  3557. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  3558. /** @hidden */
  3559. _onPointerEnter(target: Control3D): boolean;
  3560. /** @hidden */
  3561. _onPointerOut(target: Control3D): void;
  3562. /** @hidden */
  3563. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  3564. /** @hidden */
  3565. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  3566. /** @hidden */
  3567. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  3568. /** @hidden */
  3569. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  3570. /** @hidden */
  3571. _disposeNode(): void;
  3572. /**
  3573. * Releases all associated resources
  3574. */
  3575. dispose(): void;
  3576. }
  3577. }
  3578. declare module BABYLON.GUI {
  3579. /**
  3580. * Class used as a root to all buttons
  3581. */
  3582. export class AbstractButton3D extends Control3D {
  3583. /**
  3584. * Creates a new button
  3585. * @param name defines the control name
  3586. */
  3587. constructor(name?: string);
  3588. protected _getTypeName(): string;
  3589. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  3590. }
  3591. }
  3592. declare module BABYLON.GUI {
  3593. /**
  3594. * Class used to create a button in 3D
  3595. */
  3596. export class Button3D extends AbstractButton3D {
  3597. /** @hidden */
  3598. protected _currentMaterial: BABYLON.Material;
  3599. private _facadeTexture;
  3600. private _content;
  3601. private _contentResolution;
  3602. private _contentScaleRatio;
  3603. /**
  3604. * Gets or sets the texture resolution used to render content (512 by default)
  3605. */
  3606. get contentResolution(): BABYLON.int;
  3607. set contentResolution(value: BABYLON.int);
  3608. /**
  3609. * Gets or sets the texture scale ratio used to render content (2 by default)
  3610. */
  3611. get contentScaleRatio(): number;
  3612. set contentScaleRatio(value: number);
  3613. protected _disposeFacadeTexture(): void;
  3614. protected _resetContent(): void;
  3615. /**
  3616. * Creates a new button
  3617. * @param name defines the control name
  3618. */
  3619. constructor(name?: string);
  3620. /**
  3621. * Gets or sets the GUI 2D content used to display the button's facade
  3622. */
  3623. get content(): Control;
  3624. set content(value: Control);
  3625. /**
  3626. * Apply the facade texture (created from the content property).
  3627. * This function can be overloaded by child classes
  3628. * @param facadeTexture defines the AdvancedDynamicTexture to use
  3629. */
  3630. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  3631. protected _getTypeName(): string;
  3632. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  3633. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  3634. /**
  3635. * Releases all associated resources
  3636. */
  3637. dispose(): void;
  3638. }
  3639. }
  3640. declare module BABYLON.GUI {
  3641. /**
  3642. * Abstract class used to create a container panel deployed on the surface of a volume
  3643. */
  3644. export abstract class VolumeBasedPanel extends Container3D {
  3645. private _columns;
  3646. private _rows;
  3647. private _rowThenColum;
  3648. private _orientation;
  3649. protected _cellWidth: number;
  3650. protected _cellHeight: number;
  3651. /**
  3652. * Gets or sets the distance between elements
  3653. */
  3654. margin: number;
  3655. /**
  3656. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  3657. * | Value | Type | Description |
  3658. * | ----- | ----------------------------------- | ----------- |
  3659. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  3660. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  3661. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  3662. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  3663. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  3664. */
  3665. get orientation(): number;
  3666. set orientation(value: number);
  3667. /**
  3668. * Gets or sets the number of columns requested (10 by default).
  3669. * The panel will automatically compute the number of rows based on number of child controls.
  3670. */
  3671. get columns(): BABYLON.int;
  3672. set columns(value: BABYLON.int);
  3673. /**
  3674. * Gets or sets a the number of rows requested.
  3675. * The panel will automatically compute the number of columns based on number of child controls.
  3676. */
  3677. get rows(): BABYLON.int;
  3678. set rows(value: BABYLON.int);
  3679. /**
  3680. * Creates new VolumeBasedPanel
  3681. */
  3682. constructor();
  3683. protected _arrangeChildren(): void;
  3684. /** Child classes must implement this function to provide correct control positioning */
  3685. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  3686. /** Child classes can implement this function to provide additional processing */
  3687. protected _finalProcessing(): void;
  3688. }
  3689. }
  3690. declare module BABYLON.GUI {
  3691. /**
  3692. * Class used to create a container panel deployed on the surface of a cylinder
  3693. */
  3694. export class CylinderPanel extends VolumeBasedPanel {
  3695. private _radius;
  3696. /**
  3697. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  3698. */
  3699. get radius(): BABYLON.float;
  3700. set radius(value: BABYLON.float);
  3701. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  3702. private _cylindricalMapping;
  3703. }
  3704. }
  3705. declare module BABYLON.GUI {
  3706. /** @hidden */
  3707. export var fluentVertexShader: {
  3708. name: string;
  3709. shader: string;
  3710. };
  3711. }
  3712. declare module BABYLON.GUI {
  3713. /** @hidden */
  3714. export var fluentPixelShader: {
  3715. name: string;
  3716. shader: string;
  3717. };
  3718. }
  3719. declare module BABYLON.GUI {
  3720. /** @hidden */
  3721. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  3722. INNERGLOW: boolean;
  3723. BORDER: boolean;
  3724. HOVERLIGHT: boolean;
  3725. TEXTURE: boolean;
  3726. constructor();
  3727. }
  3728. /**
  3729. * Class used to render controls with fluent desgin
  3730. */
  3731. export class FluentMaterial extends BABYLON.PushMaterial {
  3732. /**
  3733. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  3734. */
  3735. innerGlowColorIntensity: number;
  3736. /**
  3737. * Gets or sets the inner glow color (white by default)
  3738. */
  3739. innerGlowColor: BABYLON.Color3;
  3740. /**
  3741. * Gets or sets alpha value (default is 1.0)
  3742. */
  3743. alpha: number;
  3744. /**
  3745. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  3746. */
  3747. albedoColor: BABYLON.Color3;
  3748. /**
  3749. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  3750. */
  3751. renderBorders: boolean;
  3752. /**
  3753. * Gets or sets border width (default is 0.5)
  3754. */
  3755. borderWidth: number;
  3756. /**
  3757. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  3758. */
  3759. edgeSmoothingValue: number;
  3760. /**
  3761. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  3762. */
  3763. borderMinValue: number;
  3764. /**
  3765. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  3766. */
  3767. renderHoverLight: boolean;
  3768. /**
  3769. * Gets or sets the radius used to render the hover light (default is 1.0)
  3770. */
  3771. hoverRadius: number;
  3772. /**
  3773. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  3774. */
  3775. hoverColor: BABYLON.Color4;
  3776. /**
  3777. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  3778. */
  3779. hoverPosition: BABYLON.Vector3;
  3780. private _albedoTexture;
  3781. /** Gets or sets the texture to use for albedo color */
  3782. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  3783. /**
  3784. * Creates a new Fluent material
  3785. * @param name defines the name of the material
  3786. * @param scene defines the hosting scene
  3787. */
  3788. constructor(name: string, scene: BABYLON.Scene);
  3789. needAlphaBlending(): boolean;
  3790. needAlphaTesting(): boolean;
  3791. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  3792. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  3793. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  3794. getActiveTextures(): BABYLON.BaseTexture[];
  3795. hasTexture(texture: BABYLON.BaseTexture): boolean;
  3796. dispose(forceDisposeEffect?: boolean): void;
  3797. clone(name: string): FluentMaterial;
  3798. serialize(): any;
  3799. getClassName(): string;
  3800. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  3801. }
  3802. }
  3803. declare module BABYLON.GUI {
  3804. /**
  3805. * Class used to create a holographic button in 3D
  3806. */
  3807. export class HolographicButton extends Button3D {
  3808. private _backPlate;
  3809. private _textPlate;
  3810. private _frontPlate;
  3811. private _text;
  3812. private _imageUrl;
  3813. private _shareMaterials;
  3814. private _frontMaterial;
  3815. private _backMaterial;
  3816. private _plateMaterial;
  3817. private _pickedPointObserver;
  3818. private _tooltipFade;
  3819. private _tooltipTextBlock;
  3820. private _tooltipTexture;
  3821. private _tooltipMesh;
  3822. private _tooltipHoverObserver;
  3823. private _tooltipOutObserver;
  3824. private _disposeTooltip;
  3825. /**
  3826. * Rendering ground id of all the mesh in the button
  3827. */
  3828. set renderingGroupId(id: number);
  3829. get renderingGroupId(): number;
  3830. /**
  3831. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  3832. */
  3833. set tooltipText(text: BABYLON.Nullable<string>);
  3834. get tooltipText(): BABYLON.Nullable<string>;
  3835. /**
  3836. * Gets or sets text for the button
  3837. */
  3838. get text(): string;
  3839. set text(value: string);
  3840. /**
  3841. * Gets or sets the image url for the button
  3842. */
  3843. get imageUrl(): string;
  3844. set imageUrl(value: string);
  3845. /**
  3846. * Gets the back material used by this button
  3847. */
  3848. get backMaterial(): FluentMaterial;
  3849. /**
  3850. * Gets the front material used by this button
  3851. */
  3852. get frontMaterial(): FluentMaterial;
  3853. /**
  3854. * Gets the plate material used by this button
  3855. */
  3856. get plateMaterial(): BABYLON.StandardMaterial;
  3857. /**
  3858. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  3859. */
  3860. get shareMaterials(): boolean;
  3861. /**
  3862. * Creates a new button
  3863. * @param name defines the control name
  3864. */
  3865. constructor(name?: string, shareMaterials?: boolean);
  3866. protected _getTypeName(): string;
  3867. private _rebuildContent;
  3868. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  3869. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  3870. private _createBackMaterial;
  3871. private _createFrontMaterial;
  3872. private _createPlateMaterial;
  3873. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  3874. /**
  3875. * Releases all associated resources
  3876. */
  3877. dispose(): void;
  3878. }
  3879. }
  3880. declare module BABYLON.GUI {
  3881. /**
  3882. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  3883. */
  3884. export class MeshButton3D extends Button3D {
  3885. /** @hidden */
  3886. protected _currentMesh: BABYLON.Mesh;
  3887. /**
  3888. * Creates a new 3D button based on a mesh
  3889. * @param mesh mesh to become a 3D button
  3890. * @param name defines the control name
  3891. */
  3892. constructor(mesh: BABYLON.Mesh, name?: string);
  3893. protected _getTypeName(): string;
  3894. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  3895. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  3896. }
  3897. }
  3898. declare module BABYLON.GUI {
  3899. /**
  3900. * Class used to create a container panel deployed on the surface of a plane
  3901. */
  3902. export class PlanePanel extends VolumeBasedPanel {
  3903. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  3904. }
  3905. }
  3906. declare module BABYLON.GUI {
  3907. /**
  3908. * Class used to create a container panel where items get randomized planar mapping
  3909. */
  3910. export class ScatterPanel extends VolumeBasedPanel {
  3911. private _iteration;
  3912. /**
  3913. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  3914. */
  3915. get iteration(): BABYLON.float;
  3916. set iteration(value: BABYLON.float);
  3917. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  3918. private _scatterMapping;
  3919. protected _finalProcessing(): void;
  3920. }
  3921. }
  3922. declare module BABYLON.GUI {
  3923. /**
  3924. * Class used to create a container panel deployed on the surface of a sphere
  3925. */
  3926. export class SpherePanel extends VolumeBasedPanel {
  3927. private _radius;
  3928. /**
  3929. * Gets or sets the radius of the sphere where to project controls (5 by default)
  3930. */
  3931. get radius(): BABYLON.float;
  3932. set radius(value: BABYLON.float);
  3933. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  3934. private _sphericalMapping;
  3935. }
  3936. }
  3937. declare module BABYLON.GUI {
  3938. /**
  3939. * Class used to create a stack panel in 3D on XY plane
  3940. */
  3941. export class StackPanel3D extends Container3D {
  3942. private _isVertical;
  3943. /**
  3944. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  3945. */
  3946. get isVertical(): boolean;
  3947. set isVertical(value: boolean);
  3948. /**
  3949. * Gets or sets the distance between elements
  3950. */
  3951. margin: number;
  3952. /**
  3953. * Creates new StackPanel
  3954. * @param isVertical
  3955. */
  3956. constructor(isVertical?: boolean);
  3957. protected _arrangeChildren(): void;
  3958. }
  3959. }