babylon.gui.d.ts 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  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. /**
  421. * Move one end of the line given 3D cartesian coordinates.
  422. * @param position Targeted world position
  423. * @param scene Scene
  424. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  425. */
  426. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  427. /**
  428. * Move one end of the line to a position in screen absolute space.
  429. * @param projectedPosition Position in screen absolute space (X, Y)
  430. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  431. */
  432. _moveToProjectedPosition(projectedPosition: Vector3, end?: boolean): void;
  433. }
  434. }
  435. declare module BABYLON.GUI {
  436. class Slider extends Control {
  437. name: string | undefined;
  438. private _thumbWidth;
  439. private _minimum;
  440. private _maximum;
  441. private _value;
  442. private _background;
  443. private _borderColor;
  444. private _barOffset;
  445. private _isThumbCircle;
  446. private _isThumbClamped;
  447. onValueChangedObservable: Observable<number>;
  448. borderColor: string;
  449. background: string;
  450. barOffset: string | number;
  451. readonly barOffsetInPixels: number;
  452. thumbWidth: string | number;
  453. readonly thumbWidthInPixels: number;
  454. minimum: number;
  455. maximum: number;
  456. value: number;
  457. isThumbCircle: boolean;
  458. isThumbClamped: boolean;
  459. constructor(name?: string | undefined);
  460. protected _getTypeName(): string;
  461. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  462. private _pointerIsDown;
  463. private _updateValueFromPointer(x, y);
  464. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  465. _onPointerMove(target: Control, coordinates: Vector2): void;
  466. _onPointerUp(target: Control, coordinates: Vector2, buttonIndex: number): void;
  467. }
  468. }
  469. declare module BABYLON.GUI {
  470. class Checkbox extends Control {
  471. name: string | undefined;
  472. private _isChecked;
  473. private _background;
  474. private _checkSizeRatio;
  475. private _thickness;
  476. thickness: number;
  477. onIsCheckedChangedObservable: Observable<boolean>;
  478. checkSizeRatio: number;
  479. background: string;
  480. isChecked: boolean;
  481. constructor(name?: string | undefined);
  482. protected _getTypeName(): string;
  483. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  484. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  485. }
  486. }
  487. declare module BABYLON.GUI {
  488. class RadioButton extends Control {
  489. name: string | undefined;
  490. private _isChecked;
  491. private _background;
  492. private _checkSizeRatio;
  493. private _thickness;
  494. thickness: number;
  495. group: string;
  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, buttonIndex: number): boolean;
  504. }
  505. }
  506. declare module BABYLON.GUI {
  507. class TextBlock extends Control {
  508. /**
  509. * Defines the name of the control
  510. */
  511. name: string | undefined;
  512. private _text;
  513. private _textWrapping;
  514. private _textHorizontalAlignment;
  515. private _textVerticalAlignment;
  516. private _lines;
  517. private _resizeToFit;
  518. private _lineSpacing;
  519. /**
  520. * An event triggered after the text is changed
  521. * @type {BABYLON.Observable}
  522. */
  523. onTextChangedObservable: Observable<TextBlock>;
  524. /**
  525. * An event triggered after the text was broken up into lines
  526. * @type {BABYLON.Observable}
  527. */
  528. onLinesReadyObservable: Observable<TextBlock>;
  529. /**
  530. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  531. */
  532. readonly lines: any[];
  533. /**
  534. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  535. */
  536. /**
  537. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  538. */
  539. resizeToFit: boolean;
  540. /**
  541. * Gets or sets a boolean indicating if text must be wrapped
  542. */
  543. /**
  544. * Gets or sets a boolean indicating if text must be wrapped
  545. */
  546. textWrapping: boolean;
  547. /**
  548. * Gets or sets text to display
  549. */
  550. /**
  551. * Gets or sets text to display
  552. */
  553. text: string;
  554. /**
  555. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  556. */
  557. /**
  558. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  559. */
  560. textHorizontalAlignment: number;
  561. /**
  562. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  563. */
  564. /**
  565. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  566. */
  567. textVerticalAlignment: number;
  568. /**
  569. * Gets or sets line spacing value
  570. */
  571. /**
  572. * Gets or sets line spacing value
  573. */
  574. lineSpacing: string | number;
  575. /**
  576. * Creates a new TextBlock object
  577. * @param name defines the name of the control
  578. * @param text defines the text to display (emptry string by default)
  579. */
  580. constructor(
  581. /**
  582. * Defines the name of the control
  583. */
  584. name?: string | undefined, text?: string);
  585. protected _getTypeName(): string;
  586. private _drawText(text, textWidth, y, context);
  587. /** @ignore */
  588. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  589. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  590. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  591. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  592. protected _renderLines(context: CanvasRenderingContext2D): void;
  593. dispose(): void;
  594. }
  595. }
  596. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  597. declare module BABYLON.GUI {
  598. class Image extends Control {
  599. name: string | undefined;
  600. private _domImage;
  601. private _imageWidth;
  602. private _imageHeight;
  603. private _loaded;
  604. private _stretch;
  605. private _source;
  606. private _autoScale;
  607. private _sourceLeft;
  608. private _sourceTop;
  609. private _sourceWidth;
  610. private _sourceHeight;
  611. private _cellWidth;
  612. private _cellHeight;
  613. private _cellId;
  614. sourceLeft: number;
  615. sourceTop: number;
  616. sourceWidth: number;
  617. sourceHeight: number;
  618. autoScale: boolean;
  619. stretch: number;
  620. domImage: HTMLImageElement;
  621. private _onImageLoaded();
  622. source: Nullable<string>;
  623. cellWidth: number;
  624. cellHeight: number;
  625. cellId: number;
  626. constructor(name?: string | undefined, url?: Nullable<string>);
  627. protected _getTypeName(): string;
  628. synchronizeSizeWithContent(): void;
  629. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  630. private static _STRETCH_NONE;
  631. private static _STRETCH_FILL;
  632. private static _STRETCH_UNIFORM;
  633. private static _STRETCH_EXTEND;
  634. static readonly STRETCH_NONE: number;
  635. static readonly STRETCH_FILL: number;
  636. static readonly STRETCH_UNIFORM: number;
  637. static readonly STRETCH_EXTEND: number;
  638. }
  639. }
  640. declare module BABYLON.GUI {
  641. class Button extends Rectangle {
  642. name: string | undefined;
  643. pointerEnterAnimation: () => void;
  644. pointerOutAnimation: () => void;
  645. pointerDownAnimation: () => void;
  646. pointerUpAnimation: () => void;
  647. constructor(name?: string | undefined);
  648. protected _getTypeName(): string;
  649. _processPicking(x: number, y: number, type: number, buttonIndex: number): boolean;
  650. _onPointerEnter(target: Control): boolean;
  651. _onPointerOut(target: Control): void;
  652. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  653. _onPointerUp(target: Control, coordinates: Vector2, buttonIndex: number): void;
  654. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  655. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  656. static CreateSimpleButton(name: string, text: string): Button;
  657. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  658. }
  659. }
  660. declare module BABYLON.GUI {
  661. class ColorPicker extends Control {
  662. name: string | undefined;
  663. private _colorWheelCanvas;
  664. private _value;
  665. private _tmpColor;
  666. private _pointerStartedOnSquare;
  667. private _pointerStartedOnWheel;
  668. private _squareLeft;
  669. private _squareTop;
  670. private _squareSize;
  671. private _h;
  672. private _s;
  673. private _v;
  674. onValueChangedObservable: Observable<Color3>;
  675. value: Color3;
  676. width: string | number;
  677. height: string | number;
  678. size: string | number;
  679. constructor(name?: string | undefined);
  680. protected _getTypeName(): string;
  681. private _updateSquareProps();
  682. private _drawGradientSquare(hueValue, left, top, width, height, context);
  683. private _drawCircle(centerX, centerY, radius, context);
  684. private _createColorWheelCanvas(radius, thickness);
  685. private _RGBtoHSV(color, result);
  686. private _HSVtoRGB(hue, saturation, value, result);
  687. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  688. private _pointerIsDown;
  689. private _updateValueFromPointer(x, y);
  690. private _isPointOnSquare(coordinates);
  691. private _isPointOnWheel(coordinates);
  692. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  693. _onPointerMove(target: Control, coordinates: Vector2): void;
  694. _onPointerUp(target: Control, coordinates: Vector2, buttonIndex: number): void;
  695. }
  696. }
  697. declare module BABYLON.GUI {
  698. class InputText extends Control implements IFocusableControl {
  699. name: string | undefined;
  700. private _text;
  701. private _placeholderText;
  702. private _background;
  703. private _focusedBackground;
  704. private _placeholderColor;
  705. private _thickness;
  706. private _margin;
  707. private _autoStretchWidth;
  708. private _maxWidth;
  709. private _isFocused;
  710. private _blinkTimeout;
  711. private _blinkIsEven;
  712. private _cursorOffset;
  713. private _scrollLeft;
  714. private _textWidth;
  715. private _clickedCoordinate;
  716. promptMessage: string;
  717. onTextChangedObservable: Observable<InputText>;
  718. onFocusObservable: Observable<InputText>;
  719. onBlurObservable: Observable<InputText>;
  720. maxWidth: string | number;
  721. readonly maxWidthInPixels: number;
  722. margin: string;
  723. readonly marginInPixels: number;
  724. autoStretchWidth: boolean;
  725. thickness: number;
  726. focusedBackground: string;
  727. background: string;
  728. placeholderColor: string;
  729. placeholderText: string;
  730. text: string;
  731. width: string | number;
  732. constructor(name?: string | undefined, text?: string);
  733. onBlur(): void;
  734. onFocus(): void;
  735. protected _getTypeName(): string;
  736. processKey(keyCode: number, key?: string): void;
  737. processKeyboard(evt: KeyboardEvent): void;
  738. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  739. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  740. _onPointerUp(target: Control, coordinates: Vector2, buttonIndex: number): void;
  741. dispose(): void;
  742. }
  743. }
  744. declare module BABYLON.GUI {
  745. class KeyPropertySet {
  746. width?: string;
  747. height?: string;
  748. paddingLeft?: string;
  749. paddingRight?: string;
  750. paddingTop?: string;
  751. paddingBottom?: string;
  752. color?: string;
  753. background?: string;
  754. }
  755. class VirtualKeyboard extends StackPanel {
  756. onKeyPressObservable: Observable<string>;
  757. defaultButtonWidth: string;
  758. defaultButtonHeight: string;
  759. defaultButtonPaddingLeft: string;
  760. defaultButtonPaddingRight: string;
  761. defaultButtonPaddingTop: string;
  762. defaultButtonPaddingBottom: string;
  763. defaultButtonColor: string;
  764. defaultButtonBackground: string;
  765. shiftButtonColor: string;
  766. selectedShiftThickness: number;
  767. shiftState: number;
  768. protected _getTypeName(): string;
  769. private _createKey(key, propertySet);
  770. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  771. applyShiftState(shiftState: number): void;
  772. private _connectedInputText;
  773. private _onFocusObserver;
  774. private _onBlurObserver;
  775. private _onKeyPressObserver;
  776. readonly connectedInputText: Nullable<InputText>;
  777. connect(input: InputText): void;
  778. disconnect(): void;
  779. static CreateDefaultLayout(): VirtualKeyboard;
  780. }
  781. }