babylon.gui.module.d.ts 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. /// <reference types="babylonjs"/>
  2. declare module 'babylonjs-gui' {
  3. export = BABYLON.GUI;
  4. }
  5. declare module BABYLON.GUI {
  6. interface IFocusableControl {
  7. onFocus(): void;
  8. onBlur(): void;
  9. processKeyboard(evt: KeyboardEvent): void;
  10. }
  11. class AdvancedDynamicTexture extends DynamicTexture {
  12. private _isDirty;
  13. private _renderObserver;
  14. private _resizeObserver;
  15. private _preKeyboardObserver;
  16. private _pointerMoveObserver;
  17. private _pointerObserver;
  18. private _canvasPointerOutObserver;
  19. private _background;
  20. _rootContainer: Container;
  21. _lastPickedControl: Control;
  22. _lastControlOver: Nullable<Control>;
  23. _lastControlDown: Nullable<Control>;
  24. _capturingControl: {
  25. [pointerId: number]: Control;
  26. };
  27. _shouldBlockPointer: boolean;
  28. _layerToDispose: Nullable<Layer>;
  29. _linkedControls: Control[];
  30. private _isFullscreen;
  31. private _fullscreenViewport;
  32. private _idealWidth;
  33. private _idealHeight;
  34. private _renderAtIdealSize;
  35. private _focusedControl;
  36. private _blockNextFocusCheck;
  37. private _renderScale;
  38. renderScale: number;
  39. background: string;
  40. idealWidth: number;
  41. idealHeight: number;
  42. renderAtIdealSize: boolean;
  43. readonly layer: Nullable<Layer>;
  44. readonly rootContainer: Container;
  45. focusedControl: Nullable<IFocusableControl>;
  46. isForeground: boolean;
  47. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  48. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  49. markAsDirty(): void;
  50. addControl(control: Control): AdvancedDynamicTexture;
  51. removeControl(control: Control): AdvancedDynamicTexture;
  52. dispose(): void;
  53. private _onResize();
  54. _getGlobalViewport(scene: Scene): Viewport;
  55. private _checkUpdate(camera);
  56. private _render();
  57. private _doPicking(x, y, type, pointerId, buttonIndex);
  58. attach(): void;
  59. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  60. moveFocusToControl(control: IFocusableControl): void;
  61. private _manageFocus();
  62. private _attachToOnPointerOut(scene);
  63. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  64. /**
  65. * FullScreenUI is created in a layer. This allows it to be treated like any other layer.
  66. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  67. * When the GUI is not Created as FullscreenUI it does not respect the layerMask.
  68. * layerMask is set through advancedTexture.layer.layerMask
  69. * @param name name for the Texture
  70. * @param foreground render in foreground (default is true)
  71. * @param scene scene to be rendered in
  72. * @param sampling method for scaling to fit screen
  73. * @returns AdvancedDynamicTexture
  74. */
  75. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  76. }
  77. }
  78. declare module BABYLON.GUI {
  79. class Measure {
  80. left: number;
  81. top: number;
  82. width: number;
  83. height: number;
  84. constructor(left: number, top: number, width: number, height: number);
  85. copyFrom(other: Measure): void;
  86. isEqualsTo(other: Measure): boolean;
  87. static Empty(): Measure;
  88. }
  89. }
  90. declare module BABYLON.GUI {
  91. class Vector2WithInfo extends Vector2 {
  92. buttonIndex: number;
  93. constructor(source: Vector2, buttonIndex?: number);
  94. }
  95. class Matrix2D {
  96. m: Float32Array;
  97. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  98. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  99. determinant(): number;
  100. invertToRef(result: Matrix2D): Matrix2D;
  101. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  102. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  103. static Identity(): Matrix2D;
  104. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  105. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  106. static RotationToRef(angle: number, result: Matrix2D): void;
  107. private static _TempPreTranslationMatrix;
  108. private static _TempPostTranslationMatrix;
  109. private static _TempRotationMatrix;
  110. private static _TempScalingMatrix;
  111. private static _TempCompose0;
  112. private static _TempCompose1;
  113. private static _TempCompose2;
  114. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  115. }
  116. }
  117. declare module BABYLON.GUI {
  118. class ValueAndUnit {
  119. unit: number;
  120. negativeValueAllowed: boolean;
  121. private _value;
  122. ignoreAdaptiveScaling: boolean;
  123. constructor(value: number, unit?: number, negativeValueAllowed?: boolean);
  124. readonly isPercentage: boolean;
  125. readonly isPixel: boolean;
  126. readonly internalValue: number;
  127. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  128. getValue(host: AdvancedDynamicTexture): number;
  129. toString(host: AdvancedDynamicTexture): string;
  130. fromString(source: string | number): boolean;
  131. private static _Regex;
  132. private static _UNITMODE_PERCENTAGE;
  133. private static _UNITMODE_PIXEL;
  134. static readonly UNITMODE_PERCENTAGE: number;
  135. static readonly UNITMODE_PIXEL: number;
  136. }
  137. }
  138. declare module BABYLON.GUI {
  139. class Control {
  140. name: string | undefined;
  141. private _alpha;
  142. private _alphaSet;
  143. private _zIndex;
  144. _root: Nullable<Container>;
  145. _host: AdvancedDynamicTexture;
  146. parent: Nullable<Container>;
  147. _currentMeasure: Measure;
  148. private _fontFamily;
  149. private _fontStyle;
  150. private _fontSize;
  151. private _font;
  152. _width: ValueAndUnit;
  153. _height: ValueAndUnit;
  154. protected _fontOffset: {
  155. ascent: number;
  156. height: number;
  157. descent: number;
  158. };
  159. private _color;
  160. protected _horizontalAlignment: number;
  161. protected _verticalAlignment: number;
  162. private _isDirty;
  163. _tempParentMeasure: Measure;
  164. protected _cachedParentMeasure: Measure;
  165. private _paddingLeft;
  166. private _paddingRight;
  167. private _paddingTop;
  168. private _paddingBottom;
  169. _left: ValueAndUnit;
  170. _top: ValueAndUnit;
  171. private _scaleX;
  172. private _scaleY;
  173. private _rotation;
  174. private _transformCenterX;
  175. private _transformCenterY;
  176. private _transformMatrix;
  177. protected _invertTransformMatrix: Matrix2D;
  178. protected _transformedPosition: Vector2;
  179. private _isMatrixDirty;
  180. private _cachedOffsetX;
  181. private _cachedOffsetY;
  182. private _isVisible;
  183. _linkedMesh: Nullable<AbstractMesh>;
  184. private _fontSet;
  185. private _dummyVector2;
  186. private _downCount;
  187. private _enterCount;
  188. private _doNotRender;
  189. private _downPointerIds;
  190. isHitTestVisible: boolean;
  191. isPointerBlocker: boolean;
  192. isFocusInvisible: boolean;
  193. shadowOffsetX: number;
  194. shadowOffsetY: number;
  195. shadowBlur: number;
  196. shadowColor: string;
  197. protected _linkOffsetX: ValueAndUnit;
  198. protected _linkOffsetY: ValueAndUnit;
  199. readonly typeName: string;
  200. /**
  201. * An event triggered when the pointer move over the control.
  202. * @type {BABYLON.Observable}
  203. */
  204. onPointerMoveObservable: Observable<Vector2>;
  205. /**
  206. * An event triggered when the pointer move out of the control.
  207. * @type {BABYLON.Observable}
  208. */
  209. onPointerOutObservable: Observable<Control>;
  210. /**
  211. * An event triggered when the pointer taps the control
  212. * @type {BABYLON.Observable}
  213. */
  214. onPointerDownObservable: Observable<Vector2WithInfo>;
  215. /**
  216. * An event triggered when pointer up
  217. * @type {BABYLON.Observable}
  218. */
  219. onPointerUpObservable: Observable<Vector2WithInfo>;
  220. /**
  221. * An event triggered when pointer enters the control
  222. * @type {BABYLON.Observable}
  223. */
  224. onPointerEnterObservable: Observable<Control>;
  225. /**
  226. * An event triggered when the control is marked as dirty
  227. * @type {BABYLON.Observable}
  228. */
  229. onDirtyObservable: Observable<Control>;
  230. /**
  231. * An event triggered after the control is drawn
  232. * @type {BABYLON.Observable}
  233. */
  234. onAfterDrawObservable: Observable<Control>;
  235. alpha: number;
  236. scaleX: number;
  237. scaleY: number;
  238. rotation: number;
  239. transformCenterY: number;
  240. transformCenterX: number;
  241. horizontalAlignment: number;
  242. verticalAlignment: number;
  243. width: string | number;
  244. readonly widthInPixels: number;
  245. height: string | number;
  246. readonly heightInPixels: number;
  247. fontFamily: string;
  248. fontStyle: string;
  249. /** @ignore */
  250. readonly _isFontSizeInPercentage: boolean;
  251. readonly fontSizeInPixels: number;
  252. fontSize: string | number;
  253. color: string;
  254. zIndex: number;
  255. notRenderable: boolean;
  256. isVisible: boolean;
  257. readonly isDirty: boolean;
  258. paddingLeft: string | number;
  259. readonly paddingLeftInPixels: number;
  260. paddingRight: string | number;
  261. readonly paddingRightInPixels: number;
  262. paddingTop: string | number;
  263. readonly paddingTopInPixels: number;
  264. paddingBottom: string | number;
  265. readonly paddingBottomInPixels: number;
  266. left: string | number;
  267. readonly leftInPixels: number;
  268. top: string | number;
  269. readonly topInPixels: number;
  270. linkOffsetX: string | number;
  271. readonly linkOffsetXInPixels: number;
  272. linkOffsetY: string | number;
  273. readonly linkOffsetYInPixels: number;
  274. readonly centerX: number;
  275. readonly centerY: number;
  276. constructor(name?: string | undefined);
  277. protected _getTypeName(): string;
  278. /** @ignore */
  279. _resetFontCache(): void;
  280. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  281. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  282. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  283. moveToVector3(position: Vector3, scene: Scene): void;
  284. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  285. _moveToProjectedPosition(projectedPosition: Vector3): void;
  286. _markMatrixAsDirty(): void;
  287. _markAsDirty(): void;
  288. _markAllAsDirty(): void;
  289. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  290. protected _transform(context: CanvasRenderingContext2D): void;
  291. protected _applyStates(context: CanvasRenderingContext2D): void;
  292. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  293. protected _clip(context: CanvasRenderingContext2D): void;
  294. _measure(): void;
  295. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  296. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  297. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  298. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  299. contains(x: number, y: number): boolean;
  300. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  301. _onPointerMove(target: Control, coordinates: Vector2): void;
  302. _onPointerEnter(target: Control): boolean;
  303. _onPointerOut(target: Control): void;
  304. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  305. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): void;
  306. forcePointerUp(pointerId?: Nullable<number>): void;
  307. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  308. private _prepareFont();
  309. dispose(): void;
  310. private static _HORIZONTAL_ALIGNMENT_LEFT;
  311. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  312. private static _HORIZONTAL_ALIGNMENT_CENTER;
  313. private static _VERTICAL_ALIGNMENT_TOP;
  314. private static _VERTICAL_ALIGNMENT_BOTTOM;
  315. private static _VERTICAL_ALIGNMENT_CENTER;
  316. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  317. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  318. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  319. static readonly VERTICAL_ALIGNMENT_TOP: number;
  320. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  321. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  322. private static _FontHeightSizes;
  323. static _GetFontOffset(font: string): {
  324. ascent: number;
  325. height: number;
  326. descent: number;
  327. };
  328. static AddHeader(control: Control, text: string, size: string | number, options: {
  329. isHorizontal: boolean;
  330. controlFirst: boolean;
  331. }): StackPanel;
  332. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  333. }
  334. }
  335. declare module BABYLON.GUI {
  336. class Container extends Control {
  337. name: string | undefined;
  338. protected _children: Control[];
  339. protected _measureForChildren: Measure;
  340. protected _background: string;
  341. background: string;
  342. readonly children: Control[];
  343. constructor(name?: string | undefined);
  344. protected _getTypeName(): string;
  345. getChildByName(name: string): Nullable<Control>;
  346. getChildByType(name: string, type: string): Nullable<Control>;
  347. containsControl(control: Control): boolean;
  348. addControl(control: Control): Container;
  349. removeControl(control: Control): Container;
  350. _reOrderControl(control: Control): void;
  351. _markMatrixAsDirty(): void;
  352. _markAllAsDirty(): void;
  353. protected _localDraw(context: CanvasRenderingContext2D): void;
  354. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  355. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  356. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  357. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  358. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  359. dispose(): void;
  360. }
  361. }
  362. declare module BABYLON.GUI {
  363. class StackPanel extends Container {
  364. name: string | undefined;
  365. private _isVertical;
  366. private _manualWidth;
  367. private _manualHeight;
  368. private _doNotTrackManualChanges;
  369. private _tempMeasureStore;
  370. isVertical: boolean;
  371. width: string | number;
  372. height: string | number;
  373. constructor(name?: string | undefined);
  374. protected _getTypeName(): string;
  375. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  376. }
  377. }
  378. declare module BABYLON.GUI {
  379. class Rectangle extends Container {
  380. name: string | undefined;
  381. private _thickness;
  382. private _cornerRadius;
  383. thickness: number;
  384. cornerRadius: number;
  385. constructor(name?: string | undefined);
  386. protected _getTypeName(): string;
  387. protected _localDraw(context: CanvasRenderingContext2D): void;
  388. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  389. private _drawRoundedRect(context, offset?);
  390. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  391. }
  392. }
  393. declare module BABYLON.GUI {
  394. class Ellipse extends Container {
  395. name: string | undefined;
  396. private _thickness;
  397. thickness: number;
  398. constructor(name?: string | undefined);
  399. protected _getTypeName(): string;
  400. protected _localDraw(context: CanvasRenderingContext2D): void;
  401. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  402. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  403. }
  404. }
  405. declare module BABYLON.GUI {
  406. class Line extends Control {
  407. name: string | undefined;
  408. private _lineWidth;
  409. private _x1;
  410. private _y1;
  411. private _x2;
  412. private _y2;
  413. private _dash;
  414. private _connectedControl;
  415. private _connectedControlDirtyObserver;
  416. dash: Array<number>;
  417. connectedControl: Control;
  418. x1: string | number;
  419. y1: string | number;
  420. x2: string | number;
  421. y2: string | number;
  422. lineWidth: number;
  423. horizontalAlignment: number;
  424. verticalAlignment: number;
  425. private readonly _effectiveX2;
  426. private readonly _effectiveY2;
  427. constructor(name?: string | undefined);
  428. protected _getTypeName(): string;
  429. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  430. _measure(): void;
  431. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  432. /**
  433. * Move one end of the line given 3D cartesian coordinates.
  434. * @param position Targeted world position
  435. * @param scene Scene
  436. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  437. */
  438. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  439. /**
  440. * Move one end of the line to a position in screen absolute space.
  441. * @param projectedPosition Position in screen absolute space (X, Y)
  442. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  443. */
  444. _moveToProjectedPosition(projectedPosition: Vector3, end?: boolean): void;
  445. }
  446. }
  447. declare module BABYLON.GUI {
  448. class Slider extends Control {
  449. name: string | undefined;
  450. private _thumbWidth;
  451. private _minimum;
  452. private _maximum;
  453. private _value;
  454. private _background;
  455. private _borderColor;
  456. private _barOffset;
  457. private _isThumbCircle;
  458. private _isThumbClamped;
  459. onValueChangedObservable: Observable<number>;
  460. borderColor: string;
  461. background: string;
  462. barOffset: string | number;
  463. readonly barOffsetInPixels: number;
  464. thumbWidth: string | number;
  465. readonly thumbWidthInPixels: number;
  466. minimum: number;
  467. maximum: number;
  468. value: number;
  469. isThumbCircle: boolean;
  470. isThumbClamped: boolean;
  471. constructor(name?: string | undefined);
  472. protected _getTypeName(): string;
  473. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  474. private _pointerIsDown;
  475. private _updateValueFromPointer(x, y);
  476. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  477. _onPointerMove(target: Control, coordinates: Vector2): void;
  478. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): void;
  479. }
  480. }
  481. declare module BABYLON.GUI {
  482. class Checkbox extends Control {
  483. name: string | undefined;
  484. private _isChecked;
  485. private _background;
  486. private _checkSizeRatio;
  487. private _thickness;
  488. thickness: number;
  489. onIsCheckedChangedObservable: Observable<boolean>;
  490. checkSizeRatio: number;
  491. background: string;
  492. isChecked: boolean;
  493. constructor(name?: string | undefined);
  494. protected _getTypeName(): string;
  495. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  496. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  497. }
  498. }
  499. declare module BABYLON.GUI {
  500. class RadioButton extends Control {
  501. name: string | undefined;
  502. private _isChecked;
  503. private _background;
  504. private _checkSizeRatio;
  505. private _thickness;
  506. thickness: number;
  507. group: string;
  508. onIsCheckedChangedObservable: Observable<boolean>;
  509. checkSizeRatio: number;
  510. background: string;
  511. isChecked: boolean;
  512. constructor(name?: string | undefined);
  513. protected _getTypeName(): string;
  514. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  515. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  516. }
  517. }
  518. declare module BABYLON.GUI {
  519. class TextBlock extends Control {
  520. /**
  521. * Defines the name of the control
  522. */
  523. name: string | undefined;
  524. private _text;
  525. private _textWrapping;
  526. private _textHorizontalAlignment;
  527. private _textVerticalAlignment;
  528. private _lines;
  529. private _resizeToFit;
  530. private _lineSpacing;
  531. private _outlineWidth;
  532. private _outlineColor;
  533. /**
  534. * An event triggered after the text is changed
  535. * @type {BABYLON.Observable}
  536. */
  537. onTextChangedObservable: Observable<TextBlock>;
  538. /**
  539. * An event triggered after the text was broken up into lines
  540. * @type {BABYLON.Observable}
  541. */
  542. onLinesReadyObservable: Observable<TextBlock>;
  543. /**
  544. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  545. */
  546. readonly lines: any[];
  547. /**
  548. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  549. */
  550. /**
  551. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  552. */
  553. resizeToFit: boolean;
  554. /**
  555. * Gets or sets a boolean indicating if text must be wrapped
  556. */
  557. /**
  558. * Gets or sets a boolean indicating if text must be wrapped
  559. */
  560. textWrapping: boolean;
  561. /**
  562. * Gets or sets text to display
  563. */
  564. /**
  565. * Gets or sets text to display
  566. */
  567. text: string;
  568. /**
  569. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  570. */
  571. /**
  572. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  573. */
  574. textHorizontalAlignment: number;
  575. /**
  576. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  577. */
  578. /**
  579. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  580. */
  581. textVerticalAlignment: number;
  582. /**
  583. * Gets or sets line spacing value
  584. */
  585. /**
  586. * Gets or sets line spacing value
  587. */
  588. lineSpacing: string | number;
  589. /**
  590. * Gets or sets outlineWidth of the text to display
  591. */
  592. /**
  593. * Gets or sets outlineWidth of the text to display
  594. */
  595. outlineWidth: number;
  596. /**
  597. * Gets or sets outlineColor of the text to display
  598. */
  599. /**
  600. * Gets or sets outlineColor of the text to display
  601. */
  602. outlineColor: string;
  603. /**
  604. * Creates a new TextBlock object
  605. * @param name defines the name of the control
  606. * @param text defines the text to display (emptry string by default)
  607. */
  608. constructor(
  609. /**
  610. * Defines the name of the control
  611. */
  612. name?: string | undefined, text?: string);
  613. protected _getTypeName(): string;
  614. private _drawText(text, textWidth, y, context);
  615. /** @ignore */
  616. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  617. protected _applyStates(context: CanvasRenderingContext2D): void;
  618. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  619. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  620. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  621. protected _renderLines(context: CanvasRenderingContext2D): void;
  622. dispose(): void;
  623. }
  624. }
  625. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  626. declare module BABYLON.GUI {
  627. class Image extends Control {
  628. name: string | undefined;
  629. private _domImage;
  630. private _imageWidth;
  631. private _imageHeight;
  632. private _loaded;
  633. private _stretch;
  634. private _source;
  635. private _autoScale;
  636. private _sourceLeft;
  637. private _sourceTop;
  638. private _sourceWidth;
  639. private _sourceHeight;
  640. private _cellWidth;
  641. private _cellHeight;
  642. private _cellId;
  643. sourceLeft: number;
  644. sourceTop: number;
  645. sourceWidth: number;
  646. sourceHeight: number;
  647. autoScale: boolean;
  648. stretch: number;
  649. domImage: HTMLImageElement;
  650. private _onImageLoaded();
  651. source: Nullable<string>;
  652. cellWidth: number;
  653. cellHeight: number;
  654. cellId: number;
  655. constructor(name?: string | undefined, url?: Nullable<string>);
  656. protected _getTypeName(): string;
  657. synchronizeSizeWithContent(): void;
  658. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  659. private static _STRETCH_NONE;
  660. private static _STRETCH_FILL;
  661. private static _STRETCH_UNIFORM;
  662. private static _STRETCH_EXTEND;
  663. static readonly STRETCH_NONE: number;
  664. static readonly STRETCH_FILL: number;
  665. static readonly STRETCH_UNIFORM: number;
  666. static readonly STRETCH_EXTEND: number;
  667. }
  668. }
  669. declare module BABYLON.GUI {
  670. class Button extends Rectangle {
  671. name: string | undefined;
  672. pointerEnterAnimation: () => void;
  673. pointerOutAnimation: () => void;
  674. pointerDownAnimation: () => void;
  675. pointerUpAnimation: () => void;
  676. constructor(name?: string | undefined);
  677. protected _getTypeName(): string;
  678. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  679. _onPointerEnter(target: Control): boolean;
  680. _onPointerOut(target: Control): void;
  681. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  682. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): void;
  683. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  684. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  685. static CreateSimpleButton(name: string, text: string): Button;
  686. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  687. }
  688. }
  689. declare module BABYLON.GUI {
  690. class ColorPicker extends Control {
  691. name: string | undefined;
  692. private _colorWheelCanvas;
  693. private _value;
  694. private _tmpColor;
  695. private _pointerStartedOnSquare;
  696. private _pointerStartedOnWheel;
  697. private _squareLeft;
  698. private _squareTop;
  699. private _squareSize;
  700. private _h;
  701. private _s;
  702. private _v;
  703. onValueChangedObservable: Observable<Color3>;
  704. value: Color3;
  705. width: string | number;
  706. height: string | number;
  707. size: string | number;
  708. constructor(name?: string | undefined);
  709. protected _getTypeName(): string;
  710. private _updateSquareProps();
  711. private _drawGradientSquare(hueValue, left, top, width, height, context);
  712. private _drawCircle(centerX, centerY, radius, context);
  713. private _createColorWheelCanvas(radius, thickness);
  714. private _RGBtoHSV(color, result);
  715. private _HSVtoRGB(hue, saturation, value, result);
  716. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  717. private _pointerIsDown;
  718. private _updateValueFromPointer(x, y);
  719. private _isPointOnSquare(coordinates);
  720. private _isPointOnWheel(coordinates);
  721. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  722. _onPointerMove(target: Control, coordinates: Vector2): void;
  723. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): void;
  724. }
  725. }
  726. declare module BABYLON.GUI {
  727. class InputText extends Control implements IFocusableControl {
  728. name: string | undefined;
  729. private _text;
  730. private _placeholderText;
  731. private _background;
  732. private _focusedBackground;
  733. private _placeholderColor;
  734. private _thickness;
  735. private _margin;
  736. private _autoStretchWidth;
  737. private _maxWidth;
  738. private _isFocused;
  739. private _blinkTimeout;
  740. private _blinkIsEven;
  741. private _cursorOffset;
  742. private _scrollLeft;
  743. private _textWidth;
  744. private _clickedCoordinate;
  745. promptMessage: string;
  746. onTextChangedObservable: Observable<InputText>;
  747. onFocusObservable: Observable<InputText>;
  748. onBlurObservable: Observable<InputText>;
  749. maxWidth: string | number;
  750. readonly maxWidthInPixels: number;
  751. margin: string;
  752. readonly marginInPixels: number;
  753. autoStretchWidth: boolean;
  754. thickness: number;
  755. focusedBackground: string;
  756. background: string;
  757. placeholderColor: string;
  758. placeholderText: string;
  759. text: string;
  760. width: string | number;
  761. constructor(name?: string | undefined, text?: string);
  762. onBlur(): void;
  763. onFocus(): void;
  764. protected _getTypeName(): string;
  765. processKey(keyCode: number, key?: string): void;
  766. processKeyboard(evt: KeyboardEvent): void;
  767. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  768. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  769. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): void;
  770. dispose(): void;
  771. }
  772. }
  773. declare module BABYLON.GUI {
  774. class KeyPropertySet {
  775. width?: string;
  776. height?: string;
  777. paddingLeft?: string;
  778. paddingRight?: string;
  779. paddingTop?: string;
  780. paddingBottom?: string;
  781. color?: string;
  782. background?: string;
  783. }
  784. class VirtualKeyboard extends StackPanel {
  785. onKeyPressObservable: Observable<string>;
  786. defaultButtonWidth: string;
  787. defaultButtonHeight: string;
  788. defaultButtonPaddingLeft: string;
  789. defaultButtonPaddingRight: string;
  790. defaultButtonPaddingTop: string;
  791. defaultButtonPaddingBottom: string;
  792. defaultButtonColor: string;
  793. defaultButtonBackground: string;
  794. shiftButtonColor: string;
  795. selectedShiftThickness: number;
  796. shiftState: number;
  797. protected _getTypeName(): string;
  798. private _createKey(key, propertySet);
  799. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  800. applyShiftState(shiftState: number): void;
  801. private _connectedInputText;
  802. private _onFocusObserver;
  803. private _onBlurObserver;
  804. private _onKeyPressObserver;
  805. readonly connectedInputText: Nullable<InputText>;
  806. connect(input: InputText): void;
  807. disconnect(): void;
  808. static CreateDefaultLayout(): VirtualKeyboard;
  809. }
  810. }