babylon.gui.d.ts 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. declare module BABYLON.GUI {
  2. interface IFocusableControl {
  3. onFocus(): void;
  4. onBlur(): void;
  5. processKeyboard(evt: KeyboardEvent): void;
  6. }
  7. class AdvancedDynamicTexture extends DynamicTexture {
  8. private _isDirty;
  9. private _renderObserver;
  10. private _resizeObserver;
  11. private _preKeyboardObserver;
  12. private _pointerMoveObserver;
  13. private _pointerObserver;
  14. private _canvasPointerOutObserver;
  15. private _background;
  16. _rootContainer: Container;
  17. _lastPickedControl: Control;
  18. _lastControlOver: {
  19. [pointerId: number]: Control;
  20. };
  21. _lastControlDown: {
  22. [pointerId: number]: Control;
  23. };
  24. _capturingControl: {
  25. [pointerId: number]: Control;
  26. };
  27. _shouldBlockPointer: boolean;
  28. _layerToDispose: Nullable<Layer>;
  29. _linkedControls: Control[];
  30. private _isFullscreen;
  31. private _fullscreenViewport;
  32. private _idealWidth;
  33. private _idealHeight;
  34. private _useSmallestIdeal;
  35. private _renderAtIdealSize;
  36. private _focusedControl;
  37. private _blockNextFocusCheck;
  38. private _renderScale;
  39. renderScale: number;
  40. background: string;
  41. idealWidth: number;
  42. idealHeight: number;
  43. useSmallestIdeal: boolean;
  44. renderAtIdealSize: boolean;
  45. readonly layer: Nullable<Layer>;
  46. readonly rootContainer: Container;
  47. focusedControl: Nullable<IFocusableControl>;
  48. isForeground: boolean;
  49. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  50. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  51. markAsDirty(): void;
  52. addControl(control: Control): AdvancedDynamicTexture;
  53. removeControl(control: Control): AdvancedDynamicTexture;
  54. dispose(): void;
  55. private _onResize();
  56. _getGlobalViewport(scene: Scene): Viewport;
  57. private _checkUpdate(camera);
  58. private _render();
  59. private _doPicking(x, y, type, pointerId, buttonIndex);
  60. attach(): void;
  61. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  62. moveFocusToControl(control: IFocusableControl): void;
  63. private _manageFocus();
  64. private _attachToOnPointerOut(scene);
  65. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean): AdvancedDynamicTexture;
  66. /**
  67. * FullScreenUI is created in a layer. This allows it to be treated like any other layer.
  68. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  69. * When the GUI is not Created as FullscreenUI it does not respect the layerMask.
  70. * layerMask is set through advancedTexture.layer.layerMask
  71. * @param name name for the Texture
  72. * @param foreground render in foreground (default is true)
  73. * @param scene scene to be rendered in
  74. * @param sampling method for scaling to fit screen
  75. * @returns AdvancedDynamicTexture
  76. */
  77. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  78. }
  79. }
  80. declare module BABYLON.GUI {
  81. class Measure {
  82. left: number;
  83. top: number;
  84. width: number;
  85. height: number;
  86. constructor(left: number, top: number, width: number, height: number);
  87. copyFrom(other: Measure): void;
  88. isEqualsTo(other: Measure): boolean;
  89. static Empty(): Measure;
  90. }
  91. }
  92. declare module BABYLON.GUI {
  93. class Vector2WithInfo extends Vector2 {
  94. buttonIndex: number;
  95. constructor(source: Vector2, buttonIndex?: number);
  96. }
  97. class Matrix2D {
  98. m: Float32Array;
  99. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  100. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  101. determinant(): number;
  102. invertToRef(result: Matrix2D): Matrix2D;
  103. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  104. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  105. static Identity(): Matrix2D;
  106. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  107. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  108. static RotationToRef(angle: number, result: Matrix2D): void;
  109. private static _TempPreTranslationMatrix;
  110. private static _TempPostTranslationMatrix;
  111. private static _TempRotationMatrix;
  112. private static _TempScalingMatrix;
  113. private static _TempCompose0;
  114. private static _TempCompose1;
  115. private static _TempCompose2;
  116. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  117. }
  118. }
  119. declare module BABYLON.GUI {
  120. class ValueAndUnit {
  121. unit: number;
  122. negativeValueAllowed: boolean;
  123. private _value;
  124. ignoreAdaptiveScaling: boolean;
  125. constructor(value: number, unit?: number, negativeValueAllowed?: boolean);
  126. readonly isPercentage: boolean;
  127. readonly isPixel: boolean;
  128. readonly internalValue: number;
  129. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  130. getValue(host: AdvancedDynamicTexture): number;
  131. toString(host: AdvancedDynamicTexture): string;
  132. fromString(source: string | number): boolean;
  133. private static _Regex;
  134. private static _UNITMODE_PERCENTAGE;
  135. private static _UNITMODE_PIXEL;
  136. static readonly UNITMODE_PERCENTAGE: number;
  137. static readonly UNITMODE_PIXEL: number;
  138. }
  139. }
  140. declare module BABYLON.GUI {
  141. class Control {
  142. name: string | undefined;
  143. private _alpha;
  144. private _alphaSet;
  145. private _zIndex;
  146. _root: Nullable<Container>;
  147. _host: AdvancedDynamicTexture;
  148. parent: Nullable<Container>;
  149. _currentMeasure: Measure;
  150. private _fontFamily;
  151. private _fontStyle;
  152. private _fontSize;
  153. private _font;
  154. _width: ValueAndUnit;
  155. _height: ValueAndUnit;
  156. protected _fontOffset: {
  157. ascent: number;
  158. height: number;
  159. descent: number;
  160. };
  161. private _color;
  162. protected _horizontalAlignment: number;
  163. protected _verticalAlignment: number;
  164. private _isDirty;
  165. _tempParentMeasure: Measure;
  166. protected _cachedParentMeasure: Measure;
  167. private _paddingLeft;
  168. private _paddingRight;
  169. private _paddingTop;
  170. private _paddingBottom;
  171. _left: ValueAndUnit;
  172. _top: ValueAndUnit;
  173. private _scaleX;
  174. private _scaleY;
  175. private _rotation;
  176. private _transformCenterX;
  177. private _transformCenterY;
  178. private _transformMatrix;
  179. protected _invertTransformMatrix: Matrix2D;
  180. protected _transformedPosition: Vector2;
  181. private _onlyMeasureMode;
  182. private _isMatrixDirty;
  183. private _cachedOffsetX;
  184. private _cachedOffsetY;
  185. private _isVisible;
  186. _linkedMesh: Nullable<AbstractMesh>;
  187. private _fontSet;
  188. private _dummyVector2;
  189. private _downCount;
  190. private _enterCount;
  191. private _doNotRender;
  192. private _downPointerIds;
  193. isHitTestVisible: boolean;
  194. isPointerBlocker: boolean;
  195. isFocusInvisible: boolean;
  196. shadowOffsetX: number;
  197. shadowOffsetY: number;
  198. shadowBlur: number;
  199. shadowColor: string;
  200. protected _linkOffsetX: ValueAndUnit;
  201. protected _linkOffsetY: ValueAndUnit;
  202. readonly typeName: string;
  203. /**
  204. * An event triggered when the pointer move over the control.
  205. * @type {BABYLON.Observable}
  206. */
  207. onPointerMoveObservable: Observable<Vector2>;
  208. /**
  209. * An event triggered when the pointer move out of the control.
  210. * @type {BABYLON.Observable}
  211. */
  212. onPointerOutObservable: Observable<Control>;
  213. /**
  214. * An event triggered when the pointer taps the control
  215. * @type {BABYLON.Observable}
  216. */
  217. onPointerDownObservable: Observable<Vector2WithInfo>;
  218. /**
  219. * An event triggered when pointer up
  220. * @type {BABYLON.Observable}
  221. */
  222. onPointerUpObservable: Observable<Vector2WithInfo>;
  223. /**
  224. * An event triggered when a control is clicked on
  225. * @type {BABYLON.Observable}
  226. */
  227. onPointerClickObservable: Observable<Vector2WithInfo>;
  228. /**
  229. * An event triggered when pointer enters the control
  230. * @type {BABYLON.Observable}
  231. */
  232. onPointerEnterObservable: Observable<Control>;
  233. /**
  234. * An event triggered when the control is marked as dirty
  235. * @type {BABYLON.Observable}
  236. */
  237. onDirtyObservable: Observable<Control>;
  238. /**
  239. * An event triggered after the control is drawn
  240. * @type {BABYLON.Observable}
  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. * @type {BABYLON.Observable}
  548. */
  549. onTextChangedObservable: Observable<TextBlock>;
  550. /**
  551. * An event triggered after the text was broken up into lines
  552. * @type {BABYLON.Observable}
  553. */
  554. onLinesReadyObservable: Observable<TextBlock>;
  555. /**
  556. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  557. */
  558. readonly lines: any[];
  559. /**
  560. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  561. */
  562. /**
  563. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  564. */
  565. resizeToFit: boolean;
  566. /**
  567. * Gets or sets a boolean indicating if text must be wrapped
  568. */
  569. /**
  570. * Gets or sets a boolean indicating if text must be wrapped
  571. */
  572. textWrapping: boolean;
  573. /**
  574. * Gets or sets text to display
  575. */
  576. /**
  577. * Gets or sets text to display
  578. */
  579. text: string;
  580. /**
  581. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  582. */
  583. /**
  584. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  585. */
  586. textHorizontalAlignment: number;
  587. /**
  588. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  589. */
  590. /**
  591. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  592. */
  593. textVerticalAlignment: number;
  594. /**
  595. * Gets or sets line spacing value
  596. */
  597. /**
  598. * Gets or sets line spacing value
  599. */
  600. lineSpacing: string | number;
  601. /**
  602. * Gets or sets outlineWidth of the text to display
  603. */
  604. /**
  605. * Gets or sets outlineWidth of the text to display
  606. */
  607. outlineWidth: number;
  608. /**
  609. * Gets or sets outlineColor of the text to display
  610. */
  611. /**
  612. * Gets or sets outlineColor of the text to display
  613. */
  614. outlineColor: string;
  615. /**
  616. * Creates a new TextBlock object
  617. * @param name defines the name of the control
  618. * @param text defines the text to display (emptry string by default)
  619. */
  620. constructor(
  621. /**
  622. * Defines the name of the control
  623. */
  624. name?: string | undefined, text?: string);
  625. protected _getTypeName(): string;
  626. private _drawText(text, textWidth, y, context);
  627. /** @ignore */
  628. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  629. protected _applyStates(context: CanvasRenderingContext2D): void;
  630. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  631. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  632. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  633. protected _renderLines(context: CanvasRenderingContext2D): void;
  634. dispose(): void;
  635. }
  636. }
  637. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  638. declare module BABYLON.GUI {
  639. class Image extends Control {
  640. name: string | undefined;
  641. private _domImage;
  642. private _imageWidth;
  643. private _imageHeight;
  644. private _loaded;
  645. private _stretch;
  646. private _source;
  647. private _autoScale;
  648. private _sourceLeft;
  649. private _sourceTop;
  650. private _sourceWidth;
  651. private _sourceHeight;
  652. private _cellWidth;
  653. private _cellHeight;
  654. private _cellId;
  655. sourceLeft: number;
  656. sourceTop: number;
  657. sourceWidth: number;
  658. sourceHeight: number;
  659. autoScale: boolean;
  660. stretch: number;
  661. domImage: HTMLImageElement;
  662. private _onImageLoaded();
  663. source: Nullable<string>;
  664. cellWidth: number;
  665. cellHeight: number;
  666. cellId: number;
  667. constructor(name?: string | undefined, url?: Nullable<string>);
  668. protected _getTypeName(): string;
  669. synchronizeSizeWithContent(): void;
  670. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  671. private static _STRETCH_NONE;
  672. private static _STRETCH_FILL;
  673. private static _STRETCH_UNIFORM;
  674. private static _STRETCH_EXTEND;
  675. static readonly STRETCH_NONE: number;
  676. static readonly STRETCH_FILL: number;
  677. static readonly STRETCH_UNIFORM: number;
  678. static readonly STRETCH_EXTEND: number;
  679. }
  680. }
  681. declare module BABYLON.GUI {
  682. class Button extends Rectangle {
  683. name: string | undefined;
  684. pointerEnterAnimation: () => void;
  685. pointerOutAnimation: () => void;
  686. pointerDownAnimation: () => void;
  687. pointerUpAnimation: () => void;
  688. constructor(name?: string | undefined);
  689. protected _getTypeName(): string;
  690. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  691. _onPointerEnter(target: Control): boolean;
  692. _onPointerOut(target: Control): void;
  693. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  694. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  695. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  696. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  697. static CreateSimpleButton(name: string, text: string): Button;
  698. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  699. }
  700. }
  701. declare module BABYLON.GUI {
  702. class ColorPicker extends Control {
  703. name: string | undefined;
  704. private _colorWheelCanvas;
  705. private _value;
  706. private _tmpColor;
  707. private _pointerStartedOnSquare;
  708. private _pointerStartedOnWheel;
  709. private _squareLeft;
  710. private _squareTop;
  711. private _squareSize;
  712. private _h;
  713. private _s;
  714. private _v;
  715. onValueChangedObservable: Observable<Color3>;
  716. value: Color3;
  717. width: string | number;
  718. height: string | number;
  719. size: string | number;
  720. constructor(name?: string | undefined);
  721. protected _getTypeName(): string;
  722. private _updateSquareProps();
  723. private _drawGradientSquare(hueValue, left, top, width, height, context);
  724. private _drawCircle(centerX, centerY, radius, context);
  725. private _createColorWheelCanvas(radius, thickness);
  726. private _RGBtoHSV(color, result);
  727. private _HSVtoRGB(hue, saturation, value, result);
  728. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  729. private _pointerIsDown;
  730. private _updateValueFromPointer(x, y);
  731. private _isPointOnSquare(coordinates);
  732. private _isPointOnWheel(coordinates);
  733. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  734. _onPointerMove(target: Control, coordinates: Vector2): void;
  735. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  736. }
  737. }
  738. declare module BABYLON.GUI {
  739. class InputText extends Control implements IFocusableControl {
  740. name: string | undefined;
  741. private _text;
  742. private _placeholderText;
  743. private _background;
  744. private _focusedBackground;
  745. private _placeholderColor;
  746. private _thickness;
  747. private _margin;
  748. private _autoStretchWidth;
  749. private _maxWidth;
  750. private _isFocused;
  751. private _blinkTimeout;
  752. private _blinkIsEven;
  753. private _cursorOffset;
  754. private _scrollLeft;
  755. private _textWidth;
  756. private _clickedCoordinate;
  757. promptMessage: string;
  758. onTextChangedObservable: Observable<InputText>;
  759. onFocusObservable: Observable<InputText>;
  760. onBlurObservable: Observable<InputText>;
  761. maxWidth: string | number;
  762. readonly maxWidthInPixels: number;
  763. margin: string;
  764. readonly marginInPixels: number;
  765. autoStretchWidth: boolean;
  766. thickness: number;
  767. focusedBackground: string;
  768. background: string;
  769. placeholderColor: string;
  770. placeholderText: string;
  771. text: string;
  772. width: string | number;
  773. constructor(name?: string | undefined, text?: string);
  774. onBlur(): void;
  775. onFocus(): void;
  776. protected _getTypeName(): string;
  777. processKey(keyCode: number, key?: string): void;
  778. processKeyboard(evt: KeyboardEvent): void;
  779. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  780. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  781. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  782. dispose(): void;
  783. }
  784. }
  785. declare module BABYLON.GUI {
  786. class KeyPropertySet {
  787. width?: string;
  788. height?: string;
  789. paddingLeft?: string;
  790. paddingRight?: string;
  791. paddingTop?: string;
  792. paddingBottom?: string;
  793. color?: string;
  794. background?: string;
  795. }
  796. class VirtualKeyboard extends StackPanel {
  797. onKeyPressObservable: Observable<string>;
  798. defaultButtonWidth: string;
  799. defaultButtonHeight: string;
  800. defaultButtonPaddingLeft: string;
  801. defaultButtonPaddingRight: string;
  802. defaultButtonPaddingTop: string;
  803. defaultButtonPaddingBottom: string;
  804. defaultButtonColor: string;
  805. defaultButtonBackground: string;
  806. shiftButtonColor: string;
  807. selectedShiftThickness: number;
  808. shiftState: number;
  809. protected _getTypeName(): string;
  810. private _createKey(key, propertySet);
  811. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  812. applyShiftState(shiftState: number): void;
  813. private _connectedInputText;
  814. private _onFocusObserver;
  815. private _onBlurObserver;
  816. private _onKeyPressObserver;
  817. readonly connectedInputText: Nullable<InputText>;
  818. connect(input: InputText): void;
  819. disconnect(): void;
  820. static CreateDefaultLayout(): VirtualKeyboard;
  821. }
  822. }