babylon.gui.d.ts 173 KB

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