babylon.gui.d.ts 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  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. background: string;
  350. readonly children: Control[];
  351. constructor(name?: string | undefined);
  352. protected _getTypeName(): string;
  353. getChildByName(name: string): Nullable<Control>;
  354. getChildByType(name: string, type: string): Nullable<Control>;
  355. containsControl(control: Control): boolean;
  356. addControl(control: Control): Container;
  357. removeControl(control: Control): Container;
  358. _reOrderControl(control: Control): void;
  359. _markMatrixAsDirty(): void;
  360. _markAllAsDirty(): void;
  361. protected _localDraw(context: CanvasRenderingContext2D): void;
  362. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  363. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  364. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  365. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  366. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  367. dispose(): void;
  368. }
  369. }
  370. declare module BABYLON.GUI {
  371. class StackPanel extends Container {
  372. name: string | undefined;
  373. private _isVertical;
  374. private _manualWidth;
  375. private _manualHeight;
  376. private _doNotTrackManualChanges;
  377. private _tempMeasureStore;
  378. isVertical: boolean;
  379. width: string | number;
  380. height: string | number;
  381. constructor(name?: string | undefined);
  382. protected _getTypeName(): string;
  383. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  384. }
  385. }
  386. declare module BABYLON.GUI {
  387. class Rectangle extends Container {
  388. name: string | undefined;
  389. private _thickness;
  390. private _cornerRadius;
  391. thickness: number;
  392. cornerRadius: number;
  393. constructor(name?: string | undefined);
  394. protected _getTypeName(): string;
  395. protected _localDraw(context: CanvasRenderingContext2D): void;
  396. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  397. private _drawRoundedRect(context, offset?);
  398. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  399. }
  400. }
  401. declare module BABYLON.GUI {
  402. class Ellipse extends Container {
  403. name: string | undefined;
  404. private _thickness;
  405. thickness: number;
  406. constructor(name?: string | undefined);
  407. protected _getTypeName(): string;
  408. protected _localDraw(context: CanvasRenderingContext2D): void;
  409. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  410. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  411. }
  412. }
  413. declare module BABYLON.GUI {
  414. class Line extends Control {
  415. name: string | undefined;
  416. private _lineWidth;
  417. private _x1;
  418. private _y1;
  419. private _x2;
  420. private _y2;
  421. private _dash;
  422. private _connectedControl;
  423. private _connectedControlDirtyObserver;
  424. dash: Array<number>;
  425. connectedControl: Control;
  426. x1: string | number;
  427. y1: string | number;
  428. x2: string | number;
  429. y2: string | number;
  430. lineWidth: number;
  431. horizontalAlignment: number;
  432. verticalAlignment: number;
  433. private readonly _effectiveX2;
  434. private readonly _effectiveY2;
  435. constructor(name?: string | undefined);
  436. protected _getTypeName(): string;
  437. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  438. _measure(): void;
  439. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  440. /**
  441. * Move one end of the line given 3D cartesian coordinates.
  442. * @param position Targeted world position
  443. * @param scene Scene
  444. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  445. */
  446. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  447. /**
  448. * Move one end of the line to a position in screen absolute space.
  449. * @param projectedPosition Position in screen absolute space (X, Y)
  450. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  451. */
  452. _moveToProjectedPosition(projectedPosition: Vector3, end?: boolean): void;
  453. }
  454. }
  455. declare module BABYLON.GUI {
  456. class Slider extends Control {
  457. name: string | undefined;
  458. private _thumbWidth;
  459. private _minimum;
  460. private _maximum;
  461. private _value;
  462. private _background;
  463. private _borderColor;
  464. private _barOffset;
  465. private _isThumbCircle;
  466. private _isThumbClamped;
  467. onValueChangedObservable: Observable<number>;
  468. borderColor: string;
  469. background: string;
  470. barOffset: string | number;
  471. readonly barOffsetInPixels: number;
  472. thumbWidth: string | number;
  473. readonly thumbWidthInPixels: number;
  474. minimum: number;
  475. maximum: number;
  476. value: number;
  477. isThumbCircle: boolean;
  478. isThumbClamped: boolean;
  479. constructor(name?: string | undefined);
  480. protected _getTypeName(): string;
  481. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  482. private _pointerIsDown;
  483. private _updateValueFromPointer(x, y);
  484. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  485. _onPointerMove(target: Control, coordinates: Vector2): void;
  486. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  487. }
  488. }
  489. declare module BABYLON.GUI {
  490. class Checkbox extends Control {
  491. name: string | undefined;
  492. private _isChecked;
  493. private _background;
  494. private _checkSizeRatio;
  495. private _thickness;
  496. thickness: number;
  497. onIsCheckedChangedObservable: Observable<boolean>;
  498. checkSizeRatio: number;
  499. background: string;
  500. isChecked: boolean;
  501. constructor(name?: string | undefined);
  502. protected _getTypeName(): string;
  503. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  504. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  505. }
  506. }
  507. declare module BABYLON.GUI {
  508. class RadioButton extends Control {
  509. name: string | undefined;
  510. private _isChecked;
  511. private _background;
  512. private _checkSizeRatio;
  513. private _thickness;
  514. thickness: number;
  515. group: string;
  516. onIsCheckedChangedObservable: Observable<boolean>;
  517. checkSizeRatio: number;
  518. background: string;
  519. isChecked: boolean;
  520. constructor(name?: string | undefined);
  521. protected _getTypeName(): string;
  522. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  523. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  524. }
  525. }
  526. declare module BABYLON.GUI {
  527. class TextBlock extends Control {
  528. /**
  529. * Defines the name of the control
  530. */
  531. name: string | undefined;
  532. private _text;
  533. private _textWrapping;
  534. private _textHorizontalAlignment;
  535. private _textVerticalAlignment;
  536. private _lines;
  537. private _resizeToFit;
  538. private _lineSpacing;
  539. private _outlineWidth;
  540. private _outlineColor;
  541. /**
  542. * An event triggered after the text is changed
  543. * @type {BABYLON.Observable}
  544. */
  545. onTextChangedObservable: Observable<TextBlock>;
  546. /**
  547. * An event triggered after the text was broken up into lines
  548. * @type {BABYLON.Observable}
  549. */
  550. onLinesReadyObservable: Observable<TextBlock>;
  551. /**
  552. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  553. */
  554. readonly lines: any[];
  555. /**
  556. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  557. */
  558. /**
  559. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  560. */
  561. resizeToFit: boolean;
  562. /**
  563. * Gets or sets a boolean indicating if text must be wrapped
  564. */
  565. /**
  566. * Gets or sets a boolean indicating if text must be wrapped
  567. */
  568. textWrapping: boolean;
  569. /**
  570. * Gets or sets text to display
  571. */
  572. /**
  573. * Gets or sets text to display
  574. */
  575. text: string;
  576. /**
  577. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  578. */
  579. /**
  580. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  581. */
  582. textHorizontalAlignment: number;
  583. /**
  584. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  585. */
  586. /**
  587. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  588. */
  589. textVerticalAlignment: number;
  590. /**
  591. * Gets or sets line spacing value
  592. */
  593. /**
  594. * Gets or sets line spacing value
  595. */
  596. lineSpacing: string | number;
  597. /**
  598. * Gets or sets outlineWidth of the text to display
  599. */
  600. /**
  601. * Gets or sets outlineWidth of the text to display
  602. */
  603. outlineWidth: number;
  604. /**
  605. * Gets or sets outlineColor of the text to display
  606. */
  607. /**
  608. * Gets or sets outlineColor of the text to display
  609. */
  610. outlineColor: string;
  611. /**
  612. * Creates a new TextBlock object
  613. * @param name defines the name of the control
  614. * @param text defines the text to display (emptry string by default)
  615. */
  616. constructor(
  617. /**
  618. * Defines the name of the control
  619. */
  620. name?: string | undefined, text?: string);
  621. protected _getTypeName(): string;
  622. private _drawText(text, textWidth, y, context);
  623. /** @ignore */
  624. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  625. protected _applyStates(context: CanvasRenderingContext2D): void;
  626. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  627. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  628. protected _parseLineWithTextWrapping(line: string | undefined, context: CanvasRenderingContext2D): object;
  629. protected _renderLines(context: CanvasRenderingContext2D): void;
  630. dispose(): void;
  631. }
  632. }
  633. declare var DOMImage: new (width?: number | undefined, height?: number | undefined) => HTMLImageElement;
  634. declare module BABYLON.GUI {
  635. class Image extends Control {
  636. name: string | undefined;
  637. private _domImage;
  638. private _imageWidth;
  639. private _imageHeight;
  640. private _loaded;
  641. private _stretch;
  642. private _source;
  643. private _autoScale;
  644. private _sourceLeft;
  645. private _sourceTop;
  646. private _sourceWidth;
  647. private _sourceHeight;
  648. private _cellWidth;
  649. private _cellHeight;
  650. private _cellId;
  651. sourceLeft: number;
  652. sourceTop: number;
  653. sourceWidth: number;
  654. sourceHeight: number;
  655. autoScale: boolean;
  656. stretch: number;
  657. domImage: HTMLImageElement;
  658. private _onImageLoaded();
  659. source: Nullable<string>;
  660. cellWidth: number;
  661. cellHeight: number;
  662. cellId: number;
  663. constructor(name?: string | undefined, url?: Nullable<string>);
  664. protected _getTypeName(): string;
  665. synchronizeSizeWithContent(): void;
  666. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  667. private static _STRETCH_NONE;
  668. private static _STRETCH_FILL;
  669. private static _STRETCH_UNIFORM;
  670. private static _STRETCH_EXTEND;
  671. static readonly STRETCH_NONE: number;
  672. static readonly STRETCH_FILL: number;
  673. static readonly STRETCH_UNIFORM: number;
  674. static readonly STRETCH_EXTEND: number;
  675. }
  676. }
  677. declare module BABYLON.GUI {
  678. class Button extends Rectangle {
  679. name: string | undefined;
  680. pointerEnterAnimation: () => void;
  681. pointerOutAnimation: () => void;
  682. pointerDownAnimation: () => void;
  683. pointerUpAnimation: () => void;
  684. constructor(name?: string | undefined);
  685. protected _getTypeName(): string;
  686. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  687. _onPointerEnter(target: Control): boolean;
  688. _onPointerOut(target: Control): void;
  689. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  690. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  691. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  692. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  693. static CreateSimpleButton(name: string, text: string): Button;
  694. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  695. }
  696. }
  697. declare module BABYLON.GUI {
  698. class ColorPicker extends Control {
  699. name: string | undefined;
  700. private _colorWheelCanvas;
  701. private _value;
  702. private _tmpColor;
  703. private _pointerStartedOnSquare;
  704. private _pointerStartedOnWheel;
  705. private _squareLeft;
  706. private _squareTop;
  707. private _squareSize;
  708. private _h;
  709. private _s;
  710. private _v;
  711. onValueChangedObservable: Observable<Color3>;
  712. value: Color3;
  713. width: string | number;
  714. height: string | number;
  715. size: string | number;
  716. constructor(name?: string | undefined);
  717. protected _getTypeName(): string;
  718. private _updateSquareProps();
  719. private _drawGradientSquare(hueValue, left, top, width, height, context);
  720. private _drawCircle(centerX, centerY, radius, context);
  721. private _createColorWheelCanvas(radius, thickness);
  722. private _RGBtoHSV(color, result);
  723. private _HSVtoRGB(hue, saturation, value, result);
  724. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  725. private _pointerIsDown;
  726. private _updateValueFromPointer(x, y);
  727. private _isPointOnSquare(coordinates);
  728. private _isPointOnWheel(coordinates);
  729. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  730. _onPointerMove(target: Control, coordinates: Vector2): void;
  731. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  732. }
  733. }
  734. declare module BABYLON.GUI {
  735. class InputText extends Control implements IFocusableControl {
  736. name: string | undefined;
  737. private _text;
  738. private _placeholderText;
  739. private _background;
  740. private _focusedBackground;
  741. private _placeholderColor;
  742. private _thickness;
  743. private _margin;
  744. private _autoStretchWidth;
  745. private _maxWidth;
  746. private _isFocused;
  747. private _blinkTimeout;
  748. private _blinkIsEven;
  749. private _cursorOffset;
  750. private _scrollLeft;
  751. private _textWidth;
  752. private _clickedCoordinate;
  753. promptMessage: string;
  754. onTextChangedObservable: Observable<InputText>;
  755. onFocusObservable: Observable<InputText>;
  756. onBlurObservable: Observable<InputText>;
  757. maxWidth: string | number;
  758. readonly maxWidthInPixels: number;
  759. margin: string;
  760. readonly marginInPixels: number;
  761. autoStretchWidth: boolean;
  762. thickness: number;
  763. focusedBackground: string;
  764. background: string;
  765. placeholderColor: string;
  766. placeholderText: string;
  767. text: string;
  768. width: string | number;
  769. constructor(name?: string | undefined, text?: string);
  770. onBlur(): void;
  771. onFocus(): void;
  772. protected _getTypeName(): string;
  773. processKey(keyCode: number, key?: string): void;
  774. processKeyboard(evt: KeyboardEvent): void;
  775. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  776. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  777. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  778. dispose(): void;
  779. }
  780. }
  781. declare module BABYLON.GUI {
  782. class KeyPropertySet {
  783. width?: string;
  784. height?: string;
  785. paddingLeft?: string;
  786. paddingRight?: string;
  787. paddingTop?: string;
  788. paddingBottom?: string;
  789. color?: string;
  790. background?: string;
  791. }
  792. class VirtualKeyboard extends StackPanel {
  793. onKeyPressObservable: Observable<string>;
  794. defaultButtonWidth: string;
  795. defaultButtonHeight: string;
  796. defaultButtonPaddingLeft: string;
  797. defaultButtonPaddingRight: string;
  798. defaultButtonPaddingTop: string;
  799. defaultButtonPaddingBottom: string;
  800. defaultButtonColor: string;
  801. defaultButtonBackground: string;
  802. shiftButtonColor: string;
  803. selectedShiftThickness: number;
  804. shiftState: number;
  805. protected _getTypeName(): string;
  806. private _createKey(key, propertySet);
  807. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  808. applyShiftState(shiftState: number): void;
  809. private _connectedInputText;
  810. private _onFocusObserver;
  811. private _onBlurObserver;
  812. private _onKeyPressObserver;
  813. readonly connectedInputText: Nullable<InputText>;
  814. connect(input: InputText): void;
  815. disconnect(): void;
  816. static CreateDefaultLayout(): VirtualKeyboard;
  817. }
  818. }