babylon.gui.d.ts 34 KB

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