babylon.gui.d.ts 30 KB

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