babylon.gui.module.d.ts 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  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. _tempParentMeasure: Measure;
  162. protected _cachedParentMeasure: Measure;
  163. private _paddingLeft;
  164. private _paddingRight;
  165. private _paddingTop;
  166. private _paddingBottom;
  167. _left: ValueAndUnit;
  168. _top: ValueAndUnit;
  169. private _scaleX;
  170. private _scaleY;
  171. private _rotation;
  172. private _transformCenterX;
  173. private _transformCenterY;
  174. private _transformMatrix;
  175. protected _invertTransformMatrix: Matrix2D;
  176. protected _transformedPosition: Vector2;
  177. private _isMatrixDirty;
  178. private _cachedOffsetX;
  179. private _cachedOffsetY;
  180. private _isVisible;
  181. _linkedMesh: Nullable<AbstractMesh>;
  182. private _fontSet;
  183. private _dummyVector2;
  184. private _downCount;
  185. private _enterCount;
  186. private _doNotRender;
  187. isHitTestVisible: boolean;
  188. isPointerBlocker: boolean;
  189. isFocusInvisible: boolean;
  190. shadowOffsetX: number;
  191. shadowOffsetY: number;
  192. shadowBlur: number;
  193. shadowColor: string;
  194. protected _linkOffsetX: ValueAndUnit;
  195. protected _linkOffsetY: ValueAndUnit;
  196. readonly typeName: string;
  197. /**
  198. * An event triggered when the pointer move over the control.
  199. * @type {BABYLON.Observable}
  200. */
  201. onPointerMoveObservable: Observable<Vector2>;
  202. /**
  203. * An event triggered when the pointer move out of the control.
  204. * @type {BABYLON.Observable}
  205. */
  206. onPointerOutObservable: Observable<Control>;
  207. /**
  208. * An event triggered when the pointer taps the control
  209. * @type {BABYLON.Observable}
  210. */
  211. onPointerDownObservable: Observable<Vector2WithInfo>;
  212. /**
  213. * An event triggered when pointer up
  214. * @type {BABYLON.Observable}
  215. */
  216. onPointerUpObservable: Observable<Vector2WithInfo>;
  217. /**
  218. * An event triggered when pointer enters the control
  219. * @type {BABYLON.Observable}
  220. */
  221. onPointerEnterObservable: Observable<Control>;
  222. /**
  223. * An event triggered when the control is marked as dirty
  224. * @type {BABYLON.Observable}
  225. */
  226. onDirtyObservable: Observable<Control>;
  227. /**
  228. * An event triggered after the control is drawn
  229. * @type {BABYLON.Observable}
  230. */
  231. onAfterDrawObservable: Observable<Control>;
  232. alpha: number;
  233. scaleX: number;
  234. scaleY: number;
  235. rotation: number;
  236. transformCenterY: number;
  237. transformCenterX: number;
  238. horizontalAlignment: number;
  239. verticalAlignment: number;
  240. width: string | number;
  241. readonly widthInPixels: number;
  242. height: string | number;
  243. readonly heightInPixels: number;
  244. fontFamily: string;
  245. fontStyle: string;
  246. /** @ignore */
  247. readonly _isFontSizeInPercentage: boolean;
  248. readonly fontSizeInPixels: number;
  249. fontSize: string | number;
  250. color: string;
  251. zIndex: number;
  252. notRenderable: boolean;
  253. isVisible: boolean;
  254. readonly isDirty: boolean;
  255. paddingLeft: string | number;
  256. readonly paddingLeftInPixels: number;
  257. paddingRight: string | number;
  258. readonly paddingRightInPixels: number;
  259. paddingTop: string | number;
  260. readonly paddingTopInPixels: number;
  261. paddingBottom: string | number;
  262. readonly paddingBottomInPixels: number;
  263. left: string | number;
  264. readonly leftInPixels: number;
  265. top: string | number;
  266. readonly topInPixels: number;
  267. linkOffsetX: string | number;
  268. readonly linkOffsetXInPixels: number;
  269. linkOffsetY: string | number;
  270. readonly linkOffsetYInPixels: number;
  271. readonly centerX: number;
  272. readonly centerY: number;
  273. constructor(name?: string | undefined);
  274. protected _getTypeName(): string;
  275. /** @ignore */
  276. _resetFontCache(): void;
  277. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  278. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  279. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  280. moveToVector3(position: Vector3, scene: Scene): void;
  281. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  282. _moveToProjectedPosition(projectedPosition: Vector3): void;
  283. _markMatrixAsDirty(): void;
  284. _markAsDirty(): void;
  285. _markAllAsDirty(): void;
  286. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  287. protected _transform(context: CanvasRenderingContext2D): void;
  288. protected _applyStates(context: CanvasRenderingContext2D): void;
  289. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  290. protected _clip(context: CanvasRenderingContext2D): void;
  291. _measure(): void;
  292. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  293. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  294. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  295. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  296. contains(x: number, y: number): boolean;
  297. _processPicking(x: number, y: number, type: number, buttonIndex: number): boolean;
  298. _onPointerMove(target: Control, coordinates: Vector2): void;
  299. _onPointerEnter(target: Control): boolean;
  300. _onPointerOut(target: Control): void;
  301. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  302. _onPointerUp(target: Control, coordinates: Vector2, buttonIndex: number): void;
  303. forcePointerUp(): void;
  304. _processObservables(type: number, x: number, y: number, buttonIndex: number): boolean;
  305. private _prepareFont();
  306. dispose(): void;
  307. private static _HORIZONTAL_ALIGNMENT_LEFT;
  308. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  309. private static _HORIZONTAL_ALIGNMENT_CENTER;
  310. private static _VERTICAL_ALIGNMENT_TOP;
  311. private static _VERTICAL_ALIGNMENT_BOTTOM;
  312. private static _VERTICAL_ALIGNMENT_CENTER;
  313. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  314. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  315. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  316. static readonly VERTICAL_ALIGNMENT_TOP: number;
  317. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  318. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  319. private static _FontHeightSizes;
  320. static _GetFontOffset(font: string): {
  321. ascent: number;
  322. height: number;
  323. descent: number;
  324. };
  325. static AddHeader(control: Control, text: string, size: string | number, options: {
  326. isHorizontal: boolean;
  327. controlFirst: boolean;
  328. }): StackPanel;
  329. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  330. }
  331. }
  332. declare module BABYLON.GUI {
  333. class Container extends Control {
  334. name: string | undefined;
  335. protected _children: Control[];
  336. protected _measureForChildren: Measure;
  337. protected _background: string;
  338. background: string;
  339. readonly children: Control[];
  340. constructor(name?: string | undefined);
  341. protected _getTypeName(): string;
  342. getChildByName(name: string): Nullable<Control>;
  343. getChildByType(name: string, type: string): Nullable<Control>;
  344. containsControl(control: Control): boolean;
  345. addControl(control: Control): Container;
  346. removeControl(control: Control): Container;
  347. _reOrderControl(control: Control): void;
  348. _markMatrixAsDirty(): void;
  349. _markAllAsDirty(): void;
  350. protected _localDraw(context: CanvasRenderingContext2D): void;
  351. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  352. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  353. _processPicking(x: number, y: number, type: number, buttonIndex: number): boolean;
  354. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  355. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  356. dispose(): void;
  357. }
  358. }
  359. declare module BABYLON.GUI {
  360. class StackPanel extends Container {
  361. name: string | undefined;
  362. private _isVertical;
  363. private _manualWidth;
  364. private _manualHeight;
  365. private _doNotTrackManualChanges;
  366. private _tempMeasureStore;
  367. isVertical: boolean;
  368. width: string | number;
  369. height: string | number;
  370. constructor(name?: string | undefined);
  371. protected _getTypeName(): string;
  372. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  373. }
  374. }
  375. declare module BABYLON.GUI {
  376. class Rectangle extends Container {
  377. name: string | undefined;
  378. private _thickness;
  379. private _cornerRadius;
  380. thickness: number;
  381. cornerRadius: number;
  382. constructor(name?: string | undefined);
  383. protected _getTypeName(): string;
  384. protected _localDraw(context: CanvasRenderingContext2D): void;
  385. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  386. private _drawRoundedRect(context, offset?);
  387. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  388. }
  389. }
  390. declare module BABYLON.GUI {
  391. class Ellipse extends Container {
  392. name: string | undefined;
  393. private _thickness;
  394. thickness: number;
  395. constructor(name?: string | undefined);
  396. protected _getTypeName(): string;
  397. protected _localDraw(context: CanvasRenderingContext2D): void;
  398. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  399. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  400. }
  401. }
  402. declare module BABYLON.GUI {
  403. class Line extends Control {
  404. name: string | undefined;
  405. private _lineWidth;
  406. private _x1;
  407. private _y1;
  408. private _x2;
  409. private _y2;
  410. private _dash;
  411. private _connectedControl;
  412. private _connectedControlDirtyObserver;
  413. dash: Array<number>;
  414. connectedControl: Control;
  415. x1: string | number;
  416. y1: string | number;
  417. x2: string | number;
  418. y2: string | number;
  419. lineWidth: number;
  420. horizontalAlignment: number;
  421. verticalAlignment: number;
  422. private readonly _effectiveX2;
  423. private readonly _effectiveY2;
  424. constructor(name?: string | undefined);
  425. protected _getTypeName(): string;
  426. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  427. _measure(): void;
  428. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  429. /**
  430. * Move one end of the line given 3D cartesian coordinates.
  431. * @param position Targeted world position
  432. * @param scene Scene
  433. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  434. */
  435. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  436. /**
  437. * Move one end of the line to a position in screen absolute space.
  438. * @param projectedPosition Position in screen absolute space (X, Y)
  439. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  440. */
  441. _moveToProjectedPosition(projectedPosition: Vector3, end?: boolean): void;
  442. }
  443. }
  444. declare module BABYLON.GUI {
  445. class Slider extends Control {
  446. name: string | undefined;
  447. private _thumbWidth;
  448. private _minimum;
  449. private _maximum;
  450. private _value;
  451. private _background;
  452. private _borderColor;
  453. private _barOffset;
  454. private _isThumbCircle;
  455. private _isThumbClamped;
  456. onValueChangedObservable: Observable<number>;
  457. borderColor: string;
  458. background: string;
  459. barOffset: string | number;
  460. readonly barOffsetInPixels: number;
  461. thumbWidth: string | number;
  462. readonly thumbWidthInPixels: number;
  463. minimum: number;
  464. maximum: number;
  465. value: number;
  466. isThumbCircle: boolean;
  467. isThumbClamped: boolean;
  468. constructor(name?: string | undefined);
  469. protected _getTypeName(): string;
  470. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  471. private _pointerIsDown;
  472. private _updateValueFromPointer(x, y);
  473. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  474. _onPointerMove(target: Control, coordinates: Vector2): void;
  475. _onPointerUp(target: Control, coordinates: Vector2, buttonIndex: number): void;
  476. }
  477. }
  478. declare module BABYLON.GUI {
  479. class Checkbox extends Control {
  480. name: string | undefined;
  481. private _isChecked;
  482. private _background;
  483. private _checkSizeRatio;
  484. private _thickness;
  485. thickness: number;
  486. onIsCheckedChangedObservable: Observable<boolean>;
  487. checkSizeRatio: number;
  488. background: string;
  489. isChecked: boolean;
  490. constructor(name?: string | undefined);
  491. protected _getTypeName(): string;
  492. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  493. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  494. }
  495. }
  496. declare module BABYLON.GUI {
  497. class RadioButton extends Control {
  498. name: string | undefined;
  499. private _isChecked;
  500. private _background;
  501. private _checkSizeRatio;
  502. private _thickness;
  503. thickness: number;
  504. group: string;
  505. onIsCheckedChangedObservable: Observable<boolean>;
  506. checkSizeRatio: number;
  507. background: string;
  508. isChecked: boolean;
  509. constructor(name?: string | undefined);
  510. protected _getTypeName(): string;
  511. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  512. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  513. }
  514. }
  515. declare module BABYLON.GUI {
  516. class TextBlock extends Control {
  517. /**
  518. * Defines the name of the control
  519. */
  520. name: string | undefined;
  521. private _text;
  522. private _textWrapping;
  523. private _textHorizontalAlignment;
  524. private _textVerticalAlignment;
  525. private _lines;
  526. private _resizeToFit;
  527. private _lineSpacing;
  528. private _outlineWidth;
  529. private _outlineColor;
  530. /**
  531. * An event triggered after the text is changed
  532. * @type {BABYLON.Observable}
  533. */
  534. onTextChangedObservable: Observable<TextBlock>;
  535. /**
  536. * An event triggered after the text was broken up into lines
  537. * @type {BABYLON.Observable}
  538. */
  539. onLinesReadyObservable: Observable<TextBlock>;
  540. /**
  541. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  542. */
  543. readonly lines: any[];
  544. /**
  545. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  546. */
  547. /**
  548. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  549. */
  550. resizeToFit: boolean;
  551. /**
  552. * Gets or sets a boolean indicating if text must be wrapped
  553. */
  554. /**
  555. * Gets or sets a boolean indicating if text must be wrapped
  556. */
  557. textWrapping: boolean;
  558. /**
  559. * Gets or sets text to display
  560. */
  561. /**
  562. * Gets or sets text to display
  563. */
  564. text: string;
  565. /**
  566. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  567. */
  568. /**
  569. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  570. */
  571. textHorizontalAlignment: number;
  572. /**
  573. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  574. */
  575. /**
  576. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  577. */
  578. textVerticalAlignment: number;
  579. /**
  580. * Gets or sets line spacing value
  581. */
  582. /**
  583. * Gets or sets line spacing value
  584. */
  585. lineSpacing: string | number;
  586. /**
  587. * Gets or sets outlineWidth of the text to display
  588. */
  589. /**
  590. * Gets or sets outlineWidth of the text to display
  591. */
  592. outlineWidth: number;
  593. /**
  594. * Gets or sets outlineColor of the text to display
  595. */
  596. /**
  597. * Gets or sets outlineColor of the text to display
  598. */
  599. outlineColor: string;
  600. /**
  601. * Creates a new TextBlock object
  602. * @param name defines the name of the control
  603. * @param text defines the text to display (emptry string by default)
  604. */
  605. constructor(
  606. /**
  607. * Defines the name of the control
  608. */
  609. name?: string | undefined, text?: string);
  610. protected _getTypeName(): string;
  611. private _drawText(text, textWidth, y, context);
  612. /** @ignore */
  613. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  614. protected _applyStates(context: CanvasRenderingContext2D): void;
  615. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  616. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  617. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  618. protected _renderLines(context: CanvasRenderingContext2D): void;
  619. dispose(): void;
  620. }
  621. }
  622. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  623. declare module BABYLON.GUI {
  624. class Image extends Control {
  625. name: string | undefined;
  626. private _domImage;
  627. private _imageWidth;
  628. private _imageHeight;
  629. private _loaded;
  630. private _stretch;
  631. private _source;
  632. private _autoScale;
  633. private _sourceLeft;
  634. private _sourceTop;
  635. private _sourceWidth;
  636. private _sourceHeight;
  637. private _cellWidth;
  638. private _cellHeight;
  639. private _cellId;
  640. sourceLeft: number;
  641. sourceTop: number;
  642. sourceWidth: number;
  643. sourceHeight: number;
  644. autoScale: boolean;
  645. stretch: number;
  646. domImage: HTMLImageElement;
  647. private _onImageLoaded();
  648. source: Nullable<string>;
  649. cellWidth: number;
  650. cellHeight: number;
  651. cellId: number;
  652. constructor(name?: string | undefined, url?: Nullable<string>);
  653. protected _getTypeName(): string;
  654. synchronizeSizeWithContent(): void;
  655. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  656. private static _STRETCH_NONE;
  657. private static _STRETCH_FILL;
  658. private static _STRETCH_UNIFORM;
  659. private static _STRETCH_EXTEND;
  660. static readonly STRETCH_NONE: number;
  661. static readonly STRETCH_FILL: number;
  662. static readonly STRETCH_UNIFORM: number;
  663. static readonly STRETCH_EXTEND: number;
  664. }
  665. }
  666. declare module BABYLON.GUI {
  667. class Button extends Rectangle {
  668. name: string | undefined;
  669. pointerEnterAnimation: () => void;
  670. pointerOutAnimation: () => void;
  671. pointerDownAnimation: () => void;
  672. pointerUpAnimation: () => void;
  673. constructor(name?: string | undefined);
  674. protected _getTypeName(): string;
  675. _processPicking(x: number, y: number, type: number, buttonIndex: number): boolean;
  676. _onPointerEnter(target: Control): boolean;
  677. _onPointerOut(target: Control): void;
  678. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  679. _onPointerUp(target: Control, coordinates: Vector2, buttonIndex: number): void;
  680. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  681. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  682. static CreateSimpleButton(name: string, text: string): Button;
  683. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  684. }
  685. }
  686. declare module BABYLON.GUI {
  687. class ColorPicker extends Control {
  688. name: string | undefined;
  689. private _colorWheelCanvas;
  690. private _value;
  691. private _tmpColor;
  692. private _pointerStartedOnSquare;
  693. private _pointerStartedOnWheel;
  694. private _squareLeft;
  695. private _squareTop;
  696. private _squareSize;
  697. private _h;
  698. private _s;
  699. private _v;
  700. onValueChangedObservable: Observable<Color3>;
  701. value: Color3;
  702. width: string | number;
  703. height: string | number;
  704. size: string | number;
  705. constructor(name?: string | undefined);
  706. protected _getTypeName(): string;
  707. private _updateSquareProps();
  708. private _drawGradientSquare(hueValue, left, top, width, height, context);
  709. private _drawCircle(centerX, centerY, radius, context);
  710. private _createColorWheelCanvas(radius, thickness);
  711. private _RGBtoHSV(color, result);
  712. private _HSVtoRGB(hue, saturation, value, result);
  713. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  714. private _pointerIsDown;
  715. private _updateValueFromPointer(x, y);
  716. private _isPointOnSquare(coordinates);
  717. private _isPointOnWheel(coordinates);
  718. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  719. _onPointerMove(target: Control, coordinates: Vector2): void;
  720. _onPointerUp(target: Control, coordinates: Vector2, buttonIndex: number): void;
  721. }
  722. }
  723. declare module BABYLON.GUI {
  724. class InputText extends Control implements IFocusableControl {
  725. name: string | undefined;
  726. private _text;
  727. private _placeholderText;
  728. private _background;
  729. private _focusedBackground;
  730. private _placeholderColor;
  731. private _thickness;
  732. private _margin;
  733. private _autoStretchWidth;
  734. private _maxWidth;
  735. private _isFocused;
  736. private _blinkTimeout;
  737. private _blinkIsEven;
  738. private _cursorOffset;
  739. private _scrollLeft;
  740. private _textWidth;
  741. private _clickedCoordinate;
  742. promptMessage: string;
  743. onTextChangedObservable: Observable<InputText>;
  744. onFocusObservable: Observable<InputText>;
  745. onBlurObservable: Observable<InputText>;
  746. maxWidth: string | number;
  747. readonly maxWidthInPixels: number;
  748. margin: string;
  749. readonly marginInPixels: number;
  750. autoStretchWidth: boolean;
  751. thickness: number;
  752. focusedBackground: string;
  753. background: string;
  754. placeholderColor: string;
  755. placeholderText: string;
  756. text: string;
  757. width: string | number;
  758. constructor(name?: string | undefined, text?: string);
  759. onBlur(): void;
  760. onFocus(): void;
  761. protected _getTypeName(): string;
  762. processKey(keyCode: number, key?: string): void;
  763. processKeyboard(evt: KeyboardEvent): void;
  764. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  765. _onPointerDown(target: Control, coordinates: Vector2, buttonIndex: number): boolean;
  766. _onPointerUp(target: Control, coordinates: Vector2, buttonIndex: number): void;
  767. dispose(): void;
  768. }
  769. }
  770. declare module BABYLON.GUI {
  771. class KeyPropertySet {
  772. width?: string;
  773. height?: string;
  774. paddingLeft?: string;
  775. paddingRight?: string;
  776. paddingTop?: string;
  777. paddingBottom?: string;
  778. color?: string;
  779. background?: string;
  780. }
  781. class VirtualKeyboard extends StackPanel {
  782. onKeyPressObservable: Observable<string>;
  783. defaultButtonWidth: string;
  784. defaultButtonHeight: string;
  785. defaultButtonPaddingLeft: string;
  786. defaultButtonPaddingRight: string;
  787. defaultButtonPaddingTop: string;
  788. defaultButtonPaddingBottom: string;
  789. defaultButtonColor: string;
  790. defaultButtonBackground: string;
  791. shiftButtonColor: string;
  792. selectedShiftThickness: number;
  793. shiftState: number;
  794. protected _getTypeName(): string;
  795. private _createKey(key, propertySet);
  796. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  797. applyShiftState(shiftState: number): void;
  798. private _connectedInputText;
  799. private _onFocusObserver;
  800. private _onBlurObserver;
  801. private _onKeyPressObserver;
  802. readonly connectedInputText: Nullable<InputText>;
  803. connect(input: InputText): void;
  804. disconnect(): void;
  805. static CreateDefaultLayout(): VirtualKeyboard;
  806. }
  807. }