babylon.gui.d.ts 31 KB

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