babylon.gui.d.ts 32 KB

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