babylon.gui.module.d.ts 30 KB

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