babylon.gui.module.d.ts 32 KB

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