babylon.gui.module.d.ts 32 KB

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