babylon.gui.module.d.ts 32 KB

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