babylon.gui.module.d.ts 34 KB

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