babylon.gui.d.ts 32 KB

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