babylon.gui.module.d.ts 36 KB

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