babylon.gui.d.ts 171 KB

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