babylon.gui.module.d.ts 33 KB

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