babylon.gui.d.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. /// <reference path="../../dist/preview release/babylon.d.ts" />
  2. declare module BABYLON.GUI {
  3. class AdvancedDynamicTexture extends DynamicTexture {
  4. private _isDirty;
  5. private _renderObserver;
  6. private _resizeObserver;
  7. private _pointerMoveObserver;
  8. private _pointerObserver;
  9. private _background;
  10. _rootContainer: Container;
  11. _lastControlOver: Control;
  12. _lastControlDown: Control;
  13. _shouldBlockPointer: boolean;
  14. _layerToDispose: Layer;
  15. _linkedControls: Control[];
  16. private _isFullscreen;
  17. private _fullscreenViewport;
  18. background: string;
  19. constructor(name: string, width: number, height: number, scene: Scene, generateMipMaps?: boolean, samplingMode?: number);
  20. markAsDirty(): void;
  21. addControl(control: Control): AdvancedDynamicTexture;
  22. removeControl(control: Control): AdvancedDynamicTexture;
  23. dispose(): void;
  24. private _onResize();
  25. private _checkUpdate(camera);
  26. private _render();
  27. private _doPicking(x, y, type);
  28. attach(): void;
  29. attachToMesh(mesh: AbstractMesh): void;
  30. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number): AdvancedDynamicTexture;
  31. static CreateFullscreenUI(name: string, foreground: boolean, scene: Scene): AdvancedDynamicTexture;
  32. }
  33. }
  34. /// <reference path="../../dist/preview release/babylon.d.ts" />
  35. declare module BABYLON.GUI {
  36. class Measure {
  37. left: number;
  38. top: number;
  39. width: number;
  40. height: number;
  41. constructor(left: number, top: number, width: number, height: number);
  42. copyFrom(other: Measure): void;
  43. isEqualsTo(other: Measure): boolean;
  44. static Empty(): Measure;
  45. }
  46. }
  47. /// <reference path="../../dist/preview release/babylon.d.ts" />
  48. declare module BABYLON.GUI {
  49. class Matrix2D {
  50. m: Float32Array;
  51. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  52. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  53. determinant(): number;
  54. invertToRef(result: Matrix2D): Matrix2D;
  55. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  57. static Identity(): Matrix2D;
  58. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  59. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60. static RotationToRef(angle: number, result: Matrix2D): void;
  61. private static _TempPreTranslationMatrix;
  62. private static _TempPostTranslationMatrix;
  63. private static _TempRotationMatrix;
  64. private static _TempScalingMatrix;
  65. private static _TempCompose0;
  66. private static _TempCompose1;
  67. private static _TempCompose2;
  68. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Matrix2D, result: Matrix2D): void;
  69. }
  70. }
  71. /// <reference path="../../dist/preview release/babylon.d.ts" />
  72. declare module BABYLON.GUI {
  73. class ValueAndUnit {
  74. value: number;
  75. unit: number;
  76. negativeValueAllowed: boolean;
  77. constructor(value?: number, unit?: number, negativeValueAllowed?: boolean);
  78. readonly isPercentage: boolean;
  79. readonly isPixel: boolean;
  80. toString(): string;
  81. fromString(source: string): boolean;
  82. private static _Regex;
  83. private static _UNITMODE_PERCENTAGE;
  84. private static _UNITMODE_PIXEL;
  85. static readonly UNITMODE_PERCENTAGE: number;
  86. static readonly UNITMODE_PIXEL: number;
  87. }
  88. }
  89. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  90. declare module BABYLON.GUI {
  91. class Control {
  92. name: string;
  93. private _alpha;
  94. private _zIndex;
  95. _root: Container;
  96. _host: AdvancedDynamicTexture;
  97. _currentMeasure: Measure;
  98. private _fontFamily;
  99. private _fontSize;
  100. private _font;
  101. private _width;
  102. private _height;
  103. private _lastMeasuredFont;
  104. protected _fontOffset: {
  105. ascent: number;
  106. height: number;
  107. descent: number;
  108. };
  109. private _color;
  110. protected _horizontalAlignment: number;
  111. protected _verticalAlignment: number;
  112. private _isDirty;
  113. private _cachedParentMeasure;
  114. private _marginLeft;
  115. private _marginRight;
  116. private _marginTop;
  117. private _marginBottom;
  118. private _left;
  119. private _top;
  120. private _scaleX;
  121. private _scaleY;
  122. private _rotation;
  123. private _transformCenterX;
  124. private _transformCenterY;
  125. private _transformMatrix;
  126. private _invertTransformMatrix;
  127. private _transformedPosition;
  128. private _isMatrixDirty;
  129. private _cachedOffsetX;
  130. private _cachedOffsetY;
  131. _linkedMesh: AbstractMesh;
  132. isHitTestVisible: boolean;
  133. isPointerBlocker: boolean;
  134. linkOffsetX: number;
  135. linkOffsetY: number;
  136. /**
  137. * An event triggered when the pointer move over the control.
  138. * @type {BABYLON.Observable}
  139. */
  140. onPointerMoveObservable: Observable<Control>;
  141. /**
  142. * An event triggered when the pointer move out of the control.
  143. * @type {BABYLON.Observable}
  144. */
  145. onPointerOutObservable: Observable<Control>;
  146. /**
  147. * An event triggered when the pointer taps the control
  148. * @type {BABYLON.Observable}
  149. */
  150. onPointerDownObservable: Observable<Control>;
  151. /**
  152. * An event triggered when pointer up
  153. * @type {BABYLON.Observable}
  154. */
  155. onPointerUpObservable: Observable<Control>;
  156. /**
  157. * An event triggered when pointer enters the control
  158. * @type {BABYLON.Observable}
  159. */
  160. onPointerEnterObservable: Observable<Control>;
  161. /**
  162. * An event triggered when the control is marked as dirty
  163. * @type {BABYLON.Observable}
  164. */
  165. onDirtyObservable: Observable<Control>;
  166. alpha: number;
  167. scaleX: number;
  168. scaleY: number;
  169. rotation: number;
  170. transformCenterY: number;
  171. transformCenterX: number;
  172. horizontalAlignment: number;
  173. verticalAlignment: number;
  174. width: string;
  175. height: string;
  176. fontFamily: string;
  177. fontSize: number;
  178. color: string;
  179. zIndex: number;
  180. readonly isDirty: boolean;
  181. marginLeft: string;
  182. marginRight: string;
  183. marginTop: string;
  184. marginBottom: string;
  185. left: string;
  186. top: string;
  187. readonly centerX: number;
  188. readonly centerY: number;
  189. constructor(name: string);
  190. linkWithMesh(mesh: AbstractMesh): void;
  191. _moveToProjectedPosition(projectedPosition: Vector3): void;
  192. _markMatrixAsDirty(): void;
  193. protected _markAsDirty(): void;
  194. _link(root: Container, host: AdvancedDynamicTexture): void;
  195. protected _transform(context: CanvasRenderingContext2D): void;
  196. protected _applyStates(context: CanvasRenderingContext2D): void;
  197. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  198. protected _clip(context: CanvasRenderingContext2D): void;
  199. _measure(): void;
  200. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  201. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  202. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  203. contains(x: number, y: number): boolean;
  204. _processPicking(x: number, y: number, type: number): boolean;
  205. protected _onPointerMove(): void;
  206. protected _onPointerEnter(): void;
  207. protected _onPointerOut(): void;
  208. protected _onPointerDown(): void;
  209. protected _onPointerUp(): void;
  210. protected _processObservables(type: number): boolean;
  211. private _prepareFont();
  212. private static _HORIZONTAL_ALIGNMENT_LEFT;
  213. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  214. private static _HORIZONTAL_ALIGNMENT_CENTER;
  215. private static _VERTICAL_ALIGNMENT_TOP;
  216. private static _VERTICAL_ALIGNMENT_BOTTOM;
  217. private static _VERTICAL_ALIGNMENT_CENTER;
  218. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  219. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  220. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  221. static readonly VERTICAL_ALIGNMENT_TOP: number;
  222. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  223. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  224. private static _FontHeightSizes;
  225. static _GetFontOffset(font: string): {
  226. ascent: number;
  227. height: number;
  228. descent: number;
  229. };
  230. }
  231. }
  232. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  233. declare module BABYLON.GUI {
  234. class Container extends Control {
  235. name: string;
  236. protected _children: Control[];
  237. protected _measureForChildren: Measure;
  238. protected _background: string;
  239. background: string;
  240. constructor(name: string);
  241. containsControl(control: Control): boolean;
  242. addControl(control: Control): Container;
  243. removeControl(control: Control): Container;
  244. _reOrderControl(control: Control): void;
  245. _markMatrixAsDirty(): void;
  246. protected _localDraw(context: CanvasRenderingContext2D): void;
  247. _link(root: Container, host: AdvancedDynamicTexture): void;
  248. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  249. _processPicking(x: number, y: number, type: number): boolean;
  250. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  251. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  252. }
  253. }
  254. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  255. declare module BABYLON.GUI {
  256. class StackPanel extends Container {
  257. name: string;
  258. private _isVertical;
  259. isVertical: boolean;
  260. constructor(name: string);
  261. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  262. }
  263. }
  264. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  265. declare module BABYLON.GUI {
  266. class Rectangle extends Container {
  267. name: string;
  268. private _thickness;
  269. private _cornerRadius;
  270. thickness: number;
  271. cornerRadius: number;
  272. background: string;
  273. constructor(name: string);
  274. protected _localDraw(context: CanvasRenderingContext2D): void;
  275. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  276. private _drawRoundedRect(context, offset?);
  277. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  278. }
  279. }
  280. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  281. declare module BABYLON.GUI {
  282. class Ellipse extends Container {
  283. name: string;
  284. private _thickness;
  285. thickness: number;
  286. constructor(name: string);
  287. protected _localDraw(context: CanvasRenderingContext2D): void;
  288. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  289. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  290. }
  291. }
  292. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  293. declare var DOMImage: new (width?: number, height?: number) => HTMLImageElement;
  294. declare module BABYLON.GUI {
  295. class Line extends Control {
  296. name: string;
  297. private _lineWidth;
  298. private _background;
  299. private _x1;
  300. private _y1;
  301. private _x2;
  302. private _y2;
  303. private _dash;
  304. private _connectedControl;
  305. private _connectedControlDirtyObserver;
  306. dash: Array<number>;
  307. connectedControl: Control;
  308. x1: number;
  309. y1: number;
  310. x2: number;
  311. y2: number;
  312. lineWidth: number;
  313. horizontalAlignment: number;
  314. verticalAlignment: number;
  315. constructor(name: string);
  316. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  317. _measure(): void;
  318. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  319. _moveToProjectedPosition(projectedPosition: Vector3): void;
  320. }
  321. }
  322. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  323. declare module BABYLON.GUI {
  324. class TextBlock extends Control {
  325. name: string;
  326. private _text;
  327. private _textY;
  328. private _textWrapping;
  329. private _textHorizontalAlignment;
  330. private _textVerticalAlignment;
  331. private _lines;
  332. private _totalHeight;
  333. textWrapping: boolean;
  334. text: string;
  335. textHorizontalAlignment: number;
  336. textVerticalAlignment: number;
  337. constructor(name: string, text: string);
  338. private _drawText(text, textWidth, y, context);
  339. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  340. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  341. protected _renderLines(context: CanvasRenderingContext2D): void;
  342. }
  343. }
  344. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  345. declare var DOMImage: new (width?: number, height?: number) => HTMLImageElement;
  346. declare module BABYLON.GUI {
  347. class Image extends Control {
  348. name: string;
  349. private _domImage;
  350. private _imageWidth;
  351. private _imageHeight;
  352. private _loaded;
  353. private _stretch;
  354. stretch: number;
  355. constructor(name: string, url: string);
  356. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  357. private static _STRETCH_NONE;
  358. private static _STRETCH_FILL;
  359. private static _STRETCH_UNIFORM;
  360. static readonly STRETCH_NONE: number;
  361. static readonly STRETCH_FILL: number;
  362. static readonly STRETCH_UNIFORM: number;
  363. }
  364. }
  365. /// <reference path="../../../dist/preview release/babylon.d.ts" />
  366. declare module BABYLON.GUI {
  367. class Button extends Rectangle {
  368. name: string;
  369. pointerEnterAnimation: () => void;
  370. pointerOutAnimation: () => void;
  371. pointerDownAnimation: () => void;
  372. pointerUpAnimation: () => void;
  373. constructor(name: string);
  374. _processPicking(x: number, y: number, type: number): boolean;
  375. protected _onPointerEnter(): void;
  376. protected _onPointerOut(): void;
  377. protected _onPointerDown(): void;
  378. protected _onPointerUp(): void;
  379. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  380. static CreateSimpleButton(name: string, text: string): Button;
  381. }
  382. }