babylon.gui.module.d.ts 32 KB

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