babylon.gui.d.ts 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. declare module BABYLON.GUI {
  2. interface IFocusableControl {
  3. onFocus(): void;
  4. onBlur(): void;
  5. processKeyboard(evt: KeyboardEvent): void;
  6. }
  7. class AdvancedDynamicTexture extends DynamicTexture {
  8. private _isDirty;
  9. private _renderObserver;
  10. private _resizeObserver;
  11. private _preKeyboardObserver;
  12. private _pointerMoveObserver;
  13. private _pointerObserver;
  14. private _canvasPointerOutObserver;
  15. private _background;
  16. _rootContainer: Container;
  17. _lastPickedControl: Control;
  18. _lastControlOver: {
  19. [pointerId: number]: Control;
  20. };
  21. _lastControlDown: {
  22. [pointerId: number]: Control;
  23. };
  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 _useSmallestIdeal;
  35. private _renderAtIdealSize;
  36. private _focusedControl;
  37. private _blockNextFocusCheck;
  38. private _renderScale;
  39. renderScale: number;
  40. background: string;
  41. idealWidth: number;
  42. idealHeight: number;
  43. useSmallestIdeal: boolean;
  44. renderAtIdealSize: boolean;
  45. readonly layer: Nullable<Layer>;
  46. readonly rootContainer: Container;
  47. focusedControl: Nullable<IFocusableControl>;
  48. isForeground: boolean;
  49. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  50. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  51. markAsDirty(): void;
  52. addControl(control: Control): AdvancedDynamicTexture;
  53. removeControl(control: Control): AdvancedDynamicTexture;
  54. dispose(): void;
  55. private _onResize();
  56. _getGlobalViewport(scene: Scene): Viewport;
  57. private _checkUpdate(camera);
  58. private _render();
  59. private _doPicking(x, y, type, pointerId, buttonIndex);
  60. attach(): void;
  61. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  62. moveFocusToControl(control: IFocusableControl): void;
  63. private _manageFocus();
  64. private _attachToOnPointerOut(scene);
  65. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  66. /**
  67. * FullScreenUI is created in a layer. This allows it to be treated like any other layer.
  68. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  69. * When the GUI is not Created as FullscreenUI it does not respect the layerMask.
  70. * layerMask is set through advancedTexture.layer.layerMask
  71. * @param name name for the Texture
  72. * @param foreground render in foreground (default is true)
  73. * @param scene scene to be rendered in
  74. * @param sampling method for scaling to fit screen
  75. * @returns AdvancedDynamicTexture
  76. */
  77. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  78. }
  79. }
  80. declare module BABYLON.GUI {
  81. class Measure {
  82. left: number;
  83. top: number;
  84. width: number;
  85. height: number;
  86. constructor(left: number, top: number, width: number, height: number);
  87. copyFrom(other: Measure): void;
  88. isEqualsTo(other: Measure): boolean;
  89. static Empty(): Measure;
  90. }
  91. }
  92. declare module BABYLON.GUI {
  93. class Vector2WithInfo extends Vector2 {
  94. buttonIndex: number;
  95. constructor(source: Vector2, buttonIndex?: number);
  96. }
  97. class Matrix2D {
  98. m: Float32Array;
  99. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  100. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  101. determinant(): number;
  102. invertToRef(result: Matrix2D): Matrix2D;
  103. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  104. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  105. static Identity(): Matrix2D;
  106. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  107. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  108. static RotationToRef(angle: number, result: Matrix2D): void;
  109. private static _TempPreTranslationMatrix;
  110. private static _TempPostTranslationMatrix;
  111. private static _TempRotationMatrix;
  112. private static _TempScalingMatrix;
  113. private static _TempCompose0;
  114. private static _TempCompose1;
  115. private static _TempCompose2;
  116. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  117. }
  118. }
  119. declare module BABYLON.GUI {
  120. class ValueAndUnit {
  121. unit: number;
  122. negativeValueAllowed: boolean;
  123. private _value;
  124. ignoreAdaptiveScaling: boolean;
  125. constructor(value: number, unit?: number, negativeValueAllowed?: boolean);
  126. readonly isPercentage: boolean;
  127. readonly isPixel: boolean;
  128. readonly internalValue: number;
  129. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  130. getValue(host: AdvancedDynamicTexture): number;
  131. toString(host: AdvancedDynamicTexture): string;
  132. fromString(source: string | number): boolean;
  133. private static _Regex;
  134. private static _UNITMODE_PERCENTAGE;
  135. private static _UNITMODE_PIXEL;
  136. static readonly UNITMODE_PERCENTAGE: number;
  137. static readonly UNITMODE_PIXEL: number;
  138. }
  139. }
  140. declare module BABYLON.GUI {
  141. class Control {
  142. name: string | undefined;
  143. private _alpha;
  144. private _alphaSet;
  145. private _zIndex;
  146. _root: Nullable<Container>;
  147. _host: AdvancedDynamicTexture;
  148. parent: Nullable<Container>;
  149. _currentMeasure: Measure;
  150. private _fontFamily;
  151. private _fontStyle;
  152. private _fontSize;
  153. private _font;
  154. _width: ValueAndUnit;
  155. _height: ValueAndUnit;
  156. protected _fontOffset: {
  157. ascent: number;
  158. height: number;
  159. descent: number;
  160. };
  161. private _color;
  162. protected _horizontalAlignment: number;
  163. protected _verticalAlignment: number;
  164. private _isDirty;
  165. _tempParentMeasure: Measure;
  166. protected _cachedParentMeasure: Measure;
  167. private _paddingLeft;
  168. private _paddingRight;
  169. private _paddingTop;
  170. private _paddingBottom;
  171. _left: ValueAndUnit;
  172. _top: ValueAndUnit;
  173. private _scaleX;
  174. private _scaleY;
  175. private _rotation;
  176. private _transformCenterX;
  177. private _transformCenterY;
  178. private _transformMatrix;
  179. protected _invertTransformMatrix: Matrix2D;
  180. protected _transformedPosition: Vector2;
  181. private _onlyMeasureMode;
  182. private _isMatrixDirty;
  183. private _cachedOffsetX;
  184. private _cachedOffsetY;
  185. private _isVisible;
  186. _linkedMesh: Nullable<AbstractMesh>;
  187. private _fontSet;
  188. private _dummyVector2;
  189. private _downCount;
  190. private _enterCount;
  191. private _doNotRender;
  192. private _downPointerIds;
  193. isHitTestVisible: boolean;
  194. isPointerBlocker: boolean;
  195. isFocusInvisible: boolean;
  196. shadowOffsetX: number;
  197. shadowOffsetY: number;
  198. shadowBlur: number;
  199. shadowColor: string;
  200. protected _linkOffsetX: ValueAndUnit;
  201. protected _linkOffsetY: ValueAndUnit;
  202. readonly typeName: string;
  203. /**
  204. * An event triggered when the pointer move over the control.
  205. */
  206. onPointerMoveObservable: Observable<Vector2>;
  207. /**
  208. * An event triggered when the pointer move out of the control.
  209. */
  210. onPointerOutObservable: Observable<Control>;
  211. /**
  212. * An event triggered when the pointer taps the control
  213. */
  214. onPointerDownObservable: Observable<Vector2WithInfo>;
  215. /**
  216. * An event triggered when pointer up
  217. */
  218. onPointerUpObservable: Observable<Vector2WithInfo>;
  219. /**
  220. * An event triggered when a control is clicked on
  221. */
  222. onPointerClickObservable: Observable<Vector2WithInfo>;
  223. /**
  224. * An event triggered when pointer enters the control
  225. */
  226. onPointerEnterObservable: Observable<Control>;
  227. /**
  228. * An event triggered when the control is marked as dirty
  229. */
  230. onDirtyObservable: Observable<Control>;
  231. /**
  232. * An event triggered after the control is drawn
  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, notifyClick: boolean): 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. protected _adaptWidthToChildren: boolean;
  342. protected _adaptHeightToChildren: boolean;
  343. adaptHeightToChildren: boolean;
  344. adaptWidthToChildren: boolean;
  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, notifyClick: boolean): 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. */
  540. onTextChangedObservable: Observable<TextBlock>;
  541. /**
  542. * An event triggered after the text was broken up into lines
  543. */
  544. onLinesReadyObservable: Observable<TextBlock>;
  545. /**
  546. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  547. */
  548. readonly lines: any[];
  549. /**
  550. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  551. */
  552. /**
  553. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  554. */
  555. resizeToFit: boolean;
  556. /**
  557. * Gets or sets a boolean indicating if text must be wrapped
  558. */
  559. /**
  560. * Gets or sets a boolean indicating if text must be wrapped
  561. */
  562. textWrapping: boolean;
  563. /**
  564. * Gets or sets text to display
  565. */
  566. /**
  567. * Gets or sets text to display
  568. */
  569. text: string;
  570. /**
  571. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  572. */
  573. /**
  574. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  575. */
  576. textHorizontalAlignment: number;
  577. /**
  578. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  579. */
  580. /**
  581. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  582. */
  583. textVerticalAlignment: number;
  584. /**
  585. * Gets or sets line spacing value
  586. */
  587. /**
  588. * Gets or sets line spacing value
  589. */
  590. lineSpacing: string | number;
  591. /**
  592. * Gets or sets outlineWidth of the text to display
  593. */
  594. /**
  595. * Gets or sets outlineWidth of the text to display
  596. */
  597. outlineWidth: number;
  598. /**
  599. * Gets or sets outlineColor of the text to display
  600. */
  601. /**
  602. * Gets or sets outlineColor of the text to display
  603. */
  604. outlineColor: string;
  605. /**
  606. * Creates a new TextBlock object
  607. * @param name defines the name of the control
  608. * @param text defines the text to display (emptry string by default)
  609. */
  610. constructor(
  611. /**
  612. * Defines the name of the control
  613. */
  614. name?: string | undefined, text?: string);
  615. protected _getTypeName(): string;
  616. private _drawText(text, textWidth, y, context);
  617. /** @ignore */
  618. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  619. protected _applyStates(context: CanvasRenderingContext2D): void;
  620. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  621. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  622. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  623. protected _renderLines(context: CanvasRenderingContext2D): void;
  624. dispose(): void;
  625. }
  626. }
  627. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  628. declare module BABYLON.GUI {
  629. class Image extends Control {
  630. name: string | undefined;
  631. private _domImage;
  632. private _imageWidth;
  633. private _imageHeight;
  634. private _loaded;
  635. private _stretch;
  636. private _source;
  637. private _autoScale;
  638. private _sourceLeft;
  639. private _sourceTop;
  640. private _sourceWidth;
  641. private _sourceHeight;
  642. private _cellWidth;
  643. private _cellHeight;
  644. private _cellId;
  645. sourceLeft: number;
  646. sourceTop: number;
  647. sourceWidth: number;
  648. sourceHeight: number;
  649. autoScale: boolean;
  650. stretch: number;
  651. domImage: HTMLImageElement;
  652. private _onImageLoaded();
  653. source: Nullable<string>;
  654. cellWidth: number;
  655. cellHeight: number;
  656. cellId: number;
  657. constructor(name?: string | undefined, url?: Nullable<string>);
  658. protected _getTypeName(): string;
  659. synchronizeSizeWithContent(): void;
  660. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  661. private static _STRETCH_NONE;
  662. private static _STRETCH_FILL;
  663. private static _STRETCH_UNIFORM;
  664. private static _STRETCH_EXTEND;
  665. static readonly STRETCH_NONE: number;
  666. static readonly STRETCH_FILL: number;
  667. static readonly STRETCH_UNIFORM: number;
  668. static readonly STRETCH_EXTEND: number;
  669. }
  670. }
  671. declare module BABYLON.GUI {
  672. class Button extends Rectangle {
  673. name: string | undefined;
  674. pointerEnterAnimation: () => void;
  675. pointerOutAnimation: () => void;
  676. pointerDownAnimation: () => void;
  677. pointerUpAnimation: () => void;
  678. constructor(name?: string | undefined);
  679. protected _getTypeName(): string;
  680. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  681. _onPointerEnter(target: Control): boolean;
  682. _onPointerOut(target: Control): void;
  683. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  684. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  685. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  686. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  687. static CreateSimpleButton(name: string, text: string): Button;
  688. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  689. }
  690. }
  691. declare module BABYLON.GUI {
  692. class ColorPicker extends Control {
  693. name: string | undefined;
  694. private _colorWheelCanvas;
  695. private _value;
  696. private _tmpColor;
  697. private _pointerStartedOnSquare;
  698. private _pointerStartedOnWheel;
  699. private _squareLeft;
  700. private _squareTop;
  701. private _squareSize;
  702. private _h;
  703. private _s;
  704. private _v;
  705. onValueChangedObservable: Observable<Color3>;
  706. value: Color3;
  707. width: string | number;
  708. height: string | number;
  709. size: string | number;
  710. constructor(name?: string | undefined);
  711. protected _getTypeName(): string;
  712. private _updateSquareProps();
  713. private _drawGradientSquare(hueValue, left, top, width, height, context);
  714. private _drawCircle(centerX, centerY, radius, context);
  715. private _createColorWheelCanvas(radius, thickness);
  716. private _RGBtoHSV(color, result);
  717. private _HSVtoRGB(hue, saturation, value, result);
  718. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  719. private _pointerIsDown;
  720. private _updateValueFromPointer(x, y);
  721. private _isPointOnSquare(coordinates);
  722. private _isPointOnWheel(coordinates);
  723. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  724. _onPointerMove(target: Control, coordinates: Vector2): void;
  725. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  726. }
  727. }
  728. declare module BABYLON.GUI {
  729. class InputText extends Control implements IFocusableControl {
  730. name: string | undefined;
  731. private _text;
  732. private _placeholderText;
  733. private _background;
  734. private _focusedBackground;
  735. private _placeholderColor;
  736. private _thickness;
  737. private _margin;
  738. private _autoStretchWidth;
  739. private _maxWidth;
  740. private _isFocused;
  741. private _blinkTimeout;
  742. private _blinkIsEven;
  743. private _cursorOffset;
  744. private _scrollLeft;
  745. private _textWidth;
  746. private _clickedCoordinate;
  747. promptMessage: string;
  748. onTextChangedObservable: Observable<InputText>;
  749. onFocusObservable: Observable<InputText>;
  750. onBlurObservable: Observable<InputText>;
  751. maxWidth: string | number;
  752. readonly maxWidthInPixels: number;
  753. margin: string;
  754. readonly marginInPixels: number;
  755. autoStretchWidth: boolean;
  756. thickness: number;
  757. focusedBackground: string;
  758. background: string;
  759. placeholderColor: string;
  760. placeholderText: string;
  761. text: string;
  762. width: string | number;
  763. constructor(name?: string | undefined, text?: string);
  764. onBlur(): void;
  765. onFocus(): void;
  766. protected _getTypeName(): string;
  767. processKey(keyCode: number, key?: string): void;
  768. processKeyboard(evt: KeyboardEvent): void;
  769. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  770. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  771. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  772. dispose(): void;
  773. }
  774. }
  775. declare module BABYLON.GUI {
  776. class KeyPropertySet {
  777. width?: string;
  778. height?: string;
  779. paddingLeft?: string;
  780. paddingRight?: string;
  781. paddingTop?: string;
  782. paddingBottom?: string;
  783. color?: string;
  784. background?: string;
  785. }
  786. class VirtualKeyboard extends StackPanel {
  787. onKeyPressObservable: Observable<string>;
  788. defaultButtonWidth: string;
  789. defaultButtonHeight: string;
  790. defaultButtonPaddingLeft: string;
  791. defaultButtonPaddingRight: string;
  792. defaultButtonPaddingTop: string;
  793. defaultButtonPaddingBottom: string;
  794. defaultButtonColor: string;
  795. defaultButtonBackground: string;
  796. shiftButtonColor: string;
  797. selectedShiftThickness: number;
  798. shiftState: number;
  799. protected _getTypeName(): string;
  800. private _createKey(key, propertySet);
  801. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  802. applyShiftState(shiftState: number): void;
  803. private _connectedInputText;
  804. private _onFocusObserver;
  805. private _onBlurObserver;
  806. private _onKeyPressObserver;
  807. readonly connectedInputText: Nullable<InputText>;
  808. connect(input: InputText): void;
  809. disconnect(): void;
  810. static CreateDefaultLayout(): VirtualKeyboard;
  811. }
  812. }