babylon.gui.module.d.ts 33 KB

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