contentControl.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. module BABYLON.GUI {
  3. export class ContentControl extends Control {
  4. private _child: Control;
  5. public get child(): Control {
  6. return this._child;
  7. }
  8. public set child(control: Control) {
  9. if (this._child === control) {
  10. return;
  11. }
  12. this._child = control;
  13. control._setRoot(this._root);
  14. this._markAsDirty();
  15. }
  16. constructor(public name: string) {
  17. super(name);
  18. }
  19. protected _localDraw(context: CanvasRenderingContext2D): void {
  20. // Implemented by child to be injected inside main draw
  21. }
  22. public _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void {
  23. this._currentMeasure = parentMeasure.copy();
  24. context.save();
  25. if (this.font) {
  26. context.font = this.font;
  27. }
  28. if (this.color) {
  29. context.fillStyle = this.color;
  30. }
  31. this._localDraw(context);
  32. if (this._child) {
  33. this._child._draw(this._currentMeasure, context);
  34. }
  35. context.restore();
  36. }
  37. }
  38. }