babylon.gui.module.d.ts 34 KB

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